1 12 package org.eclipse.jdt.internal.corext.callhierarchy; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.jdt.core.IJavaElement; 18 import org.eclipse.jdt.core.IMember; 19 import org.eclipse.jdt.core.IType; 20 21 class CallSearchResultCollector { 22 private Map fCalledMembers; 23 24 public CallSearchResultCollector() { 25 this.fCalledMembers = createCalledMethodsData(); 26 } 27 28 public Map getCallers() { 29 return fCalledMembers; 30 } 31 32 protected void addMember(IMember member, IMember calledMember, int start, int end) { 33 addMember(member, calledMember, start, end, CallLocation.UNKNOWN_LINE_NUMBER); 34 } 35 36 protected void addMember(IMember member, IMember calledMember, int start, int end, int lineNumber) { 37 if ((member != null) && (calledMember != null)) { 38 if (!isIgnored(calledMember)) { 39 MethodCall methodCall = (MethodCall) fCalledMembers.get(calledMember.getHandleIdentifier()); 40 41 if (methodCall == null) { 42 methodCall = new MethodCall(calledMember); 43 fCalledMembers.put(calledMember.getHandleIdentifier(), methodCall); 44 } 45 46 methodCall.addCallLocation(new CallLocation(member, calledMember, start, 47 end, lineNumber)); 48 } 49 } 50 } 51 52 protected Map createCalledMethodsData() { 53 return new HashMap (); 54 } 55 56 61 private boolean isIgnored(IMember enclosingElement) { 62 String fullyQualifiedName = getTypeOfElement(enclosingElement) 63 .getFullyQualifiedName(); 64 65 return CallHierarchy.getDefault().isIgnored(fullyQualifiedName); 66 } 67 68 private IType getTypeOfElement(IMember element) { 69 if (element.getElementType() == IJavaElement.TYPE) { 70 return (IType) element; 71 } 72 73 return element.getDeclaringType(); 74 } 75 } 76 | Popular Tags |