mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
use mockJdk18 by default in LightCodeInsightTestCase; remove dependency on swing/net classes in some tests
This commit is contained in:
@@ -78,9 +78,14 @@ public class ExpectedTypesProvider {
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiMethod[] findDeclaredMethods(@NotNull final PsiManager manager, @NotNull String name) {
|
||||
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
|
||||
GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
|
||||
return cache.getMethodsByNameIfNotMoreThan(name, scope, MAX_COUNT);
|
||||
Project project = manager.getProject();
|
||||
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
|
||||
GlobalSearchScope sources = GlobalSearchScope.projectScope(project);
|
||||
GlobalSearchScope libraries = GlobalSearchScope.notScope(sources);
|
||||
PsiMethod[] sourceMethods = cache.getMethodsByNameIfNotMoreThan(name, sources, MAX_COUNT);
|
||||
if (sourceMethods.length == MAX_COUNT) return sourceMethods;
|
||||
PsiMethod[] libraryMethods = cache.getMethodsByNameIfNotMoreThan(name, libraries, MAX_COUNT-sourceMethods.length);
|
||||
return ArrayUtil.mergeArrays(sourceMethods, libraryMethods);
|
||||
}
|
||||
};
|
||||
private static final PsiType[] PRIMITIVE_TYPES = {PsiType.BYTE, PsiType.CHAR, PsiType.SHORT, PsiType.INT, PsiType.LONG, PsiType.FLOAT, PsiType.DOUBLE};
|
||||
@@ -1274,9 +1279,11 @@ public class ExpectedTypesProvider {
|
||||
* By default searches in the global scope (see ourGlobalScopeClassProvider), but caller can provide its own algorithm e.g. to narrow search scope
|
||||
*/
|
||||
public interface ExpectedClassProvider {
|
||||
PsiField[] findDeclaredFields(final PsiManager manager, String name);
|
||||
@NotNull
|
||||
PsiField[] findDeclaredFields(@NotNull PsiManager manager, @NotNull String name);
|
||||
|
||||
PsiMethod[] findDeclaredMethods(final PsiManager manager, String name);
|
||||
@NotNull
|
||||
PsiMethod[] findDeclaredMethods(@NotNull PsiManager manager, @NotNull String name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.proximity.PsiProximityComparator;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -226,7 +227,7 @@ public class CreateFromUsageUtils {
|
||||
|
||||
public static void setupMethodParameters(final PsiMethod method, final TemplateBuilder builder, final PsiElement contextElement,
|
||||
final PsiSubstitutor substitutor, final PsiExpression[] arguments) {
|
||||
setupMethodParameters(method, builder, contextElement, substitutor, ContainerUtil.map2List(arguments, Pair.<PsiExpression, PsiType>createFunction(null)));
|
||||
setupMethodParameters(method, builder, contextElement, substitutor, ContainerUtil.map2List(arguments, Pair.createFunction(null)));
|
||||
}
|
||||
|
||||
static void setupMethodParameters(final PsiMethod method, final TemplateBuilder builder, final PsiElement contextElement,
|
||||
@@ -480,10 +481,12 @@ public class CreateFromUsageUtils {
|
||||
isPackage ? "cannot.create.java.package.error.title" : "cannot.create.java.file.error.title")));
|
||||
}
|
||||
|
||||
public static PsiReferenceExpression[] collectExpressions(final PsiExpression expression, Class<? extends PsiElement>... scopes) {
|
||||
@SafeVarargs
|
||||
@NotNull
|
||||
public static PsiReferenceExpression[] collectExpressions(final PsiExpression expression, @NotNull Class<? extends PsiElement>... scopes) {
|
||||
PsiElement parent = PsiTreeUtil.getParentOfType(expression, scopes);
|
||||
|
||||
final List<PsiReferenceExpression> result = new ArrayList<PsiReferenceExpression>();
|
||||
final List<PsiReferenceExpression> result = new ArrayList<>();
|
||||
JavaRecursiveElementWalkingVisitor visitor = new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expr) {
|
||||
if (expression instanceof PsiReferenceExpression) {
|
||||
@@ -512,13 +515,13 @@ public class CreateFromUsageUtils {
|
||||
}
|
||||
|
||||
static PsiVariable[] guessMatchingVariables(final PsiExpression expression) {
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<ExpectedTypeInfo[]>();
|
||||
List<String> expectedMethodNames = new ArrayList<String>();
|
||||
List<String> expectedFieldNames = new ArrayList<String>();
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<>();
|
||||
List<String> expectedMethodNames = new ArrayList<>();
|
||||
List<String> expectedFieldNames = new ArrayList<>();
|
||||
|
||||
getExpectedInformation(expression, typesList, expectedMethodNames, expectedFieldNames);
|
||||
|
||||
final List<PsiVariable> list = new ArrayList<PsiVariable>();
|
||||
final List<PsiVariable> list = new ArrayList<>();
|
||||
VariablesProcessor varproc = new VariablesProcessor("", true, list){
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
@@ -534,7 +537,7 @@ public class CreateFromUsageUtils {
|
||||
|
||||
ExpectedTypeInfo[] infos = ExpectedTypeUtil.intersect(typesList);
|
||||
|
||||
List<PsiVariable> result = new ArrayList<PsiVariable>();
|
||||
List<PsiVariable> result = new ArrayList<>();
|
||||
nextVar:
|
||||
for (PsiVariable variable : allVars) {
|
||||
PsiType varType = variable.getType();
|
||||
@@ -631,13 +634,14 @@ public class CreateFromUsageUtils {
|
||||
return new ExpectedTypeInfo[]{ExpectedTypesProvider.createInfo(type, ExpectedTypeInfo.TYPE_STRICTLY, type, TailType.NONE)};
|
||||
}
|
||||
|
||||
static ExpectedTypeInfo[] guessExpectedTypes(PsiExpression expression, boolean allowVoidType) {
|
||||
PsiManager manager = expression.getManager();
|
||||
@NotNull
|
||||
static ExpectedTypeInfo[] guessExpectedTypes(@NotNull PsiExpression expression, boolean allowVoidType) {
|
||||
PsiManager manager = expression.getManager();
|
||||
GlobalSearchScope resolveScope = expression.getResolveScope();
|
||||
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<ExpectedTypeInfo[]>();
|
||||
List<String> expectedMethodNames = new ArrayList<String>();
|
||||
List<String> expectedFieldNames = new ArrayList<String>();
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<>();
|
||||
List<String> expectedMethodNames = new ArrayList<>();
|
||||
List<String> expectedFieldNames = new ArrayList<>();
|
||||
|
||||
getExpectedInformation(expression, typesList, expectedMethodNames, expectedFieldNames);
|
||||
|
||||
@@ -660,14 +664,16 @@ public class CreateFromUsageUtils {
|
||||
}
|
||||
|
||||
for (String methodName : expectedMethodNames) {
|
||||
PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(methodName, resolveScope, MAX_RAW_GUESSED_MEMBERS_COUNT);
|
||||
PsiMethod[] projectMethods = cache.getMethodsByNameIfNotMoreThan(methodName, resolveScope.intersectWith(GlobalSearchScope.projectScope(manager.getProject())), MAX_RAW_GUESSED_MEMBERS_COUNT);
|
||||
PsiMethod[] libraryMethods = cache.getMethodsByNameIfNotMoreThan(methodName, resolveScope.intersectWith(GlobalSearchScope.notScope(GlobalSearchScope.projectScope(manager.getProject()))), MAX_RAW_GUESSED_MEMBERS_COUNT);
|
||||
PsiMethod[] methods = ArrayUtil.mergeArrays(projectMethods, libraryMethods);
|
||||
addMemberInfo(methods, expression, typesList, factory);
|
||||
}
|
||||
}
|
||||
|
||||
ExpectedTypeInfo[] expectedTypes = ExpectedTypeUtil.intersect(typesList);
|
||||
if (expectedTypes.length == 0 && !typesList.isEmpty()) {
|
||||
List<ExpectedTypeInfo> union = new ArrayList<ExpectedTypeInfo>();
|
||||
List<ExpectedTypeInfo> union = new ArrayList<>();
|
||||
for (ExpectedTypeInfo[] aTypesList : typesList) {
|
||||
ContainerUtil.addAll(union, (ExpectedTypeInfo[])aTypesList);
|
||||
}
|
||||
@@ -688,9 +694,9 @@ public class CreateFromUsageUtils {
|
||||
final PsiManager manager = expression.getManager();
|
||||
final GlobalSearchScope resolveScope = expression.getResolveScope();
|
||||
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<ExpectedTypeInfo[]>();
|
||||
final List<String> expectedMethodNames = new ArrayList<String>();
|
||||
final List<String> expectedFieldNames = new ArrayList<String>();
|
||||
List<ExpectedTypeInfo[]> typesList = new ArrayList<>();
|
||||
final List<String> expectedMethodNames = new ArrayList<>();
|
||||
final List<String> expectedFieldNames = new ArrayList<>();
|
||||
|
||||
getExpectedInformation(expression, typesList, expectedMethodNames, expectedFieldNames);
|
||||
|
||||
@@ -719,7 +725,7 @@ public class CreateFromUsageUtils {
|
||||
|
||||
ExpectedTypeInfo[] expectedTypes = ExpectedTypeUtil.intersect(typesList);
|
||||
if (expectedTypes.length == 0 && !typesList.isEmpty()) {
|
||||
List<ExpectedTypeInfo> union = new ArrayList<ExpectedTypeInfo>();
|
||||
List<ExpectedTypeInfo> union = new ArrayList<>();
|
||||
for (ExpectedTypeInfo[] aTypesList : typesList) {
|
||||
ContainerUtil.addAll(union, (ExpectedTypeInfo[])aTypesList);
|
||||
}
|
||||
@@ -731,7 +737,7 @@ public class CreateFromUsageUtils {
|
||||
}
|
||||
else {
|
||||
//Double check to avoid expensive operations on PsiClassTypes
|
||||
final Set<PsiType> typesSet = new HashSet<PsiType>();
|
||||
final Set<PsiType> typesSet = new HashSet<>();
|
||||
|
||||
PsiTypeVisitor<PsiType> visitor = new PsiTypeVisitor<PsiType>() {
|
||||
@Override
|
||||
@@ -786,7 +792,7 @@ public class CreateFromUsageUtils {
|
||||
PsiElementFactory factory) {
|
||||
Arrays.sort(members, (m1, m2) -> compareMembers(m1, m2, expression));
|
||||
|
||||
List<ExpectedTypeInfo> l = new ArrayList<ExpectedTypeInfo>();
|
||||
List<ExpectedTypeInfo> l = new ArrayList<>();
|
||||
PsiManager manager = expression.getManager();
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
|
||||
for (PsiMember member : members) {
|
||||
@@ -1026,13 +1032,13 @@ public class CreateFromUsageUtils {
|
||||
|
||||
PsiParameter parameter = PsiTreeUtil.getParentOfType(elementAt, PsiParameter.class);
|
||||
|
||||
Set<String> parameterNames = new HashSet<String>();
|
||||
Set<String> parameterNames = new HashSet<>();
|
||||
for (PsiParameter psiParameter : parameterList.getParameters()) {
|
||||
if (psiParameter == parameter) continue;
|
||||
parameterNames.add(psiParameter.getName());
|
||||
}
|
||||
|
||||
Set<LookupElement> set = new LinkedHashSet<LookupElement>();
|
||||
Set<LookupElement> set = new LinkedHashSet<>();
|
||||
|
||||
for (String name : myNames) {
|
||||
if (parameterNames.contains(name)) {
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.FilenameFilter;
|
||||
class A {
|
||||
{
|
||||
new java.io.File("aaa").list(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
<selection>return false;</selection>
|
||||
public boolean accept(File file, String s) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// access problems in inner classes
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.beancontext.BeanContextServicesSupport;
|
||||
import java.beans.beancontext.BeanContextServicesSupport.<error descr="'java.beans.beancontext.BeanContextServicesSupport.BCSSChild' has protected access in 'java.beans.beancontext.BeanContextServicesSupport'">BCSSChild</error>;
|
||||
import x.BeanContextServicesSupport;
|
||||
import x.BeanContextServicesSupport.<error descr="'x.BeanContextServicesSupport.BCSSChild' has protected access in 'x.BeanContextServicesSupport'">BCSSChild</error>;
|
||||
|
||||
class a extends Component {
|
||||
class a extends x.Component {
|
||||
void f() {
|
||||
FlipBufferStrategy s = null;
|
||||
int i = s.<error descr="'numBuffers' has protected access in 'java.awt.Component.FlipBufferStrategy'">numBuffers</error>;
|
||||
s.<error descr="'createBuffers(int, java.awt.BufferCapabilities)' has protected access in 'java.awt.Component.FlipBufferStrategy'">createBuffers</error>(1,null);
|
||||
int i = s.<error descr="'numBuffers' has protected access in 'x.Component.FlipBufferStrategy'">numBuffers</error>;
|
||||
s.<error descr="'createBuffers(int)' has protected access in 'x.Component.FlipBufferStrategy'">createBuffers</error>(1);
|
||||
|
||||
// TODO
|
||||
// now cannot distinquish private from package-private in class files
|
||||
@@ -19,9 +18,9 @@ class a extends Component {
|
||||
|
||||
|
||||
class ddd extends BeanContextServicesSupport {
|
||||
BCSSChild.<error descr="'java.beans.beancontext.BeanContextServicesSupport.BCSSChild.BCSSCServiceClassRef' is not public in 'java.beans.beancontext.BeanContextServicesSupport.BCSSChild'. Cannot be accessed from outside package">BCSSCServiceClassRef</error> fd = null;
|
||||
BCSSChild.<error descr="'x.BeanContextServicesSupport.BCSSChild.BCSSCServiceClassRef' is not public in 'x.BeanContextServicesSupport.BCSSChild'. Cannot be accessed from outside package">BCSSCServiceClassRef</error> fd = null;
|
||||
void ff() {
|
||||
fd.<error descr="'addRequestor(java.lang.Object, java.beans.beancontext.BeanContextServiceRevokedListener)' is not public in 'java.beans.beancontext.BeanContextServicesSupport.BCSSChild.BCSSCServiceClassRef'. Cannot be accessed from outside package">addRequestor</error>(null,null);
|
||||
fd.<error descr="'addRequestor(java.lang.Object)' is not public in 'x.BeanContextServicesSupport.BCSSChild.BCSSCServiceClassRef'. Cannot be accessed from outside package">addRequestor</error>(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// assign to final
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a21 {
|
||||
final int fi;
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// assignment compatible types
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a {
|
||||
final int FI = 2;
|
||||
final int FIBIG = 200000000;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// cyclic inhertiance
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
<error descr="Cyclic inheritance involving 'Foo'">class Foo extends Foo</error> {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// duplicate labels
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
public class a {
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Exception is never thrown in method
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
|
||||
class SQLException extends Exception {}
|
||||
|
||||
class a {
|
||||
private void f() throws <warning descr="Exception 'java.io.IOException' is never thrown in the method">IOException</warning> {
|
||||
@@ -50,7 +51,7 @@ final class Final {
|
||||
|
||||
|
||||
class a1 {
|
||||
a1() throws <warning descr="Exception 'java.io.IOException' is never thrown in the method">java.io.IOException</warning>, <warning descr="Exception 'java.sql.SQLException' is never thrown in the method">SQLException</warning>{
|
||||
a1() throws <warning descr="Exception 'java.io.IOException' is never thrown in the method">java.io.IOException</warning>, <warning descr="Exception 'SQLException' is never thrown in the method">SQLException</warning>{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
|
||||
|
||||
////////////
|
||||
class x {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// fields double initialization
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
class Foo {
|
||||
final int k;
|
||||
final int ff = 5;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// final Fields initialization
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
class a {
|
||||
/**
|
||||
@@ -87,8 +85,8 @@ class Test {
|
||||
}
|
||||
private final String text;
|
||||
public Test() {
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
doSomething(text);////
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// forward references
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
public class a {
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/// initalizers completion
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a {
|
||||
|
||||
@@ -26,12 +25,17 @@ class a2 {
|
||||
|
||||
<error descr="Unhandled exception: java.io.IOException">a2()</error> {}
|
||||
}
|
||||
class SocketException extends IOException {
|
||||
}
|
||||
class ConnectException extends SocketException {
|
||||
}
|
||||
|
||||
class a3 {
|
||||
{
|
||||
if (1==2) <error descr="Unhandled exception: java.net.SocketException">throw new SocketException();</error>
|
||||
if (1==2) <error descr="Unhandled exception: SocketException">throw new SocketException();</error>
|
||||
}
|
||||
|
||||
<error descr="Unhandled exception: java.net.SocketException">a3() throws ConnectException</error> {}
|
||||
<error descr="Unhandled exception: SocketException">a3() throws ConnectException</error> {}
|
||||
}
|
||||
|
||||
class b {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// labels
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
class a {
|
||||
void f() {
|
||||
@@ -66,4 +66,4 @@ class AlreadyInUse {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
public class a {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//Missing return statement
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a {
|
||||
interface ii {}
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
// throws conflicts on overriding/ override final
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a extends c3 {
|
||||
public void f() throws <error descr="'f()' in 'a' clashes with 'f()' in 'c3'; overridden method does not throw 'java.lang.Exception'">Exception</error> {
|
||||
}
|
||||
}
|
||||
class SocketException extends IOException {
|
||||
}
|
||||
class ConnectException extends SocketException {
|
||||
}
|
||||
|
||||
interface i {
|
||||
void f() throws java.net.SocketException;
|
||||
void f() throws SocketException;
|
||||
}
|
||||
class c2 implements i {
|
||||
public void f() throws <error descr="'f()' in 'c2' clashes with 'f()' in 'i'; overridden method does not throw 'java.io.IOException'">java.io.IOException</error> {}
|
||||
@@ -17,11 +21,11 @@ class c2i implements i {
|
||||
}
|
||||
|
||||
class c3 implements i {
|
||||
public void f() throws java.net.ConnectException {}
|
||||
public void f() throws ConnectException {}
|
||||
}
|
||||
|
||||
class c4 extends c3 {
|
||||
public void f() throws java.net.ConnectException {}
|
||||
public void f() throws ConnectException {}
|
||||
}
|
||||
|
||||
interface MethodsFromObject {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import java.io.*;
|
||||
import java.lang.Override;
|
||||
import java.lang.String;
|
||||
import java.net.*;
|
||||
|
||||
class A {
|
||||
A(int i) {}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// silly asignment
|
||||
import javax.swing.*;
|
||||
|
||||
class JPanel {
|
||||
JPanel getSize() { return this; }
|
||||
int height;
|
||||
}
|
||||
class a {
|
||||
int f;
|
||||
JPanel fpanel;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// single import conflict
|
||||
import java.sql.Date;
|
||||
<error descr="'java.sql.Date' is already defined in a single-type import">import java.util.Date;</error>
|
||||
import java.sql.*;
|
||||
import sql.Date;
|
||||
<error descr="'sql.Date' is already defined in a single-type import">import java.util.Date;</error>
|
||||
import sql.*;
|
||||
import java.util.*;
|
||||
// multiple single-type import of the same class is fine
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// method override
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
class a extends a1 {
|
||||
<error descr="Static method 'f()' in 'a' cannot override instance method 'f()' in 'a1'">public static void f()</error> { }
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
/**
|
||||
class a {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/// labels
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// unhandled exceptions from superclases/etc
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
class a {
|
||||
a(int i) {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// unreachables
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a {
|
||||
interface ii {}
|
||||
|
||||
@@ -135,16 +135,21 @@ interface ii {}
|
||||
int i = 6;
|
||||
}
|
||||
}
|
||||
void cf4() throws java.net.SocketException {
|
||||
void cf4() throws SocketException {
|
||||
try {
|
||||
bind();
|
||||
} catch (java.net.SocketException se) {
|
||||
} catch (SocketException se) {
|
||||
throw se;
|
||||
} catch(java.io.IOException e) {
|
||||
throw new java.net.SocketException(e.getMessage());
|
||||
} catch(IOException e) {
|
||||
throw new SocketException(e.getMessage());
|
||||
}
|
||||
}
|
||||
void bind() throws java.net.SocketException {}
|
||||
static class SocketException extends IOException {
|
||||
public SocketException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
void bind() throws SocketException {}
|
||||
|
||||
|
||||
void cf5() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// vars double initialization
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class a21 {
|
||||
|
||||
void f1(int i) {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// "Create class 'MyTableModel'" "true"
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
JTable table = new JTable(new MyTableModel());
|
||||
}
|
||||
}
|
||||
class JTable {
|
||||
JTable(TableModel t) {}
|
||||
}
|
||||
interface TableModel {}
|
||||
|
||||
<caret>public class MyTableModel implements TableModel {
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
// "Create class 'MyTableModel'" "true"
|
||||
import javax.swing.*;
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
JTable table = new JTable(new MyTable<caret>Model());
|
||||
}
|
||||
}
|
||||
}
|
||||
class JTable {
|
||||
JTable(TableModel t) {}
|
||||
}
|
||||
interface TableModel {}
|
||||
@@ -1,14 +1,13 @@
|
||||
// "Create field 'panel'" "true"
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
|
||||
class Test {
|
||||
private JPanel panel;
|
||||
private File panel;
|
||||
|
||||
void foo(JPanel container) {
|
||||
Object foo(File container) {
|
||||
if (panel == null) {
|
||||
panel = new JPanel();
|
||||
panel.setOpaque(true);
|
||||
container.add(panel);
|
||||
panel = new File();
|
||||
return new File(container, panel.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
// "Create field 'panel'" "true"
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
|
||||
class Test {
|
||||
void foo(JPanel container) {
|
||||
Object foo(File container) {
|
||||
if (p<caret>anel == null) {
|
||||
panel = new JPanel();
|
||||
panel.setOpaque(true);
|
||||
container.add(panel);
|
||||
panel = new File();
|
||||
return new File(container, panel.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
// "Create inner class 'MyTableModel'" "true"
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
@@ -9,4 +7,8 @@ public class Test {
|
||||
|
||||
private static class MyTableModel implements TableModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
class JTable {
|
||||
JTable(TableModel t) {}
|
||||
}
|
||||
interface TableModel {}
|
||||
@@ -1,8 +1,11 @@
|
||||
// "Create inner class 'MyTableModel'" "true"
|
||||
import javax.swing.*;
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
JTable table = new JTable(new MyTable<caret>Model());
|
||||
}
|
||||
}
|
||||
}
|
||||
class JTable {
|
||||
JTable(TableModel t) {}
|
||||
}
|
||||
interface TableModel {}
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ExtractMethods { }
|
||||
abstract class MyButton
|
||||
extends JButton
|
||||
@@ -13,9 +10,15 @@ abstract class MyButton
|
||||
class Foo {
|
||||
private JButton createOKButton() {
|
||||
return new MyButton( "OK" ) {
|
||||
public void actionPerformed( ActionEvent e ) {
|
||||
public void actionPerformed( int e ) {
|
||||
<selection> setVisible( false ); </selection>
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class JButton {
|
||||
public JButton(String text) {
|
||||
}
|
||||
public void setVisible(boolean b) {}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ExtractMethods { }
|
||||
abstract class MyButton
|
||||
extends JButton
|
||||
@@ -13,7 +10,7 @@ abstract class MyButton
|
||||
class Foo {
|
||||
private JButton createOKButton() {
|
||||
return new MyButton( "OK" ) {
|
||||
public void actionPerformed( ActionEvent e ) {
|
||||
public void actionPerformed( int e ) {
|
||||
newMethod();
|
||||
}
|
||||
|
||||
@@ -23,3 +20,9 @@ class Foo {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class JButton {
|
||||
public JButton(String text) {
|
||||
}
|
||||
public void setVisible(boolean b) {}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ class Test {
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(String s, String x) {
|
||||
private void newMethod(String s, String s1) {
|
||||
System.out.println(s);
|
||||
System.out.println(x);
|
||||
System.out.println(s1);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
class Test {
|
||||
|
||||
@@ -6,6 +8,7 @@ class Test {
|
||||
b(newMethod());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Supplier newMethod() {
|
||||
return (s) -> {
|
||||
System.out.println(s);
|
||||
|
||||
@@ -4,8 +4,8 @@ class Test {
|
||||
System.out.println(s1);
|
||||
}
|
||||
|
||||
private String newMethod(String x, String s) {
|
||||
System.out.println(x);
|
||||
return s;
|
||||
private String newMethod(String s, String s2) {
|
||||
System.out.println(s2);
|
||||
return s2;
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@ public class Test {
|
||||
newMethod(x, 3, 4);
|
||||
}
|
||||
|
||||
private void newMethod(int x, int x2, int x3) {
|
||||
System.out.println(x2);
|
||||
System.out.println(x3);
|
||||
private void newMethod(int x, int i, int i2) {
|
||||
System.out.println(i);
|
||||
System.out.println(i2);
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ public class Test {
|
||||
newMethod(x, x + 2);
|
||||
}
|
||||
|
||||
private void newMethod(int p, int x) {
|
||||
private void newMethod(int p, int i) {
|
||||
System.out.println(p);
|
||||
System.out.println(x);
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ class Test {
|
||||
newMethod("world, " + args[i]);
|
||||
}
|
||||
|
||||
private static void newMethod(String x) {
|
||||
System.out.println(x);
|
||||
private static void newMethod(String s) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
class A {
|
||||
private ActionListener b = new Inner();
|
||||
|
||||
private class <caret>Inner implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
interface ActionListener {
|
||||
public void actionPerformed(int e);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
class A {
|
||||
private ActionListener b = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(int e) {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
interface ActionListener {
|
||||
public void actionPerformed(int e);
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
class A {
|
||||
private ActionListener b = new Inner();
|
||||
@@ -7,7 +6,11 @@ class A {
|
||||
}
|
||||
|
||||
private class <caret>Inner extends MyActionListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
interface ActionListener {
|
||||
public void actionPerformed(int e);
|
||||
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
class A {
|
||||
private ActionListener b = new MyActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(int e) {
|
||||
}
|
||||
};
|
||||
|
||||
private abstract class MyActionListener implements ActionListener {
|
||||
}
|
||||
|
||||
}
|
||||
interface ActionListener {
|
||||
public void actionPerformed(int e);
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
class InStaticInitializer {
|
||||
public static final String x = "Hello World";
|
||||
public static final String s = "Hello World";
|
||||
|
||||
static {
|
||||
System.out.println(x);
|
||||
System.out.println(s);
|
||||
}
|
||||
//Field must be placed before initializer or illegal forward reference will happen
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
final class Bug
|
||||
extends JFrame {
|
||||
@@ -14,7 +11,15 @@ final class Bug
|
||||
|
||||
private class MyWindowListener
|
||||
extends WindowAdapter {
|
||||
public void windowActivated(WindowEvent e) {
|
||||
public void windowActivated(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JFrame {
|
||||
public void addWindowListener(WindowAdapter e) {}
|
||||
static class WindowAdapter {
|
||||
public void windowActivated(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
final class Bug
|
||||
extends JFrame {
|
||||
@@ -14,7 +11,15 @@ final class Bug
|
||||
|
||||
private class MyWindowListener
|
||||
extends WindowAdapter {
|
||||
public void windowActivated(WindowEvent e) {
|
||||
public void windowActivated(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JFrame {
|
||||
public void addWindowListener(WindowAdapter e) {}
|
||||
static class WindowAdapter {
|
||||
public void windowActivated(int e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.awt.Component;
|
||||
import javax.swing.JComponent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,3 +10,5 @@ class Types {
|
||||
Object o = list.get(0);
|
||||
}
|
||||
}
|
||||
class JComponent extends Component {}
|
||||
class Component {}
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.awt.Component;
|
||||
import javax.swing.JComponent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,3 +10,5 @@ class Types {
|
||||
method(list);
|
||||
}
|
||||
}
|
||||
class JComponent extends Component {}
|
||||
class Component {}
|
||||
@@ -1,10 +1,10 @@
|
||||
import static javax.swing.SwingConstants.BOTTOM;
|
||||
import static java.io.File.separatorChar;
|
||||
|
||||
public class RenameCollisions {
|
||||
public static class StaticInnerClass {
|
||||
public static void staticContext() {
|
||||
int localVar<caret> = 0;
|
||||
int var1 = BOTTOM;
|
||||
int var1 = separatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class RenameCollisions {
|
||||
public static class StaticInnerClass {
|
||||
public static void staticContext() {
|
||||
int BOTTOM<caret> = 0;
|
||||
int var1 = SwingConstants.BOTTOM;
|
||||
int separatorChar<caret> = 0;
|
||||
int var1 = File.separatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import static javax.swing.SwingConstants.BOTTOM;
|
||||
import static java.io.File.separatorChar;
|
||||
|
||||
public class RenameCollisions {
|
||||
public static class StaticInnerClass {
|
||||
public static void staticContext(int param<caret>) {
|
||||
int var1 = BOTTOM;
|
||||
int var1 = separatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class RenameCollisions {
|
||||
public static class StaticInnerClass {
|
||||
public static void staticContext(int BOTTOM<caret>) {
|
||||
int var1 = SwingConstants.BOTTOM;
|
||||
public static void staticContext(int separatorChar<caret>) {
|
||||
int var1 = File.separatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.GenericsUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -589,15 +587,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
assertEquals("Number & Comparable<? extends Number & Comparable<?>>", leastUpperBound.getPresentableText());
|
||||
}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
assertNotNull(collectionsClass);
|
||||
collectionsClass = (PsiClass)collectionsClass.getNavigationElement();
|
||||
final String text = collectionsClass.getContainingFile().getText();
|
||||
configureFromFileText("Collections.java", StringUtil.convertLineSeparators(StringUtil.replace(text, "package java.util;", "package java.utilx; import java.util.*;")));
|
||||
doTestConfiguredFile(false, false, null);
|
||||
}
|
||||
|
||||
public void testReturnTypeSubstitutableForSameOverrideEquivalentMethods() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,8 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
final StringBuilder imports = new StringBuilder();
|
||||
final StringBuilder usages = new StringBuilder();
|
||||
int v = 0;
|
||||
List<PsiClass> aclasses = new ArrayList<>();
|
||||
List<PsiClass> aClasses = new ArrayList<>();
|
||||
outer:
|
||||
for (String name : names) {
|
||||
PsiClass[] classes = cache.getClassesByName(name, GlobalSearchScope.allScope(getProject()));
|
||||
if (classes.length == 0) continue;
|
||||
@@ -229,12 +230,17 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
if (!aClass.hasModifierProperty(PsiModifier.PUBLIC)) continue;
|
||||
if (aClass.getSuperClass() == null) continue;
|
||||
PsiClassType[] superTypes = aClass.getSuperTypes();
|
||||
if (superTypes.length == 0 || superTypes[0].resolve() == null) continue;
|
||||
if (superTypes.length == 0) continue;
|
||||
for (PsiClassType superType : superTypes) {
|
||||
PsiClass superClass = superType.resolve();
|
||||
if (superClass == null || !superClass.hasModifierProperty(PsiModifier.PUBLIC)) continue outer;
|
||||
}
|
||||
String qualifiedName = aClass.getQualifiedName();
|
||||
if (qualifiedName.startsWith("java.lang.invoke")) continue; // java.lang.invoke.MethodHandle has weird access attributes in recent rt.jar which causes spurious highlighting errors
|
||||
if ("Sink".equals(aClass.getName())) continue;
|
||||
imports.append("import " + qualifiedName + ";\n");
|
||||
usages.append("/**/ "+aClass.getName() + " var" + v + " = null; var" + v + ".toString();\n");
|
||||
aclasses.add(aClass);
|
||||
aClasses.add(aClass);
|
||||
v++;
|
||||
if (v>100) break;
|
||||
}
|
||||
@@ -278,7 +284,7 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
});
|
||||
|
||||
System.out.println("i = " + i + " " + next + " at "+offset);
|
||||
//System.out.println("i = " + i + " " + next + " at "+offset);
|
||||
|
||||
List<HighlightInfo> infos = doHighlighting();
|
||||
errors = DaemonAnalyzerTestCase.filter(infos, HighlightSeverity.ERROR);
|
||||
@@ -290,6 +296,4 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,13 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiCompiledElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -49,6 +54,11 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), getTestRootDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17(); // has to have src.zip and weird method handle signatures
|
||||
}
|
||||
|
||||
private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... inspections) {
|
||||
enableInspectionTools(inspections);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
|
||||
@@ -170,4 +180,14 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUncheckedExtendedWarnings() { doTest(true, false); }
|
||||
public void testInaccessibleInferredTypeForVarargsArgument() { doTest(false, false);}
|
||||
public void testRuntimeClassCast() { doTest(true, false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
assertNotNull(collectionsClass);
|
||||
collectionsClass = (PsiClass)collectionsClass.getNavigationElement();
|
||||
assertTrue(!(collectionsClass instanceof PsiCompiledElement));
|
||||
final String text = collectionsClass.getContainingFile().getText();
|
||||
configureFromFileText("Collections.java", StringUtil.convertLineSeparators(StringUtil.replace(text, "package java.util;", "package java.utilx; import java.util.*;")));
|
||||
doTestConfiguredFile(false, false, null);
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,15 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.impl.source.tree.injected.JavaConcatenationInjectorManager;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
@@ -51,6 +51,11 @@ public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTest
|
||||
PathManagerEx.getTestDataPath(); // to cache stuff
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17(); // has to have awt
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
Disposer.dispose(my);
|
||||
@@ -101,12 +106,9 @@ public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTest
|
||||
getFile().getText(); //to load text
|
||||
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject());
|
||||
|
||||
final List<HighlightInfo> infos = new ArrayList<HighlightInfo>();
|
||||
PlatformTestUtil.startPerformanceTest(getTestName(false), maxMillis, () -> {
|
||||
infos.clear();
|
||||
DaemonCodeAnalyzer.getInstance(getProject()).restart();
|
||||
List<HighlightInfo> h = doHighlighting();
|
||||
infos.addAll(h);
|
||||
doHighlighting();
|
||||
}).cpuBound().usesAllCPUCores().useLegacyScaling().assertTiming();
|
||||
|
||||
return highlightErrors();
|
||||
|
||||
@@ -39,9 +39,12 @@ import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
@@ -54,6 +57,8 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.psi.xml.XmlToken;
|
||||
import com.intellij.psi.xml.XmlTokenType;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.VfsTestUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -161,7 +166,42 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testDeprecated() { doTest(true, false); }
|
||||
public void testJavadoc() { enableInspectionTool(new JavaDocLocalInspection()); doTest(true, false); }
|
||||
public void testExpressionsInSwitch () { doTest(false, false); }
|
||||
public void testAccessInner () { doTest(false, false); }
|
||||
public void testAccessInner() throws IOException {
|
||||
Editor e = createSaveAndOpenFile("x/BeanContextServicesSupport.java",
|
||||
"" +
|
||||
"package x;\n" +
|
||||
"public class BeanContextServicesSupport {" +
|
||||
" protected class BCSSChild {" +
|
||||
" class BCSSCServiceClassRef {" +
|
||||
" void addRequestor(Object requestor) {" +
|
||||
" }" +
|
||||
" }" +
|
||||
" }" +
|
||||
"}");
|
||||
Editor e2 = createSaveAndOpenFile("x/Component.java",
|
||||
"" +
|
||||
"package x;\n" +
|
||||
"public class Component {" +
|
||||
" protected class FlipBufferStrategy {" +
|
||||
" protected int numBuffers;" +
|
||||
" protected void createBuffers(int numBuffers){}" +
|
||||
" }" +
|
||||
"}");
|
||||
try {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
doTest(false, false);
|
||||
}
|
||||
finally {
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(e.getDocument());
|
||||
FileEditorManager.getInstance(getProject()).closeFile(file);
|
||||
VfsTestUtil.deleteFile(file);
|
||||
VirtualFile file2 = FileDocumentManager.getInstance().getFile(e2.getDocument());
|
||||
FileEditorManager.getInstance(getProject()).closeFile(file2);
|
||||
VfsTestUtil.deleteFile(file2);
|
||||
}
|
||||
}
|
||||
|
||||
public void testExceptionNeverThrown() { doTest(true, false); }
|
||||
public void testExceptionNeverThrownInTry() { doTest(false, false); }
|
||||
@@ -173,7 +213,12 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testExtendMultipleClasses() { doTest(false, false); }
|
||||
public void testRecursiveConstructorInvocation() { doTest(false, false); }
|
||||
public void testMethodCalls() { doTest(false, false); }
|
||||
public void testSingleTypeImportConflicts() { doTest(false, false); }
|
||||
public void testSingleTypeImportConflicts() throws IOException {
|
||||
createSaveAndOpenFile("sql/Date.java", "package sql; public class Date{}");
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
doTest(false, false);
|
||||
}
|
||||
public void testMultipleSingleTypeImports() { doTest(true, false); } //duplicate imports
|
||||
public void testNotAllowedInInterface() { doTest(false, false); }
|
||||
public void testQualifiedNew() { doTest(false, false); }
|
||||
|
||||
@@ -20,9 +20,12 @@ import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,8 @@ public class CreateFieldFromUsageTest extends LightQuickFixTestCase {
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
PsiClass aClass = JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject()));
|
||||
assertNotNull(aClass);
|
||||
doSingleTest();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class RenameCollisionsTest extends LightRefactoringTestCase {
|
||||
}
|
||||
|
||||
public void testRenameVarLocalToAlien() throws Exception {
|
||||
doTest("BOTTOM");
|
||||
doTest("separatorChar");
|
||||
}
|
||||
|
||||
public void testRenameVarLocalToConst() throws Exception {
|
||||
@@ -151,7 +151,7 @@ public class RenameCollisionsTest extends LightRefactoringTestCase {
|
||||
}
|
||||
|
||||
public void testRenameVarParamToAlien() throws Exception {
|
||||
doTest("BOTTOM");
|
||||
doTest("separatorChar");
|
||||
}
|
||||
|
||||
public void testRenameVarParamToField() throws Exception {
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.intellij.refactoring.inline;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.LightRefactoringTestCase;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -14,6 +16,11 @@ public class InlineConstantFieldTest extends LightRefactoringTestCase {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17(); // has to have src.zip
|
||||
}
|
||||
|
||||
public void testQualifiedExpression() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -62,6 +64,11 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17(); // there is JPanel inside
|
||||
}
|
||||
|
||||
public void testIDEADEV12244 () throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class LightCodeInsightTestCase extends LightPlatformCodeInsightT
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// "Convert variable to 'java.util.concurrent.atomic.LongAdder'" "true"
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
public class Main10 {
|
||||
void m() {
|
||||
java.util.concurrent.atomic.LongAdder i = new java.util.concurrent.atomic.LongAdder();
|
||||
LongAdder i = new LongAdder();
|
||||
|
||||
i.increment();
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// "Convert variable to 'java.util.concurrent.atomic.LongAdder'" "true"
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
public class Main10 {
|
||||
void m() {
|
||||
java.util.concurrent.atomic.LongAdder l = new java.util.concurrent.atomic.LongAdder();
|
||||
LongAdder l = new LongAdder();
|
||||
|
||||
l.decrement();
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// "Convert variable to 'java.util.concurrent.atomic.LongAdder'" "true"
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
public class Main10 {
|
||||
void m() {
|
||||
java.util.concurrent.atomic.LongAdder l = new java.util.concurrent.atomic.LongAdder();
|
||||
LongAdder l = new LongAdder();
|
||||
|
||||
String asString = l.toString();
|
||||
|
||||
|
||||
@@ -150,18 +150,6 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
return new WriteCommandAction<Document>(null) {
|
||||
@Override
|
||||
protected void run(@NotNull Result<Document> result) throws Throwable {
|
||||
if (myVFile != null) {
|
||||
// avoid messing with invalid files, in case someone calls configureXXX() several times
|
||||
PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
|
||||
FileEditorManager.getInstance(ourProject).closeFile(myVFile);
|
||||
try {
|
||||
myVFile.delete(this);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
myVFile = null;
|
||||
}
|
||||
final Document fakeDocument = new DocumentImpl(fileText);
|
||||
|
||||
EditorTestUtil.CaretAndSelectionState caretsState = EditorTestUtil.extractCaretAndSelectionMarkers(fakeDocument);
|
||||
@@ -216,22 +204,37 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
|
||||
PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
|
||||
deleteVFile();
|
||||
myVFile = getSourceRoot().createChildData(null, fileName);
|
||||
VfsUtil.saveText(myVFile, fileText);
|
||||
final FileDocumentManager manager = FileDocumentManager.getInstance();
|
||||
final Document document = manager.getDocument(myVFile);
|
||||
assertNotNull("Can't create document for '" + fileName + "'", document);
|
||||
manager.reloadFromDisk(document);
|
||||
document.insertString(0, " ");
|
||||
document.deleteString(0, 1);
|
||||
myFile = getPsiManager().findFile(myVFile);
|
||||
assertNotNull("Can't create PsiFile for '" + fileName + "'. Unknown file type most probably.", myFile);
|
||||
assertTrue(myFile.isPhysical());
|
||||
myEditor = createEditor(myVFile);
|
||||
myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
return document;
|
||||
myEditor = createSaveAndOpenFile(fileName, fileText);
|
||||
myVFile = FileDocumentManager.getInstance().getFile(myEditor.getDocument());
|
||||
myFile = getPsiManager().findFile(myVFile);
|
||||
|
||||
return myEditor.getDocument();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Editor createSaveAndOpenFile(@NotNull String relativePath, @NotNull String fileText) throws IOException {
|
||||
return WriteCommandAction.runWriteCommandAction(getProject(), new ThrowableComputable<Editor, IOException>() {
|
||||
@Override
|
||||
public Editor compute() throws IOException {
|
||||
VirtualFile myVFile = VfsTestUtil.createFile(getSourceRoot(),relativePath);
|
||||
VfsUtil.saveText(myVFile, fileText);
|
||||
final FileDocumentManager manager = FileDocumentManager.getInstance();
|
||||
final Document document = manager.getDocument(myVFile);
|
||||
assertNotNull("Can't create document for '" + relativePath + "'", document);
|
||||
manager.reloadFromDisk(document);
|
||||
document.insertString(0, " ");
|
||||
document.deleteString(0, 1);
|
||||
PsiFile myFile = getPsiManager().findFile(myVFile);
|
||||
assertNotNull("Can't create PsiFile for '" + relativePath + "'. Unknown file type most probably.", myFile);
|
||||
assertTrue(myFile.isPhysical());
|
||||
Editor myEditor = createEditor(myVFile);
|
||||
myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
return myEditor;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setupEditorForInjectedLanguage() {
|
||||
@@ -255,6 +258,10 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<Void, IOException>() {
|
||||
@Override
|
||||
public Void compute() throws IOException {
|
||||
// avoid messing with invalid files, in case someone calls configureXXX() several times
|
||||
PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
|
||||
FileEditorManager.getInstance(ourProject).closeFile(myVFile);
|
||||
|
||||
myVFile.delete(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user