org.eclipse.jdt.core.dom.AbstractTypeDeclaration typeDeclaration = findTypeDeclaration(rootType, cuUnit.types()); while (!typeStack.isEmpty() && typeDeclaration != null) { typeDeclaration = findTypeDeclaration(typeStack.pop(), typeDeclaration.bodyDeclarations());
tp.setName(ast.newSimpleName("X")); td.typeParameters().add(tp); cu.types().add(td);
/** * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CompilationUnit) */ public boolean visit(CompilationUnit node) { // visit only the type declarations List types = node.types(); for (Iterator iter = types.iterator(); iter.hasNext() && !fFound;) { ((TypeDeclaration) iter.next()).accept(this); } return false; }
/** * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CompilationUnit) */ public boolean visit(CompilationUnit node) { // visit only the type declarations List types = node.types(); for (Iterator iter = types.iterator(); iter.hasNext() && !fFound;) { ((TypeDeclaration) iter.next()).accept(this); } return false; }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == IMPORTS_PROPERTY) { return imports(); } if (property == TYPES_PROPERTY) { return types(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
private void findHeader() { if (this.astRoot instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) this.astRoot; List<TypeDeclaration> types = unit.types(); ASTNode firstElement = types.isEmpty() ? unit.getPackage() : types.get(0); if (firstElement != null) { int headerEndIndex = this.tokenManager.firstIndexIn(firstElement, -1); this.tokenManager.setHeaderEndIndex(headerEndIndex); } } }
private void findHeader() { if (this.astRoot instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) this.astRoot; List<TypeDeclaration> types = unit.types(); ASTNode firstElement = types.isEmpty() ? unit.getPackage() : types.get(0); if (firstElement != null) { int headerEndIndex = this.tokenManager.firstIndexIn(firstElement, -1); this.tokenManager.setHeaderEndIndex(headerEndIndex); } } }
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == IMPORTS_PROPERTY) { return imports(); } if (property == TYPES_PROPERTY) { return types(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == IMPORTS_PROPERTY) { return imports(); } if (property == TYPES_PROPERTY) { return types(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == IMPORTS_PROPERTY) { return imports(); } if (property == TYPES_PROPERTY) { return types(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
private void findHeader() { if (this.astRoot instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) this.astRoot; List<TypeDeclaration> types = unit.types(); ASTNode firstElement = types.isEmpty() ? unit.getPackage() : types.get(0); if (firstElement != null) { int headerEndIndex = this.tokenManager.firstIndexIn(firstElement, -1); this.tokenManager.setHeaderEndIndex(headerEndIndex); } } }
/** * Returns name of the class, e.g. {@code FooBarBean} * * @param path path to java source file */ public static String getClassName(final Path path) { final CompilationUnit unit = getCompilationUnit(path); unit.recordModifications(); final TypeDeclaration classType = (TypeDeclaration) unit.types().get(0); return classType.getName().getIdentifier(); }
@Override public boolean visit(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit) { if (checkMalformedNodes(compilationUnit)) { return true; // abort sorting of current element } sortElements(compilationUnit.types(), rewriter.getListRewrite(compilationUnit, org.eclipse.jdt.core.dom.CompilationUnit.TYPES_PROPERTY)); return true; }
public boolean visit(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit) { if (checkMalformedNodes(compilationUnit)) { return true; // abort sorting of current element } sortElements(compilationUnit.types(), rewriter.getListRewrite(compilationUnit, org.eclipse.jdt.core.dom.CompilationUnit.TYPES_PROPERTY)); return true; }
public static String getSupertype(final Path path) { final CompilationUnit unit = getCompilationUnit(path); unit.recordModifications(); final TypeDeclaration classType = (TypeDeclaration) unit.types().get(0); return classType.getSuperclassType().toString(); }
public boolean visit(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit) { if (checkMalformedNodes(compilationUnit)) { return true; // abort sorting of current element } sortElements(compilationUnit.types(), rewriter.getListRewrite(compilationUnit, org.eclipse.jdt.core.dom.CompilationUnit.TYPES_PROPERTY)); return true; }
@Override public void endVisit(CompilationUnit node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.imports()); process(info, node.types()); }
@Override public void endVisit(CompilationUnit node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.imports()); process(info, node.types()); }
@Override public void endVisit(CompilationUnit node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.imports()); process(info, node.types()); }
ASTNode clone0(AST target) { CompilationUnit result = new CompilationUnit(target); // n.b do not copy line number table or messages result.setSourceRange(getStartPosition(), getLength()); result.setPackage( (PackageDeclaration) ASTNode.copySubtree(target, getPackage())); result.imports().addAll(ASTNode.copySubtrees(target, imports())); result.types().addAll(ASTNode.copySubtrees(target, types())); return result; }