use of com.intellij.openapi.projectRoots.SdkModificator in project android by JetBrains.
the class AndroidModuleConverter1 method process.
@Override
public void process(ModuleSettings moduleSettings) throws CannotConvertException {
Element confElement = AndroidConversionUtil.findAndroidFacetConfigurationElement(moduleSettings);
assert confElement != null;
Element platformNameElement = AndroidConversionUtil.getOptionElement(confElement, PLATFORM_NAME_ATTRIBUTE);
String platformName = platformNameElement != null ? platformNameElement.getAttributeValue(AndroidConversionUtil.OPTION_VALUE_ATTRIBUTE) : null;
if (platformName == null)
return;
removeOldDependencies(moduleSettings, platformName);
confElement.removeContent(platformNameElement);
Library androidLibrary = LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraryByName(platformName);
if (androidLibrary != null) {
AndroidPlatform androidPlatform = AndroidPlatform.parse(androidLibrary, null, null);
if (androidPlatform != null) {
IAndroidTarget target = androidPlatform.getTarget();
Sdk androidSdk = AndroidSdkUtils.findAppropriateAndroidPlatform(target, androidPlatform.getSdkData(), false);
if (androidSdk == null) {
androidSdk = AndroidSdks.getInstance().create(target, androidPlatform.getSdkData().getLocation(), false);
if (androidSdk != null) {
final SdkModificator modificator = androidSdk.getSdkModificator();
for (OrderRootType type : OrderRootType.getAllTypes()) {
for (VirtualFile root : androidLibrary.getFiles(type)) {
modificator.addRoot(root, type);
}
}
modificator.commitChanges();
}
}
if (androidSdk != null) {
addNewDependency(moduleSettings, androidSdk.getName());
}
}
}
}
use of com.intellij.openapi.projectRoots.SdkModificator in project android by JetBrains.
the class AndroidSdks method create.
@Nullable
public Sdk create(@NotNull IAndroidTarget target, @NotNull File sdkPath, @NotNull String sdkName, @NotNull Sdk jdk, boolean addRoots) {
if (!target.getAdditionalLibraries().isEmpty()) {
// Do not create an IntelliJ SDK for add-ons. Add-ons should be handled as module-level library dependencies.
return null;
}
ProjectJdkTable table = ProjectJdkTable.getInstance();
String tempName = createUniqueSdkName(SDK_NAME, Arrays.asList(table.getAllJdks()));
Sdk sdk = table.createSdk(tempName, AndroidSdkType.getInstance());
SdkModificator sdkModificator = sdk.getSdkModificator();
sdkModificator.setHomePath(sdkPath.getPath());
setUpSdk(sdk, sdkModificator, target, sdkName, Arrays.asList(table.getAllJdks()), jdk, addRoots);
sdkModificator.commitChanges();
ApplicationManager.getApplication().runWriteAction(() -> ProjectJdkTable.getInstance().addJdk(sdk));
return sdk;
}
use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.
the class FlexTestUtils method createSdk.
public static Sdk createSdk(final String flexSdkRootPath, @Nullable String sdkVersion, final boolean removeExisting) {
Sdk sdk = WriteCommandAction.runWriteCommandAction(null, (Computable<Sdk>) () -> {
final ProjectJdkTable projectJdkTable = ProjectJdkTable.getInstance();
if (removeExisting) {
final List<Sdk> existingFlexSdks = projectJdkTable.getSdksOfType(FlexSdkType2.getInstance());
for (Sdk existingFlexSdk : existingFlexSdks) {
projectJdkTable.removeJdk(existingFlexSdk);
}
}
final FlexSdkType2 sdkType = FlexSdkType2.getInstance();
final Sdk sdk1 = new ProjectJdkImpl(sdkType.suggestSdkName(null, flexSdkRootPath), sdkType, flexSdkRootPath, "");
sdkType.setupSdkPaths(sdk1);
projectJdkTable.addJdk(sdk1);
return sdk1;
});
final SdkModificator modificator = sdk.getSdkModificator();
if (sdkVersion != null) {
modificator.setVersionString(sdkVersion);
}
if (sdk.getHomeDirectory() == null) {
throw new IllegalArgumentException("Could not find a Flex SDK at " + flexSdkRootPath);
}
modificator.addRoot(sdk.getHomeDirectory(), OrderRootType.CLASSES);
modificator.commitChanges();
return sdk;
}
use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.
the class FlexTestUtils method addASDocToSdk.
public static void addASDocToSdk(final Module module, final Class clazz, final String testName) {
WriteAction.run(() -> {
final Sdk flexSdk = FlexUtils.getSdkForActiveBC(module);
final SdkModificator sdkModificator = flexSdk.getSdkModificator();
VirtualFile docRoot = LocalFileSystem.getInstance().findFileByPath(getPathToMockFlex(clazz, testName) + "/asdoc");
sdkModificator.addRoot(docRoot, JavadocOrderRootType.getInstance());
sdkModificator.commitChanges();
});
}
use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.
the class FlexNavigationTest method testMonkeyPatching.
@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testMonkeyPatching() throws Exception {
final String testName = getTestName(false);
myAfterCommitRunnable = () -> {
final VirtualFile sdkSrc = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + BASE_PATH + testName + "_sdk_src");
final SdkModificator sdkModificator = FlexTestUtils.getFlexSdkModificator(myModule);
sdkModificator.addRoot(sdkSrc, OrderRootType.SOURCES);
sdkModificator.commitChanges();
};
configureByFiles(BASE_PATH + testName, BASE_PATH + testName + "/" + testName + ".as", BASE_PATH + testName + "/mx/events/FlexEvent.as");
final VirtualFile expectedFile = LocalFileSystem.getInstance().findFileByPath(ModuleRootManager.getInstance(myModule).getSourceRoots()[0].getPath() + "/mx/events/FlexEvent.as");
assert expectedFile != null;
final PsiReference reference = TargetElementUtil.findReference(myEditor);
assertNotNull(reference);
final Collection<PsiElement> candidates = TargetElementUtil.getInstance().getTargetCandidates(reference);
assertEquals(1, candidates.size());
doCheck(candidates.iterator().next(), expectedFile, expectedFile, null);
}
Aggregations