@Override public boolean isConstructor() { return method.isConstructor(); }
@Override public boolean isConstructor() { return method.isConstructor(); }
private MethodDeclaration[] getAllConstructors(AbstractTypeDeclaration typeDeclaration) { BodyDeclaration decl; List<BodyDeclaration> result= new ArrayList<>(1); for (Iterator<BodyDeclaration> it = typeDeclaration.bodyDeclarations().listIterator(); it.hasNext(); ) { decl= it.next(); if (decl instanceof MethodDeclaration && ((MethodDeclaration) decl).isConstructor()) result.add(decl); } return result.toArray(new MethodDeclaration[result.size()]); }
private MethodDeclaration[] getConstructorDeclarationNodes(final AbstractTypeDeclaration declaration) { if (declaration instanceof TypeDeclaration) { final MethodDeclaration[] declarations= ((TypeDeclaration) declaration).getMethods(); final List<MethodDeclaration> result= new ArrayList<>(2); for (int index= 0; index < declarations.length; index++) { if (declarations[index].isConstructor()) result.add(declarations[index]); } return result.toArray(new MethodDeclaration[result.size()]); } return new MethodDeclaration[] {}; }
public boolean isConstructor() { // always returns original value return getASTNode().isConstructor(); }
public static boolean isInsideConstructorInvocation(MethodDeclaration methodDeclaration, ASTNode node) { if (methodDeclaration.isConstructor()) { Statement statement= ASTResolving.findParentStatement(node); if (statement instanceof ConstructorInvocation || statement instanceof SuperConstructorInvocation) { return true; // argument in a this or super call } } return false; }
private MethodDeclaration[] getConstructorDeclarationNodes(final AbstractTypeDeclaration declaration) { if (declaration instanceof TypeDeclaration) { final MethodDeclaration[] declarations= ((TypeDeclaration) declaration).getMethods(); final List<MethodDeclaration> result= new ArrayList<>(2); for (int index= 0; index < declarations.length; index++) { if (declarations[index].isConstructor()) result.add(declarations[index]); } return result.toArray(new MethodDeclaration[result.size()]); } return new MethodDeclaration[] {}; }
private MethodDeclaration[] getAllConstructors(AbstractTypeDeclaration typeDeclaration) { BodyDeclaration decl; List<BodyDeclaration> result= new ArrayList<>(1); for (Iterator<BodyDeclaration> it = typeDeclaration.bodyDeclarations().listIterator(); it.hasNext(); ) { decl= it.next(); if (decl instanceof MethodDeclaration && ((MethodDeclaration) decl).isConstructor()) result.add(decl); } return result.toArray(new MethodDeclaration[result.size()]); }
public boolean isConstructor() { // always returns original value return getASTNode().isConstructor(); }
@Override public MethodSource<O> setName(final String name) { if (method.isConstructor()) { throw new IllegalStateException("Cannot set the name of a constructor."); } method.setName(ast.newSimpleName(name)); return this; }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == CONSTRUCTOR_PROPERTY) { if (get) { return isConstructor(); } else { setConstructor(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
private static SuperConstructorInvocation getSuperConstructorCallNode(IMethod constructor, CompilationUnit cuNode) throws JavaModelException { Assert.isTrue(constructor.isConstructor()); MethodDeclaration constructorNode= ASTNodeSearchUtil.getMethodDeclarationNode(constructor, cuNode); Assert.isTrue(constructorNode.isConstructor()); Block body= constructorNode.getBody(); Assert.isNotNull(body); List statements= body.statements(); if (! statements.isEmpty() && statements.get(0) instanceof SuperConstructorInvocation) return (SuperConstructorInvocation)statements.get(0); return null; } }
public boolean visit(MethodDeclaration node) { if (node.isConstructor() && fBinding.getKind() == IBinding.TYPE) { ASTNode typeNode= node.getParent(); if (typeNode instanceof AbstractTypeDeclaration) { if (fBinding == ((AbstractTypeDeclaration) typeNode).resolveBinding()) { fResult.add(node.getName()); } } } return true; }
@Override public boolean visit(MethodDeclaration node) { if (node.isConstructor()) { AbstractTypeDeclaration decl= ASTNodes.getParent(node, AbstractTypeDeclaration.class); NameData name= fNames.get(decl.getName().resolveBinding()); if (name != null) { name.addReference(node.getName()); } } return true; } @Override
public boolean visit(MethodDeclaration node) { if (node.isConstructor()) { AbstractTypeDeclaration decl= (AbstractTypeDeclaration) ASTNodes.getParent(node, AbstractTypeDeclaration.class); NameData name= (NameData)fNames.get(decl.getName().resolveBinding()); if (name != null) { name.addReference(node.getName()); } } return true; } public boolean visit(MethodInvocation node) {
@Override public boolean visit(MethodDeclaration node) { if (node.isConstructor()) { AbstractTypeDeclaration decl= (AbstractTypeDeclaration) ASTNodes.getParent(node, AbstractTypeDeclaration.class); NameData name= fNames.get(decl.getName().resolveBinding()); if (name != null) { name.addReference(node.getName()); } } return true; } @Override
private void modifyConstructors(AbstractTypeDeclaration declaration, ASTRewrite rewrite) throws CoreException { final MethodDeclaration[] declarations= getConstructorDeclarationNodes(declaration); for (int index= 0; index < declarations.length; index++) { Assert.isTrue(declarations[index].isConstructor()); addParameterToConstructor(rewrite, declarations[index]); setEnclosingInstanceFieldInConstructor(rewrite, declarations[index]); } }
public boolean canEnableSettingDeclareInConstructors(){ return ! fDeclareStatic && ! fInitializerUsesLocalTypes && ! getMethodDeclaration().isConstructor() && ! isDeclaredInAnonymousClass() && ! isTempDeclaredInStaticMethod() && tempHasInitializer(); }
private void modifyConstructors(AbstractTypeDeclaration declaration, ASTRewrite rewrite) throws CoreException { final MethodDeclaration[] declarations= getConstructorDeclarationNodes(declaration); for (int index= 0; index < declarations.length; index++) { Assert.isTrue(declarations[index].isConstructor()); addParameterToConstructor(rewrite, declarations[index]); setEnclosingInstanceFieldInConstructor(rewrite, declarations[index]); } }
@Override public boolean visit(MethodDeclaration node) { String signature= getSignature(node); push(node.isConstructor() ? JavaNode.CONSTRUCTOR : JavaNode.METHOD, signature, node.getStartPosition(), node.getLength()); return false; }