Java 类com.intellij.openapi.projectRoots.Sdk 实例源码

项目:green-cat    文件:Utils.java   
public static String getAndroidSdkPath(Project project) {
    ModuleManager manager = ModuleManager.getInstance(project);
    String androidSdkPath = null;

    for (Module module : manager.getModules()) {
        if (androidSdkPath != null) {
            break;
        }
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

        if (sdk != null && sdk.getHomePath() != null) {
            File file = new File(sdk.getHomePath());
            String[] contents = file.list();

            if (contents != null) {
                for (String path : contents) {
                    if (path.equals("build-tools")) {
                        androidSdkPath = sdk.getHomePath();
                        break;
                    }
                }
            }
        }
    }
    return androidSdkPath;
}
项目:hybris-integration-intellij-idea-plugin    文件:ImportProjectProgressModalWindow.java   
private void selectSdk(@NotNull final Project project) {
    Validate.notNull(project);

    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);

    final Sdk projectSdk = projectRootManager.getProjectSdk();

    if (null == projectSdk) {
        return;
    }

    if (StringUtils.isNotBlank(projectSdk.getVersionString())) {
        final JavaSdkVersion sdkVersion = JdkVersionUtil.getVersion(projectSdk.getVersionString());
        final LanguageLevelProjectExtension languageLevelExt = LanguageLevelProjectExtension.getInstance(project);

        if (sdkVersion.getMaxLanguageLevel() != languageLevelExt.getLanguageLevel()) {
            languageLevelExt.setLanguageLevel(sdkVersion.getMaxLanguageLevel());
        }
    }
}
项目:hybris-integration-intellij-idea-plugin    文件:ProjectRefreshAction.java   
private AddModuleWizard getWizard(final Project project) throws ConfigurationException {
    final HybrisProjectImportProvider provider = getHybrisProjectImportProvider();
    final String basePath = project.getBasePath();
    final String projectName = project.getName();
    final Sdk jdk = ProjectRootManager.getInstance(project).getProjectSdk();
    final String compilerOutputUrl = CompilerProjectExtension.getInstance(project).getCompilerOutputUrl();
    final HybrisProjectSettings settings = HybrisProjectSettingsComponent.getInstance(project).getState();

    final AddModuleWizard wizard = new AddModuleWizard(null, basePath, provider) {

        protected void init() {
            // non GUI mode
        }
    };
    final WizardContext wizardContext = wizard.getWizardContext();
    wizardContext.setProjectJdk(jdk);
    wizardContext.setProjectName(projectName);
    wizardContext.setCompilerOutputDirectory(compilerOutputUrl);
    final StepSequence stepSequence = wizard.getSequence();
    for (ModuleWizardStep step : stepSequence.getAllSteps()) {
        if (step instanceof NonGuiSupport) {
            ((NonGuiSupport) step).nonGuiModeImport(settings);
        }
    }
    return wizard;
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
private static Sdk addDetectedSdk(@NotNull Sdk sdk, @NotNull Project project) {
  final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
  final String name = sdk.getName();
  VirtualFile sdkHome = WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(name));
  sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
  if (sdk != null) {
    PythonSdkUpdater.updateOrShowError(sdk, null, project, null);
  }

  model.addSdk(sdk);
  try {
    model.apply();
  }
  catch (ConfigurationException exception) {
    LOG.error("Error adding detected python interpreter " + exception.getMessage());
  }
  return sdk;
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Nullable
@Override
public BooleanFunction<PythonProjectGenerator> beforeProjectGenerated(@Nullable Sdk sdk) {
  return generator -> {
    final List<Integer> enrolledCoursesIds = myGenerator.getEnrolledCoursesIds();
    final Course course = myGenerator.getSelectedCourse();
    if (course == null || !(course instanceof RemoteCourse)) return true;
    if (((RemoteCourse)course).getId() > 0 && !enrolledCoursesIds.contains(((RemoteCourse)course).getId())) {
      ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
        ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
        return StudyUtils.execCancelable(() -> EduStepicConnector.enrollToCourse(((RemoteCourse)course).getId(),
                                                                                 StudySettings.getInstance().getUser()));
      }, "Creating Course", true, ProjectManager.getInstance().getDefaultProject());
    }
    return true;
  };
}
项目:lua-for-idea    文件:GenerateLuaListingAction.java   
@Override
public void update(AnActionEvent e) {
    e.getPresentation().setVisible(false);
    e.getPresentation().setEnabled(false);
    Project project = e.getData(LangDataKeys.PROJECT);
    if (project != null) {
        for (Module module : ModuleManager.getInstance(project).getModules()) {
            e.getPresentation().setVisible(true);
            Sdk luaSdk = LuaSdkType.findLuaSdk(module);
            if (luaSdk == null) continue;

            final String homePath = luaSdk.getHomePath();
            if (homePath == null) continue;

            if (LuaSdkType.getByteCodeCompilerExecutable(homePath).exists()) {
                e.getPresentation().setEnabled(true);
                break;
            }
        }
    }
}
项目:intellij-ce-playground    文件:PyStudyIntroductionCourseAction.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final File projectDir = new File(ProjectUtil.getBaseDir(), INTRODUCTION_FOLDER);
  if (projectDir.exists()) {
    ProjectUtil.openProject(projectDir.getPath(), null, false);
  }
  else {
    final PyStudyDirectoryProjectGenerator generator = new PyStudyDirectoryProjectGenerator();
    CourseInfo introCourse = getIntroCourseInfo(generator.getCourses());
    if (introCourse == null) {
      return;
    }
    final GenerateProjectCallback callback = new GenerateProjectCallback();
    final ProjectSpecificSettingsStep step = new ProjectSpecificSettingsStep(generator, callback);
    step.createPanel(); // initialize panel to set location
    step.setLocation(projectDir.toString());
    generator.setSelectedCourse(introCourse);

    final Project project = ProjectManager.getInstance().getDefaultProject();
    final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
    Sdk sdk = sdks.isEmpty() ? null : sdks.iterator().next();
    step.setSdk(sdk);
    callback.consume(step);
  }
}
项目:intellij-ce-playground    文件:ProjectRootManagerImpl.java   
@Override
public void jdkNameChanged(final Sdk jdk, final String previousName) {
  mergeRootsChangesDuring(new Runnable() {
    @Override
    public void run() {
      for (ProjectJdkTable.Listener listener : getListeners()) {
        listener.jdkNameChanged(jdk, previousName);
      }
    }
  });
  String currentName = getProjectSdkName();
  if (previousName != null && previousName.equals(currentName)) {
    // if already had jdk name and that name was the name of the jdk just changed
    myProjectSdkName = jdk.getName();
    myProjectSdkType = jdk.getSdkType().getName();
  }
}
项目:intellij-ce-playground    文件:PyRemoteProcessStarter.java   
protected PyRemoteProcessHandlerBase doStartRemoteProcess(@NotNull Sdk sdk,
                                                          @NotNull final GeneralCommandLine commandLine,
                                                          @NotNull final PythonRemoteInterpreterManager manager,
                                                          @Nullable final Project project,
                                                          @Nullable PyRemotePathMapper pathMapper)
  throws ExecutionException {
  SdkAdditionalData data = sdk.getSdkAdditionalData();
  assert data instanceof PyRemoteSdkAdditionalDataBase;
  final PyRemoteSdkAdditionalDataBase pyRemoteSdkAdditionalDataBase = (PyRemoteSdkAdditionalDataBase)data;

  final PyRemotePathMapper extendedPathMapper = manager.setupMappings(project, pyRemoteSdkAdditionalDataBase, pathMapper);

  try {
    return PyRemoteProcessStarterManagerUtil
      .getManager(pyRemoteSdkAdditionalDataBase).startRemoteProcess(project, commandLine, manager, pyRemoteSdkAdditionalDataBase,
                                                   extendedPathMapper);
  }
  catch (InterruptedException e) {
    throw new ExecutionException(e);
  }
}
项目:intellij-ce-playground    文件:JavaFxChunkBuildExtension.java   
@Override
public void initArtifacts(Project project, GenerationOptions genOptions, CompositeGenerator generator) {
  final Collection<? extends Artifact> artifacts =
    ArtifactManager.getInstance(project).getArtifactsByType(JavaFxApplicationArtifactType.getInstance());
  if (artifacts.isEmpty()) return;
  final Sdk[] jdks = BuildProperties.getUsedJdks(project);
  Sdk javaSdk = null;
  for (Sdk jdk : jdks) {
    if (jdk.getSdkType() instanceof JavaSdkType) {
      javaSdk = jdk;
      break;
    }
  }
  if (javaSdk != null) {
    final Tag taskdef = new Tag("taskdef",
                                Couple.of("resource", "com/sun/javafx/tools/ant/antlib.xml"),
                                Couple.of("uri", "javafx:com.sun.javafx.tools.ant"),
                                Couple.of("classpath",
                                          BuildProperties
                                            .propertyRef(BuildProperties.getJdkHomeProperty(javaSdk.getName())) +
                                          "/lib/ant-javafx.jar"));
    generator.add(taskdef);
  }
}
项目:intellij-ce-playground    文件:PythonSdkUpdater.java   
public static void updateActiveSdks(@NotNull final Project project, final int delay) {
  final Set<Sdk> sdksToUpdate = new HashSet<Sdk>();
  for (Module module : ModuleManager.getInstance(project).getModules()) {
    final Sdk sdk = PythonSdkType.findPythonSdk(module);
    if (sdk != null) {
      final SdkTypeId sdkType = sdk.getSdkType();
      if (sdkType instanceof PythonSdkType) {
        sdksToUpdate.add(sdk);
      }
    }
  }

  // NOTE: everything is run later on the AWT thread
  if (!sdksToUpdate.isEmpty()) {
    updateSdks(project, delay, sdksToUpdate);
  }
}
项目:intellij-ce-playground    文件:LightProjectDescriptor.java   
protected void createContentEntry(@NotNull final Module module, @NotNull final VirtualFile srcRoot) {
  updateModel(module, new Consumer<ModifiableRootModel>() {
    @Override
    public void consume(ModifiableRootModel model) {
      Sdk sdk = getSdk();
      if (sdk != null) {
        model.setSdk(sdk);
      }

      ContentEntry contentEntry = model.addContentEntry(srcRoot);
      contentEntry.addSourceFolder(srcRoot, false);

      configureModule(module, model, contentEntry);
    }
  });
}
项目:intellij-ce-playground    文件:RootsChangedTest.java   
public void testEditLibraryForModuleLoadFromXml() throws IOException {
  final File tempDirectory = createTempDirectory();
  ApplicationManager.getApplication().runWriteAction(() -> {
    Module a = loadModule(PathManagerEx.getHomePath(getClass()) + "/java/java-tests/testData/moduleRootManager/rootsChanged/emptyModule/a.iml");
    assertEventsCount(1);

    final Sdk jdk = IdeaTestUtil.getMockJdk17();
    ProjectJdkTable.getInstance().addJdk(jdk);
    assertEventsCount(0);

    ModuleRootModificationUtil.setModuleSdk(a, jdk);
    assertEventsCount(1);

    final SdkModificator sdkModificator = jdk.getSdkModificator();
    sdkModificator.addRoot(getVirtualFile(tempDirectory), OrderRootType.CLASSES);
    sdkModificator.commitChanges();
  });

  assertEventsCount(1);
}
项目:intellij-ce-playground    文件:SphinxDirectiveCompletionContributor.java   
public SphinxDirectiveCompletionContributor() {
  extend(CompletionType.BASIC, DIRECTIVE_PATTERN,
     new CompletionProvider<CompletionParameters>() {
       @Override
       protected void addCompletions(@NotNull CompletionParameters parameters,
                                     ProcessingContext context,
                                     @NotNull CompletionResultSet result) {
         Sdk sdk = ProjectRootManager.getInstance(parameters.getPosition().getProject()).getProjectSdk();
         if (sdk != null) {
           for (String tag : RestUtil.SPHINX_DIRECTIVES) {
             result.addElement(LookupElementBuilder.create(tag));
           }
         }
       }
     }
     );
}
项目:intellij-ce-playground    文件:PythonSdkTableListener.java   
private static void renameLibrary(final Sdk sdk, final String previousName) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          final LibraryTable.ModifiableModel libraryTableModel =
            ModifiableModelsProvider.SERVICE.getInstance().getLibraryTableModifiableModel();
          final Library library = libraryTableModel.getLibraryByName(PythonFacet.getFacetLibraryName(previousName));
          if (library != null) {
            final Library.ModifiableModel model = library.getModifiableModel();
            model.setName(PythonFacet.getFacetLibraryName(sdk.getName()));
            model.commit();
          }
          libraryTableModel.commit();
        }
      });
    }
  }, ModalityState.NON_MODAL);
}
项目:jgiven-intellij-plugin    文件:BaseTestCase.java   
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
    return new LightProjectDescriptor() {
        @Nullable
        @Override
        public Sdk getSdk() {
            return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
        }
    };
}
项目:SmartTomcat    文件:PluginUtils.java   
public static Sdk getDefaultJDK(){
    Sdk[] allJdks = ProjectJdkTable.getInstance().getAllJdks();
    if (allJdks == null || allJdks.length == 0) {
        throw new RuntimeException("Please setup your project JDK first");
    }
    Sdk jdk = allJdks[0];
    return jdk;
}
项目:CopyCurrentActivity    文件:CopyCurrentActivityAction.java   
@Nullable
private String getAndroidSdkPath() {
    Sdk[] allSdks = ProjectJdkTable.getInstance().getAllJdks();
    for (Sdk sdk : allSdks) {
        String sdkTypeName = sdk.getSdkType().getName();
        if (ANDROID_SDK_TYPE_NAME.equals(sdkTypeName)) {
            return sdk.getHomePath();
        }
    }
    return null;
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Override
public void afterProjectGenerated(@NotNull Project project) {
  Sdk sdk = mySettings.getSdk();

  if (sdk == PLACEHOLDER_SDK) {
    createAndAddVirtualEnv(project, mySettings);
    sdk = mySettings.getSdk();
  }
  if (sdk instanceof PyDetectedSdk) {
    sdk = addDetectedSdk(sdk, project);
  }
  SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  final Project project = ProjectManager.getInstance().getDefaultProject();
  PyConfigurableInterpreterList instance = PyConfigurableInterpreterList.getInstance(project);
  if (instance == null) {
    return null;
  }
  final List<Sdk> sdks = instance.getAllPythonSdks();
  VirtualEnvProjectFilter.removeAllAssociated(sdks);
  // by default we create new virtual env in project, we need to add this non-existing sdk to sdk list
  ProjectJdkImpl fakeSdk = createFakeSdk(selectedCourse);
  if (fakeSdk != null) {
    sdks.add(0, fakeSdk);
  }
  PythonSdkChooserCombo combo = new PythonSdkChooserCombo(project, sdks, sdk -> true);
  if (fakeSdk != null) {
    patchRenderer(fakeSdk, combo);
    combo.getComboBox().setSelectedItem(fakeSdk);
  }
  if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
    combo.putClientProperty("JButton.buttonType", null);
  }
  combo.setButtonIcon(PythonIcons.Python.InterpreterGear);
  combo.addChangedListener(e -> {
    Sdk selectedSdk = (Sdk)combo.getComboBox().getSelectedItem();
    mySettings.setSdk(selectedSdk == fakeSdk ? null : selectedSdk);
  });
  return LabeledComponent.create(combo, "Interpreter", BorderLayout.WEST);
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
public void createAndAddVirtualEnv(Project project, PyNewProjectSettings settings) {
  final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return;
  }
  final String baseSdk = getBaseSdk(course);

  if (baseSdk != null) {
    final PyPackageManager packageManager = PyPackageManager.getInstance(new PyDetectedSdk(baseSdk));
    try {
      final String path = packageManager.createVirtualEnv(project.getBasePath() + "/.idea/VirtualEnvironment", false);
      AbstractCreateVirtualEnvDialog.setupVirtualEnvSdk(path, true, new AbstractCreateVirtualEnvDialog.VirtualEnvCallback() {
        @Override
        public void virtualEnvCreated(Sdk createdSdk, boolean associateWithProject) {
          settings.setSdk(createdSdk);
          model.addSdk(createdSdk);
          try {
            model.apply();
          }
          catch (ConfigurationException exception) {
            LOG.error("Error adding created virtual env " + exception.getMessage());
          }
          if (associateWithProject) {
            SdkAdditionalData additionalData = createdSdk.getSdkAdditionalData();
            if (additionalData == null) {
              additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(createdSdk.getHomePath()));
              ((ProjectJdkImpl)createdSdk).setSdkAdditionalData(additionalData);
            }
            ((PythonSdkAdditionalData)additionalData).associateWithNewProject();
          }
        }
      });
    }
    catch (ExecutionException e) {
      LOG.warn("Failed to create virtual env " + e.getMessage());
    }
  }
}
项目:educational-plugin    文件:PyStudyTestRunner.java   
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
  final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
  PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
  String testsFileName = configurator.getTestFileName();
  if (myTask instanceof TaskWithSubtasks) {
    testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
    int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
    testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
  }
  final File testRunner = new File(myTaskDir.getPath(), testsFileName);
  myCommandLine = new GeneralCommandLine();
  myCommandLine.withWorkDirectory(myTaskDir.getPath());
  final Map<String, String> env = myCommandLine.getEnvironment();

  final VirtualFile courseDir = project.getBaseDir();
  if (courseDir != null) {
    env.put(PYTHONPATH, courseDir.getPath());
  }
  if (sdk != null) {
    String pythonPath = sdk.getHomePath();
    if (pythonPath != null) {
      myCommandLine.setExePath(pythonPath);
      myCommandLine.addParameter(testRunner.getPath());
      myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
      return myCommandLine.createProcess();
    }
  }
  return null;
}
项目:manifold-ij    文件:ManProject.java   
private int findJdkVersion()
{
  Sdk projectSdk = ProjectRootManager.getInstance( _ijProject ).getProjectSdk();
  if( projectSdk == null )
  {
    return -1;
  }

  // expected format:
  // 'java version "1.8.1"'
  // 'java version "9.0.1"'
  // 'java version "10.0.1"'
  // etc.
  String version = projectSdk.getVersionString();
  int iQuote = version.indexOf( '"' );
  if( iQuote < 0 )
  {
    return -1;
  }

  String verNum = version.substring( iQuote+1 );
  int iDot = verNum.indexOf( '.' );
  if( iDot < 0 )
  {
    return -1;
  }

  verNum = verNum.substring( 0, iDot );
  if( verNum.equals( "1" ) )
  {
    return 8;
  }
  else
  {
    return Integer.parseInt( verNum );
  }
}
项目:manifold-ij    文件:AbstractManifoldCodeInsightTest.java   
@Override
public Sdk getSdk()
{
  return _sdk == null
         ? _sdk = JavaSdk.getInstance().createJdk( getJdkVersion(), getPath_JdkRoot() + File.separatorChar + getJdkVersion(), false )
         : _sdk;
}
项目:lua-for-idea    文件:LuaSdkChooserPanel.java   
public LuaSdkChooserPanel(final Project project) {
    myJdkChooser = new JdkChooserPanel(project);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEtchedBorder());

    final JLabel label = new JLabel(LuaBundle.message("sdk.chooser.luabinaries.prompt"));
    label.setUI(new MultiLineLabelUI());
    add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0));

    final JLabel jdkLabel = new JLabel(LuaBundle.message("sdk.chooser.select.sdk.prompt"));
    jdkLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    add(jdkLabel,
            new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.NONE, new Insets(8, 10, 0, 10), 0, 0));

    add(myJdkChooser,
            new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.BOTH, new Insets(2, 10, 10, 5), 0, 0));
    JButton configureButton = new JButton(LuaBundle.message("sdk.chooser.configure.button"));
    add(configureButton,
            new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.NONE, new Insets(2, 0, 10, 5), 0, 0));

    configureButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myJdkChooser.editJdkTable();
        }
    });

    myJdkChooser.setAllowedJdkTypes(new SdkType[]{LuaSdkType.getInstance()});

    final Sdk selectedJdk = project == null ? null : ProjectRootManager.getInstance(project).getProjectSdk();

    myJdkChooser.fillList(LuaSdkType.getInstance(), null);
    if (selectedJdk != null) {
        myJdkChooser.selectJdk(selectedJdk);
    }
}
项目:intellij-ce-playground    文件:NamedLibraryElementNode.java   
private static Icon getJdkIcon(JdkOrderEntry entry) {
  final Sdk sdk = entry.getJdk();
  if (sdk == null) {
    return AllIcons.General.Jdk;
  }
  final SdkType sdkType = (SdkType) sdk.getSdkType();
  return sdkType.getIcon();
}
项目:intellij-ce-playground    文件:SdkConfigurationUtil.java   
public static void addSdk(@NotNull final Sdk sdk) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable.getInstance().addJdk(sdk);
    }
  });
}
项目:intellij-ce-playground    文件:AndroidSdkUtils.java   
@VisibleForTesting
static boolean tryToCreateAndSetAndroidSdk(@NotNull Module module, @NotNull String sdkPath, @NotNull String targetHashString) {
  File path = new File(toSystemDependentName(sdkPath));
  Sdk sdk = tryToCreateAndroidSdk(path, targetHashString);
  if (sdk != null) {
    setModuleSdk(module, sdk);
    return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:PythonSdkUpdater.java   
private static void updateSdks(final Project project, final int delay, final Set<Sdk> sdksToUpdate) {
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    public void run() {
      if (delay > 0) {
        try {
          Thread.sleep(delay); // wait until all short-term disk-hitting activity ceases
        }
        catch (InterruptedException ignore) {
        }
      }
      // update skeletons
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          ProgressManager.getInstance().run(new Task.Backgroundable(project, PyBundle.message("sdk.gen.updating.skels"), false) {
            @Override
            public void run(@NotNull ProgressIndicator indicator) {
              for (final Sdk sdk : sdksToUpdate) {
                updateSdk(sdk, project);
              }
            }
          });
        }
      });
    }
  });
}
项目:lua-for-idea    文件:LuaRunConfiguration.java   
public Sdk getSdk() {
    RunConfigurationModule runConfigurationModule = getConfigurationModule();
    Module currentModule = runConfigurationModule.getModule();
    if (currentModule != null)
        return LuaSdkType.findLuaSdk(currentModule);
    Project currentProject = runConfigurationModule.getProject();
    return ProjectRootManager.getInstance(currentProject).getProjectSdk();
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void editRemoteSdk(Sdk currentSdk) {
  PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance();
  if (remoteInterpreterManager != null) {
    final SdkModificator modificator = myModificators.get(currentSdk);
    Set<Sdk> existingSdks = Sets.newHashSet(myProjectSdksModel.getSdks());
    existingSdks.remove(currentSdk);
    if (remoteInterpreterManager.editSdk(myProject, modificator, existingSdks)) {
      myModifiedModificators.add(modificator);
    }
  }
}
项目:intellij-ce-playground    文件:PlatformTestCase.java   
protected void setUpJdk() {
    //final ProjectJdkEx jdk = ProjectJdkUtil.getDefaultJdk("java 1.4");
    final Sdk jdk = getTestProjectJdk();
//    ProjectJdkImpl jdk = ProjectJdkTable.getInstance().addJdk(defaultJdk);
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    for (Module module : modules) {
      ModuleRootModificationUtil.setModuleSdk(module, jdk);
    }
  }
项目:intellij    文件:BlazeAndroidSyncPlugin.java   
@Override
public void updateProjectSdk(
    Project project,
    BlazeContext context,
    ProjectViewSet projectViewSet,
    BlazeVersionData blazeVersionData,
    BlazeProjectData blazeProjectData) {
  if (!isAndroidWorkspace(blazeProjectData.workspaceLanguageSettings)) {
    return;
  }
  BlazeAndroidSyncData syncData = blazeProjectData.syncState.get(BlazeAndroidSyncData.class);
  if (syncData == null) {
    return;
  }
  AndroidSdkPlatform androidSdkPlatform = syncData.androidSdkPlatform;
  if (androidSdkPlatform == null) {
    return;
  }
  Sdk sdk = BlazeSdkProvider.getInstance().findSdk(androidSdkPlatform.androidSdk);
  if (sdk == null) {
    IssueOutput.error(
            String.format("Android platform '%s' not found.", androidSdkPlatform.androidSdk))
        .submit(context);
    return;
  }

  LanguageLevel defaultLanguageLevel =
      BuildSystemAndroidJdkProvider.languageLevel(
          Blaze.getBuildSystem(project), blazeVersionData);
  LanguageLevel javaLanguageLevel =
      JavaLanguageLevelSection.getLanguageLevel(projectViewSet, defaultLanguageLevel);
  setProjectSdkAndLanguageLevel(project, sdk, javaLanguageLevel);
}
项目:intellij-ce-playground    文件:JavaCommandLineTest.java   
public void testClasspath() throws CantRunException {
  JavaParameters javaParameters;
  String commandLineString;

  javaParameters = new JavaParameters();
  final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
  javaParameters.setJdk(internalJdk);
  javaParameters.getClassPath().add("my-jar-file.jar");
  javaParameters.setMainClass("Main");
  commandLineString = CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString();
  assertTrue(containsClassPath(commandLineString));

  javaParameters = new JavaParameters();
  javaParameters.setJdk(internalJdk);
  javaParameters.getClassPath().add("my-jar-file.jar");
  javaParameters.setMainClass("Main");
  javaParameters.getVMParametersList().add("-cp");
  javaParameters.getVMParametersList().add("..");
  commandLineString = CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString();
  commandLineString = removeClassPath(commandLineString, "-cp ..");
  assertTrue(!containsClassPath(commandLineString));

  javaParameters = new JavaParameters();
  javaParameters.setJdk(internalJdk);
  javaParameters.getClassPath().add("my-jar-file.jar");
  javaParameters.setMainClass("Main");
  javaParameters.getVMParametersList().add("-classpath");
  javaParameters.getVMParametersList().add("..");
  commandLineString = CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString();
  commandLineString = removeClassPath(commandLineString, "-classpath ..");
  assertTrue(!containsClassPath(commandLineString));
}
项目:intellij-ce-playground    文件:PyActiveSdkConfigurable.java   
private void rehighlightVersionSpecific(@Nullable final Sdk newSdk, @Nullable final Sdk prevSdk) {
  if (prevSdk != null && newSdk != null) {
    final PythonSdkFlavor flavor1 = PythonSdkFlavor.getFlavor(newSdk);
    final PythonSdkFlavor flavor2 = PythonSdkFlavor.getFlavor(prevSdk);
    if (flavor1 != null && flavor2 != null) {
      final LanguageLevel languageLevel1 = flavor1.getLanguageLevel(newSdk);
      final LanguageLevel languageLevel2 = flavor2.getLanguageLevel(prevSdk);
      if ((languageLevel1.isPy3K() && !languageLevel2.isPy3K()) ||
          (!languageLevel1.isPy3K()) && languageLevel2.isPy3K()) {
        PyUtil.rehighlightOpenEditors(myProject);
      }
    }
  }
}
项目:intellij-ce-playground    文件:PythonConsoleView.java   
public PythonConsoleView(final Project project, final String title, final Sdk sdk) {
  super(project, title, PythonLanguage.getInstance());

  getVirtualFile().putUserData(LanguageLevel.KEY, PythonSdkType.getLanguageLevelForSdk(sdk));
  // Mark editor as console one, to prevent autopopup completion
  getConsoleEditor().putUserData(PythonConsoleAutopopupBlockingHandler.REPL_KEY, new Object());

  setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
  setUpdateFoldingsEnabled(false);
  //noinspection ConstantConditions
  myPyHighlighter = new PyHighlighter(
    sdk != null && sdk.getVersionString() != null ? LanguageLevel.fromPythonVersion(sdk.getVersionString()) : LanguageLevel.getDefault());
  myScheme = getConsoleEditor().getColorsScheme();
}
项目:intellij-ce-playground    文件:AndroidSdkModuleCustomizer.java   
/**
 * Sets an Android SDK to the given module only if:
 * <ol>
 * <li>the given module was created by importing an {@code AndroidProject}</li>
 * <li>there is a matching Android SDK already defined in IDEA</li>
 * </ol>
 * @param project         project that owns the module to customize.
 * @param ideaModuleModel modifiable root module of the module to customize.
 * @param androidProject  the imported Android-Gradle project.
 */
@Override
public void customizeModule(@NotNull Project project,
                            @NotNull Module module,
                            @NotNull IdeModifiableModelsProvider modelsProvider,
                            @Nullable IdeaAndroidProject androidProject) {
  if (androidProject == null) {
    return;
  }
  File androidSdkHomePath = IdeSdks.getAndroidSdkPath();
  // Android SDK may be not configured in IntelliJ
  if (androidSdkHomePath == null) {
    return;
  }

  final ModifiableRootModel ideaModuleModel = modelsProvider.getModifiableRootModel(module);
  LanguageLevel languageLevel = androidProject.getJavaLanguageLevel();
  if (languageLevel != null) {
    ideaModuleModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class).setLanguageLevel(languageLevel);
  }

  String compileTarget = androidProject.getDelegate().getCompileTarget();

  Sdk sdk = findSuitableAndroidSdk(compileTarget);
  if (sdk == null) {
    sdk = tryToCreateAndroidSdk(androidSdkHomePath, compileTarget);
  }

  if (sdk != null) {
    ideaModuleModel.setSdk(sdk);
    return;
  }

  String text = String.format("Module '%1$s': platform '%2$s' not found.", module.getName(), compileTarget);
  LOG.info(text);

  Message msg = new Message(FAILED_TO_SET_UP_SDK, Message.Type.ERROR, text);
  ProjectSyncMessages.getInstance(project).add(msg);
}
项目:intellij-ce-playground    文件:JavaParameters.java   
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, @MagicConstant(valuesFromClass = JavaParameters.class) int classPathType, Sdk jdk) {
  if ((classPathType & JDK_ONLY) == 0) {
    enumerator = enumerator.withoutSdk();
  }
  if ((classPathType & TESTS_ONLY) == 0) {
    enumerator = enumerator.productionOnly();
  }
  OrderRootsEnumerator rootsEnumerator = enumerator.classes();
  final NotNullFunction<OrderEntry, VirtualFile[]> provider = computeRootProvider(classPathType, jdk);
  if (provider != null) {
    rootsEnumerator = rootsEnumerator.usingCustomRootProvider(provider);
  }
  return rootsEnumerator;
}
项目:intellij-ce-playground    文件:AndroidSdkUtils.java   
public static void clearLocalPkgInfo(@NotNull Sdk sdk) {
  AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);
  if (data == null) {
    return;
  }

  if (data.getAndroidPlatform() != null) {
    data.getAndroidPlatform().getSdkData().getLocalSdk().clearLocalPkg(PkgType.PKG_ALL);
  }
  data.clearAndroidPlatform();
}
项目:intellij-ce-playground    文件:PyPackageManagementService.java   
@Nullable
public static ErrorDescription toErrorDescription(@Nullable List<ExecutionException> exceptions, @Nullable Sdk sdk) {
  if (exceptions != null && !exceptions.isEmpty() && !isCancelled(exceptions)) {
    return createDescription(exceptions.get(0), sdk);
  }
  return null;
}