mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
introduce parameter: ignore parts of qualified name (IDEA-104485)
This commit is contained in:
+14
-4
@@ -197,12 +197,22 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
PsiExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, PsiExpression.class);
|
||||
while (expression != null) {
|
||||
if (!expressions.contains(expression) && !(expression instanceof PsiParenthesizedExpression) && !(expression instanceof PsiSuperExpression) && expression.getType() != PsiType.VOID) {
|
||||
if (expression instanceof PsiMethodReferenceExpression ||
|
||||
!(expression instanceof PsiReferenceExpression &&
|
||||
(expression.getParent() instanceof PsiMethodCallExpression || ((PsiReferenceExpression)expression).resolve() instanceof PsiClass)) &&
|
||||
!(expression instanceof PsiAssignmentExpression)) {
|
||||
if (expression instanceof PsiMethodReferenceExpression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
else if (!(expression instanceof PsiAssignmentExpression)) {
|
||||
if (!(expression instanceof PsiReferenceExpression)) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
else {
|
||||
if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
|
||||
final PsiElement resolve = ((PsiReferenceExpression)expression).resolve();
|
||||
if (!(resolve instanceof PsiClass) && !(resolve instanceof PsiPackage)) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
expression = PsiTreeUtil.getParentOfType(expression, PsiExpression.class);
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.io.File;
|
||||
|
||||
class Test {
|
||||
public void foo(final File anObject) {
|
||||
bar(anObject);
|
||||
}
|
||||
void bar(java.io.File f){}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
public void foo() {
|
||||
bar(<caret>java.io.File.createTempFile("a", "b"));
|
||||
}
|
||||
void bar(java.io.File f){}
|
||||
}
|
||||
@@ -316,6 +316,10 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
public void testPackageReferenceShouldBeIgnored() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
private void doTestThroughHandler() throws Exception {
|
||||
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
|
||||
boolean enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user