use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method visitTypeDefinition.
@Override
public void visitTypeDefinition(@NotNull GrTypeDefinition typeDefinition) {
final PsiElement parent = typeDefinition.getParent();
if (!(typeDefinition.isAnonymous() || parent instanceof GrTypeDefinitionBody || parent instanceof GroovyFile || typeDefinition instanceof GrTypeParameter)) {
final TextRange range = GrHighlightUtil.getClassHeaderTextRange(typeDefinition);
final Annotation errorAnnotation = myHolder.createErrorAnnotation(range, GroovyBundle.message("class.definition.is.not.expected.here"));
errorAnnotation.registerFix(new GrMoveClassToCorrectPlaceFix(typeDefinition));
}
checkTypeDefinition(myHolder, typeDefinition);
checkImplementedMethodsOfClass(myHolder, typeDefinition);
checkConstructors(myHolder, typeDefinition);
checkAnnotationCollector(myHolder, typeDefinition);
checkSameNameMethodsWithDifferentAccessModifiers(myHolder, typeDefinition.getCodeMethods());
checkInheritorOfSelfTypes(myHolder, typeDefinition);
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method visitOpenBlock.
@Override
public void visitOpenBlock(@NotNull GrOpenBlock block) {
if (block.getParent() instanceof GrMethod) {
final GrMethod method = (GrMethod) block.getParent();
if (method.getModifierList().hasExplicitModifier(PsiModifier.ABSTRACT) || GrTraitUtil.isInterface(method.getContainingClass())) {
final Annotation annotation = myHolder.createErrorAnnotation(block, GroovyBundle.message("abstract.methods.must.not.have.body"));
registerMakeAbstractMethodNotAbstractFix(annotation, method, true);
}
}
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method checkTypeDefinitionModifiers.
private static void checkTypeDefinitionModifiers(AnnotationHolder holder, GrTypeDefinition typeDefinition) {
GrModifierList modifiersList = typeDefinition.getModifierList();
if (modifiersList == null)
return;
/**** class ****/
checkAccessModifiers(holder, modifiersList, typeDefinition);
checkDuplicateModifiers(holder, modifiersList, typeDefinition);
PsiClassType[] extendsListTypes = typeDefinition.getExtendsListTypes();
for (PsiClassType classType : extendsListTypes) {
PsiClass psiClass = classType.resolve();
if (psiClass != null && psiClass.hasModifierProperty(PsiModifier.FINAL)) {
final Annotation annotation = holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("final.class.cannot.be.extended"));
registerFix(annotation, new GrModifierFix(typeDefinition, PsiModifier.FINAL, false, false, GrModifierFix.MODIFIER_LIST_OWNER), typeDefinition);
}
}
if (!typeDefinition.isEnum()) {
checkForAbstractAndFinalCombination(holder, typeDefinition, modifiersList);
}
checkModifierIsNotAllowed(modifiersList, PsiModifier.TRANSIENT, GroovyBundle.message("modifier.transient.not.allowed.here"), holder);
checkModifierIsNotAllowed(modifiersList, PsiModifier.VOLATILE, GroovyBundle.message("modifier.volatile.not.allowed.here"), holder);
/**** interface ****/
if (typeDefinition.isInterface()) {
checkModifierIsNotAllowed(modifiersList, PsiModifier.FINAL, GroovyBundle.message("intarface.cannot.have.modifier.final"), holder);
}
if (GroovyConfigUtils.getInstance().isVersionAtLeast(typeDefinition, GroovyConfigUtils.GROOVY1_8)) {
if (typeDefinition.getContainingClass() == null && !(typeDefinition instanceof GrTraitTypeDefinition)) {
checkModifierIsNotAllowed(modifiersList, PsiModifier.STATIC, holder);
}
}
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method checkImplementedMethodsOfClass.
private static void checkImplementedMethodsOfClass(AnnotationHolder holder, GrTypeDefinition typeDefinition) {
if (typeDefinition.hasModifierProperty(PsiModifier.ABSTRACT))
return;
if (typeDefinition.isAnnotationType())
return;
if (typeDefinition instanceof GrTypeParameter)
return;
PsiMethod abstractMethod = ClassUtil.getAnyAbstractMethod(typeDefinition);
if (abstractMethod == null)
return;
String notImplementedMethodName = abstractMethod.getName();
final TextRange range = GrHighlightUtil.getClassHeaderTextRange(typeDefinition);
final Annotation annotation = holder.createErrorAnnotation(range, GroovyBundle.message("method.is.not.implemented", notImplementedMethodName));
registerImplementsMethodsFix(typeDefinition, abstractMethod, annotation);
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyDslAnnotator method annotate.
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
if (!(psiElement instanceof GroovyFile))
return;
final GroovyFile groovyFile = (GroovyFile) psiElement;
if (!GrFileIndexUtil.isGroovySourceFile(groovyFile))
return;
final VirtualFile vfile = groovyFile.getVirtualFile();
if (!GdslUtil.GDSL_FILTER.value(vfile))
return;
final DslActivationStatus.Status status = GroovyDslFileIndex.getStatus(vfile);
if (status == ACTIVE)
return;
final String message = status == MODIFIED ? "DSL descriptor file has been changed and isn't currently executed." : "DSL descriptor file has been disabled due to a processing error.";
final Annotation annotation = holder.createWarningAnnotation(psiElement, message);
annotation.setFileLevelAnnotation(true);
if (status == ERROR) {
final String error = GroovyDslFileIndex.getError(vfile);
if (error != null) {
annotation.registerFix(GroovyQuickFixFactory.getInstance().createInvestigateFix(error));
}
}
annotation.registerFix(new ActivateFix(vfile));
}
Aggregations