Search in sources :

Example 31 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project flux by eclipse.

the class SimilarElementsRequestor method findSimilarElement.

public static SimilarElement[] findSimilarElement(ICompilationUnit cu, Name name, int kind) throws JavaModelException {
    int pos = name.getStartPosition();
    int nArguments = -1;
    String identifier = ASTNodes.getSimpleNameIdentifier(name);
    String returnType = null;
    ICompilationUnit preparedCU = null;
    try {
        if (name.isQualifiedName()) {
            pos = ((QualifiedName) name).getName().getStartPosition();
        } else {
            // first letter must be included, other
            pos = name.getStartPosition() + 1;
        }
        Javadoc javadoc = (Javadoc) ASTNodes.getParent(name, ASTNode.JAVADOC);
        if (javadoc != null) {
            preparedCU = createPreparedCU(cu, javadoc, name.getStartPosition());
            cu = preparedCU;
        }
        SimilarElementsRequestor requestor = new SimilarElementsRequestor(identifier, kind, nArguments, returnType);
        requestor.setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, true);
        requestor.setIgnored(CompletionProposal.KEYWORD, true);
        requestor.setIgnored(CompletionProposal.LABEL_REF, true);
        requestor.setIgnored(CompletionProposal.METHOD_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.PACKAGE_REF, true);
        requestor.setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.METHOD_REF, true);
        requestor.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, true);
        requestor.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, true);
        requestor.setIgnored(CompletionProposal.FIELD_REF, true);
        requestor.setIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, true);
        requestor.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, true);
        requestor.setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, true);
        requestor.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, true);
        return requestor.process(cu, pos);
    } finally {
        if (preparedCU != null) {
            preparedCU.discardWorkingCopy();
        }
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) QualifiedName(org.eclipse.jdt.core.dom.QualifiedName) Javadoc(org.eclipse.jdt.core.dom.Javadoc)

Example 32 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project generator by mybatis.

the class ExistingJavaFileVisitor method isGenerated.

@SuppressWarnings("unchecked")
private boolean isGenerated(BodyDeclaration node) {
    boolean rc = false;
    Javadoc jd = node.getJavadoc();
    if (jd != null) {
        List<TagElement> tags = jd.tags();
        for (TagElement tag : tags) {
            String tagName = tag.getTagName();
            if (tagName == null) {
                continue;
            }
            for (String javadocTag : javadocTags) {
                if (tagName.equals(javadocTag)) {
                    String string = tag.toString();
                    if (string.contains("do_not_delete_during_merge")) {
                        if (node.getNodeType() == ASTNode.TYPE_DECLARATION) {
                            String name = ((TypeDeclaration) node).getName().getFullyQualifiedName();
                            generatedInnerClassesToKeep.add(name);
                        }
                    } else {
                        rc = true;
                    }
                    break;
                }
            }
        }
    }
    return rc;
}
Also used : Javadoc(org.eclipse.jdt.core.dom.Javadoc) TagElement(org.eclipse.jdt.core.dom.TagElement)

Aggregations

Javadoc (org.eclipse.jdt.core.dom.Javadoc)32 AST (org.eclipse.jdt.core.dom.AST)20 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)19 Type (org.eclipse.jdt.core.dom.Type)14 ASTNode (org.eclipse.jdt.core.dom.ASTNode)13 TagElement (org.eclipse.jdt.core.dom.TagElement)12 Block (org.eclipse.jdt.core.dom.Block)11 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)11 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)11 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)10 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)10 ReturnStatement (org.eclipse.jdt.core.dom.ReturnStatement)9 ImportRewrite (org.eclipse.jdt.core.dom.rewrite.ImportRewrite)8 ImportRewriteContext (org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext)8 ContextSensitiveImportRewriteContext (org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext)8 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)7 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)7 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)7 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)6 Expression (org.eclipse.jdt.core.dom.Expression)6