mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 20:39:40 +07:00
analyze dependencies: display lib root name (IDEA-203484)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
package com.package1;
|
||||
|
||||
public class Class2 {
|
||||
String s;
|
||||
}
|
||||
@@ -77,7 +77,11 @@ public class DependenciesPanelTest extends TestSourceBasedTestCase {
|
||||
" -dependencies\n" +
|
||||
" -src\n" +
|
||||
" com/package1\n",
|
||||
"Root\n");
|
||||
"-Root\n" +
|
||||
" -External Dependencies\n" +
|
||||
" -src.zip\n" +
|
||||
" -java/lang\n" +
|
||||
" String.java");
|
||||
}
|
||||
|
||||
private void doTestDependenciesTrees(AnalysisScope scope, String expectedLeftTree, String expectedRightTree) {
|
||||
|
||||
@@ -26,10 +26,14 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FilePatternPackageSet extends PatternBasedPackageSet {
|
||||
@@ -196,13 +200,14 @@ public class FilePatternPackageSet extends PatternBasedPackageSet {
|
||||
}
|
||||
|
||||
public static String getLibRelativePath(final VirtualFile virtualFile, final ProjectFileIndex index) {
|
||||
StringBuilder relativePath = new StringBuilder(100);
|
||||
List<String> path = new ArrayList<>();
|
||||
VirtualFile directory = virtualFile;
|
||||
while (directory != null && index.isInLibraryClasses(directory)) {
|
||||
relativePath.insert(0, '/');
|
||||
relativePath.insert(0, directory.getName());
|
||||
while (directory != null && index.isInLibrary(directory)) {
|
||||
path.add(directory.getName());
|
||||
directory = directory.getParent();
|
||||
}
|
||||
return relativePath.toString();
|
||||
if (path.isEmpty()) return "";
|
||||
Collections.reverse(path);
|
||||
return StringUtil.join(ArrayUtil.toStringArray(path), 1, path.size(), "/");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,12 @@ public class DirectoryNode extends PackageDependenciesNode {
|
||||
}
|
||||
}
|
||||
else {
|
||||
myFQName = FilePatternPackageSet.getLibRelativePath(myVDirectory, index);
|
||||
if (myVDirectory.equals(index.getSourceRootForFile(myVDirectory)) || myVDirectory.equals(index.getClassRootForFile(myVDirectory))) {
|
||||
myFQName = dirName;
|
||||
}
|
||||
else {
|
||||
myFQName = FilePatternPackageSet.getLibRelativePath(myVDirectory, index);
|
||||
}
|
||||
}
|
||||
dirName = myFQName;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user