Don't repeat full qualified name in error messages for field annotations
This commit is contained in:
+6
-29
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.containers.ComparatorUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
@@ -70,47 +69,25 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
}
|
||||
|
||||
private static void checkFieldAnnotation(JetProperty altProperty, PsiFieldWrapper fieldWrapper, boolean isVar) {
|
||||
String fieldLink = getFieldQualifiedName(fieldWrapper);
|
||||
|
||||
if (!ComparatorUtil.equalsNullable(fieldWrapper.getName(), altProperty.getName())) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Field name mismatch, original: %s, alternative: %s",
|
||||
fieldLink, altProperty.getName());
|
||||
throw new AlternativeSignatureMismatchException("Field name mismatch, original: %s, alternative: %s",
|
||||
fieldWrapper.getName(), altProperty.getName());
|
||||
}
|
||||
|
||||
if (altProperty.getTypeRef() == null) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Field annotation for '%s' shouldn't have type reference",
|
||||
fieldLink);
|
||||
throw new AlternativeSignatureMismatchException("Field annotation for shouldn't have type reference");
|
||||
}
|
||||
|
||||
if (altProperty.getGetter() != null || altProperty.getSetter() != null) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Field annotation for '%s' shouldn't have getters and setters",
|
||||
fieldLink);
|
||||
throw new AlternativeSignatureMismatchException("Field annotation for shouldn't have getters and setters");
|
||||
}
|
||||
|
||||
if (altProperty.isVar() != isVar) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Wrong mutability in annotation for field '%s'",
|
||||
fieldLink);
|
||||
throw new AlternativeSignatureMismatchException("Wrong mutability in annotation for field");
|
||||
}
|
||||
|
||||
if (altProperty.getInitializer() != null) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Default value is not expected in annotation for field '%s'",
|
||||
fieldLink);
|
||||
throw new AlternativeSignatureMismatchException("Default value is not expected in annotation for field");
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getFieldQualifiedName(PsiFieldWrapper fieldWrapper) {
|
||||
PsiClass containingClass = fieldWrapper.getPsiField().getContainingClass();
|
||||
String fieldLink = containingClass != null ?
|
||||
String.format("%s.%s", containingClass.getQualifiedName(), fieldWrapper.getName()) :
|
||||
fieldWrapper.getName();
|
||||
assert (fieldLink != null);
|
||||
|
||||
return fieldLink;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user