mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make method static: warn about broken method references if filed or class need to be passed; NPE (EA-66661 - NPE: MakeMethodStaticProcessor.changeExternalUsage)
This commit is contained in:
+2
-2
@@ -83,7 +83,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor<
|
||||
@Override
|
||||
protected MultiMap<PsiElement, String> getConflictDescriptions(UsageInfo[] usages) {
|
||||
MultiMap<PsiElement, String> descriptions = super.getConflictDescriptions(usages);
|
||||
if (mySettings.isMakeClassParameter()) {
|
||||
if (mySettings.isMakeClassParameter() || mySettings.isMakeFieldParameters()) {
|
||||
for (UsageInfo usage : usages) {
|
||||
PsiElement element = usage.getElement();
|
||||
if (element instanceof PsiMethodReferenceExpression) {
|
||||
@@ -329,7 +329,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor<
|
||||
if (anchor != null) {
|
||||
anchor = argList.addAfter(fieldRef, anchor);
|
||||
}
|
||||
else {
|
||||
else if (argList != null) {
|
||||
if (exprs.length > 0) {
|
||||
anchor = argList.addBefore(fieldRef, exprs[0]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test4 {
|
||||
void test() {
|
||||
Runnable f = Test4::yyy;
|
||||
}
|
||||
|
||||
String myField = "";
|
||||
static void yyy() {
|
||||
System.out.println(myField);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test4 {
|
||||
void test() {
|
||||
Runnable f = this::yyy;
|
||||
}
|
||||
|
||||
String myField = "";
|
||||
void yy<caret>y() {
|
||||
System.out.println(myField);
|
||||
}
|
||||
}
|
||||
@@ -203,6 +203,10 @@ public class MakeMethodStaticTest extends LightRefactoringTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testThisMethodReference() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testPreserveParametersAlignment() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user