BaseInspectionVisitor () { return new BaseInspectionVisitor() { @Override public void visitNewExpression(@NotNull GrNewExpression newExpression) { if (newExpression.getArrayDeclaration() != null) return; GrCodeReferenceElement refElement = newExpression.getReferenceElement(); if (refElement == null) return; PsiElement resolved = refElement.resolve(); if (!(resolved instanceof GrTypeDefinition)) return; PsiAnnotation annotation = AnnotationUtil.findAnnotation((GrTypeDefinition)resolved, GROOVY_LANG_SINGLETON); if (annotation == null) return; registerError( newExpression, GroovyBundle.message("new.instance.of.singleton"), ContainerUtil.ar(new ReplaceWithInstanceAccessFix()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING ); } }; }