@Nullable
  private static File getExecutable() {
    String execPath = System.getProperty(PROPERTY_WATCHER_EXECUTABLE_PATH);
    if (execPath != null) return new File(execPath);

    String execName = getExecutableName(false);
    if (execName == null) return null;

    return FileUtil.findFirstThatExist(
        FileUtil.join(PathManager.getBinPath(), execName),
        FileUtil.join(PathManager.getHomePath(), "community", "bin", getExecutableName(true)),
        FileUtil.join(PathManager.getBinPath(), getExecutableName(true)));
  }
  @NotNull
  private String getVmParameters() {
    if (myVmParameters == null) {
      String vmOptions;
      try {
        vmOptions =
            FileUtil.loadFile(new File(PathManager.getBinPath(), "idea.plugins.vmoptions"))
                .replaceAll("\\s+", " ");
      } catch (IOException e) {
        vmOptions = VMOptions.read();
      }
      myVmParameters = vmOptions != null ? vmOptions.trim() : "";
    }

    return myVmParameters;
  }
Exemple #3
0
  @SuppressWarnings("UseOfSystemOutOrSystemErr")
  private static synchronized void printOrder(Loader loader, String url, Resource resource) {
    if (!ourDumpOrder) return;
    if (!ourOrderedUrls.add(url)) return;

    String home = FileUtil.toSystemIndependentName(PathManager.getHomePath());
    try {
      ourOrderSize += resource.getContentLength();
    } catch (IOException e) {
      e.printStackTrace(System.out);
    }

    if (ourOrder == null) {
      final File orderFile = new File(PathManager.getBinPath() + File.separator + "order.txt");
      try {
        if (!FileUtil.ensureCanCreateFile(orderFile)) return;
        ourOrder = new PrintStream(new FileOutputStream(orderFile, true));
        ShutDownTracker.getInstance()
            .registerShutdownTask(
                new Runnable() {
                  public void run() {
                    ourOrder.close();
                    System.out.println(ourOrderSize);
                  }
                });
      } catch (IOException e) {
        return;
      }
    }

    if (ourOrder != null) {
      String jarURL = FileUtil.toSystemIndependentName(loader.getBaseURL().getFile());
      jarURL = StringUtil.trimStart(jarURL, "file:/");
      if (jarURL.startsWith(home)) {
        jarURL = jarURL.replaceFirst(home, "");
        jarURL = StringUtil.trimEnd(jarURL, "!/");
        ourOrder.println(url + ":" + jarURL);
      }
    }
  }