当前位置: 首页>>代码示例>>Java>>正文


Java Sdk.getSdkModificator方法代码示例

本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk.getSdkModificator方法的典型用法代码示例。如果您正苦于以下问题:Java Sdk.getSdkModificator方法的具体用法?Java Sdk.getSdkModificator怎么用?Java Sdk.getSdkModificator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.projectRoots.Sdk的用法示例。


在下文中一共展示了Sdk.getSdkModificator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retainRtJarOnlyAndSetVersion

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@NotNull
private static Sdk retainRtJarOnlyAndSetVersion(Sdk jdk) {
  final SdkModificator modificator = jdk.getSdkModificator();
  VirtualFile rtJar = null;
  for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) {
    if (root.getName().equals("rt.jar")) {
      rtJar = root;
      break;
    }
  }
  assertNotNull("rt.jar not found in jdk: " + jdk, rtJar);
  modificator.setVersionString(IdeaTestUtil.getMockJdkVersion(jdk.getHomePath()));
  modificator.removeAllRoots();
  modificator.addRoot(rtJar, OrderRootType.CLASSES);
  modificator.commitChanges();
  return jdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ModuleRootManagerTestCase.java

示例2: createNewAndroidPlatform

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static Sdk createNewAndroidPlatform(@NotNull IAndroidTarget target,
                                           @NotNull String sdkPath,
                                           @NotNull String sdkName,
                                           @Nullable Sdk jdk,
                                           boolean addRoots) {
  ProjectJdkTable table = ProjectJdkTable.getInstance();
  String tmpName = createUniqueSdkName(SDK_NAME, Arrays.asList(table.getAllJdks()));

  final Sdk sdk = table.createSdk(tmpName, AndroidSdkType.getInstance());

  SdkModificator sdkModificator = sdk.getSdkModificator();
  sdkModificator.setHomePath(sdkPath);
  sdkModificator.commitChanges();

  setUpSdk(sdk, sdkName, table.getAllJdks(), target, jdk, addRoots);

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable.getInstance().addJdk(sdk);
    }
  });
  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidSdkUtils.java

示例3: addJdkAnnotations

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static Sdk addJdkAnnotations(Sdk sdk) {
  VirtualFile root = LocalFileSystem.getInstance().findFileByPath(
    FileUtil.toSystemIndependentName(PlatformTestUtil.getCommunityPath()) + "/java/jdkAnnotations");
  if (root != null) {
    SdkModificator sdkModificator = sdk.getSdkModificator();
    sdkModificator.addRoot(root, AnnotationOrderRootType.getInstance());
    sdkModificator.commitChanges();
  }
  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiTestUtil.java

示例4: create

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static Sdk create(final String version, @NotNull final VirtualFile ... additionalRoots) {
  final String mock_path = PythonTestUtil.getTestDataPath() + "/MockSdk" + version + "/";

  String sdkHome = new File(mock_path, "bin/python"+version).getPath();
  SdkType sdkType = PythonSdkType.getInstance();


  final Sdk sdk = new ProjectJdkImpl(MOCK_SDK_NAME + " " + version, sdkType) {
    @Override
    public String getVersionString() {
      return "Python " + version + " Mock SDK";
    }
  };
  final SdkModificator sdkModificator = sdk.getSdkModificator();
  sdkModificator.setHomePath(sdkHome);

  File libPath = new File(mock_path, "Lib");
  if (libPath.exists()) {
    sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath), OrderRootType.CLASSES);
  }

  PyUserSkeletonsUtil.addUserSkeletonsRoot(PySdkUpdater.fromSdkModificator(sdk, sdkModificator));

  String mock_stubs_path = mock_path + PythonSdkType.SKELETON_DIR_NAME;
  sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), PythonSdkType.BUILTIN_ROOT_TYPE);

  for (final VirtualFile root : additionalRoots) {
    sdkModificator.addRoot(root, OrderRootType.CLASSES);
  }

  sdkModificator.commitChanges();

  final FileBasedIndex index = FileBasedIndex.getInstance();
  index.requestRebuild(StubUpdatingIndex.INDEX_ID);
  index.requestRebuild(PyModuleNameIndex.NAME);

  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PythonMockSdk.java

示例5: createNewAndroidSdkForMaven

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
private static Sdk createNewAndroidSdkForMaven(String sdkPath, IAndroidTarget target) {
  String sdkName = "Maven " + AndroidSdkUtils.chooseNameForNewLibrary(target);
  Sdk sdk = AndroidSdkUtils.createNewAndroidPlatform(target, sdkPath, sdkName, false);

  if (sdk == null) {
    return null;
  }
  SdkModificator modificator = sdk.getSdkModificator();

  for (OrderRoot root : AndroidSdkUtils.getLibraryRootsForTarget(target, sdkPath, false)) {
    modificator.addRoot(root.getFile(), root.getType());
  }
  AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);

  if (data != null) {
    final Sdk javaSdk = data.getJavaSdk();

    if (javaSdk != null) {
      for (VirtualFile file : javaSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
        modificator.addRoot(file, OrderRootType.CLASSES);
      }
    }
    else {
      LOG.error("AndroidSdkUtils.createNewAndroidPlatform should return Android SDK with a valid JDK reference, or return null");
    }
  }
  modificator.commitChanges();
  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:AndroidFacetImporterBase.java

