use of org.jetbrains.plugins.groovy.codeInspection.type.GroovyStaticTypeCheckVisitor in project intellij-community by JetBrains.
the class GrAnnotatorImpl method annotate.
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (FileIndexFacade.getInstance(element.getProject()).isInLibrarySource(element.getContainingFile().getVirtualFile()))
return;
if (element instanceof GroovyPsiElement) {
final GroovyAnnotator annotator = new GroovyAnnotator(holder);
((GroovyPsiElement) element).accept(annotator);
if (PsiUtil.isCompileStatic(element)) {
final GroovyStaticTypeCheckVisitor typeCheckVisitor = myTypeCheckVisitorThreadLocal.get();
assert typeCheckVisitor != null;
typeCheckVisitor.accept((GroovyPsiElement) element, holder);
}
} else if (element instanceof PsiComment) {
String text = element.getText();
if (text.startsWith("/*") && !(text.endsWith("*/"))) {
TextRange range = element.getTextRange();
holder.createErrorAnnotation(TextRange.create(range.getEndOffset() - 1, range.getEndOffset()), GroovyBundle.message("doc.end.expected"));
}
} else {
final PsiElement parent = element.getParent();
if (parent instanceof GrMethod) {
if (element.equals(((GrMethod) parent).getNameIdentifierGroovy()) && ((GrMethod) parent).getReturnTypeElementGroovy() == null) {
GroovyAnnotator.checkMethodReturnType((GrMethod) parent, element, holder);
}
} else if (parent instanceof GrField) {
final GrField field = (GrField) parent;
if (element.equals(field.getNameIdentifierGroovy())) {
final GrAccessorMethod[] getters = field.getGetters();
for (GrAccessorMethod getter : getters) {
GroovyAnnotator.checkMethodReturnType(getter, field.getNameIdentifierGroovy(), holder);
}
final GrAccessorMethod setter = field.getSetter();
if (setter != null) {
GroovyAnnotator.checkMethodReturnType(setter, field.getNameIdentifierGroovy(), holder);
}
}
}
}
}
Aggregations