本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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());
}
示例13: create
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Override
protected SdkModificator create(Sdk sdk) {
return sdk.getSdkModificator();
}
示例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);
}
}
示例15: addAnnotations
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public static void addAnnotations(@NotNull Sdk sdk) {
SdkModificator modifier = sdk.getSdkModificator();
attachJdkAnnotations(modifier);
modifier.commitChanges();
}