mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
testdata to ensure inline from library doesn't find library usages
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
class A {
|
||||
void foo(List<String> l) {
|
||||
Collections.so<caret>rt(l);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.*;
|
||||
|
||||
class A {
|
||||
void foo(List<String> l) {
|
||||
Object[] a = l.toArray();
|
||||
Arrays.sort(a);
|
||||
ListIterator<String> i = l.listIterator();
|
||||
for (int j=0; j<a.length; j++) {
|
||||
i.next();
|
||||
i.set((String)a[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package com.intellij.refactoring.inline;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
@@ -26,6 +27,7 @@ import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.LightRefactoringTestCase;
|
||||
import com.intellij.refactoring.MockInlineMethodOptions;
|
||||
import com.intellij.refactoring.util.InlineUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -334,6 +336,15 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRespectProjectScopeSrc() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return getTestName(false).contains("Src") ? IdeaTestUtil.getMockJdk17() : super.getProjectJDK();
|
||||
}
|
||||
|
||||
private void doTestInlineThisOnly() {
|
||||
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
|
||||
configureByFile(fileName);
|
||||
@@ -368,7 +379,7 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
final PsiReference ref = myFile.findReferenceAt(myEditor.getCaretModel().getOffset());
|
||||
PsiReferenceExpression refExpr = ref instanceof PsiReferenceExpression ? (PsiReferenceExpression)ref : null;
|
||||
assertTrue(element instanceof PsiMethod);
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
PsiMethod method = (PsiMethod)element.getNavigationElement();
|
||||
final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
|
||||
assertFalse("Bad returns found", condition);
|
||||
final InlineMethodProcessor processor =
|
||||
|
||||
Reference in New Issue
Block a user