mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
findInferredAnnotations returns @NotNull array
This commit is contained in:
+6
-6
@@ -46,7 +46,7 @@ import java.util.Collection;
|
||||
* @author lambdamix
|
||||
*/
|
||||
public class ProjectBytecodeAnalysis extends AbstractProjectComponent {
|
||||
|
||||
private static final PsiAnnotation[] NO_DATA = new PsiAnnotation[0];
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.bytecodeAnalysis.ProjectBytecodeAnalysis");
|
||||
private static final CharTableImpl charTable = new CharTableImpl();
|
||||
private static final JavaParserUtil.ParserWrapper ANNOTATION = new JavaParserUtil.ParserWrapper() {
|
||||
@@ -149,13 +149,13 @@ public class ProjectBytecodeAnalysis extends AbstractProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public PsiAnnotation[] findInferredAnnotations(@NotNull PsiModifierListOwner listOwner) {
|
||||
return collectInferredAnnotations(listOwner);
|
||||
}
|
||||
|
||||
// TODO the best way to synchronize?
|
||||
@Nullable
|
||||
@NotNull
|
||||
private synchronized PsiAnnotation[] collectInferredAnnotations(PsiModifierListOwner listOwner) {
|
||||
if (myAnnotations == null) {
|
||||
loadAnnotations();
|
||||
@@ -163,7 +163,7 @@ public class ProjectBytecodeAnalysis extends AbstractProjectComponent {
|
||||
try {
|
||||
int key = getKey(listOwner);
|
||||
if (key == -1) {
|
||||
return null;
|
||||
return NO_DATA;
|
||||
}
|
||||
boolean notNull = myAnnotations.notNulls.contains(key);
|
||||
String contractValue = myAnnotations.contracts.get(key);
|
||||
@@ -185,12 +185,12 @@ public class ProjectBytecodeAnalysis extends AbstractProjectComponent {
|
||||
};
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
return NO_DATA;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
return NO_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -58,8 +58,7 @@ public class ExternalAnnotationsLineMarkerProvider implements LineMarkerProvider
|
||||
final InferredAnnotationsManager inferredAnnotationsManager = InferredAnnotationsManager.getInstance(modifierListOwner.getProject());
|
||||
PsiAnnotation[] inferredAnnotations = inferredAnnotationsManager.findInferredAnnotations(modifierListOwner);
|
||||
|
||||
if (externalAnnotations != null && externalAnnotations.length > 0 ||
|
||||
inferredAnnotations != null && inferredAnnotations.length > 0) {
|
||||
if (externalAnnotations != null && externalAnnotations.length > 0 || inferredAnnotations.length > 0) {
|
||||
owner = (PsiModifierListOwner)element;
|
||||
} else if (element instanceof PsiMethod) {
|
||||
final PsiParameter[] parameters = ((PsiMethod)element).getParameterList().getParameters();
|
||||
@@ -70,7 +69,7 @@ public class ExternalAnnotationsLineMarkerProvider implements LineMarkerProvider
|
||||
break;
|
||||
}
|
||||
inferredAnnotations = inferredAnnotationsManager.findInferredAnnotations(parameter);
|
||||
if (inferredAnnotations != null && inferredAnnotations.length > 0) {
|
||||
if (inferredAnnotations.length > 0) {
|
||||
owner = (PsiMethod)element;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -390,9 +390,7 @@ public class AnnotationUtil {
|
||||
annotations = ArrayUtil.mergeArrays(annotations, externalAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
final PsiAnnotation[] inferredAnnotations = InferredAnnotationsManager.getInstance(project).findInferredAnnotations(owner);
|
||||
if (inferredAnnotations != null) {
|
||||
annotations = ArrayUtil.mergeArrays(annotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
annotations = ArrayUtil.mergeArrays(annotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
|
||||
if (inHierarchy) {
|
||||
if (owner instanceof PsiClass) {
|
||||
|
||||
@@ -33,6 +33,6 @@ public abstract class InferredAnnotationsManager {
|
||||
@Nullable
|
||||
public abstract PsiAnnotation findInferredAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public abstract PsiAnnotation[] findInferredAnnotations(@NotNull PsiModifierListOwner listOwner);
|
||||
}
|
||||
|
||||
@@ -705,9 +705,7 @@ public class JavaDocInfoGenerator {
|
||||
externalAnnotations = new PsiAnnotation[]{};
|
||||
}
|
||||
PsiAnnotation[] inferredAnnotations = InferredAnnotationsManager.getInstance(owner.getProject()).findInferredAnnotations(owner);
|
||||
if (inferredAnnotations != null) {
|
||||
externalAnnotations = ArrayUtil.mergeArrays(externalAnnotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
externalAnnotations = ArrayUtil.mergeArrays(externalAnnotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
generateAnnotations(buffer, owner, externalAnnotations, true, generateLink);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user