Targeting / retention for a set of standard annotations, some inapplicable annotation checks replaced with target check, some fixed tests
This commit is contained in:
@@ -112,7 +112,6 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, JetModifierKeywordToken> ILLEGAL_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetModifierKeywordToken> REPEATED_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_PLATFORM_NAME = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> WRONG_ANNOTATION_TARGET = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
|
||||
-1
@@ -135,7 +135,6 @@ public class DefaultErrorMessages {
|
||||
});
|
||||
MAP.put(ILLEGAL_MODIFIER, "Illegal modifier ''{0}''", TO_STRING);
|
||||
MAP.put(REPEATED_MODIFIER, "Repeated ''{0}''", TO_STRING);
|
||||
MAP.put(INAPPLICABLE_ANNOTATION, "This annotation is only applicable to top level functions");
|
||||
MAP.put(INAPPLICABLE_PLATFORM_NAME, "platformName annotation is not applicable to this declaration");
|
||||
MAP.put(WRONG_ANNOTATION_TARGET, "This annotation is not applicable to target ''{0}''", TO_STRING);
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ModifiersChecker {
|
||||
JetAnnotationEntry annotationEntry = trace.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation);
|
||||
if (annotationEntry == null) return;
|
||||
|
||||
if (!isRenamableDeclaration(descriptor)) {
|
||||
if (descriptor instanceof FunctionDescriptor && !isRenamableFunction((FunctionDescriptor) descriptor)) {
|
||||
trace.report(INAPPLICABLE_PLATFORM_NAME.on(annotationEntry));
|
||||
}
|
||||
|
||||
@@ -324,12 +324,10 @@ public class ModifiersChecker {
|
||||
|
||||
}
|
||||
|
||||
private static boolean isRenamableDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
private static boolean isRenamableFunction(@NotNull FunctionDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
|
||||
return (descriptor instanceof PropertyAccessorDescriptor)
|
||||
|| (containingDescriptor instanceof PackageFragmentDescriptor || containingDescriptor instanceof ClassDescriptor)
|
||||
&& descriptor instanceof FunctionDescriptor && !(descriptor instanceof ConstructorDescriptor);
|
||||
return containingDescriptor instanceof PackageFragmentDescriptor || containingDescriptor instanceof ClassDescriptor;
|
||||
}
|
||||
|
||||
private void checkCompatibility(@Nullable JetModifierList modifierList, Collection<JetModifierKeywordToken> availableModifiers, Collection<JetModifierKeywordToken>... availableCombinations) {
|
||||
|
||||
Reference in New Issue
Block a user