com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess Java Examples
The following examples show how to use
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GradleImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { assumeThat(gradleVersion, versionMatcherRule.getMatcher()); myJdkHome = IdeaTestUtil.requireRealJdkHome(); super.setUp(); WriteAction.runAndWait(() -> { Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME); if (oldJdk != null) { ProjectJdkTable.getInstance().removeJdk(oldJdk); } VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome)); JavaSdk javaSdk = JavaSdk.getInstance(); SdkType javaSdkType = javaSdk == null ? SimpleJavaSdkType.getInstance() : javaSdk; Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, javaSdkType, true, null, GRADLE_JDK_NAME); assertNotNull("Cannot create JDK for " + myJdkHome, jdk); ProjectJdkTable.getInstance().addJdk(jdk); }); myProjectSettings = new GradleProjectSettings().withQualifiedModuleNames(); System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS)); PathAssembler.LocalDistribution distribution = configureWrapper(); List<String> allowedRoots = new ArrayList<>(); collectAllowedRoots(allowedRoots, distribution); if (!allowedRoots.isEmpty()) { VfsRootAccess.allowRootAccess(myTestFixture.getTestRootDisposable(), ArrayUtil.toStringArray(allowedRoots)); } }
Example #2
Source File: LocalFileSystemTest.java From consulo with Apache License 2.0 | 5 votes |
public void testWindowsHiddenDirectory() throws Exception { if (!SystemInfo.isWindows) { System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME); return; } File file = new File("C:\\Documents and Settings\\desktop.ini"); if (!file.exists()) { System.err.println(getName() + " skipped: missing " + file); return; } String parent = FileUtil.toSystemIndependentName(file.getParent()); VfsRootAccess.allowRootAccess(parent); try { VirtualFile virtualFile = myFS.refreshAndFindFileByIoFile(file); assertNotNull(virtualFile); NewVirtualFileSystem fs = (NewVirtualFileSystem)virtualFile.getFileSystem(); FileAttributes attributes = fs.getAttributes(virtualFile); assertNotNull(attributes); assertEquals(FileAttributes.Type.FILE, attributes.type); assertEquals(FileAttributes.HIDDEN, attributes.flags); } finally { VfsRootAccess.disallowRootAccess(parent); } }
Example #3
Source File: FieldNameConstantsOldTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); final Disposable projectDisposable = myFixture.getProjectDisposable(); final String basePath = new File(getTestDataPath(), getBasePath()).getCanonicalPath(); VfsRootAccess.allowRootAccess(projectDisposable, basePath, new File(LOMBOK_SRC_PATH).getCanonicalPath()); VfsRootAccess.allowRootAccess(projectDisposable, basePath, new File(OLD_LOMBOK_SRC_PATH).getCanonicalPath()); //TODO disable assertions for the moment RecursionManager.disableMissedCacheAssertions(myFixture.getProjectDisposable()); }
Example #4
Source File: PantsIntegrationTestCase.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { cleanProjectIdeaDir(); super.setUp(); VfsRootAccess.allowRootAccess(myProject, "/"); for (String pluginId : getRequiredPluginIds()) { IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(PluginId.getId(pluginId)); assertNotNull(pluginId + " plugin should be in classpath for integration tests!", plugin); assertTrue(pluginId + " is not enabled!", plugin.isEnabled()); } myProjectSettings = new PantsProjectSettings(); myCompilerTester = null; }
Example #5
Source File: BashTestUtils.java From BashSupport with Apache License 2.0 | 5 votes |
public static String getBasePath() { if (basePath == null) { basePath = computeBasePath(); } if (basePath == null) { throw new IllegalStateException("Could not find the testData directory."); } VfsRootAccess.allowRootAccess(basePath); return basePath; }
Example #6
Source File: AswbIntegrationTestSetupRule.java From intellij with Apache License 2.0 | 5 votes |
private void symlinkRequiredLibraries() { VfsRootAccess.allowRootAccess("/"); // Bazel tests are sandboxed so we disable VfsRoot checks. /* * Android annotation requires a different path to match one of the candidate paths in * {@link com.android.tools.idea.startup.ExternalAnnotationsSupport.DEVELOPMENT_ANNOTATIONS_PATHS} */ symlinkToSandboxHome( "tools/adt/idea/android/annotations", SANDBOX_IDEA_HOME + "android/android/annotations"); symlinkToSandboxHome("prebuilts/studio/layoutlib"); symlinkToSandboxHome("prebuilts/studio/sdk"); }
Example #7
Source File: FlutterTestUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void configureFlutterSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) { final String sdkHome; if (realSdk) { sdkHome = System.getProperty("flutter.sdk"); if (sdkHome == null) { Assert.fail("To run tests that use the flutter tools you need to add '-Dflutter.sdk=[real SDK home]' to the VM Options field of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } if (!FlutterSdkUtil.isFlutterSdkHome(sdkHome)) { Assert.fail("Incorrect path to the Flutter SDK (" + sdkHome + ") is set as '-Dflutter.sdk' VM option of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } VfsRootAccess.allowRootAccess(disposable, sdkHome); } else { sdkHome = SDK_HOME_PATH; } ApplicationManager.getApplication().runWriteAction(() -> { FlutterSdkUtil.setFlutterSdkPath(module.getProject(), sdkHome); DartPlugin.enableDartSdk(module); }); Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { DartPlugin.disableDartSdk(Collections.singletonList(module)); } final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable(); final Library library = libraryTable.getLibraryByName(FlutterSdk.FLUTTER_SDK_GLOBAL_LIB_NAME); if (library != null) { libraryTable.removeLibrary(library); } })); }
Example #8
Source File: FlutterTestUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void configureFlutterSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) { final String sdkHome; if (realSdk) { sdkHome = System.getProperty("flutter.sdk"); if (sdkHome == null) { Assert.fail("To run tests that use the flutter tools you need to add '-Dflutter.sdk=[real SDK home]' to the VM Options field of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } if (!FlutterSdkUtil.isFlutterSdkHome(sdkHome)) { Assert.fail("Incorrect path to the Flutter SDK (" + sdkHome + ") is set as '-Dflutter.sdk' VM option of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } VfsRootAccess.allowRootAccess(disposable, sdkHome); } else { sdkHome = SDK_HOME_PATH; } ApplicationManager.getApplication().runWriteAction(() -> { FlutterSdkUtil.setFlutterSdkPath(module.getProject(), sdkHome); DartPlugin.enableDartSdk(module); }); Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { DartPlugin.disableDartSdk(Collections.singletonList(module)); } final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable(); final Library library = libraryTable.getLibraryByName(FlutterSdk.FLUTTER_SDK_GLOBAL_LIB_NAME); if (library != null) { libraryTable.removeLibrary(library); } })); }
Example #9
Source File: MavenImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { VfsRootAccess.allowRootAccess(getTestRootDisposable(), PathManager.getConfigPath()); super.setUp(); File settingsFile = MavenWorkspaceSettingsComponent.getInstance(myProject).getSettings().generalSettings.getEffectiveGlobalSettingsIoFile(); if (settingsFile != null) { VfsRootAccess.allowRootAccess(getTestRootDisposable(), settingsFile.getAbsolutePath()); } }
Example #10
Source File: ExternalSystemTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Before @Override public void setUp() throws Exception { super.setUp(); ensureTempDirCreated(); myTestDir = new File(ourTempDir, getTestName(false)); FileUtil.ensureExists(myTestDir); setUpFixtures(); myProject = myTestFixture.getProject(); EdtTestUtil.runInEdtAndWait(() -> ApplicationManager.getApplication().runWriteAction(() -> { try { setUpInWriteAction(); } catch (Throwable e) { try { tearDown(); } catch (Exception e1) { e1.printStackTrace(); } throw new RuntimeException(e); } })); List<String> allowedRoots = new ArrayList<>(); collectAllowedRoots(allowedRoots); if (!allowedRoots.isEmpty()) { VfsRootAccess.allowRootAccess(myTestFixture.getTestRootDisposable(), ArrayUtil.toStringArray(allowedRoots)); } }
Example #11
Source File: DartTestUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@SuppressWarnings("Duplicates") public static void configureDartSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) { final String sdkHome; if (realSdk) { sdkHome = System.getProperty("dart.sdk"); if (sdkHome == null) { Assert.fail("To run tests that use Dart Analysis Server you need to add '-Ddart.sdk=[real SDK home]' to the VM Options field of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } if (!DartPlugin.isDartSdkHome(sdkHome)) { Assert.fail("Incorrect path to the Dart SDK (" + sdkHome + ") is set as '-Ddart.sdk' VM option of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } VfsRootAccess.allowRootAccess(disposable, sdkHome); // Dart Analysis Server threads ThreadTracker.longRunningThreadCreated(ApplicationManager.getApplication(), "ByteRequestSink.LinesWriterThread", "ByteResponseStream.LinesReaderThread", "RemoteAnalysisServerImpl watcher", "ServerErrorReaderThread", "ServerResponseReaderThread"); } else { sdkHome = SDK_HOME_PATH; } ApplicationManager.getApplication().runWriteAction(() -> { DartPlugin.ensureDartSdkConfigured(module.getProject(), sdkHome); DartPlugin.enableDartSdk(module); }); Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { DartPlugin.disableDartSdk(Collections.singletonList(module)); } final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable(); final Library library = libraryTable.getLibraryByName(DartSdk.DART_SDK_LIB_NAME); if (library != null) { libraryTable.removeLibrary(library); } })); }
Example #12
Source File: DartTestUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@SuppressWarnings("Duplicates") public static void configureDartSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) { final String sdkHome; if (realSdk) { sdkHome = System.getProperty("dart.sdk"); if (sdkHome == null) { Assert.fail("To run tests that use Dart Analysis Server you need to add '-Ddart.sdk=[real SDK home]' to the VM Options field of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } if (!DartPlugin.isDartSdkHome(sdkHome)) { Assert.fail("Incorrect path to the Dart SDK (" + sdkHome + ") is set as '-Ddart.sdk' VM option of " + "the corresponding JUnit run configuration (Run | Edit Configurations)"); } VfsRootAccess.allowRootAccess(disposable, sdkHome); // Dart Analysis Server threads ThreadTracker.longRunningThreadCreated(ApplicationManager.getApplication(), "ByteRequestSink.LinesWriterThread", "ByteResponseStream.LinesReaderThread", "RemoteAnalysisServerImpl watcher", "ServerErrorReaderThread", "ServerResponseReaderThread"); } else { sdkHome = SDK_HOME_PATH; } ApplicationManager.getApplication().runWriteAction(() -> { DartPlugin.ensureDartSdkConfigured(module.getProject(), sdkHome); DartPlugin.enableDartSdk(module); }); Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { DartPlugin.disableDartSdk(Collections.singletonList(module)); } final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable(); final Library library = libraryTable.getLibraryByName(DartSdk.DART_SDK_LIB_NAME); if (library != null) { libraryTable.removeLibrary(library); } })); }
Example #13
Source File: ClionUnitTestSystemPropertiesRule.java From intellij with Apache License 2.0 | 4 votes |
/** Sets up the necessary system properties for running IntelliJ tests via blaze/bazel. */ private static void configureSystemProperties() throws IOException { File sandbox = new File(getTmpDirFile(), "_intellij_test_sandbox"); setSandboxPath("idea.home.path", new File(sandbox, "home")); setSandboxPath("idea.config.path", new File(sandbox, "config")); setSandboxPath("idea.system.path", new File(sandbox, "system")); setSandboxPath("java.util.prefs.userRoot", new File(sandbox, "userRoot")); setSandboxPath("java.util.prefs.systemRoot", new File(sandbox, "systemRoot")); setIfEmpty("idea.classpath.index.enabled", "false"); // Some plugins have a since-build and until-build restriction, so we need // to update the build number here PluginManagerCore.BUILD_NUMBER = readApiVersionNumber(); // Tests fail if they access files outside of the project roots and other system directories. // Ensure runfiles and platform api are whitelisted. VfsRootAccess.allowRootAccess(RUNFILES_PATH); String platformApi = getPlatformApiPath(); if (platformApi != null) { VfsRootAccess.allowRootAccess(platformApi); } List<String> pluginJars = Lists.newArrayList(); try { Enumeration<URL> urls = ClionUnitTestSystemPropertiesRule.class .getClassLoader() .getResources("META-INF/plugin.xml"); while (urls.hasMoreElements()) { URL url = urls.nextElement(); addArchiveFile(url, pluginJars); } } catch (IOException e) { System.err.println("Cannot find plugin.xml resources"); e.printStackTrace(); } setIfEmpty("idea.plugins.path", Joiner.on(File.pathSeparator).join(pluginJars)); }
Example #14
Source File: BlazeTestSystemPropertiesRule.java From intellij with Apache License 2.0 | 4 votes |
/** Sets up the necessary system properties for running IntelliJ tests via blaze/bazel. */ private static void configureSystemProperties() throws IOException { File sandbox = new File(TestUtils.getTmpDirFile(), "_intellij_test_sandbox"); setSandboxPath("idea.home.path", new File(sandbox, "home")); setSandboxPath("idea.config.path", new File(sandbox, "config")); setSandboxPath("idea.system.path", new File(sandbox, "system")); setSandboxPath("java.util.prefs.userRoot", new File(sandbox, "userRoot")); setSandboxPath("java.util.prefs.systemRoot", new File(sandbox, "systemRoot")); setIfEmpty("idea.classpath.index.enabled", "false"); // Some plugins have a since-build and until-build restriction, so we need // to update the build number here String buildNumber = readApiVersionNumber(); if (buildNumber == null) { buildNumber = BuildNumber.currentVersion().asString(); } setIfEmpty("idea.plugins.compatible.build", buildNumber); setIfEmpty(PlatformUtils.PLATFORM_PREFIX_KEY, determinePlatformPrefix(buildNumber)); // Tests fail if they access files outside of the project roots and other system directories. // Ensure runfiles and platform api are whitelisted. VfsRootAccess.allowRootAccess(RUNFILES_PATH); String platformApi = getPlatformApiPath(); if (platformApi != null) { VfsRootAccess.allowRootAccess(platformApi); } List<String> pluginJars = Lists.newArrayList(); try { Enumeration<URL> urls = BlazeTestSystemPropertiesRule.class.getClassLoader().getResources("META-INF/plugin.xml"); while (urls.hasMoreElements()) { URL url = urls.nextElement(); addArchiveFile(url, pluginJars); } } catch (IOException e) { System.err.println("Cannot find plugin.xml resources"); e.printStackTrace(); } setIfEmpty("idea.plugins.path", Joiner.on(File.pathSeparator).join(pluginJars)); }
Example #15
Source File: OSSPantsPythonIntegrationTest.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@Override public void setUp() throws Exception { super.setUp(); // todo: Remove if possible. Now the test fails with VfsRootAccess to python interpreter in /opt VfsRootAccess.allowRootAccess("/"); }
Example #16
Source File: LombokTestUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static void loadLibrary(@NotNull Disposable projectDisposable, @NotNull Module module, String libraryName, String libraryJarName) { final String lombokLibPath = PathUtil.toSystemIndependentName(new File(THIRD_PARTY_LIB_DIRECTORY).getAbsolutePath()); VfsRootAccess.allowRootAccess(projectDisposable, lombokLibPath); PsiTestUtil.addLibrary(projectDisposable, module, libraryName, lombokLibPath, libraryJarName); }
Example #17
Source File: FileWatcherTest.java From consulo with Apache License 2.0 | 4 votes |
public void testSubst() throws Exception { if (!SystemInfo.isWindows) { System.err.println("Ignored: Windows required"); return; } File targetDir = createTestDir("top"); File subDir = createTestDir(targetDir, "sub"); File file = createTestFile(subDir, "test.txt"); File rootFile = createSubst(targetDir.getPath()); VfsRootAccess.allowRootAccess(rootFile.getPath()); VirtualFile vfsRoot = myFileSystem.findFileByIoFile(rootFile); try { assertNotNull(rootFile.getPath(), vfsRoot); File substDir = new File(rootFile, subDir.getName()); File substFile = new File(substDir, file.getName()); refresh(targetDir); refresh(substDir); myAcceptedDirectories.add(substDir.getPath()); LocalFileSystem.WatchRequest request = watch(substDir); try { myAccept = true; FileUtil.writeToFile(file, "new content"); assertEvent(VFileContentChangeEvent.class, substFile.getPath()); LocalFileSystem.WatchRequest request2 = watch(targetDir); try { myAccept = true; FileUtil.delete(file); assertEvent(VFileDeleteEvent.class, file.getPath(), substFile.getPath()); } finally { unwatch(request2); } myAccept = true; FileUtil.writeToFile(file, "re-creation"); assertEvent(VFileCreateEvent.class, substFile.getPath()); } finally { unwatch(request); } } finally { delete(targetDir); deleteSubst(rootFile.getPath()); if (vfsRoot != null) { ((NewVirtualFile)vfsRoot).markDirty(); myFileSystem.refresh(false); } VfsRootAccess.disallowRootAccess(rootFile.getPath()); } }