com.intellij.openapi.application.PathManager Java Examples

The following examples show how to use com.intellij.openapi.application.PathManager. 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: PantsClasspathRunConfigurationExtension.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Filter out all jars imported to the project with the exception of
 * jars on the JDK path, IntelliJ installation paths, and plugin installation path,
 * because Pants is already exporting all the runtime classpath in manifest.jar.
 *
 * Exception applies during unit test of this plugin because "JUnit" and "com.intellij"
 * plugin lives under somewhere under ivy, whereas during normal usage, they are covered
 * by `homePath`.
 *
 *
 * @param params JavaParameters
 * @return a set of paths that should be allowed to passed to the test runner.
 */
@NotNull
private Set<String> calculatePathsAllowed(JavaParameters params) {

  String homePath = PathManager.getHomePath();
  String pluginPath = PathManager.getPluginsPath();

  Set<String> pathsAllowed = Sets.newHashSet(homePath, pluginPath);

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    // /Users/yic/.ivy2/pants/com.intellij.sdk.community/idea_rt/jars/idea_rt-latest.jar ->
    // /Users/yic/.ivy2/pants/com.intellij.sdk.community/
    Optional.ofNullable(PluginManagerCore.getPlugin(PluginId.getId("com.intellij")))
      .map(s -> s.getPath().getParentFile().getParentFile().getParentFile().getAbsolutePath())
      .ifPresent(pathsAllowed::add);

    // At this point we know junit plugin is already enabled.
    // //Users/yic/.ivy2/pants/com.intellij.junit-plugin/junit-rt/jars/junit-rt-latest.jar ->
    // /Users/yic/.ivy2/pants/com.intellij.junit-plugin/
    Optional.ofNullable(PluginManagerCore.getPlugin(PluginId.getId("JUnit")))
      .map(s -> s.getPath().getParentFile().getParentFile().getParentFile().getAbsolutePath())
      .ifPresent(pathsAllowed::add);
  }
  return pathsAllowed;
}
 
Example #2
Source File: ReactiveTfvcClientHost.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
public static ReactiveTfvcClientHost create(Project project, Path clientPath) throws ExecutionException {
    SingleThreadScheduler scheduler = new SingleThreadScheduler(defineNestedLifetime(project), "ReactiveTfClient Scheduler");
    ReactiveClientConnection connection = new ReactiveClientConnection(scheduler);
    try {
        Path logDirectory = Paths.get(PathManager.getLogPath(), "ReactiveTfsClient");
        Path clientHomeDir = clientPath.getParent().getParent();
        GeneralCommandLine commandLine = ProcessHelper.patchPathEnvironmentVariable(
                getClientCommandLine(clientPath, connection.getPort(), logDirectory, clientHomeDir));
        ProcessHandler processHandler = new OSProcessHandler(commandLine);
        connection.getLifetime().onTerminationIfAlive(processHandler::destroyProcess);

        processHandler.addProcessListener(createProcessListener(connection));
        processHandler.startNotify();

        return new ReactiveTfvcClientHost(connection);
    } catch (Throwable t) {
        connection.terminate();
        throw t;
    }
}
 
