don't show synthetic methods in groovy structure view

This commit is contained in:
peter
2012-01-05 20:38:46 +01:00
parent 6d51f2738f
commit d3329c8512
8 changed files with 135 additions and 23 deletions
@@ -16,6 +16,7 @@
package com.intellij.ide.structureView.impl;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.scope.BaseScopeProcessor;
import com.intellij.psi.util.MethodSignature;
import com.intellij.psi.util.PsiUtil;
@@ -55,11 +56,11 @@ public class AddAllMembersProcessor extends BaseScopeProcessor {
PsiMethod psiMethod = (PsiMethod)member;
if (shouldAdd(psiMethod)) {
mapMethodBySignature(psiMethod);
myAllMembers.add(psiMethod);
myAllMembers.add(PsiImplUtil.handleMirror(psiMethod));
}
}
else {
myAllMembers.add(member);
myAllMembers.add(PsiImplUtil.handleMirror(member));
}
}
return true;
@@ -17,7 +17,7 @@ package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.psi.impl.PsiImplUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -43,11 +43,7 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase<PsiClass> {
final PsiClass aClass = getElement();
if (aClass == null) return Collections.emptyList();
Collection<PsiElement> members = new ArrayList<PsiElement>();
ContainerUtil.addAll(members, aClass.getFields());
ContainerUtil.addAll(members, aClass.getMethods());
ContainerUtil.addAll(members, aClass.getInnerClasses());
ContainerUtil.addAll(members, aClass.getInitializers());
LinkedHashSet<PsiElement> members = getOwnChildren(aClass);
List<StructureViewTreeElement> children = new ArrayList<StructureViewTreeElement>(members.size());
//aClass.processDeclarations(new AddAllMembersProcessor(inherited, aClass), ResolveState.initial(), null, aClass);
@@ -70,6 +66,21 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase<PsiClass> {
return children;
}
static LinkedHashSet<PsiElement> getOwnChildren(PsiClass aClass) {
LinkedHashSet<PsiElement> members = new LinkedHashSet<PsiElement>();
addPhysicalElements(aClass.getFields(), members);
addPhysicalElements(aClass.getMethods(), members);
addPhysicalElements(aClass.getInnerClasses(), members);
addPhysicalElements(aClass.getInitializers(), members);
return members;
}
private static void addPhysicalElements(PsiElement[] elements, LinkedHashSet<PsiElement> to) {
for (PsiElement element : elements) {
to.add(PsiImplUtil.handleMirror(element));
}
}
public Set<PsiClass> getParents() {
return myParents;
}
@@ -26,7 +26,6 @@ import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.util.IconLoader;
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -51,11 +50,7 @@ public class JavaInheritedMembersNodeProvider implements FileStructureNodeProvid
if (node instanceof JavaClassTreeElement) {
final PsiClass aClass = ((JavaClassTreeElement)node).getValue();
Collection<PsiElement> inherited = new LinkedHashSet<PsiElement>();
Collection<PsiElement> ownChildren = new THashSet<PsiElement>();
ContainerUtil.addAll(ownChildren, aClass.getFields());
ContainerUtil.addAll(ownChildren, aClass.getMethods());
ContainerUtil.addAll(ownChildren, aClass.getInnerClasses());
ContainerUtil.addAll(ownChildren, aClass.getInitializers());
Collection<PsiElement> ownChildren = JavaClassTreeElement.getOwnChildren(aClass);
aClass.processDeclarations(new AddAllMembersProcessor(inherited, aClass), ResolveState.initial(), null, aClass);
inherited.removeAll(ownChildren);