From a53fd0bb789c8f8627e44239f6a857c6aedc4253 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Fri, 23 Dec 2016 18:18:01 +0300 Subject: [PATCH] javac ast indices: test ui; add hierarchy information --- .../view/CompilerReferenceHierarchyTestInfo.java | 4 +--- .../view/InternalCompilerRefServiceView.java | 14 ++++++++++++++ ...nceServiceFunctionalExpressionSearchAction.java | 8 +++++--- ...tCompilerReferenceServiceInheritanceAction.java | 5 +++-- resources/src/idea/JavaActions.xml | 4 +++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/CompilerReferenceHierarchyTestInfo.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/CompilerReferenceHierarchyTestInfo.java index 453bf8f2ab34..3ccf033f4f91 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/CompilerReferenceHierarchyTestInfo.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/CompilerReferenceHierarchyTestInfo.java @@ -65,9 +65,7 @@ public class CompilerReferenceHierarchyTestInfo { if (isEnabled()) { final DefaultMutableTreeNode knownOccurrences = new DefaultMutableTreeNode("Known hierarchy direct children"); node.add(knownOccurrences); - getHierarchyChildren().forEach(e -> { - knownOccurrences.add(new DefaultMutableTreeNode(e)); - }); + getHierarchyChildren().forEach(e -> knownOccurrences.add(new DefaultMutableTreeNode(e))); final DefaultMutableTreeNode dirtyModules = new DefaultMutableTreeNode("Dirty modules"); node.add(dirtyModules); diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/InternalCompilerRefServiceView.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/InternalCompilerRefServiceView.java index 3e9d72b91560..d3a7fb30e1bc 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/InternalCompilerRefServiceView.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/InternalCompilerRefServiceView.java @@ -23,7 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFunctionalExpression; +import com.intellij.psi.presentation.java.ClassPresentationUtil; import com.intellij.psi.presentation.java.SymbolPresentationUtil; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; @@ -66,6 +69,10 @@ public class InternalCompilerRefServiceView extends JPanel implements DataProvid append(((VirtualFile)userObject).getName()); append(" in "); append(((VirtualFile)userObject).getParent().getPath(), SimpleTextAttributes.GRAY_ATTRIBUTES); + } else if (userObject instanceof PsiFunctionalExpression) { + append(ClassPresentationUtil.getFunctionalExpressionPresentation((PsiFunctionalExpression)userObject, true)); + } else if (userObject instanceof PsiClass) { + append(ClassPresentationUtil.getNameForClass((PsiClass)userObject, true)); } else { append(userObject.toString()); } @@ -97,6 +104,13 @@ public class InternalCompilerRefServiceView extends JPanel implements DataProvid ((DefaultTreeModel)view.myTree.getModel()).setRoot(node); } + public static void showHierarchyInfo(CompilerReferenceHierarchyTestInfo info, PsiElement element) { + final InternalCompilerRefServiceView view = getView(element); + final DefaultMutableTreeNode node = info.asTree(); + node.setUserObject(element); + ((DefaultTreeModel)view.myTree.getModel()).setRoot(node); + } + public static InternalCompilerRefServiceView getView(PsiElement element) { Project project = element.getProject(); final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceFunctionalExpressionSearchAction.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceFunctionalExpressionSearchAction.java index f77688df33c9..727831adbfcd 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceFunctionalExpressionSearchAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceFunctionalExpressionSearchAction.java @@ -29,8 +29,8 @@ import org.jetbrains.annotations.NotNull; public class TestCompilerReferenceServiceFunctionalExpressionSearchAction extends TestCompilerReferenceServiceAction { - public TestCompilerReferenceServiceFunctionalExpressionSearchAction(String text) { - super(text); + public TestCompilerReferenceServiceFunctionalExpressionSearchAction() { + super("Compiler Reference Functional Expression Search"); } @Override @@ -40,7 +40,9 @@ public class TestCompilerReferenceServiceFunctionalExpressionSearchAction extend final CompilerReferenceServiceImpl compilerReferenceService = (CompilerReferenceServiceImpl)CompilerReferenceService.getInstance( project); final GlobalSearchScope scope = GlobalSearchScopeUtil.toGlobalSearchScope(element.getUseScope(), project); - compilerReferenceService.getTestFunExpressions((PsiNamedElement)element, scope, StdFileTypes.JAVA); + final CompilerReferenceHierarchyTestInfo hierarchyTestInfo = + compilerReferenceService.getTestFunExpressions((PsiNamedElement)element, scope, StdFileTypes.JAVA); + InternalCompilerRefServiceView.showHierarchyInfo(hierarchyTestInfo, element); } } } diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceInheritanceAction.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceInheritanceAction.java index 9eea7dc14101..00b7a3652896 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceInheritanceAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/view/TestCompilerReferenceServiceInheritanceAction.java @@ -27,8 +27,8 @@ import com.intellij.psi.search.GlobalSearchScopeUtil; import org.jetbrains.annotations.NotNull; public class TestCompilerReferenceServiceInheritanceAction extends TestCompilerReferenceServiceAction { - public TestCompilerReferenceServiceInheritanceAction(String text) { - super(text); + public TestCompilerReferenceServiceInheritanceAction() { + super("Compiler Reference Direct Inheritor Search"); } @Override @@ -41,6 +41,7 @@ public class TestCompilerReferenceServiceInheritanceAction extends TestCompilerR (PsiNamedElement)element, scope, StdFileTypes.JAVA); + InternalCompilerRefServiceView.showHierarchyInfo(hierarchyInfo, element); } } } diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index eb892f604723..3fb2a24d4ac2 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -447,6 +447,8 @@ - + + +