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

项目:hybris-integration-intellij-idea-plugin    文件:DefaultAntConfigurator.java   
private void createAntClassPath(final File platformDir) {
    classPaths = new ArrayList<>();
    //brutal hack. Do not do this at home, kids!
    //we are hiding class in a classpath to confuse the classloader and pick our implementation
    final String entry = PathManager.getResourceRoot(
        HybrisIdeaAntLogger.class, "/" + HybrisIdeaAntLogger.class.getName().replace('.', '/') + ".class"
    );
    classPaths.add(new SinglePathEntry(entry));
    //end of hack
    final File platformLibDir = new File(platformDir, HybrisConstants.LIB_DIRECTORY);
    classPaths.add(new AllJarsUnderDirEntry(platformLibDir));
    classPaths.addAll(
        extHybrisModuleDescriptorList
            .parallelStream()
            .map(e -> new AllJarsUnderDirEntry(new File(e.getRootDirectory(), HybrisConstants.LIB_DIRECTORY)))
            .collect(Collectors.toList())
    );
    final File libDir = new File(platformDir, HybrisConstants.ANT_LIB_DIR);
    classPaths.add(new AllJarsUnderDirEntry(libDir));
}
项目:intellij-ce-playground    文件:SettingsProviderComponent.java   
public Set<String> getRootDirs(final Project project) {
  if (!Registry.is("editor.config.stop.at.project.root")) {
    return Collections.emptySet();
  }

  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Set<String>>() {
    @Nullable
    @Override
    public Result<Set<String>> compute() {
      final Set<String> dirs = new HashSet<String>();
      final VirtualFile projectBase = project.getBaseDir();
      if (projectBase != null) {
        dirs.add(project.getBasePath());
        for (Module module : ModuleManager.getInstance(project).getModules()) {
          for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) {
            if (!VfsUtilCore.isAncestor(projectBase, root, false)) {
              dirs.add(root.getPath());
            }
          }
        }
      }
      dirs.add(PathManager.getConfigPath());
      return new Result<Set<String>>(dirs, ProjectRootModificationTracker.getInstance(project));
    }
  });
}
项目:intellij-ce-playground    文件:GreclipseBuilder.java   
@Nullable
private ClassLoader createGreclipseLoader(@Nullable String jar) {
  if (StringUtil.isEmpty(jar)) return null;

  if (jar.equals(myGreclipseJar)) {
    return myGreclipseLoader;
  }

  try {
    URL[] urls = {
      new File(jar).toURI().toURL(),
      new File(ObjectUtils.assertNotNull(PathManager.getJarPathForClass(GreclipseMain.class))).toURI().toURL()
    };
    ClassLoader loader = new URLClassLoader(urls, null);
    Class.forName("org.eclipse.jdt.internal.compiler.batch.Main", false, loader);
    myGreclipseJar = jar;
    myGreclipseLoader = loader;
    return loader;
  }
  catch (Exception e) {
    LOG.error(e);
    return null;
  }
}
项目:intellij-ce-playground    文件:CoverageDataManagerImpl.java   
public void removeCoverageSuite(final CoverageSuite suite) {
  final String fileName = suite.getCoverageDataFileName();

  boolean deleteTraces = suite.isTracingEnabled();
  if (!FileUtil.isAncestor(PathManager.getSystemPath(), fileName, false)) {
    String message = "Would you like to delete file \'" + fileName + "\' ";
    if (deleteTraces) {
      message += "and traces directory \'" + FileUtil.getNameWithoutExtension(new File(fileName)) + "\' ";
    }
    message += "on disk?";
    if (Messages.showYesNoDialog(myProject, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) == Messages.YES) {
      deleteCachedCoverage(fileName, deleteTraces);
    }
  } else {
    deleteCachedCoverage(fileName, deleteTraces);
  }

  myCoverageSuites.remove(suite);
  if (myCurrentSuitesBundle != null && myCurrentSuitesBundle.contains(suite)) {
    CoverageSuite[] suites = myCurrentSuitesBundle.getSuites();
    suites = ArrayUtil.remove(suites, suite);
    chooseSuitesBundle(suites.length > 0 ? new CoverageSuitesBundle(suites) : null);
  }
}
项目:intellij-ce-playground    文件:EclipseCompilerTool.java   
@Nullable
public static File findEcjJarFile() {
  File[] libs = {new File(PathManager.getHomePath(), "lib"), new File(PathManager.getHomePath(), "community/lib")};
  for (File lib : libs) {
    File[] children = lib.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.startsWith("ecj-") && name.endsWith(".jar");
      }
    });
    if (children != null && children.length > 0) {
      return children[0];
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:RepositoryArtifactDeploymentRuntimeProviderBase.java   
@Override
protected CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
                                                           File artifactFile,
                                                           CloudMultiSourceServerRuntimeInstance serverRuntime,
                                                           DeploymentTask<? extends CloudDeploymentNameConfiguration> deploymentTask,
                                                           DeploymentLogManager logManager) throws ServerRuntimeException {
  RepositoryDeploymentConfiguration config = (RepositoryDeploymentConfiguration)deploymentTask.getConfiguration();

  String repositoryPath = config.getRepositoryPath();
  File repositoryRootFile;
  if (StringUtil.isEmpty(repositoryPath)) {
    File repositoryParentFolder = new File(PathManager.getSystemPath(), "cloud-git-artifact-deploy");
    repositoryRootFile = FileUtil.findSequentNonexistentFile(repositoryParentFolder, artifactFile.getName(), "");
  }
  else {
    repositoryRootFile = new File(repositoryPath);
  }

  if (!FileUtil.createDirectory(repositoryRootFile)) {
    throw new ServerRuntimeException("Unable to create deploy folder: " + repositoryRootFile);
  }
  config.setRepositoryPath(repositoryRootFile.getAbsolutePath());
  return doCreateDeploymentRuntime(artifactSource, artifactFile, serverRuntime, deploymentTask, logManager, repositoryRootFile);
}
项目:intellij-ce-playground    文件:AsmCodeGeneratorTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  myNestedFormLoader = new MyNestedFormLoader();

  final String swingPath = PathUtil.getJarPathForClass(AbstractButton.class);

  java.util.List<URL> cp = new ArrayList<URL>();
  appendPath(cp, JBTabbedPane.class);
  appendPath(cp, TIntObjectHashMap.class);
  appendPath(cp, UIUtil.class);
  appendPath(cp, SystemInfoRt.class);
  appendPath(cp, ApplicationManager.class);
  appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/messages/UIBundle.properties"));
  appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties"));
  appendPath(cp, GridLayoutManager.class); // forms_rt
  appendPath(cp, DataProvider.class);
  myClassFinder = new MyClassFinder(
    new URL[] {new File(swingPath).toURI().toURL()},
    cp.toArray(new URL[cp.size()])
  );
}
项目:intellij-ce-playground    文件:JavaSdkImpl.java   
public static void attachJdkAnnotations(@NotNull SdkModificator modificator) {
  LocalFileSystem lfs = LocalFileSystem.getInstance();
  // community idea under idea
  VirtualFile root = lfs.findFileByPath(FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/java/jdkAnnotations");

  if (root == null) {  // idea under idea
    root = lfs.findFileByPath(FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/community/java/jdkAnnotations");
  }
  if (root == null) { // build
    root = VirtualFileManager.getInstance().findFileByUrl("jar://"+ FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar!/");
  }
  if (root == null) {
    LOG.error("jdk annotations not found in: "+ FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar!/");
    return;
  }

  OrderRootType annoType = AnnotationOrderRootType.getInstance();
  modificator.removeRoot(root, annoType);
  modificator.addRoot(root, annoType);
}
项目:intellij-ce-playground    文件:StartupActionScriptManager.java   
private static void saveActionScript(List<ActionCommand> commands) throws IOException {
  File temp = new File(PathManager.getPluginTempPath());
  boolean exists = true;
  if (!temp.exists()) {
    exists = temp.mkdirs();
  }

  if (exists) {
    File file = new File(getActionScriptPath());
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file, false));
    try {
      oos.writeObject(commands);
    }
    finally {
      oos.close();
    }
  }
}
项目:intellij-ce-playground    文件:UrlClassLoader.java   
public static void loadPlatformLibrary(@NotNull String libName) {
  String libFileName = mapLibraryName(libName);
  String libPath = PathManager.getBinPath() + "/" + libFileName;

  if (!new File(libPath).exists()) {
    String platform = getPlatformName();
    if (!new File(libPath = PathManager.getHomePath() + "/community/bin/" + platform + libFileName).exists()) {
      if (!new File(libPath = PathManager.getHomePath() + "/bin/" + platform + libFileName).exists()) {
        if (!new File(libPath = PathManager.getHomePathFor(IdeaWin32.class) + "/bin/" + libFileName).exists()) {
          File libDir = new File(PathManager.getBinPath());
          throw new UnsatisfiedLinkError("'" + libFileName + "' not found in '" + libDir + "' among " + Arrays.toString(libDir.list()));
        }
      }
    }
  }

  System.load(libPath);
}
项目:intellij-ce-playground    文件:JsonParserTest.java   
private static String getFileText(@NotNull final String fileName) throws IOException {
  String fullPath = PathManager.getHomePath() + "/community/python/ipnb/" + fileName;
  final BufferedReader br = new BufferedReader(new FileReader(fullPath));
  try {
    final StringBuilder sb = new StringBuilder();
    String line = br.readLine();

    while (line != null) {
      sb.append(line);
      sb.append("\n");
      line = br.readLine();
    }
    return sb.toString();
  }
  finally {
    br.close();
  }
}
项目:intellij-ce-playground    文件:GradleImportingTestCase.java   
@Override
protected void collectAllowedRoots(final List<String> roots) throws IOException {
  roots.add(myJdkHome);
  FileUtil.processFilesRecursively(new File(myJdkHome), new Processor<File>() {
    @Override
    public boolean process(File file) {
      try {
        String path = file.getCanonicalPath();
        if (!FileUtil.isAncestor(myJdkHome, path, false)) {
          roots.add(path);
        }
      }
      catch (IOException ignore) { }
      return true;
    }
  });

  roots.add(PathManager.getConfigPath());
}
项目:intellij-ce-playground    文件:GradleExecutionHelper.java   
@NotNull
private static String getToolingExtensionsJarPaths(@NotNull Set<Class> toolingExtensionClasses) {
  final Set<String> jarPaths = ContainerUtil.map2SetNotNull(toolingExtensionClasses, new Function<Class, String>() {
    @Override
    public String fun(Class aClass) {
      String path = PathManager.getJarPathForClass(aClass);
      return path == null ? null : PathUtil.getCanonicalPath(path);
    }
  });
  StringBuilder buf = new StringBuilder();
  buf.append('[');
  for (Iterator<String> it = jarPaths.iterator(); it.hasNext(); ) {
    String jarPath = it.next();
    buf.append('\"').append(jarPath).append('\"');
    if (it.hasNext()) {
      buf.append(',');
    }
  }
  buf.append(']');
  return buf.toString();
}
项目:intellij-ce-playground    文件:BaseCoverageSuite.java   
public void writeExternal(final Element element) throws WriteExternalException {
  final String fileName =
    FileUtil.getRelativePath(new File(PathManager.getSystemPath()), new File(myCoverageDataFileProvider.getCoverageDataFilePath()));
  element.setAttribute(FILE_PATH, fileName != null ? FileUtil.toSystemIndependentName(fileName) : myCoverageDataFileProvider.getCoverageDataFilePath());
  element.setAttribute(NAME_ATTRIBUTE, myName);
  element.setAttribute(MODIFIED_STAMP, String.valueOf(myLastCoverageTimeStamp));
  element.setAttribute(SOURCE_PROVIDER, myCoverageDataFileProvider instanceof DefaultCoverageFileProvider
                                        ? ((DefaultCoverageFileProvider)myCoverageDataFileProvider).getSourceProvider()
                                        : myCoverageDataFileProvider.getClass().getName());
  // runner
  if (getRunner() != null) {
    element.setAttribute(COVERAGE_RUNNER, myRunner.getId());
  }

  // cover by test
  element.setAttribute(COVERAGE_BY_TEST_ENABLED_ATTRIBUTE_NAME, String.valueOf(myCoverageByTestEnabled));

  // tracing
  element.setAttribute(TRACING_ENABLED_ATTRIBUTE_NAME, String.valueOf(myTracingEnabled));
}
项目:intellij-ce-playground    文件:WinUACTemporaryFix.java   
static boolean nativeCopy(File fromFile, File toFile, boolean syncTimestamp) {
  File launcherFile = new File(PathManager.getBinPath(), "vistalauncher.exe");
  try {
    // todo vistalauncher should be replaced with generic "elevate" process
    // todo   so the second java process will be unnecessary: plain 'elevate cmd /C copy' will work
    return execExternalProcess(new String[]{launcherFile.getPath(),
      //"cmd",  "/C", "move", fromFile.getPath(),
      //toFile.getPath()

      System.getProperty("java.home") + "/bin/java",
      "-classpath",
      PathManager.getLibPath() + "/util.jar",
      WinUACTemporaryFix.class.getName(),
      "copy",
      fromFile.getPath(),
      toFile.getPath(),
      String.valueOf(syncTimestamp),
      // vistalauncher hack
      "install",
      toFile.getParent()
    });
  }
  catch (Exception ex) {
    return false;
  }
}
项目:intellij-ce-playground    文件:RenderSecurityManagerFactory.java   
/**
 * Returns a {@link RenderSecurityManager} for the current module. The {@link RenderSecurityManager} will be
 * setup with the SDK path and project path of the module.
 */
public static RenderSecurityManager create(Module module, AndroidPlatform platform) {
  String projectPath = null;
  String sdkPath = null;
  if (RenderSecurityManager.RESTRICT_READS) {
    projectPath = module.getProject().getBasePath();
    if (platform != null) {
      sdkPath = platform.getSdkData().getLocation().getPath();
    }
  }

  @SuppressWarnings("ConstantConditions")
  RenderSecurityManager securityManager = new RenderSecurityManager(sdkPath, projectPath);
  securityManager.setLogger(new LogWrapper(RenderLogger.LOG));
  securityManager.setAppTempDir(PathManager.getTempPath());

  return securityManager;
}
项目:intellij-ce-playground    文件:EmbeddedDistributionPaths.java   
@Nullable
public static File findAndroidStudioLocalMavenRepoPath() {
  File defaultRootDirPath = getDefaultRootDirPath();
  File repoPath;
  if (defaultRootDirPath != null) {
    // Release build
    repoPath = new File(defaultRootDirPath, "m2repository");
  }
  else {
    // Development build
    String relativePath = toSystemDependentName("/../../prebuilts/tools/common/offline-m2");
    repoPath = new File(toCanonicalPath(toSystemDependentName(PathManager.getHomePath()) + relativePath));
  }
  LOG.info("Looking for embedded Maven repo at '" + repoPath.getPath() + "'");
  return repoPath.isDirectory() ? repoPath : null;
}
项目:intellij-ce-playground    文件:PerformanceWatcher.java   
private static void deleteOldThreadDumps() {
  File allLogsDir = new File(PathManager.getLogPath());
  if (allLogsDir.isDirectory()) {
    final String[] dirs = allLogsDir.list(new FilenameFilter() {
      @Override
      public boolean accept(@NotNull final File dir, @NotNull final String name) {
        return name.startsWith("threadDumps-");
      }
    });
    if (dirs != null) {
      Arrays.sort(dirs);
      for (int i = 0; i < dirs.length - 11; i++) {
        FileUtil.delete(new File(allLogsDir, dirs [i]));
      }
    }
  }
}
项目:IntelliJ-codestyle-sync    文件:CodeStyleManager.java   
private void copyFiles(ArrayList<File> files) {
    String configPath = PathManager.getConfigPath();
    createFolder(configPath + "/codestyles");

    for(File file : files) {
        try {
            copyFile(file, new File(configPath + "/codestyles/" + file.getName()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
项目:educational-plugin    文件:PyStudyInitialConfigurator.java   
/**
 * @noinspection UnusedParameters
 */
public PyStudyInitialConfigurator(MessageBus bus,
                                  CodeInsightSettings codeInsightSettings,
                                  final PropertiesComponent propertiesComponent,
                                  FileTypeManager fileTypeManager,
                                  final ProjectManagerEx projectManager) {
  if (!propertiesComponent.getBoolean(CONFIGURED_V40)) {
    final File courses = new File(PathManager.getConfigPath(), "courses");
    FileUtil.delete(courses);
    propertiesComponent.setValue(CONFIGURED_V40, "true");
  }
}
项目:manifold-ij    文件:HotSwapComponent.java   
private File createTempFile( byte[] bytes )
{
  try
  {
    File file = FileUtil.createTempFile( new File( PathManager.getTempPath() ), "manifoldHotSwap", ".class" );
    FileUtil.writeToFile( file, bytes );
    return file;
  }
  catch( IOException e )
  {
    throw new RuntimeException( e );
  }
}
项目:intellij-ce-playground    文件:PythonHelpersLocator.java   
public static String getPythonCommunityPath() {
  File pathFromUltimate = new File(PathManager.getHomePath(), "community/python");
  if (pathFromUltimate.exists()) {
    return pathFromUltimate.getPath();
  }
  return new File(PathManager.getHomePath(), "python").getPath();
}
项目:MissingInActions    文件:Plugin.java   
@Nullable
public static String getPluginCustomPath() {
    String[] variants = { PathManager.getHomePath(), PathManager.getPluginsPath() };

    for (String variant : variants) {
        String path = variant + "/" + getProductId();
        if (LocalFileSystem.getInstance().findFileByPath(path) != null) {
            return path;
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:IdeTestApplication.java   
private static void addIdeaLibraries(@NotNull Collection<URL> classpath) throws MalformedURLException {
  Class<BootstrapClassLoaderUtil> aClass = BootstrapClassLoaderUtil.class;
  String selfRoot = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
  assertNotNull(selfRoot);

  URL selfRootUrl = new File(selfRoot).getAbsoluteFile().toURI().toURL();
  classpath.add(selfRootUrl);

  File libFolder = new File(PathManager.getLibPath());
  addLibraries(classpath, libFolder, selfRootUrl);
  addLibraries(classpath, new File(libFolder, "ext"), selfRootUrl);
  addLibraries(classpath, new File(libFolder, "ant/lib"), selfRootUrl);
}
项目:intellij-ce-playground    文件:PluginManagerCore.java   
@NotNull
public static List<String> getDisabledPlugins() {
  if (ourDisabledPlugins == null) {
    ourDisabledPlugins = new ArrayList<String>();
    if (System.getProperty("idea.ignore.disabled.plugins") == null && !isUnitTestMode()) {
      loadDisabledPlugins(PathManager.getConfigPath(), ourDisabledPlugins);
    }
  }
  return ourDisabledPlugins;
}
项目:intellij-ce-playground    文件:StreamLogger.java   
private void initLogOutput() {
  if (CvsApplicationLevelConfiguration.getInstance().DO_OUTPUT) {
    final File cvsOutputFile = new File(PathManager.getLogPath(), OUTPUT_FILE_NAME);
    if (cvsOutputFile.isFile() && cvsOutputFile.length() > MAX_OUTPUT_SIZE) {
      FileUtil.delete(cvsOutputFile);
    }
    myLogOutput = createFileOutputStream(cvsOutputFile);
  } else {
    myLogOutput = DUMMY_OUTPUT_STREAM;
  }
}
项目:intellij-ce-playground    文件:MavenImportingTestCase.java   
@Override
protected void tearDown() throws Exception {
  try {
    if (myGlobalSettingsFile != null) {
      VfsRootAccess.disallowRootAccess(myGlobalSettingsFile.getAbsolutePath());
    }
    VfsRootAccess.disallowRootAccess(PathManager.getConfigPath());
    Messages.setTestDialog(TestDialog.DEFAULT);
    removeFromLocalRepository("test");
    FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory());
  }
  finally {
    super.tearDown();
  }
}
项目:intellij-ce-playground    文件:RegExpCompletionTest.java   
@Override
protected String getBasePath() {
  String homePath = PathManager.getHomePath();
  File candidate = new File(homePath, "community/RegExpSupport");
  if (candidate.isDirectory()) {
    return "/community/RegExpSupport/testData/completion";
  }
  return "/RegExpSupport/testData/completion";
}
项目:intellij-ce-playground    文件:ClasspathBootstrap.java   
public static List<String> getBuildProcessApplicationClasspath(boolean isLauncherUsed) {
  final Set<String> cp = ContainerUtil.newHashSet();

  cp.add(getResourcePath(BuildMain.class));

  cp.addAll(PathManager.getUtilClassPath()); // util
  cp.add(getResourcePath(Message.class)); // protobuf
  cp.add(getResourcePath(NetUtil.class)); // netty
  cp.add(getResourcePath(ClassWriter.class));  // asm
  cp.add(getResourcePath(ClassVisitor.class));  // asm-commons
  cp.add(getResourcePath(JpsModel.class));  // jps-model-api
  cp.add(getResourcePath(JpsModelImpl.class));  // jps-model-impl
  cp.add(getResourcePath(JpsProjectLoader.class));  // jps-model-serialization
  cp.add(getResourcePath(AlienFormFileException.class));  // forms-compiler
  cp.add(getResourcePath(GridConstraints.class));  // forms-rt
  cp.add(getResourcePath(CellConstraints.class));  // jGoodies-forms
  cp.add(getResourcePath(NotNullVerifyingInstrumenter.class));  // not-null
  cp.add(getResourcePath(IXMLBuilder.class));  // nano-xml
  cp.add(getResourcePath(SequenceLock.class));  // jsr166
  cp.add(getJpsPluginSystemClassesPath().getAbsolutePath().replace('\\', '/'));

  //don't forget to update layoutCommunityJps() in layouts.gant accordingly

  if (!isLauncherUsed) {
    appendJavaCompilerClasspath(cp);
  }

  try {
    final Class<?> cmdLineWrapper = Class.forName("com.intellij.rt.execution.CommandLineWrapper");
    cp.add(getResourcePath(cmdLineWrapper));  // idea_rt.jar
  }
  catch (Throwable ignored) {
  }

  return ContainerUtil.newArrayList(cp);
}
项目:intellij-ce-playground    文件:SvnBusyOnAddTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  //PlatformTestCase.initPlatformLangPrefix();
  File pluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea"));
  if (!pluginRoot.isDirectory()) {
    // try standalone mode
    Class aClass = Svn17TestCase.class;
    String rootPath = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
    pluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile();
  }
  myWorkingCopyRoot = new File(pluginRoot, "testData/move2unv");
}
项目:intellij-ce-playground    文件:JpsBuildTestCase.java   
protected void loadProject(String projectPath,
                           Map<String, String> pathVariables) {
  try {
    String testDataRootPath = getTestDataRootPath();
    String fullProjectPath = FileUtil.toSystemDependentName(testDataRootPath != null ? testDataRootPath + "/" + projectPath : projectPath);
    Map<String, String> allPathVariables = new HashMap<String, String>(pathVariables.size() + 1);
    allPathVariables.putAll(pathVariables);
    allPathVariables.put(PathMacroUtil.APPLICATION_HOME_DIR, PathManager.getHomePath());
    allPathVariables.putAll(getAdditionalPathVariables());
    JpsProjectLoader.loadProject(myProject, allPathVariables, fullProjectPath);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:intellij-ce-playground    文件:JpsProjectSerializationTest.java   
public void testLoadIdeaProject() {
  long start = System.currentTimeMillis();
  loadProjectByAbsolutePath(PathManager.getHomePath());
  assertTrue(myProject.getModules().size() > 0);
  System.out.println("JpsProjectSerializationTest: " + myProject.getModules().size() + " modules, " + myProject.getLibraryCollection().getLibraries().size() + " libraries and " +
                     JpsArtifactService.getInstance().getArtifacts(myProject).size() + " artifacts loaded in " + (System.currentTimeMillis() - start) + "ms");
}
项目:intellij-ce-playground    文件:PySkeletonRefresher.java   
private void copyBaseSdkSkeletonsToVirtualEnv(String skeletonsPath, PySkeletonGenerator.ListBinariesResult binaries)
  throws InvalidSdkException {
  final Sdk base = PythonSdkType.getInstance().getVirtualEnvBaseSdk(mySdk);
  if (base != null) {
    indicate("Copying base SDK skeletons for virtualenv...");
    final String baseSkeletonsPath = PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), base.getHomePath());
    final PySkeletonGenerator.ListBinariesResult baseBinaries =
      mySkeletonsGenerator.listBinaries(base, calculateExtraSysPath(base, baseSkeletonsPath));
    for (Map.Entry<String, PyBinaryItem> entry : binaries.modules.entrySet()) {
      final String module = entry.getKey();
      final PyBinaryItem binary = entry.getValue();
      final PyBinaryItem baseBinary = baseBinaries.modules.get(module);
      final File fromFile = getSkeleton(module, baseSkeletonsPath);
      if (baseBinaries.modules.containsKey(module) &&
          fromFile.exists() &&
          binary.length() == baseBinary.length()) { // Weak binary modules equality check
        final File toFile = fromFile.isDirectory() ?
                            getPackageSkeleton(module, skeletonsPath) :
                            getModuleSkeleton(module, skeletonsPath);
        try {
          FileUtil.copy(fromFile, toFile);
        }
        catch (IOException e) {
          LOG.info("Error copying base virtualenv SDK skeleton for " + module, e);
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:TemplateManager.java   
/**
 * @return the root folder containing templates
 */
@Nullable
public static File getTemplateRootFolder() {
  String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
  // Release build?
  VirtualFile root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(homePath + BUNDLED_TEMPLATE_PATH));
  if (root == null) {
    // Development build?
    for (String path : DEVELOPMENT_TEMPLATE_PATHS) {
      root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(homePath + path));

      if (root != null) {
        break;
      }
    }
  }
  if (root != null) {
    File rootFile = VfsUtilCore.virtualToIoFile(root);
    if (templateRootIsValid(rootFile)) {
      return rootFile;
    }
  }

  // Fall back to SDK template root
  AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
  if (sdkData != null) {
    File location = sdkData.getLocation();
    File folder = new File(location, FD_TOOLS + File.separator + FD_TEMPLATES);
    if (folder.isDirectory()) {
      return folder;
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:GithubDownloadUtil.java   
@NotNull
public static File getCacheDir(@NotNull String userName, @NotNull String repositoryName) {
  File generatorsDir = new File(PathManager.getSystemPath(), "projectGenerators");
  String dirName = formatGithubRepositoryName(userName, repositoryName);
  File dir = new File(generatorsDir, dirName);
  try {
    return dir.getCanonicalFile();
  } catch (IOException e) {
    return dir;
  }
}
项目:intellij-ce-playground    文件:CoverageEnabledConfiguration.java   
@Nullable
@NonNls
protected String createCoverageFile() {
  if (myCoverageRunner == null) {
    return null;
  }

  @NonNls final String coverageRootPath = PathManager.getSystemPath() + File.separator + "coverage";
  final String path = coverageRootPath + File.separator + myProject.getName() + coverageFileNameSeparator()
                      + FileUtil.sanitizeFileName(myConfiguration.getName()) + ".coverage";

  new File(coverageRootPath).mkdirs();
  return path;
}
项目:intellij-ce-playground    文件:MigrationMapSet.java   
private static File getMapDirectory() {
  File dir = new File(PathManager.getConfigPath() + File.separator + "migration");

  if (!dir.exists()){
    if (!dir.mkdir()){
      LOG.error("cannot create directory: " + dir.getAbsolutePath());
      return null;
    }

    for (int i = 0; i < DEFAULT_MAPS.length; i++) {
      String defaultTemplate = DEFAULT_MAPS[i];
      URL url = MigrationMapSet.class.getResource(defaultTemplate);
      LOG.assertTrue(url != null);
      String fileName = defaultTemplate.substring(defaultTemplate.lastIndexOf("/") + 1);
      File targetFile = new File(dir, fileName);

      try {
        FileOutputStream outputStream = new FileOutputStream(targetFile);
        InputStream inputStream = url.openStream();

        try {
          FileUtil.copy(inputStream, outputStream);
        }
        finally {
          outputStream.close();
          inputStream.close();
        }
      }
      catch (Exception e) {
        LOG.error(e);
      }
    }
  }

  return dir;
}
项目:intellij-ce-playground    文件:WorkingContextManager.java   
private File getArchiveFile(String postfix) {
  File tasksFolder = new File(PathManager.getConfigPath(), TASKS_FOLDER);
  if (!tasksFolder.exists()) {
    //noinspection ResultOfMethodCallIgnored
    tasksFolder.mkdirs();
  }
  String projectName = FileUtil.sanitizeFileName(myProject.getName());
  return new File(tasksFolder, projectName + postfix);
}
项目:intellij-ce-playground    文件:PyUserSkeletonsUtil.java   
@NotNull
private static List<String> getPossibleUserSkeletonsPaths() {
  final List<String> result = new ArrayList<String>();
  result.add(PathManager.getConfigPath() + File.separator + USER_SKELETONS_DIR);
  result.add(PythonHelpersLocator.getHelperPath(USER_SKELETONS_DIR));
  return result;
}
项目:intellij-ce-playground    文件:PropertyFileGeneratorImpl.java   
/**
 * A constctor that extracts all neeed properties for ant build from the project.
 *
 * @param project    a project to examine
 * @param genOptions generation options
 */
public PropertyFileGeneratorImpl(Project project, GenerationOptions genOptions) {
  // path variables
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNamesSet = pathMacros.getUserMacroNames();
  if (macroNamesSet.size() > 0) {
    final String[] macroNames = ArrayUtil.toStringArray(macroNamesSet);
    Arrays.sort(macroNames);
    for (final String macroName : macroNames) {
      addProperty(BuildProperties.getPathMacroProperty(macroName), pathMacros.getValue(macroName));
    }
  }
  // jdk homes
  if (genOptions.forceTargetJdk) {
    final Sdk[] usedJdks = BuildProperties.getUsedJdks(project);
    for (Sdk jdk : usedJdks) {
      if (jdk.getHomeDirectory() == null) {
        continue;
      }
      final File homeDir = BuildProperties.toCanonicalFile(VfsUtil.virtualToIoFile(jdk.getHomeDirectory()));
      addProperty(BuildProperties.getJdkHomeProperty(jdk.getName()), homeDir.getPath().replace(File.separatorChar, '/'));
    }
  }
  // generate idea.home property
  if (genOptions.isIdeaHomeGenerated()) {
    addProperty(BuildProperties.PROPERTY_IDEA_HOME, PathManager.getHomePath());
  }

  if (genOptions.enableFormCompiler) {
    addProperty(BuildProperties.PROPERTY_INCLUDE_JAVA_RUNTIME_FOR_INSTRUMENTATION, genOptions.forceTargetJdk? "false" : "true");
  }

  ChunkBuildExtension.generateAllProperties(this, project, genOptions);
}