Search in sources :

Example 1 with GrDocFieldReference

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocFieldReference in project intellij-community by JetBrains.

the class GroovyDocCheckInspection method buildVisitor.

@NotNull
@Override
protected BaseInspectionVisitor buildVisitor() {
    return new BaseInspectionVisitor() {

        @Override
        public void visitDocMethodReference(@NotNull GrDocMethodReference reference) {
            checkGrDocMemberReference(reference);
        }

        @Override
        public void visitDocFieldReference(@NotNull GrDocFieldReference reference) {
            checkGrDocMemberReference(reference);
        }

        @Override
        public void visitCodeReferenceElement(@NotNull GrCodeReferenceElement refElement) {
            GroovyResolveResult resolveResult = refElement.advancedResolve();
            if (refElement.getReferenceName() == null)
                return;
            if (PsiTreeUtil.getParentOfType(refElement, GroovyDocPsiElement.class, true, GrMember.class, GrCodeBlock.class) == null)
                return;
            final PsiElement resolved = resolveResult.getElement();
            if (resolved != null)
                return;
            final PsiElement toHighlight = refElement.getReferenceNameElement();
            registerError(toHighlight, GroovyBundle.message("cannot.resolve", refElement.getReferenceName()));
        }

        private void checkGrDocMemberReference(final GrDocMemberReference reference) {
            if (reference.resolve() != null)
                return;
            registerError(reference.getReferenceNameElement(), GroovyBundle.message("cannot.resolve", reference.getReferenceName()));
        }
    };
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) BaseInspectionVisitor(org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor) GrMember(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember) GrDocFieldReference(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocFieldReference) GrDocMemberReference(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference) NotNull(org.jetbrains.annotations.NotNull) PsiElement(com.intellij.psi.PsiElement) GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) GrDocMethodReference(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodReference) GrCodeBlock(org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 NotNull (org.jetbrains.annotations.NotNull)1 BaseInspectionVisitor (org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor)1 GrDocFieldReference (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocFieldReference)1 GrDocMemberReference (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference)1 GrDocMethodReference (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodReference)1 GroovyDocPsiElement (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement)1 GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)1 GrCodeBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock)1 GrMember (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1