本文整理汇总了Java中com.intellij.util.PathUtil.getParentPath方法的典型用法代码示例。如果您正苦于以下问题:Java PathUtil.getParentPath方法的具体用法?Java PathUtil.getParentPath怎么用?Java PathUtil.getParentPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.PathUtil
的用法示例。
在下文中一共展示了PathUtil.getParentPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGradleClassPath
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
private static void addGradleClassPath(@NotNull final List<String> classpath) {
String gradleLibDirPath = null;
String gradleToolingApiJarPath = PathUtil.getJarPathForClass(ProjectConnection.class);
if (!StringUtil.isEmpty(gradleToolingApiJarPath)) {
gradleLibDirPath = PathUtil.getParentPath(gradleToolingApiJarPath);
}
if (gradleLibDirPath == null || gradleLibDirPath.isEmpty()) return;
File gradleLibDir = new File(gradleLibDirPath);
if (!gradleLibDir.isDirectory()) return;
File[] children = FileUtil.notNullize(gradleLibDir.listFiles());
for (File child : children) {
final String fileName = child.getName();
if (fileName.endsWith(".jar") && child.isFile()) {
classpath.add(child.getAbsolutePath());
}
}
}
示例2: removeImportPathSuffix
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
private static PsiElement removeImportPathSuffix(PsiElement resolvedImportPath, String suffix) {
if (Strings.isNullOrEmpty(suffix)) {
return resolvedImportPath;
}
// Last component is rule name.
suffix = PathUtil.getParentPath(suffix);
PsiDirectory path = resolvedImportPath.getContainingFile().getContainingDirectory();
while (!suffix.isEmpty()
&& path != null
&& PathUtil.getFileName(suffix).equals(path.getName())) {
suffix = PathUtil.getParentPath(suffix);
if (suffix.isEmpty()) {
return path;
}
path = path.getParent();
}
return resolvedImportPath;
}
示例3: copyFile
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@NotNull
@Override
public VirtualFile copyFile(@NotNull final VirtualFile file, @NotNull final String targetPath) {
final String path = PathUtil.getParentPath(targetPath);
return ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
try {
VirtualFile targetDir = findOrCreateDir(path);
final String newName = PathUtil.getFileName(targetPath);
final VirtualFile existing = targetDir.findChild(newName);
if (existing != null) {
existing.setBinaryContent(file.contentsToByteArray());
return existing;
}
return VfsUtilCore.copyFile(this, file, targetDir, newName);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
示例4: 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;
}
示例5: testAddRoot
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testAddRoot() {
String dir1 = PathUtil.getParentPath(createFile("dir1/a.txt", "a"));
String dir2 = PathUtil.getParentPath(createFile("dir2/b.txt", "b"));
JpsArtifact a = addArtifact(root().dirCopy(dir1));
buildAll();
assertOutput(a, fs().file("a.txt", "a"));
a.getRootElement().addChild(JpsPackagingElementFactory.getInstance().createDirectoryCopy(dir2));
buildAll();
assertOutput(a, fs().file("a.txt", "a").file("b.txt", "b"));
assertDeletedAndCopied("out/artifacts/a/a.txt", "dir1/a.txt", "dir2/b.txt");
buildAllAndAssertUpToDate();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RebuildArtifactOnConfigurationChangeTest.java
示例6: testDoNotCleanIfContainsArtifactRoot
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testDoNotCleanIfContainsArtifactRoot() {
JpsModule m = addModule("m");
String resDir = PathUtil.getParentPath(createFile("res/a.txt"));
m.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(resDir));
JpsArtifact a = addArtifact(root().dirCopy(resDir));
a.setOutputPath(resDir);
buildArtifacts(a);
assertOutput(a, fs().file("a.txt"));
createFile("res/b.txt");
rebuildAll();
assertOutput(a, fs().file("a.txt").file("b.txt"));
}
示例7: testCopyExcludedFolder
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testCopyExcludedFolder() {
//explicitly added excluded files should be copied (e.g. compile output)
final String file = createFile("xxx/excluded/a.txt");
createFile("xxx/excluded/CVS");
final String excluded = PathUtil.getParentPath(file);
final String dir = PathUtil.getParentPath(excluded);
final JpsModule module = addModule("myModule");
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(dir));
module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(excluded));
final JpsArtifact a = addArtifact(root().dirCopy(excluded));
buildAll();
assertOutput(a, fs().file("a.txt"));
}
示例8: generateTasksForArtifact
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Override
public void generateTasksForArtifact(Artifact artifact, boolean preprocessing, ArtifactAntGenerationContext context,
CompositeGenerator generator) {
final ArtifactPropertiesProvider provider;
if (preprocessing) {
provider = AntArtifactPreProcessingPropertiesProvider.getInstance();
}
else {
provider = AntArtifactPostprocessingPropertiesProvider.getInstance();
}
final AntArtifactProperties properties = (AntArtifactProperties)artifact.getProperties(provider);
if (properties != null && properties.isEnabled()) {
final String path = VfsUtil.urlToPath(properties.getFileUrl());
String fileName = PathUtil.getFileName(path);
String dirPath = PathUtil.getParentPath(path);
final String relativePath = GenerationUtils.toRelativePath(dirPath, BuildProperties.getProjectBaseDir(context.getProject()),
BuildProperties.getProjectBaseDirProperty(), context.getGenerationOptions());
final Tag ant = new Tag("ant", Pair.create("antfile", fileName), Pair.create("target", properties.getTargetName()),
Pair.create("dir", relativePath));
final String outputPath = BuildProperties.propertyRef(context.getArtifactOutputProperty(artifact));
ant.add(new Property(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, outputPath));
for (BuildFileProperty property : properties.getUserProperties()) {
ant.add(new Property(property.getPropertyName(), property.getPropertyValue()));
}
generator.add(ant);
}
}
示例9: testExtractDirectoryFromExcludedJar
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testExtractDirectoryFromExcludedJar() throws IOException {
String jarPath = createFile("dir/lib/j.jar");
FileUtil.copy(new File(getJUnitJarPath()), new File(jarPath));
JpsModule module = addModule("m");
String libDir = PathUtil.getParentPath(jarPath);
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(PathUtil.getParentPath(libDir)));
module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(libDir));
final JpsArtifact a = addArtifact("a", root().extractedDir(jarPath, "/junit/textui/"));
buildAll();
assertOutput(a, fs().file("ResultPrinter.class")
.file("TestRunner.class"));
}
示例10: testBuildModuleBeforeArtifactIfSomeDirectoryInsideModuleOutputIsCopiedToArtifact
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testBuildModuleBeforeArtifactIfSomeDirectoryInsideModuleOutputIsCopiedToArtifact() {
String src = PathUtil.getParentPath(PathUtil.getParentPath(createFile("src/x/A.java", "package x; class A{}")));
JpsModule module = addModule("m", src);
File output = JpsJavaExtensionService.getInstance().getOutputDirectory(module, false);
JpsArtifact artifact = addArtifact(root().dirCopy(new File(output, "x").getAbsolutePath()));
rebuildAll();
assertOutput(module, fs().dir("x").file("A.class"));
assertOutput(artifact, fs().file("A.class"));
}
示例11: getCharset
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Override
@NotNull
public Charset getCharset(@Nullable Project project) {
VirtualFile file = getVirtualFile();
String path = myPath;
while ((file == null || !file.isValid()) && !path.isEmpty()) {
path = PathUtil.getParentPath(path);
file = LocalFileSystem.getInstance().findFileByPath(path);
}
if (file != null) {
return file.getCharset();
}
EncodingManager e = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
return e.getDefaultCharset();
}
示例12: testTestOnProductionDependency
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testTestOnProductionDependency() {
String depRoot = PathUtil.getParentPath(createFile("dep/A.java", "class A{}"));
String testRoot = PathUtil.getParentPath(createFile("test/B.java", "class B extends A{}"));
JpsModule main = addModule("main");
main.addSourceRoot(JpsPathUtil.pathToUrl(testRoot), JavaSourceRootType.TEST_SOURCE);
JpsModule dep = addModule("dep", depRoot);
main.getDependenciesList().addModuleDependency(dep);
rebuildAll();
}
示例13: testTransitiveDependencyViaDummyModule
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testTransitiveDependencyViaDummyModule() {
String depRoot = PathUtil.getParentPath(createFile("dep/A.java", "class A{}"));
String mainRoot = PathUtil.getParentPath(createFile("main/B.java", "class B extends A{}"));
JpsModule main = addModule("main", mainRoot);
JpsModule dep = addModule("dep", depRoot);
JpsModule dummy = addModule("dummy");
JpsModule dummy2 = addModule("dummy2");
dep.getDependenciesList().addModuleDependency(main);//force 'main' to be built before 'dep' unless transitive dependency is correctly considered
main.getDependenciesList().addModuleDependency(dummy);
addExportedDependency(dummy, dummy2);
addExportedDependency(dummy2, dep);
dummy2.getDependenciesList().addModuleDependency(dummy);
rebuildAll();
}
示例14: testRecompileDependentAfterForcedCompilation
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public void testRecompileDependentAfterForcedCompilation() {
String srcRoot = PathUtil.getParentPath(createFile("src/A.java", "class A{ { new B(); } }"));
String b = createFile("depSrc/B.java", "public class B{}");
JpsModule main = addModule("main", srcRoot);
JpsModule dep = addModule("dep", PathUtil.getParentPath(b));
main.getDependenciesList().addModuleDependency(dep);
rebuildAll();
change(b, "public class B{ public B(int i){} }");
doBuild(CompileScopeTestBuilder.recompile().module(dep)).assertSuccessful();
doBuild(CompileScopeTestBuilder.make().module(main)).assertFailed();
}
示例15: loadProjectByAbsolutePath
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
protected void loadProjectByAbsolutePath(String path) {
myProjectHomePath = FileUtilRt.toSystemIndependentName(path);
if (myProjectHomePath.endsWith(".ipr")) {
myProjectHomePath = PathUtil.getParentPath(myProjectHomePath);
}
try {
JpsProjectLoader.loadProject(myProject, getPathVariables(), path);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}