当前位置: 首页>>代码示例>>Java>>正文


Java PathUtil类代码示例

本文整理汇总了Java中com.intellij.util.PathUtil的典型用法代码示例。如果您正苦于以下问题:Java PathUtil类的具体用法?Java PathUtil怎么用?Java PathUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PathUtil类属于com.intellij.util包,在下文中一共展示了PathUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBundledCourseRoot

import com.intellij.util.PathUtil; //导入依赖的package包/类
public static File getBundledCourseRoot(final String courseName, Class clazz) {
  @NonNls String jarPath = PathUtil.getJarPathForClass(clazz);
  if (jarPath.endsWith(".jar")) {
    final File jarFile = new File(jarPath);
    File pluginBaseDir = jarFile.getParentFile();
    File coursesDir = new File(pluginBaseDir, "courses");

    if (!coursesDir.exists()) {
      if (!coursesDir.mkdir()) {
        LOG.info("Failed to create courses dir");
        return coursesDir;
      }
    }
    try {
      ZipUtil.extract(jarFile, pluginBaseDir, (dir, name) -> name.equals(courseName));
    } catch (IOException e) {
      LOG.info("Failed to extract default course", e);
    }
    return coursesDir;
  }
  return new File(jarPath, "courses");
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:StudyUtils.java

示例2: getClassRoots

import com.intellij.util.PathUtil; //导入依赖的package包/类
@NotNull
public List<File> getClassRoots(Element libraryElement, @Nullable ModuleSettingsImpl moduleSettings) {
  List<File> files = new ArrayList<File>();
  //todo[nik] support jar directories
  final Element classesChild = libraryElement.getChild("CLASSES");
  if (classesChild != null) {
    final List<Element> roots = JDOMUtil.getChildren(classesChild, "root");
    final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings);
    for (Element root : roots) {
      final String url = root.getAttributeValue("url");
      final String path = VfsUtilCore.urlToPath(url);
      files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true))));
    }
  }
  return files;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ConversionContextImpl.java

示例3: testDeleteOverwritingFiles

