类com.intellij.openapi.application.PathManager源码实例Demo

下面列出了怎么用com.intellij.openapi.application.PathManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: flutter-intellij   文件: FlutterTestUtils.java
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 "";
}
 
源代码2 项目: flutter-intellij   文件: FlutterTestUtils.java
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 "";
}
 
源代码3 项目: intellij   文件: BlazeCWorkspace.java
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);
}
 
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;
    }
}
 
/**
 * 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;
}
 
源代码6 项目: intellij-quarkus   文件: MavenImportingTestCase.java
@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());
  }
}
 
源代码7 项目: leetcode-editor   文件: LoginFrame.java
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;
        }
    }
}
 
源代码8 项目: flutter-intellij   文件: ProjectWrangler.java
@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);
}
 
源代码9 项目: flutter-intellij   文件: DartTestUtils.java
@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 "";
}
 
源代码10 项目: flutter-intellij   文件: DartTestUtils.java
@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 "";
}
 
源代码11 项目: tmc-intellij   文件: PropertySetter.java
public void setLog4jProperties() {
    File file =
            new File(
                    PathManager.getPluginsPath()
                            + "/tmc-plugin-intellij/lib/tmc-plugin-intellij.jar");

    if (file.exists()) {
        setPluginLog();
    } else {
        setDevLog();
    }
}
 
源代码12 项目: tmc-intellij   文件: PropertySetter.java
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();
    }
}
 
@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;
}
 
源代码14 项目: intellij   文件: IntellijTestSetupRule.java
@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();
}
 
源代码15 项目: intellij   文件: IntellijTestSetupRule.java
@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);
  }
}
 
源代码16 项目: intellij   文件: BlazeTestSystemPropertiesRule.java
@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;
}
 
源代码17 项目: intellij-pants-plugin   文件: PantsTestUtils.java
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);
}
 
源代码18 项目: intellij-haxe   文件: HaxeTestUtils.java
private static String findTestDataPath() {
  File f = new File("testData");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/haxe/testData";
}
 
源代码19 项目: intellij-thrift   文件: ThriftTestUtils.java
private static String findTestDataPath() {
  File f = new File("src/test/resources");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/thrift/testData";
}
 
源代码20 项目: CppTools   文件: ServerExecutableState.java
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;
}
 
源代码21 项目: intellij-quarkus   文件: GradleImportingTestCase.java
@Override
protected void collectAllowedRoots(final List<String> roots) {
  roots.add(myJdkHome);
  roots.addAll(collectRootsInside(myJdkHome));
  roots.add(PathManager.getConfigPath());
}
 
源代码22 项目: PackageTemplates   文件: BinaryFileHelper.java
public static String getBinaryFileDirPath() {
    return Paths.get(PathManager.getConfigPath()).toString() + File.separator + Const.BINARY_FILES_DIR_NAME + File.separator;
}
 
源代码23 项目: PackageTemplates   文件: PackageTemplateHelper.java
@NotNull
public static String getRootDirPath() {
    return Paths.get(PathManager.getConfigPath()).toString() + File.separator + Const.PACKAGE_TEMPLATES_DIR_NAME + File.separator;
}
 
源代码24 项目: PackageTemplates   文件: PathHelper.java
public static String getBinaryFilesCacheDefaultDir() {
    return PathManager.getSystemPath()
            + File.separator + Const.CACHE_DIR_NAME
            + File.separator + Const.BINARY_FILES_CACHE_DIR_NAME;
}
 
源代码25 项目: PackageTemplates   文件: LibraryManager.java
@NotNull
private String getLibrariesPath() {
    return Paths.get(PathManager.getConfigPath()).toString() + File.separator + Const.LIBRARIES_DIR_NAME + File.separator;
}
 
源代码26 项目: intellij   文件: BlazeDataStorage.java
private static File getProjectConfigurationDir() {
  return new File(PathManager.getSystemPath(), "blaze/projects").getAbsoluteFile();
}
 
源代码27 项目: intellij   文件: WebExperimentSyncer.java
WebExperimentSyncer(String pluginName) {
  this.pluginName = pluginName;
  cacheFile =
      Paths.get(PathManager.getSystemPath(), "blaze", pluginName + ".experiments.cache.dat")
          .toFile();
}
 
@Override
public File[] getExportFiles() {
  return new File[]{new File(PathManager.getOptionsPath() + File.separatorChar + "buck.xml")};
}
 
@NotNull
public static String getApplicationFolder() {
    return PathManager.getConfigPath() + "/php-toolbox";
}
 
源代码30 项目: BashSupport   文件: PluginErrorSubmitDialog.java
private String getOptionsFilePath() {
    String optionsPath = PathManager.getOptionsPath();
    return optionsPath + File.separator + "pluginErrorReportSubmitter.xml";
}