mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
package dependencies cosmetics
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.ImportHelper;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.RefCountHolder;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -25,11 +33,11 @@ public abstract class DependenciesBuilder {
|
||||
myTotalFileCount = scope.getFileCount();
|
||||
}
|
||||
|
||||
protected void setInitialFileCount(final int fileCount) {
|
||||
public void setInitialFileCount(final int fileCount) {
|
||||
myFileCount = fileCount;
|
||||
}
|
||||
|
||||
protected void setTotalFileCount(final int totalFileCount) {
|
||||
public void setTotalFileCount(final int totalFileCount) {
|
||||
myTotalFileCount = totalFileCount;
|
||||
}
|
||||
|
||||
@@ -89,6 +97,7 @@ public abstract class DependenciesBuilder {
|
||||
void process(PsiElement place, PsiElement dependency);
|
||||
}
|
||||
|
||||
|
||||
private static class DependenciesWalker extends PsiRecursiveElementVisitor {
|
||||
private final DependencyProcessor myProcessor;
|
||||
|
||||
@@ -116,6 +125,10 @@ public abstract class DependenciesBuilder {
|
||||
//empty
|
||||
}
|
||||
|
||||
public void visitImportStatement(PsiImportStatement statement) {
|
||||
//empty - to exclude imports from dependency analyzing
|
||||
}
|
||||
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
super.visitMethodCallExpression(expression);
|
||||
PsiMethod psiMethod = expression.resolveMethod();
|
||||
|
||||
@@ -27,11 +27,11 @@ public class DependencyRule {
|
||||
public String getDisplayText() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(myDenyRule ? "Deny " : "Allow ");
|
||||
buf.append("usages of '");
|
||||
buf.append("usages of scope '");
|
||||
if (myToScope != null) {
|
||||
buf.append(myToScope.getName());
|
||||
}
|
||||
buf.append("' " + (myDenyRule ? " " : "only ") + "in '");
|
||||
buf.append("' " + (myDenyRule ? " " : "only ") + "in scope '");
|
||||
if (myFromScope != null) {
|
||||
buf.append(myFromScope.getName());
|
||||
}
|
||||
|
||||
@@ -42,6 +42,19 @@ public class DependencyValidationManager extends NamedScopesHolder implements Pr
|
||||
return null;
|
||||
}
|
||||
|
||||
public DependencyRule[] getViolatorDependencyRules(PsiFile from, PsiFile to) {
|
||||
ArrayList<DependencyRule> result = new ArrayList<DependencyRule>();
|
||||
for (int i = 0; i < myRules.size(); i++) {
|
||||
DependencyRule dependencyRule = myRules.get(i);
|
||||
if (dependencyRule.isForbiddenToUse(from, to)){
|
||||
result.add(dependencyRule);
|
||||
}
|
||||
}
|
||||
return result.toArray(new DependencyRule[result.size()]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public DependencyRule[] getAllRules() {
|
||||
return myRules.toArray(new DependencyRule[myRules.size()]);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.ImportHelper;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -305,15 +305,16 @@ public class DependenciesPanel extends JPanel {
|
||||
return myRightTree;
|
||||
}
|
||||
|
||||
private static class MyTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||
public Component getTreeCellRendererComponent(JTree tree,
|
||||
Object value,
|
||||
boolean sel,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
||||
private static class MyTreeCellRenderer extends ColoredTreeCellRenderer {
|
||||
public void customizeCellRenderer(
|
||||
JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus
|
||||
){
|
||||
PackageDependenciesNode node = (PackageDependenciesNode)value;
|
||||
if (expanded) {
|
||||
setIcon(node.getOpenIcon());
|
||||
@@ -322,11 +323,11 @@ public class DependenciesPanel extends JPanel {
|
||||
setIcon(node.getClosedIcon());
|
||||
}
|
||||
|
||||
if (node.hasMarked() && !sel) {
|
||||
if (node.hasMarked() && !selected) {
|
||||
setForeground(Color.red);
|
||||
}
|
||||
|
||||
return this;
|
||||
append(node.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
append(node.getPresentableFilesCount(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ public class FileNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (isEquals()){
|
||||
return super.equals(o);
|
||||
}
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof FileNode)) return false;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GeneralGroupNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myName + getPresentableFilesCount();
|
||||
return myName;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
@@ -38,6 +38,9 @@ public class GeneralGroupNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (isEquals()){
|
||||
return super.equals(o);
|
||||
}
|
||||
if (!(o instanceof GeneralGroupNode)) return false;
|
||||
return myName.equals(((GeneralGroupNode)o).myName);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class LibraryNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myLibraryOrJdk.getPresentableName() + getPresentableFilesCount();
|
||||
return myLibraryOrJdk.getPresentableName();
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
@@ -38,6 +38,9 @@ public class LibraryNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (isEquals()){
|
||||
return super.equals(o);
|
||||
}
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof LibraryNode)) return false;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ModuleNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myModule == null ? "<unknown>" : myModule.getName() + getPresentableFilesCount();
|
||||
return myModule == null ? "<unknown>" : myModule.getName();
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
@@ -46,6 +46,9 @@ public class ModuleNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (isEquals()){
|
||||
return super.equals(o);
|
||||
}
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ModuleNode)) return false;
|
||||
|
||||
|
||||
@@ -21,6 +21,15 @@ public class PackageDependenciesNode extends DefaultMutableTreeNode implements N
|
||||
private Set<PsiFile> myRegisteredFiles = new HashSet<PsiFile>();
|
||||
private boolean myHasUnmarked = false;
|
||||
private boolean myHasMarked = false;
|
||||
private boolean myEquals;
|
||||
|
||||
public void setEquals(final boolean equals) {
|
||||
myEquals = equals;
|
||||
}
|
||||
|
||||
public boolean isEquals() {
|
||||
return myEquals;
|
||||
}
|
||||
|
||||
public void fillFiles(Set<PsiFile> set, boolean recursively) {
|
||||
set.addAll(myRegisteredFiles);
|
||||
@@ -63,7 +72,7 @@ public class PackageDependenciesNode extends DefaultMutableTreeNode implements N
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String getPresentableFilesCount(){
|
||||
public String getPresentableFilesCount(){
|
||||
final int filesCount = getContainingFiles();
|
||||
return filesCount > 0 ? " (" + filesCount + (filesCount > 1 ? " entries" : " entry") + ")" : "";
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class PackageNode extends PackageDependenciesNode {
|
||||
private String myPackageQName;
|
||||
private final PsiPackage myPackage;
|
||||
|
||||
|
||||
public PackageNode(PsiPackage aPackage, boolean showFQName) {
|
||||
myPackage = aPackage;
|
||||
myPackageName = showFQName ? aPackage.getQualifiedName() : aPackage.getName();
|
||||
@@ -40,7 +41,7 @@ public class PackageNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myPackageName + getPresentableFilesCount();
|
||||
return myPackageName;
|
||||
}
|
||||
|
||||
public String getPackageQName() {
|
||||
@@ -56,6 +57,9 @@ public class PackageNode extends PackageDependenciesNode {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (isEquals()){
|
||||
return super.equals(o);
|
||||
}
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof PackageNode)) return false;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public class UsagesPanel extends JPanel {
|
||||
private DependenciesBuilder myBuilder;
|
||||
private ProgressIndicator myCurrentProgress;
|
||||
private JComponent myCurrentComponent;
|
||||
private UsageView myCurrentUsageView;
|
||||
private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
|
||||
|
||||
public UsagesPanel(Project project, DependenciesBuilder builder) {
|
||||
@@ -107,9 +108,9 @@ public class UsagesPanel extends JPanel {
|
||||
Usage[] usages = UsageInfoToUsageConverter.convert(descriptor, usageInfos);
|
||||
UsageViewPresentation presentation = new UsageViewPresentation();
|
||||
presentation.setCodeUsagesString(myBuilder.getRootNodeNameInUsageView());
|
||||
UsageView usageView = myProject.getComponent(UsageViewManager.class).createUsageView(new UsageTarget[0],
|
||||
myCurrentUsageView = myProject.getComponent(UsageViewManager.class).createUsageView(new UsageTarget[0],
|
||||
usages, presentation);
|
||||
setToComponent(usageView.getComponent());
|
||||
setToComponent(myCurrentUsageView.getComponent());
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
setToCanceled();
|
||||
@@ -124,6 +125,9 @@ public class UsagesPanel extends JPanel {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myCurrentComponent != null) {
|
||||
if (myCurrentUsageView != null && myCurrentComponent == myCurrentUsageView.getComponent()){
|
||||
myCurrentUsageView.dispose();
|
||||
}
|
||||
remove(myCurrentComponent);
|
||||
}
|
||||
myCurrentComponent = cmp;
|
||||
|
||||
Reference in New Issue
Block a user