mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
Java: use resolve scope instead of all scope
GitOrigin-RevId: 3ce9519cf59154d16e9c8f8b84e7a05afaa99b32
This commit is contained in:
committed by
intellij-monorepo-bot
parent
27c012f0dd
commit
2436b544e9
@@ -118,7 +118,7 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
LOG.assertTrue(var != null);
|
||||
|
||||
PsiType fromType = var.getType();
|
||||
PsiClassType toType = getMigrationTargetType(project, element, fromType);
|
||||
PsiClassType toType = getMigrationTargetType(element, fromType);
|
||||
if (toType == null) return;
|
||||
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(var)) return;
|
||||
@@ -162,14 +162,14 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiClassType getMigrationTargetType(@NotNull Project project,
|
||||
@NotNull PsiElement element,
|
||||
@NotNull PsiType fromType) {
|
||||
private PsiClassType getMigrationTargetType(@NotNull PsiElement element, @NotNull PsiType fromType) {
|
||||
final Project project = element.getProject();
|
||||
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
GlobalSearchScope scope = element.getResolveScope();
|
||||
String atomicQualifiedName = myFromToMap.get(fromType);
|
||||
if (atomicQualifiedName != null) {
|
||||
PsiClass atomicClass = psiFacade.findClass(atomicQualifiedName, GlobalSearchScope.allScope(project));
|
||||
PsiClass atomicClass = psiFacade.findClass(atomicQualifiedName, scope);
|
||||
if (atomicClass == null) {//show warning
|
||||
return null;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
}
|
||||
else if (fromType instanceof PsiArrayType) {
|
||||
PsiClass atomicReferenceArrayClass =
|
||||
psiFacade.findClass(AtomicReferenceArray.class.getName(), GlobalSearchScope.allScope(project));
|
||||
psiFacade.findClass(AtomicReferenceArray.class.getName(), scope);
|
||||
if (atomicReferenceArrayClass == null) {//show warning
|
||||
return null;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
return factory.createType(atomicReferenceArrayClass, factory.createSubstitutor(substitutor));
|
||||
}
|
||||
else {
|
||||
PsiClass atomicReferenceClass = psiFacade.findClass(AtomicReference.class.getName(), GlobalSearchScope.allScope(project));
|
||||
PsiClass atomicReferenceClass = psiFacade.findClass(AtomicReference.class.getName(), scope);
|
||||
if (atomicReferenceClass == null) {//show warning
|
||||
return null;
|
||||
}
|
||||
@@ -211,6 +211,7 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("IntentionDescriptionNotFoundInspection")
|
||||
public static class ConvertNonFinalLocalToAtomicFix extends ConvertFieldToAtomicIntention implements HighPriorityAction {
|
||||
private final PsiElement myContext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user