Example #3
Source File: FlutterTestUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static String findTestDataPath() {
  if (new File(PathManager.getHomePath() + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Ultimate project
    return FileUtil.toSystemIndependentName(PathManager.getHomePath() + "/contrib/flutter-intellij/testData");
  }

  final File f = new File("testData");
  if (f.isDirectory()) {
    // started from flutter plugin project
    return FileUtil.toSystemIndependentName(f.getAbsolutePath());
  }

  final String parentPath = PathUtil.getParentPath(PathManager.getHomePath());

  if (new File(parentPath + "/intellij-plugins").isDirectory()) {
    // started from IntelliJ IDEA Community Edition + flutter plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/intellij-plugins/flutter-intellij/testData");
  }

  if (new File(parentPath + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Community + flutter plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/contrib/flutter-intellij/testData");
  }

  return "";
}
 
Example #4
Source File: FlutterTestUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static String findTestDataPath() {
  if (new File(PathManager.getHomePath() + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Ultimate project
    return FileUtil.toSystemIndependentName(PathManager.getHomePath() + "/contrib/flutter-intellij/testData");
  }

  final File f = new File("testData");
  if (f.isDirectory()) {
    // started from flutter plugin project
    return FileUtil.toSystemIndependentName(f.getAbsolutePath());
  }

  final String parentPath = PathUtil.getParentPath(PathManager.getHomePath());

  if (new File(parentPath + "/intellij-plugins").isDirectory()) {
    // started from IntelliJ IDEA Community Edition + flutter plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/intellij-plugins/flutter-intellij/testData");
  }

  if (new File(parentPath + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Community + flutter plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/contrib/flutter-intellij/testData");
  }

  return "";
}
 
Example #5
Source File: BlazeCWorkspace.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static void showSetupIssues(ImmutableList<String> issues, BlazeContext context) {
  logger.warn(
      String.format(
          "Issues collecting info from C++ compiler. Showing first few out of %d:\n%s",
          issues.size(), Iterables.limit(issues, 25)));
  IssueOutput.warn("Issues collecting info from C++ compiler (click to see logs)")
      .navigatable(
          new Navigatable() {
            @Override
            public void navigate(boolean b) {
              ShowFilePathAction.openFile(new File(PathManager.getLogPath(), "idea.log"));
            }

            @Override
            public boolean canNavigate() {
              return true;
            }

            @Override
            public boolean canNavigateToSource() {
              return false;
            }
          })
      .submit(context);
}
 
Example #6
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@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 #7
Source File: PantsTestUtils.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static File findTestPath(String folderName) {
  final File f = new File(folderName);
  if (f.exists()) {
    return f.getAbsoluteFile();
  }
  return new File(PathManager.getHomePath() + "/plugins/pants/" + folderName);
}
 
Example #8
Source File: HaxeTestUtils.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private static String findTestDataPath() {
  File f = new File("testData");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/haxe/testData";
}
 
Example #9
Source File: BlazeTestSystemPropertiesRule.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private static String getPlatformApiPath() {
  String platformJar = PathManager.getJarPathForClass(Application.class);
  if (platformJar == null) {
    return null;
  }
  File jarFile = new File(platformJar).getAbsoluteFile();
  File jarDir = jarFile.getParentFile();
  if (jarDir == null) {
    return null;
  }
  if (jarDir.getName().equals("lib")) {
    // Building against IDE distribution.
    // root/ <- we want this
    // |-lib/
    // | `-openapi.jar (jarFile)
    // `-plugins/
    return jarDir.getParent();
  } else if (jarDir.getName().equals("core-api")) {
    // Building against source.
    // tools/idea/ <- we want this
    // |-platform/
    // | `-core-api/
    // |   `-libcore-api.jar (jarFile)
    // `-plugins/
    File platformDir = jarDir.getParentFile();
    if (platformDir != null && platformDir.getName().equals("platform")) {
      return platformDir.getParent();
    }
  }
  return null;
}
 
Example #10
Source File: IntellijTestSetupRule.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void after() {
  if (oldPluginPathProperty != null) {
    System.setProperty(PathManager.PROPERTY_PLUGINS_PATH, oldPluginPathProperty);
  } else {
    System.clearProperty(PathManager.PROPERTY_PLUGINS_PATH);
  }
  try {
    Disposer.dispose(testRootDisposable);
    cleanupSwingDataStructures();
    cleanupDeleteOnExitHookList();
  } catch (Throwable e) {
    throw new RuntimeException(e);
  }
}
 
Example #11
Source File: IntellijTestSetupRule.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void before() throws Throwable {
  if (!isRunThroughBlaze()) {
    // If running directly through the IDE, don't try to load plugins from the sandbox environment
    // Instead we'll rely on the slightly more hermetic module classpath
    oldPluginPathProperty = System.getProperty(PathManager.PROPERTY_PLUGINS_PATH);
    System.setProperty(PathManager.PROPERTY_PLUGINS_PATH, "/dev/null");
  }
  testRootDisposable = Disposer.newDisposable();
}
 
Example #12
Source File: ClionUnitTestSystemPropertiesRule.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private static String getPlatformApiPath() {
  String platformJar = PathManager.getJarPathForClass(Application.class);
  if (platformJar == null) {
    return null;
  }
  File jarFile = new File(platformJar).getAbsoluteFile();
  File jarDir = jarFile.getParentFile();
  if (jarDir == null) {
    return null;
  }
  if (jarDir.getName().equals("lib")) {
    // Building against IDE distribution.
    // root/ <- we want this
    // |-lib/
    // | `-openapi.jar (jarFile)
    // `-plugins/
    return jarDir.getParent();
  } else if (jarDir.getName().equals("core-api")) {
    // Building against source.
    // tools/idea/ <- we want this
    // |-platform/
    // | `-core-api/
    // |   `-libcore-api.jar (jarFile)
    // `-plugins/
    File platformDir = jarDir.getParentFile();
    if (platformDir != null && platformDir.getName().equals("platform")) {
      return platformDir.getParent();
    }
  }
  return null;
}
 
Example #13
Source File: PropertySetter.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void setPluginLog() {
    String jarPath =
            PathManager.getPluginsPath() + "/tmc-plugin-intellij/lib/tmc-plugin-intellij.jar";
    try {
        JarFile jar = new JarFile(jarPath);
        JarEntry entry = jar.getJarEntry("log4j.properties");
        InputStream is = jar.getInputStream(entry);
        PropertyConfigurator.configure(is);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #14
Source File: PropertySetter.java    From tmc-intellij with MIT License 5 votes vote down vote up
public void setLog4jProperties() {
    File file =
            new File(
                    PathManager.getPluginsPath()
                            + "/tmc-plugin-intellij/lib/tmc-plugin-intellij.jar");

    if (file.exists()) {
        setPluginLog();
    } else {
        setDevLog();
    }
}
 
Example #15
Source File: DartTestUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
private static String findTestDataPath() {
  if (new File(PathManager.getHomePath() + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Ultimate project
    return FileUtil.toSystemIndependentName(PathManager.getHomePath() + "/contrib/Dart/testData");
  }

  final File f = new File("testData");
  if (f.isDirectory()) {
    // started from 'Dart-plugin' project
    return FileUtil.toSystemIndependentName(f.getAbsolutePath());
  }

  final String parentPath = PathUtil.getParentPath(PathManager.getHomePath());

  if (new File(parentPath + "/intellij-plugins").isDirectory()) {
    // started from IntelliJ IDEA Community Edition + Dart Plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/intellij-plugins/Dart/testData");
  }

  if (new File(parentPath + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Community + Dart Plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/contrib/Dart/testData");
  }

  return "";
}
 
Example #16
Source File: DartTestUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
private static String findTestDataPath() {
  if (new File(PathManager.getHomePath() + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Ultimate project
    return FileUtil.toSystemIndependentName(PathManager.getHomePath() + "/contrib/Dart/testData");
  }

  final File f = new File("testData");
  if (f.isDirectory()) {
    // started from 'Dart-plugin' project
    return FileUtil.toSystemIndependentName(f.getAbsolutePath());
  }

  final String parentPath = PathUtil.getParentPath(PathManager.getHomePath());

  if (new File(parentPath + "/intellij-plugins").isDirectory()) {
    // started from IntelliJ IDEA Community Edition + Dart Plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/intellij-plugins/Dart/testData");
  }

  if (new File(parentPath + "/contrib").isDirectory()) {
    // started from IntelliJ IDEA Community + Dart Plugin project
    return FileUtil.toSystemIndependentName(parentPath + "/contrib/Dart/testData");
  }

  return "";
}
 
Example #17
Source File: ProjectWrangler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
private static File getTestProjectsRootDirPath() {
  // It is important that the testData directory be marked as a test resource so its content is copied to out/test dir
  String testDataPath = PathManager.getHomePathFor(ProjectWrangler.class);
  // "out/test" is defined by IntelliJ but we may want to change the module or root dir of the test projects.
  testDataPath = Paths.get(testDataPath, "out", "test", MODULE_NAME).toString();
  testDataPath = toCanonicalPath(toSystemDependentName(testDataPath));
  return new File(testDataPath, PROJECT_DIR);
}
 
Example #18
Source File: ThriftTestUtils.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
private static String findTestDataPath() {
  File f = new File("src/test/resources");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/thrift/testData";
}
 
Example #19
Source File: ServerExecutableState.java    From CppTools with Apache License 2.0 5 votes vote down vote up
private String getBasePath() {
  if (myBasePath == null) {
    String s = PathManager.getPluginsPath() + File.separatorChar + CPP_TOOLS;

    if (!new File(s).exists()) {
      s = PathManager.getPreinstalledPluginsPath() + File.separatorChar + CPP_TOOLS;

      if (!new File(s).exists()) {
        throw new RuntimeException("Plugin home is not found");
      }
    }
    myBasePath = s;
  }
  return myBasePath;
}
 
Example #20
Source File: LoginFrame.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
private boolean classLoader() {
    synchronized (this) {
        String path = PathManager.getPluginsPath() + File.separator + "leetcode-editor" + File.separator + "natives" + File.separator;
        if (!new File(path, "icudtl.dat").exists()
                && !new File(path, "jcef_app.app").exists()) {
            return Boolean.FALSE;
        } else {
            JourneyLoader.getJourneyClassLoader(path);
            return Boolean.TRUE;
        }
    }
}
 
Example #21
Source File: SarosLogFileAppender.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
private String getFormattedFileName(String filePattern) {
  String file = "'" + PathManager.getLogPath() + filePattern;
  SimpleDateFormat sdf = new SimpleDateFormat(file);
  return sdf.format(new Date());
}
 
Example #22
Source File: AsposeMavenUtil.java    From Aspose.OCR-for-Java with MIT License 4 votes vote down vote up
public static File getPluginSystemDir(String folder) {
    // PathManager.getSystemPath() may return relative path
    return new File(PathManager.getSystemPath(), "Maven" + "/" + folder).getAbsoluteFile();
}
 
Example #23
Source File: BaseFunctionalTestCase.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
protected String getTestDataPath() {
    return PathManager.getHomePath();
}
 
Example #24
Source File: XQueryDataSourcesSettings.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public File[] getExportFiles() {
    return new File[]{PathManager.getOptionsFile("xquery.xml")};
}
 
Example #25
Source File: GlobalSettings.java    From EclipseCodeFormatter with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public File[] getExportFiles() {
	return new File[] { PathManager.getOptionsFile("eclipseCodeFormatter") };
}
 
Example #26
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void collectAllowedRoots(final List<String> roots) {
  roots.add(myJdkHome);
  roots.addAll(collectRootsInside(myJdkHome));
  roots.add(PathManager.getConfigPath());
}
 
Example #27
Source File: PhpToolboxApplicationService.java    From idea-php-toolbox with MIT License 4 votes vote down vote up
@NotNull
public static String getApplicationFolder() {
    return PathManager.getConfigPath() + "/php-toolbox";
}
 
Example #28
Source File: TempFileManager.java    From markdown-doclet with GNU General Public License v3.0 4 votes vote down vote up
public synchronized void initComponent() {
    baseDir = new File(PathManager.getPluginTempPath(), "markdown-doclet-idea");
    cleanup();
    cleanupService.startAsync().awaitRunning();
}
 
Example #29
Source File: PluginErrorSubmitDialog.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
private String getOptionsFilePath() {
    String optionsPath = PathManager.getOptionsPath();
    return optionsPath + File.separator + "pluginErrorReportSubmitter.xml";
}
 
Example #30
Source File: PhpToolboxApplicationService.java    From idea-php-toolbox with MIT License 4 votes vote down vote up
@NotNull
public static String getApplicationFolder() {
    return PathManager.getConfigPath() + "/php-toolbox";
}