[java-intentions] Edit Contract, Edit Range: remove on references, keep on declarations only

Also fixes EA-945090 - T: PsiSearchHelperImpl.processFilesConcurrentlyDespiteWriteActions

GitOrigin-RevId: 94cca91f42d6595a33edc1e8b2ba89ac38ee65bc
This commit is contained in:
Tagir Valeev
2024-02-06 21:35:09 +00:00
committed by intellij-monorepo-bot
parent 465109fe09
commit 832a845510
5 changed files with 2 additions and 5 deletions
@@ -39,7 +39,7 @@ public final class EditContractIntention extends BaseIntentionAction implements
}
private static @Nullable PsiMethod getTargetMethod(Editor editor, PsiFile file) {
final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset(), true);
final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
if (owner instanceof PsiMethod && ExternalAnnotationsManagerImpl.areExternalAnnotationsApplicable(owner)) {
PsiElement original = owner.getOriginalElement();
return original instanceof PsiMethod ? (PsiMethod)original : (PsiMethod)owner;
@@ -36,7 +36,7 @@ public final class EditRangeIntention extends BaseIntentionAction implements Low
@Nullable
private static PsiModifierListOwner getTarget(Editor editor, PsiFile file) {
final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset(), true);
final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
LongRangeSet rangeFromType = rangeFromType(owner);
if (rangeFromType == null || !ExternalAnnotationsManagerImpl.areExternalAnnotationsApplicable(owner)) return null;
PsiElement original = owner.getOriginalElement();
@@ -1,5 +1,4 @@
// "Replace with 'declaringJavaClass'" "true"
// ACTION: Add method contract to 'getDeclaringClass()'...
// ACTION: Introduce local variable
// ACTION: Put calls on separate lines
// ACTION: Replace with 'declaringJavaClass'
@@ -1,5 +1,4 @@
// "Replace with 'declaringJavaClass'" "true"
// ACTION: Add method contract to 'getDeclaringClass()'...
// ACTION: Introduce local variable
// ACTION: Put calls on separate lines
// ACTION: Replace with 'declaringJavaClass'
@@ -3,7 +3,6 @@
// ACTION: Add full qualifier
// ACTION: Change parameter 'block' type of function 'str' to 'Object'
// ACTION: Create function 'str'
// ACTION: Edit method contract of 'Object()'...
// ACTION: Introduce import alias
fun fn() {
str(<caret>Object())