1 4 package org.terracotta.dso.editors.tree; 5 6 import org.eclipse.jdt.core.IMethod; 7 import org.eclipse.jdt.core.Signature; 8 9 import org.terracotta.dso.PatternHelper; 10 11 16 17 public class MethodNode extends JavaProjectNode { 18 private IMethod m_method; 19 private String m_moniker; 20 private String m_signature; 21 22 public MethodNode(IMethod method) { 23 super(method); 24 25 m_method = method; 26 m_moniker = buildMoniker(method); 27 m_signature = buildSignature(method); 28 } 29 30 private static String buildSignature(IMethod method) { 31 return PatternHelper.getExecutionPattern(method); 32 } 33 34 private static String buildMoniker(IMethod method) { 35 StringBuffer sb = new StringBuffer (); 36 String paramTypes[] = getParameterTypes(method); 37 38 sb.append(method.getElementName()); 39 sb.append("("); 40 41 for(int i = 0; i < paramTypes.length; i++) { 42 sb.append(paramTypes[i]); 43 44 if(i < paramTypes.length-1) { 45 sb.append(", "); 46 } 47 } 48 sb.append(")"); 49 50 return sb.toString(); 51 } 52 53 private static String [] getParameterTypes(IMethod method) { 54 String [] typeSigs = method.getParameterTypes(); 55 String [] types = new String [typeSigs.length]; 56 57 for(int i= 0; i < typeSigs.length; i++) { 58 types[i]= Signature.getSimpleName(Signature.toString(typeSigs[i])); 59 } 60 61 return types; 62 } 63 64 public IMethod getMethod() { 65 return m_method; 66 } 67 68 public String getSignature() { 69 return m_signature; 70 } 71 72 public String [] getFields() { 73 return new String [0]; 74 } 75 76 public String toString() { 77 return m_moniker; 78 } 79 } 80 | Popular Tags |