protected static void copyAnnotations(final FieldDeclaration oldField, final FieldDeclaration newField) { final AST ast= newField.getAST(); for (int index= 0, n= oldField.modifiers().size(); index < n; index++) { final IExtendedModifier modifier= (IExtendedModifier) oldField.modifiers().get(index); final List<IExtendedModifier> modifiers= newField.modifiers(); if (modifier.isAnnotation() && !modifiers.contains(modifier)) modifiers.add((IExtendedModifier) ASTNode.copySubtree(ast, (Annotation) modifier)); } }
protected static void copyAnnotations(final FieldDeclaration oldField, final FieldDeclaration newField) { final AST ast= newField.getAST(); for (int index= 0, n= oldField.modifiers().size(); index < n; index++) { final IExtendedModifier modifier= (IExtendedModifier) oldField.modifiers().get(index); final List modifiers= newField.modifiers(); if (modifier.isAnnotation() && !modifiers.contains(modifier)) modifiers.add(index, ASTNode.copySubtree(ast, (Annotation) modifier)); } }
protected static void copyAnnotations(final FieldDeclaration oldField, final FieldDeclaration newField) { final AST ast= newField.getAST(); for (int index= 0, n= oldField.modifiers().size(); index < n; index++) { final IExtendedModifier modifier= (IExtendedModifier) oldField.modifiers().get(index); final List<IExtendedModifier> modifiers= newField.modifiers(); if (modifier.isAnnotation() && !modifiers.contains(modifier)) modifiers.add((IExtendedModifier) ASTNode.copySubtree(ast, (Annotation) modifier)); } }
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment(); fragment.setName(ast.newSimpleName("log")); final FieldDeclaration declaration = ast.newFieldDeclaration(fragment); declaration.setType(ast.newSimpleType(ast.newName("Logger"))); declaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL));
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
public static boolean isFieldInjectable(FieldDeclaration fd, String annoClassSimpleName) { for (Object modifier : fd.modifiers()) { if (modifier instanceof Annotation) { Annotation annotation = (Annotation) modifier; String annoTypeName = annotation.getTypeName().getFullyQualifiedName(); if (annoTypeName.equals(annoClassSimpleName)) { return true; } else if (annoTypeName.contains(annoClassSimpleName)) { logger.log("Strange annotation type: " + annoTypeName); } } } return false; }
public FieldDeclaration createInjectableField(String type, String name) { VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment(); fragment.setName(ast.newSimpleName(name)); FieldDeclaration field = ast.newFieldDeclaration(fragment); field.setType(createSimpleType(type)); field.modifiers().add(createMarkerAnnotation("In")); List<Modifier> modifiers = field.modifiers(); modifiers.add(ast.newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD)); return field; }
private FieldDeclaration getNewFinalStringFieldDeclaration(String name) { VariableDeclarationFragment variableDeclarationFragment= fAst.newVariableDeclarationFragment(); variableDeclarationFragment.setName(fAst.newSimpleName(name)); FieldDeclaration fieldDeclaration= fAst.newFieldDeclaration(variableDeclarationFragment); fieldDeclaration.setType(fAst.newSimpleType(fAst.newSimpleName("String"))); //$NON-NLS-1$ fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD)); return fieldDeclaration; }
private FieldDeclaration getNewFinalStringFieldDeclaration(String name) { VariableDeclarationFragment variableDeclarationFragment= fAst.newVariableDeclarationFragment(); variableDeclarationFragment.setName(fAst.newSimpleName(name)); FieldDeclaration fieldDeclaration= fAst.newFieldDeclaration(variableDeclarationFragment); fieldDeclaration.setType(fAst.newSimpleType(fAst.newSimpleName("String"))); //$NON-NLS-1$ fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD)); return fieldDeclaration; }
private FieldDeclaration getNewFinalStringFieldDeclaration(String name) { VariableDeclarationFragment variableDeclarationFragment= fAst.newVariableDeclarationFragment(); variableDeclarationFragment.setName(fAst.newSimpleName(name)); FieldDeclaration fieldDeclaration= fAst.newFieldDeclaration(variableDeclarationFragment); fieldDeclaration.setType(fAst.newSimpleType(fAst.newSimpleName("String"))); //$NON-NLS-1$ fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); fieldDeclaration.modifiers().add(fAst.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD)); return fieldDeclaration; }
private void applyInFields(AbstractTypeDeclaration typeScope, boolean isSuper) { for (Object bd : typeScope.bodyDeclarations()) { if (bd instanceof FieldDeclaration) { if (isSuper && AstFind.hasModifierKeyword(((FieldDeclaration) bd).modifiers(), Modifier.ModifierKeyword.PRIVATE_KEYWORD)) {//TODO handle package-private continue; } ((FieldDeclaration) bd).accept(visitor); if (found()) {return;} } } }
@Override public boolean visit(final FieldDeclaration node) { return visitMultiDeclaration(node, node.modifiers(), node.getType(), node.fragments(), node.getJavadoc()); }
ASTNode clone0(AST target) { FieldDeclaration result = new FieldDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.internalSetModifiers(getModifiers()); } if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); } result.setType((Type) getType().clone(target)); result.fragments().addAll( ASTNode.copySubtrees(target, fragments())); return result; }
@SuppressWarnings("unchecked") @Override public boolean visit(FieldDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); } // @Inria pushNode(node, node.toString()); // visitListAsNode(EntityType.MODIFIERS, node.modifiers()); node.getType().accept(this); visitListAsNode(EntityType.FRAGMENTS, node.fragments()); return false; }
@SuppressWarnings("unchecked") @Override public boolean visit(FieldDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); } // @Inria pushNode(node, node.toString()); // visitListAsNode(EntityType.MODIFIERS, node.modifiers()); node.getType().accept(this); visitListAsNode(EntityType.FRAGMENTS, node.fragments()); return false; }