mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[Java. Code Formatting] Perform a manual lookup of the annotation in the import list in JavaFormatterUtil#isTypeAnnotation
IDEA-353192 GitOrigin-RevId: fa51cf055f554369102a71e9518aee0f5c520406
This commit is contained in:
committed by
intellij-monorepo-bot
parent
36df18e29b
commit
6517ffb793
@@ -464,12 +464,21 @@ public final class JavaFormatterUtil {
|
||||
String referenceNameText = referenceName.getText();
|
||||
return ContainerUtil.or(KNOWN_TYPE_ANNOTATIONS, fqn -> {
|
||||
if (!fqn.endsWith(referenceNameText)) return false;
|
||||
String packageName = StringUtil.getPackageName(fqn);
|
||||
return importList.findOnDemandImportStatement(packageName) != null || importList.findSingleClassImportStatement(fqn) != null;
|
||||
return isAnnotationInImportList(fqn, importList);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAnnotationInImportList(String annotationFqn, PsiImportList importList) {
|
||||
String packageName = StringUtil.getPackageName(annotationFqn);
|
||||
return ContainerUtil.or(importList.getImportStatements(), statement -> {
|
||||
PsiJavaCodeReferenceElement referenceElement = statement.getImportReference();
|
||||
if (referenceElement == null) return false;
|
||||
String referenceElementText = referenceElement.getText();
|
||||
return referenceElementText.equals(annotationFqn) || statement.isOnDemand() && referenceElementText.startsWith(packageName);
|
||||
});
|
||||
}
|
||||
|
||||
private static void putPreferredWrapInParentBlock(@NotNull AbstractJavaBlock block, @NotNull Wrap preferredWrap) {
|
||||
AbstractJavaBlock parentBlock = block.getParentBlock();
|
||||
if (parentBlock != null) {
|
||||
|
||||
Reference in New Issue
Block a user