org.eclipse.jdt.core.dom.AnnotationTypeDeclaration Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.AnnotationTypeDeclaration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModifierRewrite.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) { switch (declNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY); case ASTNode.FIELD_DECLARATION: return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY); case ASTNode.SINGLE_VARIABLE_DECLARATION: return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY); case ASTNode.TYPE_DECLARATION: return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_DECLARATION: return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_CONSTANT_DECLARATION: return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY); default: throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$ } }
Example #2
Source File: FileVisitor.java From repositoryminer with Apache License 2.0 | 6 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { AbstractAnnotation absAnnotation = new AbstractAnnotation(); if (packageName != null) { absAnnotation.setName(packageName+'.'+node.getName().getFullyQualifiedName()); } else { absAnnotation.setName(node.getName().getFullyQualifiedName()); } TypeVisitor visitor = new TypeVisitor(); node.accept(visitor); absAnnotation.setMethods(visitor.getMethods()); absAnnotation.setFields(visitor.getFields()); absAnnotation.setStartPosition(node.getStartPosition()); absAnnotation.setEndPosition(node.getStartPosition() + node.getLength() - 1); absAnnotation.setMembers(visitor.getAnnotationMembers()); types.add(absAnnotation); return true; }
Example #3
Source File: ModifierRewrite.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) { switch (declNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY); case ASTNode.FIELD_DECLARATION: return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY); case ASTNode.SINGLE_VARIABLE_DECLARATION: return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY); case ASTNode.TYPE_DECLARATION: return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_DECLARATION: return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_CONSTANT_DECLARATION: return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY); default: throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$ } }
Example #4
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Start self Converted part */ @Override public boolean visit(final AnnotationTypeDeclaration node) { Javadoc _javadoc = node.getJavadoc(); boolean _tripleNotEquals = (_javadoc != null); if (_tripleNotEquals) { node.getJavadoc().accept(this); } this.appendModifiers(node, node.modifiers()); this.appendToBuffer("annotation "); node.getName().accept(this); this.appendToBuffer(" {"); this.appendLineWrapToBuffer(); this.visitAll(node.bodyDeclarations()); this.appendToBuffer("}"); return false; }
Example #5
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(AnnotationTypeDeclaration node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.bodyDeclarations()); info.setNoReturn(); }
Example #6
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(AnnotationTypeDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.bodyDeclarations()); info.setNoReturn(); }
Example #7
Source File: CreateTypeMemberOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent) { switch (parent.getNodeType()) { case ASTNode.COMPILATION_UNIT: return CompilationUnit.TYPES_PROPERTY; case ASTNode.ENUM_DECLARATION: return EnumDeclaration.BODY_DECLARATIONS_PROPERTY; case ASTNode.ANNOTATION_TYPE_DECLARATION: return AnnotationTypeDeclaration.BODY_DECLARATIONS_PROPERTY; default: return TypeDeclaration.BODY_DECLARATIONS_PROPERTY; } }
Example #8
Source File: JavaHistoryActionImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
final ASTNode getBodyContainer(CompilationUnit root, IMember parent) throws JavaModelException { ISourceRange sourceRange= parent.getNameRange(); ASTNode parentNode= NodeFinder.perform(root, sourceRange); do { if (parentNode instanceof TypeDeclaration || parentNode instanceof EnumDeclaration || parentNode instanceof AnnotationTypeDeclaration) return parentNode; parentNode= parentNode.getParent(); } while (parentNode != null); return null; }
Example #9
Source File: AbstractExceptionAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { // Don't dive into a local type. if (node.isLocalTypeDeclaration()) { return false; } return true; }
Example #10
Source File: NewAnnotationMemberProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= ASTResolving.findParentCompilationUnit(fInvocationNode); ASTNode typeDecl= astRoot.findDeclaringNode(fSenderBinding); ASTNode newTypeDecl= null; if (typeDecl != null) { newTypeDecl= typeDecl; } else { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } createImportRewrite(astRoot); if (newTypeDecl instanceof AnnotationTypeDeclaration) { AnnotationTypeDeclaration newAnnotationTypeDecl= (AnnotationTypeDeclaration) newTypeDecl; ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); AnnotationTypeMemberDeclaration newStub= getStub(rewrite, newAnnotationTypeDecl); List<BodyDeclaration> members= newAnnotationTypeDecl.bodyDeclarations(); int insertIndex= members.size(); ListRewrite listRewriter= rewrite.getListRewrite(newAnnotationTypeDecl, AnnotationTypeDeclaration.BODY_DECLARATIONS_PROPERTY); listRewriter.insertAt(newStub, insertIndex, null); return rewrite; } return null; }
Example #11
Source File: SnippetFinder.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { if (++fTypes > 1) { return false; } return super.visit(node); }
Example #12
Source File: NewAnnotationMemberProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private int evaluateModifiers(AnnotationTypeDeclaration targetTypeDecl) { List<BodyDeclaration> methodDecls= targetTypeDecl.bodyDeclarations(); for (int i= 0; i < methodDecls.size(); i++) { Object curr= methodDecls.get(i); if (curr instanceof AnnotationTypeMemberDeclaration) { return ((AnnotationTypeMemberDeclaration) curr).getModifiers(); } } return 0; }
Example #13
Source File: AbstractExceptionAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { // Don't dive into a local type. if (node.isLocalTypeDeclaration()) return false; return true; }
Example #14
Source File: AstVisitor.java From jdt2famix with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { ITypeBinding binding = node.resolveBinding(); if (binding == null) { logNullBinding("annotation type declaration", node.getName(), ((CompilationUnit) node.getRoot()).getLineNumber(node.getStartPosition())); return false; } Type type = importer.ensureTypeFromTypeBinding(binding); type.setIsStub(false); importer.createSourceAnchor(type, node); importer.pushOnContainerStack(type); importer.ensureCommentFromBodyDeclaration(type, node); return true; }
Example #15
Source File: NewAnnotationMemberProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int evaluateModifiers(AnnotationTypeDeclaration targetTypeDecl) { List<BodyDeclaration> methodDecls= targetTypeDecl.bodyDeclarations(); for (int i= 0; i < methodDecls.size(); i++) { Object curr= methodDecls.get(i); if (curr instanceof AnnotationTypeMemberDeclaration) { return ((AnnotationTypeMemberDeclaration) curr).getModifiers(); } } return 0; }
Example #16
Source File: NewAnnotationMemberProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= ASTResolving.findParentCompilationUnit(fInvocationNode); ASTNode typeDecl= astRoot.findDeclaringNode(fSenderBinding); ASTNode newTypeDecl= null; if (typeDecl != null) { newTypeDecl= typeDecl; } else { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } createImportRewrite(astRoot); if (newTypeDecl instanceof AnnotationTypeDeclaration) { AnnotationTypeDeclaration newAnnotationTypeDecl= (AnnotationTypeDeclaration) newTypeDecl; ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); AnnotationTypeMemberDeclaration newStub= getStub(rewrite, newAnnotationTypeDecl); List<BodyDeclaration> members= newAnnotationTypeDecl.bodyDeclarations(); int insertIndex= members.size(); ListRewrite listRewriter= rewrite.getListRewrite(newAnnotationTypeDecl, AnnotationTypeDeclaration.BODY_DECLARATIONS_PROPERTY); listRewriter.insertAt(newStub, insertIndex, null); return rewrite; } return null; }
Example #17
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static boolean isInterfaceOrAnnotation(ASTNode node) { boolean isInterface= (node instanceof TypeDeclaration) && ((TypeDeclaration) node).isInterface(); boolean isAnnotation= node instanceof AnnotationTypeDeclaration; return isInterface || isAnnotation; }
Example #18
Source File: NewAnnotationMemberProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private AnnotationTypeMemberDeclaration getStub(ASTRewrite rewrite, AnnotationTypeDeclaration targetTypeDecl) { AST ast= targetTypeDecl.getAST(); AnnotationTypeMemberDeclaration decl= ast.newAnnotationTypeMemberDeclaration(); SimpleName newNameNode= getNewName(rewrite); decl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, evaluateModifiers(targetTypeDecl))); ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(getLinkedProposalModel(), rewrite, decl.modifiers(), true); decl.setName(newNameNode); Type returnType= getNewType(rewrite); decl.setType(returnType); return decl; }
Example #19
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { return visitNode(node); }
Example #20
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(AnnotationTypeDeclaration node) { endVisitNode(node); }
Example #21
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private static boolean isInterfaceOrAnnotation(ASTNode node) { boolean isInterface= (node instanceof TypeDeclaration) && ((TypeDeclaration) node).isInterface(); boolean isAnnotation= node instanceof AnnotationTypeDeclaration; return isInterface || isAnnotation; }
Example #22
Source File: ExtractMethodRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { return visitType(node); }
Example #23
Source File: AstMatchingNodeFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
Example #24
Source File: MethodExitsFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { // Don't dive into a local type. return false; }
Example #25
Source File: ReturnTypeSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { return false; }
Example #26
Source File: SuppressWarningsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Adds a SuppressWarnings proposal if possible and returns whether parent nodes should be processed or not (and with what relevance). * * @param cu the compilation unit * @param node the node on which to add a SuppressWarning token * @param warningToken the warning token to add * @param relevance the proposal's relevance * @param proposals collector to which the proposal should be added * @return <code>0</code> if no further proposals should be added to parent nodes, or the relevance of the next proposal * * @since 3.6 */ private static int addSuppressWarningsProposalIfPossible(ICompilationUnit cu, ASTNode node, String warningToken, int relevance, Collection<ICommandAccess> proposals) { ChildListPropertyDescriptor property; String name; boolean isLocalVariable= false; switch (node.getNodeType()) { case ASTNode.SINGLE_VARIABLE_DECLARATION: property= SingleVariableDeclaration.MODIFIERS2_PROPERTY; name= ((SingleVariableDeclaration) node).getName().getIdentifier(); isLocalVariable= true; break; case ASTNode.VARIABLE_DECLARATION_STATEMENT: property= VariableDeclarationStatement.MODIFIERS2_PROPERTY; name= getFirstFragmentName(((VariableDeclarationStatement) node).fragments()); isLocalVariable= true; break; case ASTNode.VARIABLE_DECLARATION_EXPRESSION: property= VariableDeclarationExpression.MODIFIERS2_PROPERTY; name= getFirstFragmentName(((VariableDeclarationExpression) node).fragments()); isLocalVariable= true; break; case ASTNode.TYPE_DECLARATION: property= TypeDeclaration.MODIFIERS2_PROPERTY; name= ((TypeDeclaration) node).getName().getIdentifier(); break; case ASTNode.ANNOTATION_TYPE_DECLARATION: property= AnnotationTypeDeclaration.MODIFIERS2_PROPERTY; name= ((AnnotationTypeDeclaration) node).getName().getIdentifier(); break; case ASTNode.ENUM_DECLARATION: property= EnumDeclaration.MODIFIERS2_PROPERTY; name= ((EnumDeclaration) node).getName().getIdentifier(); break; case ASTNode.FIELD_DECLARATION: property= FieldDeclaration.MODIFIERS2_PROPERTY; name= getFirstFragmentName(((FieldDeclaration) node).fragments()); break; // case ASTNode.INITIALIZER: not used, because Initializer cannot have annotations case ASTNode.METHOD_DECLARATION: property= MethodDeclaration.MODIFIERS2_PROPERTY; name= ((MethodDeclaration) node).getName().getIdentifier() + "()"; //$NON-NLS-1$ break; case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: property= AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY; name= ((AnnotationTypeMemberDeclaration) node).getName().getIdentifier() + "()"; //$NON-NLS-1$ break; case ASTNode.ENUM_CONSTANT_DECLARATION: property= EnumConstantDeclaration.MODIFIERS2_PROPERTY; name= ((EnumConstantDeclaration) node).getName().getIdentifier(); break; default: return relevance; } String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_suppress_warnings_label, new String[] { warningToken, BasicElementLabels.getJavaElementName(name) }); ASTRewriteCorrectionProposal proposal= new SuppressWarningsProposal(warningToken, label, cu, node, property, relevance); proposals.add(proposal); return isLocalVariable ? relevance - 1 : 0; }
Example #27
Source File: SnippetFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { if (++fTypes > 1) return false; return super.visit(node); }
Example #28
Source File: JavaParseTreeBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(AnnotationTypeDeclaration node) { push(JavaNode.ANNOTATION, node.getName().toString(), node.getStartPosition(), node.getLength()); return true; }
Example #29
Source File: JavaParseTreeBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(AnnotationTypeDeclaration node) { pop(); }
Example #30
Source File: JavaReplaceWithEditionActionImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void performReplace(IMember input, IFile file, ITextFileBuffer textFileBuffer, IDocument document, ITypedElement ti) throws CoreException, JavaModelException, InvocationTargetException, InterruptedException { if (ti instanceof IStreamContentAccessor) { boolean inEditor= beingEdited(file); String content= JavaCompareUtilities.readString((IStreamContentAccessor)ti); String newContent= trimTextBlock(content, TextUtilities.getDefaultLineDelimiter(document), input.getJavaProject()); if (newContent == null) { showError(); return; } ICompilationUnit compilationUnit= input.getCompilationUnit(); CompilationUnit root= parsePartialCompilationUnit(compilationUnit); ISourceRange nameRange= input.getNameRange(); if (nameRange == null) nameRange= input.getSourceRange(); // workaround for bug in getNameRange(): for AnnotationMembers length is negative int length= nameRange.getLength(); if (length < 0) length= 1; ASTNode node2= NodeFinder.perform(root, new SourceRange(nameRange.getOffset(), length)); ASTNode node; if (node2.getNodeType() == ASTNode.INITIALIZER) node= node2; else node= ASTNodes.getParent(node2, BodyDeclaration.class); if (node == null) node= ASTNodes.getParent(node2, AnnotationTypeDeclaration.class); if (node == null) node= ASTNodes.getParent(node2, EnumDeclaration.class); //ASTNode node= getBodyContainer(root, input); if (node == null) { showError(); return; } ASTRewrite rewriter= ASTRewrite.create(root.getAST()); rewriter.replace(node, rewriter.createStringPlaceholder(newContent, node.getNodeType()), null); if (inEditor) { JavaEditor je= getEditor(file); if (je != null) je.setFocus(); } Map<String, String> options= null; IJavaProject javaProject= compilationUnit.getJavaProject(); if (javaProject != null) options= javaProject.getOptions(true); applyChanges(rewriter, document, textFileBuffer, getShell(), inEditor, options); } }