1 19 package org.netbeans.modules.javacore.jmiimpl.javamodel; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 import org.netbeans.jmi.javamodel.ArgumentList; 25 import org.netbeans.jmi.javamodel.ArgumentListClass; 26 import org.netbeans.jmi.javamodel.Element; 27 import org.netbeans.jmi.javamodel.JavaModelPackage; 28 import org.netbeans.lib.java.parser.ASTree; 29 import org.netbeans.mdr.storagemodel.StorableObject; 30 import org.netbeans.modules.javacore.parser.ASTProvider; 31 32 36 public abstract class ArgumentListImpl extends TransientElement implements ArgumentList { 37 private LightAttrList arguments; 38 39 40 public ArgumentListImpl(StorableObject o) { 41 super(o); 42 } 43 44 public List getArguments() { 45 if (!childrenInited) { 46 initChildren(); 47 } 48 return arguments; 49 } 50 51 void setData(List arguments) { 52 this.arguments = createChildrenList("arguments", arguments, CHANGED_ARGUMENTS); } 54 55 protected void _delete() { 56 if (childrenInited) { 58 deleteChildren(arguments); 59 } 60 super._delete(); 64 } 65 66 public void replaceChild(Element oldElement, Element newElement) { 67 if (childrenInited) { 68 replaceObject(getArguments(), oldElement, newElement); 69 } 70 } 71 72 public List getChildren() { 73 return new ArrayList (getArguments()); 74 } 75 76 protected void initChildren() { 77 childrenInited = false; 78 arguments = createChildrenList(arguments, "arguments", getASTree().getSubTrees(), CHANGED_ARGUMENTS, false); childrenInited = true; 80 } 81 82 public String getSourceText() { 83 String origElem; 84 if ((origElem = checkChange()) != null) 85 return origElem; 86 StringBuffer buf = new StringBuffer (); 87 List arguments = getArguments(); 88 for (Iterator iter = arguments.iterator(); iter.hasNext();) { 89 StatementImpl expr = (StatementImpl) iter.next(); 90 buf.append(expr.getSourceText()); 91 if (iter.hasNext()) { 92 buf.append(", "); } 94 } 95 return buf.toString(); 96 } 97 98 public void getDiff(List diff) { 99 ASTProvider parser = getParser(); 100 ASTree tree = getASTree(); 101 ASTree[] children = tree.getSubTrees(); 102 if (children == null) 103 children = new ASTree[0]; 104 int pos = parser.getToken(tree.getLastToken()).getStartOffset(); 105 getCollectionDiff(diff, parser, CHANGED_ARGUMENTS, children, getArguments(), pos, ", "); } 107 108 public Element duplicate(JavaModelPackage targetExtent) { 109 return targetExtent.getArgumentList().createArgumentList(duplicateList(getArguments(), targetExtent)); 110 } 111 } 112 | Popular Tags |