mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
inline: find this ref corresponding to static imports (IDEA-64508)
This commit is contained in:
@@ -78,10 +78,13 @@ public class InlineUtil {
|
||||
final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expr).getMethodExpression();
|
||||
final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
|
||||
if (qualifierExpression == null) {
|
||||
if (((PsiMethod)resolved).getModifierList().hasModifierProperty(PsiModifier.STATIC)) {
|
||||
methodExpression.setQualifierExpression(elementFactory.createReferenceExpression(thisClass));
|
||||
final PsiMethod method = (PsiMethod)resolved;
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
LOG.assertTrue(containingClass != null);
|
||||
if (method.getModifierList().hasModifierProperty(PsiModifier.STATIC)) {
|
||||
methodExpression.setQualifierExpression(elementFactory.createReferenceExpression(containingClass));
|
||||
} else {
|
||||
methodExpression.setQualifierExpression(createThisExpression(manager, thisClass, refParent));
|
||||
methodExpression.setQualifierExpression(createThisExpression(manager, containingClass, refParent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static Statics._emptyList;
|
||||
|
||||
public class Statics {
|
||||
|
||||
public static <T> List<T> _emptyList() {
|
||||
return new ArrayList<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Foo {
|
||||
public static void main(String[] args) {
|
||||
List<String> v1 = _emptyList();
|
||||
doSomething(v<caret>1);
|
||||
}
|
||||
|
||||
public static void doSomething(List<String> list) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static Statics._emptyList;
|
||||
|
||||
public class Statics {
|
||||
|
||||
public static <T> List<T> _emptyList() {
|
||||
return new ArrayList<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Foo {
|
||||
public static void main(String[] args) {
|
||||
doSomething(Statics.<String>_emptyList());
|
||||
}
|
||||
|
||||
public static void doSomething(List<String> list) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testStaticImported() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
|
||||
try {
|
||||
doTest(inlineDef);
|
||||
|
||||
Reference in New Issue
Block a user