import com.intellij.util.PathUtil; //导入依赖的package包/类
public void testDeleteOverwritingFiles() {
  final String firstFile = createFile("d1/xxx.txt", "1");
  final String secondFile = createFile("d2/xxx.txt", "2");
  final JpsArtifact a = addArtifact("a",
    root().dir("ddd").dirCopy(PathUtil.getParentPath(firstFile)).parentDirCopy(secondFile).fileCopy(createFile("y.txt"))
  );
  buildAll();
  assertOutput(a, fs().dir("ddd").file("xxx.txt", "1").file("y.txt"));

  delete(firstFile);
  buildAll();
  assertDeletedAndCopied("out/artifacts/a/ddd/xxx.txt", "d2/xxx.txt");
  assertOutput(a, fs().dir("ddd").file("xxx.txt", "2").file("y.txt"));
  buildAllAndAssertUpToDate();

  delete(secondFile);
  buildAll();
  assertDeleted("out/artifacts/a/ddd/xxx.txt");
  assertOutput(a, fs().dir("ddd").file("y.txt"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ArtifactBuilderOverwriteTest.java

示例4: testTwoDirsInArchive

import com.intellij.util.PathUtil; //导入依赖的package包/类
public void testTwoDirsInArchive() {
  final String dir1 = PathUtil.getParentPath(PathUtil.getParentPath(createFile("dir1/a/x.txt")));
  final String dir2 = PathUtil.getParentPath(PathUtil.getParentPath(createFile("dir2/a/y.txt")));
  final JpsArtifact a = addArtifact(
    root()
      .archive("a.jar")
        .dirCopy(dir1)
        .dirCopy(dir2)
        .dir("a").fileCopy(createFile("z.txt"))
  );
  buildAll();
  assertOutput(a, fs()
    .archive("a.jar")
      .dir("a")
        .file("x.txt")
        .file("y.txt")
        .file("z.txt")
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ArtifactBuilderTest.java

示例5: getSdkDownloadUrl

import com.intellij.util.PathUtil; //导入依赖的package包/类
/**
 * @return Android SDK download URL
 */
@NotNull
public static String getSdkDownloadUrl() {
  String url = System.getProperty("android.sdkurl");
  if (!StringUtil.isEmptyOrSpaces(url)) {
    File file = new File(url);
    if (file.isFile()) {
      // Can't use any path => URL utilities as they don't add two slashes
      // after the protocol as required by IJ downloader
      return LocalFileSystem.PROTOCOL_PREFIX + PathUtil.toSystemIndependentName(file.getAbsolutePath());
    }
    else {
      System.err.println("File " + file.getAbsolutePath() + " does not exist.");
    }
  }
  String downloadUrl = AndroidSdkUtils.getSdkDownloadUrl();
  if (downloadUrl == null) {
    throw new IllegalStateException("Unsupported OS");
  }
  return downloadUrl;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FirstRunWizardDefaults.java

示例6: getGoTestTarget

import com.intellij.util.PathUtil; //导入依赖的package包/类
@Nullable
private static TargetIdeInfo getGoTestTarget(Project project, String path) {
  WorkspacePath targetPackage = WorkspacePath.createIfValid(PathUtil.getParentPath(path));
  if (targetPackage == null) {
    return null;
  }
  TargetName targetName = TargetName.createIfValid(PathUtil.getFileName(path));
  if (targetName == null) {
    return null;
  }
  Label label = Label.create(targetPackage, targetName);
  BlazeProjectData projectData =
      BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
  if (projectData == null) {
    return null;
  }
  TargetIdeInfo target = projectData.targetMap.get(TargetKey.forPlainTarget(label));
  if (target != null
      && target.kind.languageClass.equals(LanguageClass.GO)
      && target.kind.ruleType.equals(RuleType.TEST)) {
    return target;
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:25,代码来源:BlazeGoTestLocator.java

示例7: testMoveClassAndDelete

import com.intellij.util.PathUtil; //导入依赖的package包/类
public void testMoveClassAndDelete() {
  String a1 = createFile("src1/A.java", "class A{}");
  String b = createFile("src2/B.java", "class B{}");
  JpsModule m = addModule("m", PathUtil.getParentPath(a1), PathUtil.getParentPath(b));
  makeAll();
  assertOutput(m, fs().file("A.class").file("B.class"));

  delete(a1);
  String a2 = createFile("src2/A.java", "class A{}");
  makeAll();
  assertOutput(m, fs().file("A.class").file("B.class"));

  delete(a2);
  makeAll();
  assertOutput(m, fs().file("B.class"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ClassMoveTest.java

示例8: isPath

import com.intellij.util.PathUtil; //导入依赖的package包/类
public static boolean isPath(@Nullable String s) {
  if (!StringUtil.isEmpty(s)) {
    s = ObjectUtils.assertNotNull(s);
    s = FileUtil.toSystemIndependentName(s);
    final List<String> components = StringUtil.split(s, "/");
    for (String name : components) {
      if (name == components.get(0) && SystemInfo.isWindows && name.endsWith(":")) {
        continue;
      }
      if (!PathUtil.isValidFileName(name)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PythonStringUtil.java

示例9: createLabelFromString

import com.intellij.util.PathUtil; //导入依赖的package包/类
/**
 * Canonicalizes the label (to the form [@external_workspace]//packagePath:packageRelativeTarget).
 * Returns null if the string does not represent a valid label.
 */
@Nullable
public static Label createLabelFromString(
    @Nullable BlazePackage blazePackage, @Nullable String labelString) {
  if (labelString == null) {
    return null;
  }
  int colonIndex = labelString.indexOf(':');
  if (isAbsolute(labelString)) {
    if (colonIndex == -1) {
      // add the implicit rule name
      labelString += ":" + PathUtil.getFileName(labelString);
    }
    return Label.createIfValid(labelString);
  }
  // package-relative label of the form '[:]relativePath'
  if (colonIndex > 0 || blazePackage == null) {
    return null;
  }
  Label packageLabel = blazePackage.getPackageLabel();
  return packageLabel != null
      ? packageLabel.withTargetName(labelString.substring(colonIndex + 1))
      : null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:28,代码来源:LabelUtils.java

示例10: collectListeners

import com.intellij.util.PathUtil; //导入依赖的package包/类
protected void collectListeners(JavaParameters javaParameters, StringBuilder buf, String epName, String delimiter) {
  final T configuration = getConfiguration();
  final Object[] listeners = Extensions.getExtensions(epName);
  for (final Object listener : listeners) {
    boolean enabled = true;
    for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
      if (ext.isListenerDisabled(configuration, listener, getRunnerSettings())) {
        enabled = false;
        break;
      }
    }
    if (enabled) {
      if (buf.length() > 0) buf.append(delimiter);
      final Class classListener = listener.getClass();
      buf.append(classListener.getName());
      javaParameters.getClassPath().add(PathUtil.getJarPathForClass(classListener));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaTestFrameworkRunnableState.java

示例11: setUp

import com.intellij.util.PathUtil; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  if (ourOutputRoot == null) {
    ourOutputRoot = FileUtil.createTempDirectory("ExecutionTestCase", null, true);
  }
  myModuleOutputDir = new File(ourOutputRoot, PathUtil.getFileName(getTestAppPath()));
  myChecker = initOutputChecker();
  EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
    @Override
    public void run() throws Throwable {
      ExecutionTestCase.super.setUp();
    }
  });
  if (!myModuleOutputDir.exists()) {
    myCompilerTester = new CompilerTester(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
    List<CompilerMessage> messages = myCompilerTester.rebuild();
    for (CompilerMessage message : messages) {
      if (message.getCategory() == CompilerMessageCategory.ERROR) {
        FileUtil.delete(myModuleOutputDir);
        fail("Compilation failed: " + message);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExecutionTestCase.java

示例12: getItemText

import com.intellij.util.PathUtil; //导入依赖的package包/类
private String getItemText(String relativePath) {
  if (pathFormat == PathFormat.PackageLocal) {
    if (containingPackage.length() > relativePath.length()) {
      return "";
    }
    return StringUtil.trimStart(relativePath.substring(containingPackage.length()), "/");
  }
  String parentPath = PathUtil.getParentPath(relativePath);
  while (!parentPath.isEmpty()) {
    if (filePathFragment.startsWith(parentPath + "/")) {
      return StringUtil.trimStart(relativePath, parentPath + "/");
    } else if (filePathFragment.startsWith(parentPath)) {
      return StringUtil.trimStart(relativePath, parentPath);
    }
    parentPath = PathUtil.getParentPath(parentPath);
  }
  return relativePath;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:19,代码来源:FileLookupData.java

示例13: getNotExcludedRoots

import com.intellij.util.PathUtil; //导入依赖的package包/类
private Set<VirtualFile> getNotExcludedRoots() {
  Set<VirtualFile> roots = new LinkedHashSet<VirtualFile>();
  String[] excludedRootUrls = getLibraryEditor().getExcludedRootUrls();
  Set<VirtualFile> excludedRoots = new HashSet<VirtualFile>();
  for (String url : excludedRootUrls) {
    ContainerUtil.addIfNotNull(excludedRoots, VirtualFileManager.getInstance().findFileByUrl(url));
  }
  for (PersistentOrderRootType type : OrderRootType.getAllPersistentTypes()) {
    VirtualFile[] files = getLibraryEditor().getFiles(type);
    for (VirtualFile file : files) {
      if (!VfsUtilCore.isUnder(file, excludedRoots)) {
        roots.add(PathUtil.getLocalFile(file));
      }
    }
  }
  return roots;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LibraryRootsComponent.java

示例14: setUp

import com.intellij.util.PathUtil; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  JavaTestFixtureFactory.getFixtureFactory();   // registers Java module fixture builder
  final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
  final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getClass().getSimpleName());
  myFixture = fixtureFactory.createTempDirTestFixture();
  myFixture.setUp();

  FileUtil.copyDir(new File(PluginPathManager.getPluginHomePath("testng") + "/testData/runConfiguration/module1"),
                   new File(myFixture.getTempDirPath()), false);

  myProjectFixture = testFixtureBuilder.getFixture();
  final JavaModuleFixtureBuilder javaModuleFixtureBuilder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
  javaModuleFixtureBuilder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot("src");
  javaModuleFixtureBuilder.addLibrary("testng", PathUtil.getJarPathForClass(AfterMethod.class));
  myProjectFixture.setUp();

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ConfigurationsTest.java

示例15: createProjectWithSubprojects

import com.intellij.util.PathUtil; //导入依赖的package包/类
@NotNull
private VirtualFile createProjectWithSubprojects(Map<String, String> modules, String... nonExistingReferencedModules) throws IOException {
  Collection<String> customLocationStatements = new LinkedList<String>();

  for (Map.Entry<String, String> module : modules.entrySet()) {
    String path = module.getValue();
    if (Strings.isNullOrEmpty(path)) {
      path = PathUtil.toSystemIndependentName(GradleUtil.getDefaultPhysicalPathFromGradlePath(module.getKey()));
    }
    else {
      customLocationStatements.add(String.format("project('%s').projectDir = new File('%s')", module.getKey(), path));
    }
    createGradleProjectToImport(dir, path);
  }
  Iterable<String> allModules =
    Iterables.concat(modules.keySet(), Iterables.transform(Arrays.asList(nonExistingReferencedModules), pathToModuleName));
  return configureTopLevelProject(dir, allModules, customLocationStatements);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GradleModuleImportTest.java


注:本文中的com.intellij.util.PathUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。