示例6: addFilesToSdkIfNecessary

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static void addFilesToSdkIfNecessary(@NotNull Sdk sdk, @NotNull Collection<VirtualFile> files) {
  List<VirtualFile> newFiles = Lists.newArrayList(files);
  newFiles.removeAll(Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES)));

  if (newFiles.size() > 0) {
    SdkModificator modificator = sdk.getSdkModificator();

    for (VirtualFile file : newFiles) {
      modificator.addRoot(file, OrderRootType.CLASSES);
    }
    modificator.commitChanges();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AndroidFacet.java

示例7: setUpSdk

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static void setUpSdk(@NotNull Sdk androidSdk,
                            @NotNull String sdkName,
                            @NotNull Sdk[] allSdks,
                            @NotNull IAndroidTarget target,
                            @Nullable Sdk jdk,
                            boolean addRoots) {
  AndroidSdkAdditionalData data = new AndroidSdkAdditionalData(androidSdk, jdk);
  data.setBuildTarget(target);

  String name = createUniqueSdkName(sdkName, Arrays.asList(allSdks));

  SdkModificator sdkModificator = androidSdk.getSdkModificator();
  findAndSetPlatformSources(target, sdkModificator);

  sdkModificator.setName(name);
  if (jdk != null) {
    sdkModificator.setVersionString(jdk.getVersionString());
  }
  sdkModificator.setSdkAdditionalData(data);

  if (addRoots) {
    sdkModificator.removeAllRoots();
    for (OrderRoot orderRoot : getLibraryRootsForTarget(target, androidSdk.getHomePath(), true)) {
      sdkModificator.addRoot(orderRoot.getFile(), orderRoot.getType());
    }
    attachJdkAnnotations(sdkModificator);
  }

  sdkModificator.commitChanges();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:AndroidSdkUtils.java

示例8: updateSdkSourceRoot

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/**
 * Reload SDK information and update the source root of the SDK.
 */
public static void updateSdkSourceRoot(@NotNull Sdk sdk) {
  clearLocalPkgInfo(sdk);

  AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
  if (platform != null) {
    IAndroidTarget target = platform.getTarget();
    SdkModificator sdkModificator = sdk.getSdkModificator();
    sdkModificator.removeRoots(SOURCES);
    findAndSetPlatformSources(target, sdkModificator);
    sdkModificator.commitChanges();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:AndroidSdkUtils.java

示例9: refreshLibrariesIn

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static void refreshLibrariesIn(@NotNull Sdk sdk) {
  VirtualFile[] libraries = sdk.getRootProvider().getFiles(CLASSES);

  SdkModificator sdkModificator = sdk.getSdkModificator();
  sdkModificator.removeRoots(CLASSES);
  sdkModificator.commitChanges();

  sdkModificator = sdk.getSdkModificator();
  for (VirtualFile library : libraries) {
    sdkModificator.addRoot(library, CLASSES);
  }
  sdkModificator.commitChanges();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PostProjectSetupTasksExecutor.java

示例10: checkAndSetSources

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static void checkAndSetSources(@NotNull Sdk sdk) {
  VirtualFile[] storedSources = sdk.getRootProvider().getFiles(OrderRootType.SOURCES);
  if (storedSources.length > 0) {
    return;
  }

  AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
  if (platform != null) {
    SdkModificator sdkModificator = sdk.getSdkModificator();
    IAndroidTarget target = platform.getTarget();
    findAndSetPlatformSources(target, sdkModificator);
    sdkModificator.commitChanges();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AndroidStudioSpecificInitializer.java

示例11: addAnnotationsIfNecessary

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static void addAnnotationsIfNecessary(@NotNull Sdk sdk) {
  // Attempt to insert SDK annotations
  VirtualFile[] roots = sdk.getRootProvider().getFiles(AnnotationOrderRootType.getInstance());
  if (roots.length > 0) {
    return;
  }
  SdkModificator modifier = sdk.getSdkModificator();
  attachJdkAnnotations(modifier);
  modifier.commitChanges();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ExternalAnnotationsSupport.java

示例12: generateTempSkeletonsOrPackages

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/**
 * Adds installed eggs to SDK, generates skeletons (optionally) and associates it with modle.
 *
 * @param sdk          sdk to process
 * @param addSkeletons add skeletons or only packages
 * @param module       module to associate with (if provided)
 * @throws InvalidSdkException bas sdk
 * @throws IOException         failed to read eggs
 */
private static void generateTempSkeletonsOrPackages(@NotNull final Sdk sdk,
                                                    final boolean addSkeletons,
                                                    @Nullable final Module module)
  throws InvalidSdkException, IOException {

  if (module != null) {
    // Associate with module
    final Project project = module.getProject();
    ModuleRootModificationUtil.setModuleSdk(module, sdk);

    UsefulTestCase.edt(new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            ProjectRootManager.getInstance(project).setProjectSdk(sdk);
          }
        });
      }
    });
  }


  final SdkModificator modificator = sdk.getSdkModificator();
  modificator.removeRoots(OrderRootType.CLASSES);

  for (final String path : PythonSdkType.getSysPathsFromScript(sdk.getHomePath())) {
    PythonSdkType.addSdkRoot(PySdkUpdater.fromSdkModificator(sdk, modificator), path);
  }
  if (!addSkeletons) {
    UsefulTestCase.edt(new Runnable() {
      @Override
      public void run() {
        modificator.commitChanges();
      }
    });
    return;
  }

  final File tempDir = FileUtil.createTempDirectory(PyTestSdkTools.class.getName(), null);
  final File skeletonsDir = new File(tempDir, PythonSdkType.SKELETON_DIR_NAME);
  FileUtil.createDirectory(skeletonsDir);
  final String skeletonsPath = skeletonsDir.toString();
  PythonSdkType.addSdkRoot(PySdkUpdater.fromSdkModificator(sdk, modificator), skeletonsPath);

  UsefulTestCase.edt(new Runnable() {
    @Override
    public void run() {
      modificator.commitChanges();
    }
  });

  final SkeletonVersionChecker checker = new SkeletonVersionChecker(0);

  final PySkeletonRefresher refresher = new PySkeletonRefresher(null, null, sdk, skeletonsPath, null, null);
  final List<String> errors = refresher.regenerateSkeletons(checker);
  Assert.assertThat("Errors found", errors, Matchers.empty());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:PyTestSdkTools.java

示例13: create

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
protected SdkModificator create(Sdk sdk) {
  return sdk.getSdkModificator();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PythonSdkDetailsDialog.java

示例14: ensureValidSdks

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private void ensureValidSdks() {
  boolean checkJdkVersion = true;
  Collection<Sdk> invalidAndroidSdks = Sets.newHashSet();
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);

  for (Module module : moduleManager.getModules()) {
    AndroidFacet androidFacet = AndroidFacet.getInstance(module);
    if (androidFacet != null && androidFacet.getIdeaAndroidProject() != null) {
      Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
      if (sdk != null && !invalidAndroidSdks.contains(sdk) && (isMissingAndroidLibrary(sdk) || shouldRemoveAnnotationsJar(sdk))) {
        // First try to recreate SDK; workaround for issue 78072
        AndroidSdkAdditionalData additionalData = getAndroidSdkAdditionalData(sdk);
        AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
        if (additionalData != null && sdkData != null) {
          IAndroidTarget target = additionalData.getBuildTarget(sdkData);
          if (target == null) {
            LocalSdk localSdk = sdkData.getLocalSdk();
            localSdk.clearLocalPkg(EnumSet.of(PkgType.PKG_PLATFORM));
            target = localSdk.getTargetFromHashString(additionalData.getBuildTargetHashString());
          }
          if (target != null) {
            SdkModificator sdkModificator = sdk.getSdkModificator();
            sdkModificator.removeAllRoots();
            for (OrderRoot orderRoot : getLibraryRootsForTarget(target, sdk.getHomePath(), true)) {
              sdkModificator.addRoot(orderRoot.getFile(), orderRoot.getType());
            }
            attachJdkAnnotations(sdkModificator);
            sdkModificator.commitChanges();
          }
        }

        // If attempting to fix up the roots in the SDK fails, install the target over again
        // (this is a truly corrupt install, as opposed to an incorrectly synced SDK which the
        // above workaround deals with)
        if (isMissingAndroidLibrary(sdk)) {
          invalidAndroidSdks.add(sdk);
        }
      }

      IdeaAndroidProject androidProject = androidFacet.getIdeaAndroidProject();
      if (checkJdkVersion && !hasCorrectJdkVersion(module, androidProject)) {
        // we already displayed the error, no need to check each module.
        checkJdkVersion = false;
      }
    }
  }

  if (!invalidAndroidSdks.isEmpty()) {
    reinstallMissingPlatforms(invalidAndroidSdks);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:PostProjectSetupTasksExecutor.java

示例15: addAnnotations

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static void addAnnotations(@NotNull Sdk sdk) {
  SdkModificator modifier = sdk.getSdkModificator();
  attachJdkAnnotations(modifier);
  modifier.commitChanges();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ExternalAnnotationsSupport.java


注:本文中的com.intellij.openapi.projectRoots.Sdk.getSdkModificator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。