Search in sources :

Example 36 with SdkModificator

use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testAssets.

@JSTestOptions({ JSTestOption.WithFlexFacet })
public void testAssets() throws Throwable {
    final String testName = getTestName(false);
    final String fileRelPath = "pack/" + testName + ".mxml";
    final VirtualFile swcFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + "/" + testName + ".swc");
    final SdkModificator modificator = FlexTestUtils.getFlexSdkModificator(getModule());
    modificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(swcFile), OrderRootType.CLASSES);
    modificator.commitChanges();
    final Module dependentModule = doCreateRealModule("dependent");
    final VirtualFile contentRoot = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + "_dependent_module");
    PsiTestUtil.addSourceRoot(dependentModule, contentRoot);
    final String absPath = LocalFileSystem.getInstance().findFileByPath("").getPath();
    myAfterCommitRunnable = () -> ApplicationManager.getApplication().runWriteAction(() -> {
        replaceText(fileRelPath, "${SOME_ABSOLUTE_PATH}", absPath);
        ModuleRootModificationUtil.addDependency(myModule, dependentModule);
    });
    doTestFor(true, getDefaultProjectRoot(testName), (Runnable) null, testName + "/" + fileRelPath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) Module(com.intellij.openapi.module.Module)

Example 37 with SdkModificator

use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testIgnoreClassesFromOnlySdkSources.

@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testIgnoreClassesFromOnlySdkSources() throws Exception {
    final String testName = getTestName(false);
    final VirtualFile srcFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + "/sdk_src/");
    final SdkModificator modificator = FlexTestUtils.getFlexSdkModificator(myModule);
    modificator.addRoot(srcFile, OrderRootType.SOURCES);
    modificator.commitChanges();
    doTestFor(true, testName + "/" + testName + ".mxml");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator)

Example 38 with SdkModificator

use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.

the class FlexCompletionTest method testResourceBundleFromSdk.

@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testResourceBundleFromSdk() throws Exception {
    final String testName = getTestName(false);
    final Sdk flexSdk = FlexUtils.getSdkForActiveBC(getModule());
    final SdkModificator sdkModificator = flexSdk.getSdkModificator();
    final VirtualFile swcFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + "/" + getBasePath() + "/" + testName + ".swc");
    sdkModificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(swcFile), OrderRootType.CLASSES);
    sdkModificator.commitChanges();
    doTest("", "as");
    doTest("", "mxml");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 39 with SdkModificator

use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testNamespacesFromSdkSwcs.

@JSTestOptions({ JSTestOption.WithJsSupportLoader, JSTestOption.WithFlexSdk })
public void testNamespacesFromSdkSwcs() throws Exception {
    final String name = getTestName(false);
    final SdkModificator sdkModificator = FlexTestUtils.getFlexSdkModificator(getModule());
    final VirtualFile swcFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + "/" + getBasePath() + "/" + name + ".swc");
    sdkModificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(swcFile), OrderRootType.CLASSES);
    sdkModificator.commitChanges();
    doTestFor(true, name + ".mxml");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator)

Example 40 with SdkModificator

use of com.intellij.openapi.projectRoots.SdkModificator in project intellij-plugins by JetBrains.

the class AppTestBase method doSetupFlexSdk.

private void doSetupFlexSdk(final Module module, final String flexSdkRootPath, final TargetPlatform targetPlatform, final String sdkVersion) {
    final String sdkName = generateSdkName(sdkVersion);
    Sdk sdk = ProjectJdkTable.getInstance().findJdk(sdkName);
    if (sdk == null) {
        ApplicationManager.getApplication().runWriteAction(() -> {
            FlexSdkType2 sdkType = FlexSdkType2.getInstance();
            Sdk sdk1 = new ProjectJdkImpl(sdkName, sdkType, flexSdkRootPath, "");
            ProjectJdkTable.getInstance().addJdk(sdk1);
            Disposer.register(getSdkParentDisposable(), new Disposable() {

                @Override
                public void dispose() {
                    ApplicationManager.getApplication().runWriteAction(() -> {
                        ProjectJdkTable sdkTable = ProjectJdkTable.getInstance();
                        sdkTable.removeJdk(sdkTable.findJdk(sdkName));
                    });
                }
            });
            final SdkModificator modificator = sdk1.getSdkModificator();
            modificator.setVersionString(FlexSdkType2.getInstance().getVersionString(sdk1.getHomePath()));
            modifySdk(sdk1, modificator);
            modificator.commitChanges();
        });
    }
    FlexTestUtils.modifyBuildConfiguration(module, bc -> {
        bc.setNature(new BuildConfigurationNature(targetPlatform, false, getOutputType()));
        bc.getDependencies().setSdkEntry(Factory.createSdkEntry(sdkName));
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) FlexSdkType2(com.intellij.lang.javascript.flex.sdk.FlexSdkType2) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator)

Aggregations

SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)51 Sdk (com.intellij.openapi.projectRoots.Sdk)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)30 File (java.io.File)8 Module (com.intellij.openapi.module.Module)7 IAndroidTarget (com.android.sdklib.IAndroidTarget)6 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)5 NotNull (org.jetbrains.annotations.NotNull)5 ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)4 Library (com.intellij.openapi.roots.libraries.Library)4 Nullable (org.jetbrains.annotations.Nullable)4 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)3 Project (com.intellij.openapi.project.Project)3 ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)3 FirstRunWizardMode (com.android.tools.idea.welcome.config.FirstRunWizardMode)2 FlexSdkType2 (com.intellij.lang.javascript.flex.sdk.FlexSdkType2)2 OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)2 IOException (java.io.IOException)2 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)2 Contract (org.jetbrains.annotations.Contract)2