1 19 package org.netbeans.modules.javacore.jmiimpl.javamodel; 20 21 import java.util.ArrayList ; 22 import java.util.Collection ; 23 import org.netbeans.jmi.javamodel.*; 24 import org.netbeans.lib.java.parser.ASTree; 25 import org.netbeans.mdr.storagemodel.StorableObject; 26 import org.netbeans.modules.javacore.parser.ASTUtil; 27 28 32 public abstract class ElementReferenceImpl extends ExpressionImpl { 33 protected String name = null; 34 35 36 public ElementReferenceImpl(StorableObject o) { 37 super(o); 38 } 39 40 public String getName() { 41 if (isChanged(CHANGED_NAME)) { 42 return name; 43 } else { 44 return getParser().getText(getNameAST()); 45 } 46 } 47 48 public void setName(String name) { 49 objectChanged(CHANGED_NAME); 50 this.name = name; 51 } 52 53 protected ASTree getNameAST() { 54 return getASTree().getSubTrees()[2]; 55 } 56 57 protected ASTree getPartTree(ElementPartKind part) { 58 if (ElementPartKindEnum.NAME.equals(part)) { 59 return getNameAST(); 60 } 61 throw new IllegalArgumentException ("Invalid part for this element: " + part); } 63 64 void setData(String name) { 65 this.name = name; 66 } 67 68 public NamedElement getElement() { 69 return (NamedElement) getParser().getSemanticInfo(getASTree(), this); 70 } 71 } 72 | Popular Tags |