/** * WORKAROUND UNTIL CODEELEMENT IS REMOVED required from ISourceUnit FIXME only sample * implementation for getTypes()! */ public IType[] getTypes() { // FIXME // missing (IType[])getInterfaceList().toArray() // mising (IType[])getEnumList().toArray() // missing (IType[])getStructList().toArray List classElem = this.getClassList(); Iterator iter = classElem.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceType type = new SourceType( elem.parent, elem.calcTypeFlags(), null /*no IDoc*/, elem.calcEvents(), elem.calcFields(), elem.calcMethods(), elem.calcProperties(), new IType[0] /*elem.getTypes()*/, elem.codeType, elem.elementName, elem.elementName /*fullname*/, elem.getSuperClass(), elem.getSuperInterfaces(), elem.getSourceRange(), elem.source); ret.add(type); } return (IType[]) ret.toArray(new IType[ret.size()]); }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED */ private IField[] calcFields() { ArrayList resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.FIELD); Iterator iter = resList.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceField field = new SourceField( elem.parent, elem.calcFieldFlags(), elem.elementName, null /*noDoc*/, elem.typeSignature, elem.getSourceRange(), elem.source); ret.add(field); } return (IField[]) ret.toArray(new IField[ret.size()]); }
/** * Returns a list with all comment code elements in the AST, except those that exist of fewer * lines than <code>minLineCount</code>. * * @param minLineCount Minimum line count * @param doc The IDocument the AST was generated for * @return The list with comment elements */ public List getCommentList(int minLineCount, IDocument doc) { List resList = getCommentList(); int endLine = 0, startLine = 0; for (int i = 0; i < resList.size(); i++) { CodeElement actual = (CodeElement) resList.get(i); try { startLine = doc.getLineOfOffset(actual.getOffset()); // multi line comments include one character more than necessary (for folding) endLine = doc.getLineOfOffset(actual.getOffset() + actual.getLength() - 1); } catch (BadLocationException e) { continue; } if (endLine - startLine + 1 < minLineCount) { resList.remove(i); i--; // decrease i because we removed one element! } } return resList; }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED */ private ILocalVariable[] getLocalVars() { ArrayList resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.VARIABLE); Iterator iter = resList.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceLocalVariable variable = new SourceLocalVariable( elem.parent, elem.calcFieldFlags(), elem.elementName, elem.typeSignature, null /*nodoc*/, elem.getSourceRange(), elem.source); ret.add(variable); } return (ILocalVariable[]) ret.toArray(new ILocalVariable[ret.size()]); }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED */ private IProperty[] calcProperties() { ArrayList resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.PROPERTY); Iterator iter = resList.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceProperty property = new SourceProperty( elem.parent, elem.calcMethodFlags(), elem.elementName, elem.getPropertyReturn(), elem.signature, null /*no Idoc*/, elem.getSourceRange(), elem.source); ret.add(property); } return (IProperty[]) ret.toArray(new IProperty[ret.size()]); }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED INCOMPLETE EVENT BUILDING */ private IEvent[] calcEvents() { ArrayList resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.EVENT); Iterator iter = resList.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceEvent event = new SourceEvent( elem.parent, elem.calcMethodFlags(), null /*nodoc*/, null /*nodelegate*/, elem.elementName, elem.signature, new String[0], new String[0], elem.getSourceRange(), elem.source); ret.add(event); } return (IEvent[]) ret.toArray(new IEvent[ret.size()]); }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED required from ISourceUnit */ public INamespace[] getNamespaces() { List nsElem = this.getNameSpaceList(); Iterator iter = nsElem.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceNamespace ns = new SourceNamespace( elem.parent, elem.elementName, null /*FIXME IPath*/, null /*FIXME IDocumentation*/, elem.getSourceRange(), elem.source); // add types to namespace IType[] types = elem.getTypes(); for (int i = 0; i < types.length; i++) { ns.put(types[i].getElementName(), types[i]); } ret.add(ns); } return (INamespace[]) ret.toArray(new INamespace[ret.size()]); }
/** WORKAROUND UNTIL CODEELEMENT IS REMOVED add methods and constructors */ private IMethod[] calcMethods() { // add methods ArrayList resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.METHOD); Iterator iter = resList.iterator(); ArrayList ret = new ArrayList(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceMethod method = new SourceMethod( elem.parent, elem.elementName, elem.calcMethodFlags(), elem.getMethodReturnType(), elem.signature, false, null /*no idoc*/, elem.getParameterTypes(), elem.getParameterNames(), elem.getLocalVars(), elem.getSourceRange(), elem.source); ret.add(method); } // add constructors resList = new ArrayList(); resList = recBuildElementList(this, resList, IDotNetElement.CONSTRUCTOR); iter = resList.iterator(); while (iter.hasNext()) { CodeElement elem = (CodeElement) iter.next(); SourceMethod constructor = new SourceMethod( elem.parent, elem.elementName, elem.calcMethodFlags(), elem.getMethodReturnType(), elem.signature, true, null /*no idoc*/, elem.getParameterTypes(), elem.getParameterNames(), elem.getLocalVars(), elem.getSourceRange(), elem.source); ret.add(constructor); } return (IMethod[]) ret.toArray(new IMethod[ret.size()]); }
public static CodeElement getCopy(CodeElement orig) { CodeElement res = new CodeElement(orig.getParent(), orig.getCodeType()); res.setAccessType(orig.getAccessType()); res.setChildren(orig.children); res.setDerived(orig.getDerived()); res.setElementName(orig.getElementName()); res.setTypeSignature(orig.getTypeSignature()); res.setEndPoint(orig.getEndPoint()); res.setLength(orig.getLength()); res.setNameOffset(orig.getNameOffset()); res.setOffset(orig.getOffset()); res.setSignature(orig.getSignature()); res.setSource(orig.getSource()); res.setStartPoint(orig.getStartPoint()); res.setValidLength(orig.getValidLength()); res.setValidOffset(orig.getValidOffset()); return res; }