diff options
Diffstat (limited to 'java')
361 files changed, 6360 insertions, 1724 deletions
diff --git a/java/compiler/forms-compiler/forms-compiler.iml b/java/compiler/forms-compiler/forms-compiler.iml index 1a851bf7859f..7b957e27ad00 100644 --- a/java/compiler/forms-compiler/forms-compiler.iml +++ b/java/compiler/forms-compiler/forms-compiler.iml @@ -10,7 +10,7 @@ <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="JDOM" level="project" /> <orderEntry type="module" module-name="forms_rt" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> <orderEntry type="library" scope="TEST" name="JUnit3" level="project" /> <orderEntry type="library" name="jgoodies-forms" level="project" /> <orderEntry type="module" module-name="instrumentation-util" exported="" /> diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java index 22ab2a7f8bd6..62f2eef28ff4 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java @@ -19,10 +19,10 @@ import com.intellij.compiler.instrumentation.InstrumentationClassFinder; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.lw.*; import com.intellij.uiDesigner.shared.BorderType; -import org.jetbrains.asm4.*; -import org.jetbrains.asm4.Label; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.*; +import org.jetbrains.org.objectweb.asm.Label; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; import javax.swing.border.Border; @@ -235,7 +235,7 @@ public class AsmCodeGenerator { private final boolean myExplicitSetupCall; public FormClassVisitor(final ClassVisitor cv, final boolean explicitSetupCall) { - super(Opcodes.ASM4, cv); + super(Opcodes.ASM5, cv); myExplicitSetupCall = explicitSetupCall; } @@ -307,7 +307,7 @@ public class AsmCodeGenerator { if (haveCustomCreateComponents && myHaveCreateComponentsMethod) { generator.visitVarInsn(Opcodes.ALOAD, 0); int opcode = myCreateComponentsAccess == Opcodes.ACC_PRIVATE ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL; - generator.visitMethodInsn(opcode, myClassName, CREATE_COMPONENTS_METHOD_NAME, "()V"); + generator.visitMethodInsn(opcode, myClassName, CREATE_COMPONENTS_METHOD_NAME, "()V", false); } buildSetupMethod(generator); @@ -902,7 +902,7 @@ public class AsmCodeGenerator { private boolean mySuperCalled = false; public FormConstructorVisitor(final MethodVisitor mv, final String className, final String superName) { - super(Opcodes.ASM4, mv); + super(Opcodes.ASM5, mv); myClassName = className; mySuperName = superName; } @@ -914,7 +914,7 @@ public class AsmCodeGenerator { super.visitFieldInsn(opcode, owner, name, desc); } - public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { + public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, boolean itf) { if (opcode == Opcodes.INVOKESPECIAL && name.equals(CONSTRUCTOR_NAME)) { if (owner.equals(myClassName)) { callsSelfConstructor = true; @@ -929,7 +929,7 @@ public class AsmCodeGenerator { else if (mySuperCalled) { callSetupUI(); } - super.visitMethodInsn(opcode, owner, name, desc); + super.visitMethodInsn(opcode, owner, name, desc, itf); } public void visitJumpInsn(final int opcode, final Label label) { @@ -942,7 +942,7 @@ public class AsmCodeGenerator { private void callSetupUI() { if (!mySetupCalled) { mv.visitVarInsn(Opcodes.ALOAD, 0); - mv.visitMethodInsn(Opcodes.INVOKESPECIAL, myClassName, SETUP_METHOD_NAME, "()V"); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, myClassName, SETUP_METHOD_NAME, "()V", false); mySetupCalled = true; } } @@ -959,7 +959,7 @@ public class AsmCodeGenerator { private boolean myExplicitSetupCall = false; public FirstPassClassVisitor() { - super(Opcodes.ASM4, new ClassVisitor(Opcodes.ASM4){}); + super(Opcodes.ASM5, new ClassVisitor(Opcodes.ASM5){}); } public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { @@ -975,10 +975,10 @@ public class AsmCodeGenerator { private class FirstPassConstructorVisitor extends MethodVisitor { public FirstPassConstructorVisitor() { - super(Opcodes.ASM4, new MethodVisitor(Opcodes.ASM4){}); + super(Opcodes.ASM5, new MethodVisitor(Opcodes.ASM5){}); } - public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (name.equals(SETUP_METHOD_NAME)) { myExplicitSetupCall = true; } diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/CardLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/CardLayoutCodeGenerator.java index 86b6e42c09b2..7dc880559e17 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/CardLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/CardLayoutCodeGenerator.java @@ -17,9 +17,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.lw.LwComponent; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ColorPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ColorPropertyCodeGenerator.java index 8443020bfc37..6e0161c2edff 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ColorPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ColorPropertyCodeGenerator.java @@ -16,9 +16,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.ColorDescriptor; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/DimensionPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/DimensionPropertyCodeGenerator.java index 7a0fd4f9ec86..632c4ef4008b 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/DimensionPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/DimensionPropertyCodeGenerator.java @@ -15,9 +15,9 @@ */ package com.intellij.uiDesigner.compiler; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/EnumPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/EnumPropertyCodeGenerator.java index 720d4c01582b..27d354c6898e 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/EnumPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/EnumPropertyCodeGenerator.java @@ -16,8 +16,8 @@ package com.intellij.uiDesigner.compiler; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; /** * @author yole diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FlowLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FlowLayoutCodeGenerator.java index 34a41d89eb22..a2448632656c 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FlowLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FlowLayoutCodeGenerator.java @@ -18,9 +18,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FontPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FontPropertyCodeGenerator.java index f15a8d4c314f..a8306b91d6d4 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FontPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FontPropertyCodeGenerator.java @@ -19,9 +19,9 @@ import com.intellij.compiler.instrumentation.InstrumentationClassFinder; import com.intellij.uiDesigner.lw.FontDescriptor; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwIntrospectedProperty; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FormLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FormLayoutCodeGenerator.java index a30061f0c784..f83d2d54d15b 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FormLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/FormLayoutCodeGenerator.java @@ -21,10 +21,10 @@ import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; -import org.jetbrains.asm4.Opcodes; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Opcodes; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridBagLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridBagLayoutCodeGenerator.java index 711d2c44726e..2435e902e5c5 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridBagLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridBagLayoutCodeGenerator.java @@ -18,9 +18,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.core.Spacer; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridLayoutCodeGenerator.java index 954f166bb42e..86839ec49203 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/GridLayoutCodeGenerator.java @@ -19,9 +19,9 @@ import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; /** * @author yole diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/IconPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/IconPropertyCodeGenerator.java index c435704a0144..d966a6838b2d 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/IconPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/IconPropertyCodeGenerator.java @@ -16,9 +16,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.IconDescriptor; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/InsetsPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/InsetsPropertyCodeGenerator.java index fb516ca430b3..347eb205a849 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/InsetsPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/InsetsPropertyCodeGenerator.java @@ -15,9 +15,9 @@ */ package com.intellij.uiDesigner.compiler; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/LayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/LayoutCodeGenerator.java index f5d2594c3b99..e3e4e7953ff8 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/LayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/LayoutCodeGenerator.java @@ -17,10 +17,10 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; -import org.jetbrains.asm4.Opcodes; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Opcodes; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ListModelPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ListModelPropertyCodeGenerator.java index 93ed130f6fbb..01c14d9782c6 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ListModelPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ListModelPropertyCodeGenerator.java @@ -16,9 +16,9 @@ package com.intellij.uiDesigner.compiler; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; /** * @author yole diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/PropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/PropertyCodeGenerator.java index b3c1aeb94d87..16cb0790f8f6 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/PropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/PropertyCodeGenerator.java @@ -18,7 +18,7 @@ package com.intellij.uiDesigner.compiler; import com.intellij.compiler.instrumentation.InstrumentationClassFinder; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwIntrospectedProperty; -import org.jetbrains.asm4.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; import java.io.IOException; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/RectanglePropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/RectanglePropertyCodeGenerator.java index fb86b0833ddf..2a559d6747b6 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/RectanglePropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/RectanglePropertyCodeGenerator.java @@ -15,9 +15,9 @@ */ package com.intellij.uiDesigner.compiler; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import java.awt.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ScrollPaneLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ScrollPaneLayoutCodeGenerator.java index 68725007cf43..061308c51c83 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ScrollPaneLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ScrollPaneLayoutCodeGenerator.java @@ -17,9 +17,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SimpleLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SimpleLayoutCodeGenerator.java index 5836b6ca29d7..388fa192605f 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SimpleLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SimpleLayoutCodeGenerator.java @@ -18,9 +18,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwContainer; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; /** * Layout code generator shared between BorderLayout and CardLayout. diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SplitPaneLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SplitPaneLayoutCodeGenerator.java index 28533f4776b4..765815682311 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SplitPaneLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/SplitPaneLayoutCodeGenerator.java @@ -17,9 +17,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwSplitPane; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/StringPropertyCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/StringPropertyCodeGenerator.java index 4438fd0c4f76..94dffc379ed0 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/StringPropertyCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/StringPropertyCodeGenerator.java @@ -20,12 +20,12 @@ import com.intellij.uiDesigner.core.SupportCode; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwIntrospectedProperty; import com.intellij.uiDesigner.lw.StringDescriptor; -import org.jetbrains.asm4.Label; -import org.jetbrains.asm4.MethodVisitor; -import org.jetbrains.asm4.Opcodes; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Label; +import org.jetbrains.org.objectweb.asm.MethodVisitor; +import org.jetbrains.org.objectweb.asm.Opcodes; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; import java.io.IOException; @@ -164,7 +164,7 @@ public class StringPropertyCodeGenerator extends PropertyCodeGenerator implement mv.visitCode(); mv.visitTypeInsn(NEW, "java/lang/StringBuffer"); mv.visitInsn(DUP); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "()V"); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "()V", false); mv.visitVarInsn(ASTORE, 3); mv.visitInsn(ICONST_0); mv.visitVarInsn(ISTORE, 4); @@ -178,19 +178,19 @@ public class StringPropertyCodeGenerator extends PropertyCodeGenerator implement mv.visitLabel(l0); mv.visitVarInsn(ILOAD, 7); mv.visitVarInsn(ALOAD, 2); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I", false); Label l1 = new Label(); mv.visitJumpInsn(IF_ICMPGE, l1); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ILOAD, 7); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C", false); mv.visitIntInsn(BIPUSH, 38); Label l2 = new Label(); mv.visitJumpInsn(IF_ICMPNE, l2); mv.visitIincInsn(7, 1); mv.visitVarInsn(ILOAD, 7); mv.visitVarInsn(ALOAD, 2); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I", false); Label l3 = new Label(); mv.visitJumpInsn(IF_ICMPNE, l3); mv.visitJumpInsn(GOTO, l1); @@ -199,42 +199,42 @@ public class StringPropertyCodeGenerator extends PropertyCodeGenerator implement mv.visitJumpInsn(IFNE, l2); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ILOAD, 7); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C", false); mv.visitIntInsn(BIPUSH, 38); mv.visitJumpInsn(IF_ICMPEQ, l2); mv.visitInsn(ICONST_1); mv.visitVarInsn(ISTORE, 4); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ILOAD, 7); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C", false); mv.visitVarInsn(ISTORE, 5); mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "length", "()I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "length", "()I", false); mv.visitVarInsn(ISTORE, 6); mv.visitLabel(l2); mv.visitVarInsn(ALOAD, 3); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ILOAD, 7); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(C)Ljava/lang/StringBuffer;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(C)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitIincInsn(7, 1); mv.visitJumpInsn(GOTO, l0); mv.visitLabel(l1); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "toString", "()Ljava/lang/String;"); - mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, "setText", "(Ljava/lang/String;)V"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "toString", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, "setText", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ILOAD, 4); Label l4 = new Label(); mv.visitJumpInsn(IFEQ, l4); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ILOAD, 5); - mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, setMnemonicMethodName, "(C)V"); + mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, setMnemonicMethodName, "(C)V", false); if (myHaveSetDisplayedMnemonicIndex) { mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ILOAD, 6); - mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, "setDisplayedMnemonicIndex", "(I)V"); + mv.visitMethodInsn(INVOKEVIRTUAL, componentClass, "setDisplayedMnemonicIndex", "(I)V", false); } mv.visitLabel(l4); mv.visitInsn(RETURN); diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/TabbedPaneLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/TabbedPaneLayoutCodeGenerator.java index ee867bf21a56..94d6093b05cd 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/TabbedPaneLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/TabbedPaneLayoutCodeGenerator.java @@ -17,9 +17,9 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; import com.intellij.uiDesigner.lw.LwTabbedPane; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.Type; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; import javax.swing.*; diff --git a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ToolBarLayoutCodeGenerator.java b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ToolBarLayoutCodeGenerator.java index b90a778cbed9..53feecc7d09e 100644 --- a/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ToolBarLayoutCodeGenerator.java +++ b/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/ToolBarLayoutCodeGenerator.java @@ -17,8 +17,8 @@ package com.intellij.uiDesigner.compiler; import com.intellij.uiDesigner.lw.LwComponent; -import org.jetbrains.asm4.commons.GeneratorAdapter; -import org.jetbrains.asm4.commons.Method; +import org.jetbrains.org.objectweb.asm.commons.GeneratorAdapter; +import org.jetbrains.org.objectweb.asm.commons.Method; /** * @author yole diff --git a/java/compiler/impl/compiler-impl.iml b/java/compiler/impl/compiler-impl.iml index 8a42f6d5b8ab..08d3ca179fc0 100644 --- a/java/compiler/impl/compiler-impl.iml +++ b/java/compiler/impl/compiler-impl.iml @@ -16,7 +16,7 @@ <orderEntry type="library" name="Trove4j" level="project" /> <orderEntry type="module" module-name="java-runtime" /> <orderEntry type="module" module-name="instrumentation-util" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> <orderEntry type="library" name="Eclipse" level="project" /> <orderEntry type="module" module-name="platform-api" /> <orderEntry type="module" module-name="lang-impl" /> diff --git a/java/compiler/impl/src/com/intellij/compiler/PsiClassWriter.java b/java/compiler/impl/src/com/intellij/compiler/PsiClassWriter.java index 61d1e05e6663..ce315be023ad 100644 --- a/java/compiler/impl/src/com/intellij/compiler/PsiClassWriter.java +++ b/java/compiler/impl/src/com/intellij/compiler/PsiClassWriter.java @@ -27,7 +27,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiManager; import com.intellij.psi.util.ClassUtil; import org.jetbrains.annotations.NonNls; -import org.jetbrains.asm4.ClassWriter; +import org.jetbrains.org.objectweb.asm.ClassWriter; /** * @author yole diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java index c7596e5cbaa4..f0c390d31459 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java @@ -19,7 +19,6 @@ import com.intellij.history.LocalHistory; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompileStatusNotification; @@ -31,7 +30,9 @@ public class CompileProjectAction extends CompileActionBase { protected void doAction(DataContext dataContext, final Project project) { CompilerManager.getInstance(project).rebuild(new CompileStatusNotification() { public void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { - if (aborted) return; + if (aborted || project.isDisposed()) { + return; + } String text = getTemplatePresentation().getText(); LocalHistory.getInstance().putSystemLabel(project, errors == 0 diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java index 5a8539629fb5..d96d6dfe0f83 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java @@ -40,7 +40,7 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { private final static int FILTER_RATIO = 10; @Override - public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) { + public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result) { if (parameters.getInvocationCount() >= INVOCATIONS_THRESHOLD && ClassFilesIndexFeaturesHolder.getInstance(parameters.getPosition().getProject()) .enableFeatureIfNeed(ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION)) { diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java index 6c6897a21665..16c7f309a6f4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java @@ -15,14 +15,11 @@ */ package com.intellij.compiler.classFilesIndex.chainsSearch.context; -import com.intellij.psi.*; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.psi.PsiArrayType; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiClassType; +import com.intellij.psi.PsiType; import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.Type; - -import java.util.Collections; -import java.util.List; -import java.util.Map; /** * @author Dmitry Batkovich diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java index 17e2dfed1dee..c9e9ce31020a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -24,6 +24,7 @@ package com.intellij.compiler.impl; import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerMessageImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; +import com.intellij.compiler.ProblemsView; import com.intellij.compiler.progress.CompilerTask; import com.intellij.execution.impl.ExecutionManagerImpl; import com.intellij.openapi.application.ApplicationManager; @@ -156,7 +157,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon myTask.addMessage(msg); } if (myShouldUpdateProblemsView && msg.getCategory() == CompilerMessageCategory.ERROR) { - ProblemsViewImpl.SERVICE.getInstance(myProject).addMessage(msg, mySessionId); + ProblemsView.SERVICE.getInstance(myProject).addMessage(msg, mySessionId); } } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index f50fa0ad68bb..46584ef9c8bf 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -261,7 +261,7 @@ public class CompileDriver { @Override public void sessionTerminated(final UUID sessionId) { if (compileContext.shouldUpdateProblemsView()) { - final ProblemsView view = ProblemsViewImpl.SERVICE.getInstance(myProject); + final ProblemsView view = ProblemsView.SERVICE.getInstance(myProject); view.clearProgress(); view.clearOldMessages(compileContext.getCompileScope(), compileContext.getSessionId()); } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java index 216f03b750d6..68dce61619cb 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java @@ -157,9 +157,10 @@ public class ProblemsViewImpl extends ProblemsView{ ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - final ToolWindowManager twManager = ToolWindowManager.getInstance(myProject); - final ToolWindow tw = twManager.getToolWindow(PROBLEMS_TOOLWINDOW_ID); - tw.setIcon(active ? myActiveIcon : myPassiveIcon); + final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(PROBLEMS_TOOLWINDOW_ID); + if (tw != null) { + tw.setIcon(active ? myActiveIcon : myPassiveIcon); + } } }, myProject.getDisposed()); } diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 710baf36f29b..395a7a711398 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,15 +120,18 @@ public class CompilerTask extends Task.Backgroundable { mySessionId = sessionId; } + @Override public String getProcessId() { return "compilation"; } + @NotNull @Override public DumbModeAction getDumbModeAction() { return DumbModeAction.WAIT; } + @Override public boolean shouldStartInBackground() { return true; } @@ -137,6 +140,7 @@ public class CompilerTask extends Task.Backgroundable { return myIndicator; } + @Override @Nullable public NotificationInfo getNotificationInfo() { return new NotificationInfo(myErrorCount > 0? "Compiler (errors)" : "Compiler (success)", "Compilation Finished", myErrorCount + " Errors, " + myWarningCount + " Warnings", true); @@ -144,6 +148,7 @@ public class CompilerTask extends Task.Backgroundable { private CloseListener myCloseListener; + @Override public void run(@NotNull final ProgressIndicator indicator) { myIndicator = indicator; @@ -197,6 +202,7 @@ public class CompilerTask extends Task.Backgroundable { } ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { final Project project = myProject; if (project == null || project.isDisposed()) { @@ -218,12 +224,14 @@ public class CompilerTask extends Task.Backgroundable { if (!(indicator instanceof ProgressIndicatorEx)) return; ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { + @Override public void cancel() { super.cancel(); closeUI(); stopAppIconProgress(); } + @Override public void stop() { super.stop(); if (!isCanceled()) { @@ -234,6 +242,7 @@ public class CompilerTask extends Task.Backgroundable { private void stopAppIconProgress() { UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override public void run() { AppIcon appIcon = AppIcon.getInstance(); if (appIcon.hideProgress(myProject, APP_ICON_ID)) { @@ -249,26 +258,31 @@ public class CompilerTask extends Task.Backgroundable { }); } + @Override public void setText(final String text) { super.setText(text); updateProgressText(); } + @Override public void setText2(final String text) { super.setText2(text); updateProgressText(); } + @Override public void setFraction(final double fraction) { super.setFraction(fraction); updateProgressText(); UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override public void run() { AppIcon.getInstance().setProgress(myProject, APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true); } }); } + @Override protected void onProgressChange() { prepareMessageView(); } @@ -301,6 +315,7 @@ public class CompilerTask extends Task.Backgroundable { final Window window = getWindow(); final ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL; ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (!myProject.isDisposed()) { openMessageView(); @@ -409,10 +424,12 @@ public class CompilerTask extends Task.Backgroundable { ); myErrorTreeView.setProcessController(new NewErrorTreeViewPanel.ProcessController() { + @Override public void stopProcess() { cancel(); } + @Override public boolean isProcessStopped() { return !myIndicator.isRunning(); } @@ -485,6 +502,7 @@ public class CompilerTask extends Task.Backgroundable { ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL; final Application application = ApplicationManager.getApplication(); application.invokeLater(new Runnable() { + @Override public void run() { synchronized (myMessageViewLock) { if (myErrorTreeView != null) { @@ -508,6 +526,7 @@ public class CompilerTask extends Task.Backgroundable { return null; } + @Override public boolean isHeadless() { return myHeadlessMode && !myForceAsyncExecution; } @@ -542,6 +561,7 @@ public class CompilerTask extends Task.Backgroundable { private boolean myIsApplicationExitingOrProjectClosing = false; private boolean myUserAcceptedCancel = false; + @Override public boolean canCloseProject(final Project project) { assert project != null; if (!project.equals(myProject)) { @@ -561,6 +581,7 @@ public class CompilerTask extends Task.Backgroundable { final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(CompilerTopics.COMPILATION_STATUS, new CompilationStatusAdapter() { + @Override public void compilationFinished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { connection.disconnect(); ProjectUtil.closeAndDispose(project); @@ -578,6 +599,7 @@ public class CompilerTask extends Task.Backgroundable { contentManager.addContentManagerListener(this); } + @Override public void contentRemoved(ContentManagerEvent event) { if (event.getContent() == myContent) { synchronized (myMessageViewLock) { @@ -598,6 +620,7 @@ public class CompilerTask extends Task.Backgroundable { } } + @Override public void contentRemoveQuery(ContentManagerEvent event) { if (event.getContent() == myContent) { if (!myIndicator.isCanceled() && shouldAskUser()) { @@ -620,15 +643,18 @@ public class CompilerTask extends Task.Backgroundable { return !myUserAcceptedCancel && !myIsApplicationExitingOrProjectClosing && myIndicator.isRunning(); } + @Override public void projectOpened(Project project) { } + @Override public void projectClosed(Project project) { if (project.equals(myProject) && myContent != null) { myContentManager.removeContent(myContent, true); } } + @Override public void projectClosing(Project project) { if (project.equals(myProject)) { myIsApplicationExitingOrProjectClosing = true; @@ -643,6 +669,7 @@ public class CompilerTask extends Task.Backgroundable { myDisplayName = displayName; } + @Override public String toString() { return myDisplayName; } diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index cb01abba6015..c32d9ecda313 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -611,7 +611,7 @@ public class BuildManager implements ApplicationComponent{ data = new ProjectData(new SequentialTaskExecutor(PooledThreadExecutor.INSTANCE)); myProjectDataMap.put(projectPath, data); } - if (isRebuild) { + if (isRebuild || (isAutomake && Registry.is("compiler.automake.force.fs.rescan", false))) { data.dropChanges(); } if (IS_UNIT_TEST_MODE) { diff --git a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java index 80c2aaf72fac..e4df975348d9 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.search.*; import com.intellij.util.SmartList; -import com.intellij.util.cls.ClsUtil; import com.intellij.util.concurrency.SequentialTaskExecutor; import io.netty.channel.Channel; import org.jetbrains.annotations.NotNull; @@ -38,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.ide.PooledThreadExecutor; import org.jetbrains.jps.api.CmdlineProtoUtil; import org.jetbrains.jps.api.CmdlineRemoteProto; +import org.jetbrains.org.objectweb.asm.Opcodes; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -177,7 +177,7 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { } else { for (final PsiField changedField : changedFields) { - if (!accessChanged && ClsUtil.isPrivate(accessFlags)) { + if (!accessChanged && isPrivate(accessFlags)) { // optimization: don't need to search, cause may be used only in this class continue; } @@ -291,7 +291,7 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { private SearchScope getSearchScope(PsiClass aClass, int fieldAccessFlags) { SearchScope searchScope = GlobalSearchScope.projectScope(myProject); - if (aClass != null && ClsUtil.isPackageLocal(fieldAccessFlags)) { + if (aClass != null && isPackageLocal(fieldAccessFlags)) { final PsiFile containingFile = aClass.getContainingFile(); if (containingFile instanceof PsiJavaFile) { final String packageName = ((PsiJavaFile)containingFile).getPackageName(); @@ -308,7 +308,7 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { private static boolean processIdentifiers(PsiSearchHelper helper, @NotNull final PsiElementProcessor<PsiIdentifier> processor, @NotNull final String identifier, @NotNull SearchScope searchScope, short searchContext) { TextOccurenceProcessor processor1 = new TextOccurenceProcessor() { @Override - public boolean execute(PsiElement element, int offsetInElement) { + public boolean execute(@NotNull PsiElement element, int offsetInElement) { return !(element instanceof PsiIdentifier) || processor.execute((PsiIdentifier)element); } }; @@ -386,4 +386,11 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { return null; } + private static boolean isPackageLocal(int flags) { + return (Opcodes.ACC_PUBLIC & flags) == 0 && (Opcodes.ACC_PROTECTED & flags) == 0 && (Opcodes.ACC_PRIVATE & flags) == 0; + } + + private static boolean isPrivate(int flags) { + return (Opcodes.ACC_PRIVATE & flags) != 0; + } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java index 39f9ec7936a6..3547d3847c25 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.ProjectLoadingErrorsNotifier; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; -import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser; import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.packaging.artifacts.*; @@ -67,12 +67,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo private final DefaultPackagingElementResolvingContext myResolvingContext; private boolean myInsideCommit = false; private boolean myLoaded; - private long myModificationCount; - private final ModificationTracker myModificationTracker = new ModificationTracker() { - public long getModificationCount() { - return myModificationCount; - } - }; + private final SimpleModificationTracker myModificationTracker = new SimpleModificationTracker(); private final Map<String, LocalFileSystem.WatchRequest> myWatchedOutputs = new HashMap<String, LocalFileSystem.WatchRequest>(); public ArtifactManagerImpl(Project project) { @@ -355,7 +350,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo } myModel.setArtifactsList(allArtifacts); - myModificationCount++; + myModificationTracker.incModificationCount(); final ArtifactListener publisher = myProject.getMessageBus().syncPublisher(TOPIC); hasChanges = !removed.isEmpty() || !added.isEmpty() || !changed.isEmpty(); ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() { @@ -389,7 +384,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo @NotNull public Artifact addArtifact(@NotNull final String name, @NotNull final ArtifactType type, final CompositePackagingElement<?> root) { return new WriteAction<Artifact>() { - protected void run(final Result<Artifact> result) { + protected void run(@NotNull final Result<Artifact> result) { final ModifiableArtifactModel model = createModifiableModel(); final ModifiableArtifact artifact = model.addArtifact(name, type); if (root != null) { @@ -413,7 +408,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo final CompositePackagingElement<?> root = model.getOrCreateModifiableArtifact(artifact).getRootElement(); PackagingElementFactory.getInstance().getOrCreateDirectory(root, relativePath).addOrFindChildren(elements); new WriteAction() { - protected void run(final Result result) { + protected void run(@NotNull final Result result) { model.commit(); } }.execute(); diff --git a/java/compiler/instrumentation-util/instrumentation-util.iml b/java/compiler/instrumentation-util/instrumentation-util.iml index 370070ea380b..5e45b771a830 100644 --- a/java/compiler/instrumentation-util/instrumentation-util.iml +++ b/java/compiler/instrumentation-util/instrumentation-util.iml @@ -7,7 +7,7 @@ </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> </component> </module> diff --git a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java index 3716f4d540ef..02f4ffcd5f37 100644 --- a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java +++ b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java @@ -1,9 +1,9 @@ package com.intellij.compiler.instrumentation; -import org.jetbrains.asm4.ClassReader; -import org.jetbrains.asm4.ClassVisitor; -import org.jetbrains.asm4.MethodVisitor; -import org.jetbrains.asm4.Opcodes; +import org.jetbrains.org.objectweb.asm.ClassReader; +import org.jetbrains.org.objectweb.asm.ClassVisitor; +import org.jetbrains.org.objectweb.asm.MethodVisitor; +import org.jetbrains.org.objectweb.asm.Opcodes; import sun.misc.Resource; import java.io.*; @@ -415,7 +415,7 @@ public class InstrumentationClassFinder { private final List<PseudoMethod> myMethods = new ArrayList<PseudoMethod>(); private V() { - super(Opcodes.ASM4); + super(Opcodes.ASM5); } public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { diff --git a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumenterClassWriter.java b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumenterClassWriter.java index b2f93c5e4603..0d1ec34ea176 100644 --- a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumenterClassWriter.java +++ b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumenterClassWriter.java @@ -1,6 +1,6 @@ package com.intellij.compiler.instrumentation; -import org.jetbrains.asm4.ClassWriter; +import org.jetbrains.org.objectweb.asm.ClassWriter; /** * @author Eugene Zhuravlev diff --git a/java/compiler/instrumentation-util/src/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenter.java b/java/compiler/instrumentation-util/src/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenter.java index af36e512dd26..3bc0dc093fc8 100644 --- a/java/compiler/instrumentation-util/src/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenter.java +++ b/java/compiler/instrumentation-util/src/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenter.java @@ -15,7 +15,7 @@ */ package com.intellij.compiler.notNullVerification; -import org.jetbrains.asm4.*; +import org.jetbrains.org.objectweb.asm.*; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -50,7 +50,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode private RuntimeException myPostponedError; private NotNullVerifyingInstrumenter(final ClassVisitor classVisitor, ClassReader reader) { - super(Opcodes.ASM4, classVisitor); + super(Opcodes.ASM5, classVisitor); myMethodParamNames = getAllParameterNames(reader); } @@ -63,7 +63,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode private static Map<String, Map<Integer, String>> getAllParameterNames(ClassReader reader) { final Map<String, Map<Integer, String>> methodParamNames = new LinkedHashMap<String, Map<Integer, String>>(); - reader.accept(new ClassVisitor(Opcodes.ASM4) { + reader.accept(new ClassVisitor(Opcodes.ASM5) { private String myClassName = null; public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { @@ -106,7 +106,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode final Type returnType = Type.getReturnType(desc); final MethodVisitor v = cv.visitMethod(access, name, desc, signature, exceptions); final Map<Integer, String> paramNames = myMethodParamNames.get(myClassName + '.' + name + desc); - return new MethodVisitor(Opcodes.ASM4, v) { + return new MethodVisitor(Opcodes.ASM5, v) { private final List<Integer> myNotNullParams = new ArrayList<Integer>(); private int mySyntheticCount = 0; @@ -118,7 +118,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode AnnotationVisitor av = mv.visitParameterAnnotation(parameter, anno, visible); if (isReferenceType(args[parameter]) && anno.equals(NOT_NULL_TYPE)) { myNotNullParams.add(new Integer(parameter)); - av = new AnnotationVisitor(Opcodes.ASM4, av) { + av = new AnnotationVisitor(Opcodes.ASM5, av) { @Override public void visit(String methodName, Object o) { if(ANNOTATION_DEFAULT_METHOD.equals(methodName)) { @@ -144,7 +144,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode AnnotationVisitor av = mv.visitAnnotation(anno, isRuntime); if (isReferenceType(returnType) && anno.equals(NOT_NULL_TYPE)) { myIsNotNull = true; - av = new AnnotationVisitor(Opcodes.ASM4, av) { + av = new AnnotationVisitor(Opcodes.ASM5, av) { @Override public void visit(String methodName, Object o) { if(ANNOTATION_DEFAULT_METHOD.equals(methodName)) { @@ -229,9 +229,9 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode } //noinspection SpellCheckingInspection - mv.visitMethodInsn(INVOKESTATIC, STRING_CLASS_NAME, "format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;"); + mv.visitMethodInsn(INVOKESTATIC, STRING_CLASS_NAME, "format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false); - mv.visitMethodInsn(INVOKESPECIAL, exceptionClass, CONSTRUCTOR_NAME, EXCEPTION_INIT_SIGNATURE); + mv.visitMethodInsn(INVOKESPECIAL, exceptionClass, CONSTRUCTOR_NAME, EXCEPTION_INIT_SIGNATURE, false); mv.visitInsn(ATHROW); mv.visitLabel(end); diff --git a/java/compiler/javac2/javac2.iml b/java/compiler/javac2/javac2.iml index c44096e70df1..f41cc0db6970 100644 --- a/java/compiler/javac2/javac2.iml +++ b/java/compiler/javac2/javac2.iml @@ -10,7 +10,7 @@ <orderEntry type="library" name="Ant" level="project" /> <orderEntry type="module" module-name="forms-compiler" /> <orderEntry type="module" module-name="forms_rt" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> <orderEntry type="module" module-name="instrumentation-util" /> </component> <component name="copyright"> diff --git a/java/compiler/javac2/src/com/intellij/ant/Javac2.java b/java/compiler/javac2/src/com/intellij/ant/Javac2.java index cc8ab2c5ae2e..88095a9cdc36 100644 --- a/java/compiler/javac2/src/com/intellij/ant/Javac2.java +++ b/java/compiler/javac2/src/com/intellij/ant/Javac2.java @@ -25,10 +25,10 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.types.Path; -import org.jetbrains.asm4.ClassReader; -import org.jetbrains.asm4.ClassVisitor; -import org.jetbrains.asm4.ClassWriter; -import org.jetbrains.asm4.Opcodes; +import org.jetbrains.org.objectweb.asm.ClassReader; +import org.jetbrains.org.objectweb.asm.ClassVisitor; +import org.jetbrains.org.objectweb.asm.ClassWriter; +import org.jetbrains.org.objectweb.asm.Opcodes; import java.io.*; import java.net.MalformedURLException; @@ -462,7 +462,7 @@ public class Javac2 extends Javac { private static int getClassFileVersion(ClassReader reader) { final int[] classfileVersion = new int[1]; - reader.accept(new ClassVisitor(Opcodes.ASM4) { + reader.accept(new ClassVisitor(Opcodes.ASM5) { public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { classfileVersion[0] = version; } diff --git a/java/debugger/impl/src/com/intellij/debugger/InstanceFilter.java b/java/debugger/impl/src/com/intellij/debugger/InstanceFilter.java index 09be13076ca1..58134d49a138 100644 --- a/java/debugger/impl/src/com/intellij/debugger/InstanceFilter.java +++ b/java/debugger/impl/src/com/intellij/debugger/InstanceFilter.java @@ -94,4 +94,24 @@ public class InstanceFilter implements JDOMExternalizable{ } return cFilters; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + InstanceFilter filter = (InstanceFilter)o; + + if (ID != filter.ID) return false; + if (ENABLED != filter.ENABLED) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (int)(ID ^ (ID >>> 32)); + result = 31 * result + (ENABLED ? 1 : 0); + return result; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java index d2216191903a..86ddfaa5fc08 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java @@ -123,14 +123,14 @@ public abstract class DebuggerAction extends AnAction { return true; } }; - //listener.installOn(tree); + listener.installOn(tree); final AnAction action = ActionManager.getInstance().getAction(actionName); action.registerCustomShortcutSet(CommonShortcuts.getEditSource(), tree); return new Disposable() { public void dispose() { - //listener.uninstall(tree); + listener.uninstall(tree); action.unregisterCustomShortcutSet(tree); } }; diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/GotoFrameSourceAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/GotoFrameSourceAction.java index 01e214091308..e127596ec3b5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/GotoFrameSourceAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/GotoFrameSourceAction.java @@ -15,13 +15,12 @@ */ package com.intellij.debugger.actions; -import com.intellij.debugger.impl.DebuggerContextUtil; +import com.intellij.debugger.SourcePosition; import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; /** @@ -38,7 +37,11 @@ public abstract class GotoFrameSourceAction extends DebuggerAction{ if(project == null) return; StackFrameDescriptorImpl stackFrameDescriptor = getStackFrameDescriptor(dataContext); if(stackFrameDescriptor != null) { - DebuggerContextUtil.setStackFrame(getContextManager(dataContext), stackFrameDescriptor.getFrameProxy()); + //DebuggerContextUtil.setStackFrame(getContextManager(dataContext), stackFrameDescriptor.getFrameProxy()); + SourcePosition sourcePosition = stackFrameDescriptor.getSourcePosition(); + if (sourcePosition != null) { + sourcePosition.navigate(true); + } } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java index 8904331bfaba..48efa9ac87dc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java @@ -80,7 +80,8 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { //noinspection unchecked final List<SmartStepTarget> targets = new OrderedSet<SmartStepTarget>(); - final Range<Integer> lines = new Range<Integer>(doc.getLineNumber(element.getTextOffset()), doc.getLineNumber(element.getTextOffset() + element.getTextLength())); + TextRange textRange = element.getTextRange(); + final Range<Integer> lines = new Range<Integer>(doc.getLineNumber(textRange.getStartOffset()), doc.getLineNumber(textRange.getEndOffset())); final PsiElementVisitor methodCollector = new JavaRecursiveElementVisitor() { final Stack<PsiMethod> myContextStack = new Stack<PsiMethod>(); diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java deleted file mode 100644 index a57211b60ead..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.engine.DebuggerUtils; -import com.intellij.debugger.ui.breakpoints.Breakpoint; -import com.intellij.debugger.ui.breakpoints.BreakpointManager; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; -import org.jetbrains.annotations.Nullable; - -public class ToggleBreakpointEnabledAction extends AnAction { - - public void actionPerformed(AnActionEvent e) { - final Project project = e.getData(CommonDataKeys.PROJECT); - Breakpoint breakpoint = findBreakpoint(project); - if (breakpoint != null) { - final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager(); - breakpointManager.setBreakpointEnabled(breakpoint, !breakpoint.isEnabled()); - } - } - - @Nullable - private static Breakpoint findBreakpoint(final Project project) { - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if(editor == null) { - return null; - } - BreakpointManager manager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager(); - int offset = editor.getCaretModel().getOffset(); - return manager.findBreakpoint(editor.getDocument(), offset, null); - } - - public void update(AnActionEvent event){ - final Presentation presentation = event.getPresentation(); - Project project = event.getData(CommonDataKeys.PROJECT); - if (project == null) { - presentation.setEnabled(false); - return; - } - - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (editor == null) { - presentation.setEnabled(false); - return; - } - PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); - if (file == null) { - presentation.setEnabled(false); - return; - } - - if (DebuggerUtils.isBreakpointAware(file)) { - Breakpoint breakpoint = findBreakpoint(project); - if (breakpoint == null) { - presentation.setEnabled(false); - return; - } - presentation.setEnabled(true); - } - else { - presentation.setEnabled(false); - } - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java index 45e2cef4b883..4d77dda4b0ad 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java @@ -17,6 +17,7 @@ package com.intellij.debugger.actions; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.EditorTextField; import com.intellij.xdebugger.impl.ui.TextViewer; import com.intellij.xdebugger.impl.ui.tree.actions.XFetchValueActionBase; @@ -33,7 +34,7 @@ public class ViewTextAction extends XFetchValueActionBase { protected void handle(Project project, String value) { final MyDialog dialog = new MyDialog(project); dialog.setTitle("View Text"); - dialog.setText(value); + dialog.setText(StringUtil.unquoteString(value)); dialog.show(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java b/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java index 1e3fa9bcd452..50fafaf563cc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java @@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable; * @author Eugene Zhuravlev * Date: 10/26/13 */ -public class BasicStepMethodFilter implements MethodFilter { +public class BasicStepMethodFilter implements NamedMethodFilter { @NotNull protected final JVMName myDeclaringClassName; @NotNull diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java index 127765ae9b1b..7e64da1a1bff 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java @@ -26,6 +26,7 @@ import com.intellij.util.ThreeState; import com.intellij.xdebugger.frame.XStackFrame; import com.sun.jdi.Location; import com.sun.jdi.ReferenceType; +import com.sun.jdi.VMDisconnectedException; import com.sun.jdi.request.ClassPrepareRequest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,6 +61,9 @@ public class CompoundPositionManager extends PositionManagerEx { } catch (NoDataException ignored) { } + catch (VMDisconnectedException e) { + throw e; + } catch (Exception e) { LOG.error(e); } @@ -79,6 +83,9 @@ public class CompoundPositionManager extends PositionManagerEx { } catch (NoDataException ignored) { } + catch (VMDisconnectedException e) { + throw e; + } catch (Exception e) { LOG.error(e); } @@ -98,6 +105,9 @@ public class CompoundPositionManager extends PositionManagerEx { } catch (NoDataException ignored) { } + catch (VMDisconnectedException e) { + throw e; + } catch (Exception e) { LOG.error(e); } @@ -116,6 +126,9 @@ public class CompoundPositionManager extends PositionManagerEx { } catch (NoDataException ignored) { } + catch (VMDisconnectedException e) { + throw e; + } catch (Exception e) { LOG.error(e); } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java index 2f41cb2288f1..1db0ed60774e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java @@ -40,6 +40,8 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Pair; +import com.intellij.xdebugger.XDebugSession; +import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.impl.XDebugSessionImpl; import com.sun.jdi.InternalException; import com.sun.jdi.ThreadReference; @@ -319,6 +321,12 @@ public class DebugProcessEvents extends DebugProcessImpl { myDebugProcessDispatcher.getMulticaster().processAttached(this); + // breakpoints should be initialized after all processAttached listeners work + XDebugSession session = getSession().getXDebugSession(); + if (session != null) { + session.initBreakpoints(); + } + final String addressDisplayName = DebuggerBundle.getAddressDisplayName(getConnection()); final String transportName = DebuggerBundle.getTransportName(getConnection()); showStatusText(DebuggerBundle.message("status.connected", addressDisplayName, transportName)); @@ -393,8 +401,8 @@ public class DebugProcessEvents extends DebugProcessImpl { getSuspendManager().voteSuspend(suspendContext); if (hint != null) { final MethodFilter methodFilter = hint.getMethodFilter(); - if (methodFilter instanceof BasicStepMethodFilter && !hint.wasStepTargetMethodMatched()) { - final String message = "Method <b>" + ((BasicStepMethodFilter)methodFilter).getMethodName() + "()</b> has not been called"; + if (methodFilter instanceof NamedMethodFilter && !hint.wasStepTargetMethodMatched()) { + final String message = "Method <b>" + ((NamedMethodFilter)methodFilter).getMethodName() + "()</b> has not been called"; XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project); } } @@ -451,7 +459,13 @@ public class DebugProcessEvents extends DebugProcessImpl { if (requestHit && requestor instanceof Breakpoint) { // if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy - myBreakpointManager.processBreakpointHit((Breakpoint)requestor); + XDebugSession session = getSession().getXDebugSession(); + if (session != null) { + XBreakpoint breakpoint = ((Breakpoint)requestor).getXBreakpoint(); + if (breakpoint != null) { + ((XDebugSessionImpl)session).processDependencies(breakpoint); + } + } } if(!requestHit || resumePreferred) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index f10491282d0e..613217f93ac2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -1157,7 +1157,12 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb public ArrayReference newInstance(final ArrayType arrayType, final int dimension) throws EvaluateException { - return arrayType.newInstance(dimension); + try { + return arrayType.newInstance(dimension); + } + catch (Exception e) { + throw EvaluateExceptionUtil.createEvaluateException(e); + } } @Override @@ -1264,7 +1269,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb // for this refType and the refType is not visible to the loader. // Attempt to evaluate method with this refType will yield ClassNotLoadedException. // The only way to say for sure whether the class is _visible_ to the given loader, is to use the following API call - return fromLoader == null || fromLoader.visibleClasses().contains(refType); + return fromLoader == null || fromLoader.equals(refType.classLoader()) || fromLoader.visibleClasses().contains(refType); } private static String reformatArrayName(String className) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java index 1050c99a34b1..ad2c881d1336 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java @@ -49,6 +49,8 @@ public class JavaBreakpointHandler extends XBreakpointHandler { if (javaBreakpoint != null) { final Breakpoint bpt = javaBreakpoint; BreakpointManager.addBreakpoint(bpt); + // must use invoke to stay in the current request, + // otherwise dependent breakpoints do not get enabled on not-suspending parents hit myProcess.getManagerThread().invoke(new DebuggerCommandImpl() { @Override protected void action() throws Exception { @@ -62,6 +64,7 @@ public class JavaBreakpointHandler extends XBreakpointHandler { public void unregisterBreakpoint(@NotNull final XBreakpoint breakpoint, boolean temporary) { final Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint); if (javaBreakpoint != null) { + // must use invoke to stay in the current request, see comment in registerBreakpoint myProcess.getManagerThread().invoke(new DebuggerCommandImpl() { @Override protected void action() throws Exception { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java index 166ec95e7aeb..37ee00b94eaf 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java @@ -54,6 +54,7 @@ import com.intellij.xdebugger.breakpoints.XBreakpointHandler; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.frame.XStackFrame; import com.intellij.xdebugger.frame.XValueMarkerProvider; +import com.intellij.xdebugger.impl.XDebugSessionImpl; import com.intellij.xdebugger.impl.XDebuggerUtilImpl; import com.intellij.xdebugger.impl.actions.XDebuggerActions; import com.intellij.xdebugger.ui.XDebugTabLayouter; @@ -114,7 +115,7 @@ public class JavaDebugProcess extends XDebugProcess { Breakpoint breakpoint = descriptors.get(0).getFirst(); XBreakpoint xBreakpoint = breakpoint.getXBreakpoint(); if (xBreakpoint != null) { - getSession().breakpointReached(xBreakpoint, null, context); + ((XDebugSessionImpl)getSession()).breakpointReachedNoProcessing(xBreakpoint, context); return; } } @@ -130,9 +131,10 @@ public class JavaDebugProcess extends XDebugProcess { myNodeManager = new NodeManagerImpl(session.getProject(), null) { @Override public DebuggerTreeNodeImpl createNode(final NodeDescriptor descriptor, EvaluationContext evaluationContext) { - ((NodeDescriptorImpl)descriptor).setContext((EvaluationContextImpl)evaluationContext); + // value gathered here is required for correct renderers work. e.g. array renderer + //((NodeDescriptorImpl)descriptor).setContext((EvaluationContextImpl)evaluationContext); final DebuggerTreeNodeImpl node = new DebuggerTreeNodeImpl(null, descriptor); - ((NodeDescriptorImpl)descriptor).updateRepresentation((EvaluationContextImpl)evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); + //((NodeDescriptorImpl)descriptor).updateRepresentation((EvaluationContextImpl)evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); return node; } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java index 4104000a0b27..e37576bae8f4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java @@ -20,7 +20,6 @@ import com.intellij.debugger.engine.evaluation.TextWithImportsImpl; import com.intellij.debugger.engine.events.DebuggerContextCommandImpl; import com.intellij.debugger.impl.EditorTextProvider; import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor; -import com.intellij.debugger.ui.tree.render.DescriptorLabelListener; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; @@ -61,6 +60,11 @@ public class JavaDebuggerEvaluator extends XDebuggerEvaluator { @Nullable XSourcePosition expressionPosition) { myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext()) { @Override + public Priority getPriority() { + return Priority.NORMAL; + } + + @Override public void threadAction() { WatchItemDescriptor descriptor = new WatchItemDescriptor(myDebugProcess.getProject(), TextWithImportsImpl.fromXExpression( expression)); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java index 5d8f50c2a594..793438ebbe05 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java @@ -18,6 +18,8 @@ package com.intellij.debugger.engine; import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.events.DebuggerCommandImpl; +import com.intellij.debugger.engine.events.DebuggerContextCommandImpl; +import com.intellij.debugger.engine.events.SuspendContextCommandImpl; import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadGroupReferenceProxyImpl; @@ -31,8 +33,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.ArrayList; -import java.util.List; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; /** * @author egor @@ -69,7 +72,7 @@ public class JavaExecutionStack extends XExecutionStack { } @NotNull - public ThreadReferenceProxyImpl getThreadProxy() { + ThreadReferenceProxyImpl getThreadProxy() { return myThreadProxy; } @@ -101,6 +104,11 @@ public class JavaExecutionStack extends XExecutionStack { else { myDebugProcess.getManagerThread().invokeAndWait(new DebuggerCommandImpl() { @Override + public Priority getPriority() { + return Priority.HIGH; + } + + @Override protected void action() throws Exception { myTopFrame = calcTopFrame(); } @@ -112,46 +120,81 @@ public class JavaExecutionStack extends XExecutionStack { @Override public void computeStackFrames(final int firstFrameIndex, final XStackFrameContainer container) { - myDebugProcess.getManagerThread().schedule(new DebuggerCommandImpl() { + myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext()) { + @Override + public Priority getPriority() { + return Priority.NORMAL; + } + @Override - protected void action() throws Exception { - boolean showLibraryStackframes = DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES; - List<JavaStackFrame> frames = new ArrayList<JavaStackFrame>(); + public void threadAction() { if (!myThreadProxy.isCollected() && myDebugProcess.getSuspendManager().isSuspended(myThreadProxy)) { int status = myThreadProxy.status(); if (!(status == ThreadReference.THREAD_STATUS_UNKNOWN) && !(status == ThreadReference.THREAD_STATUS_NOT_STARTED) && !(status == ThreadReference.THREAD_STATUS_ZOMBIE)) { try { - int framesToSkip = firstFrameIndex; - boolean first = true; - for (StackFrameProxyImpl stackFrame : myThreadProxy.frames()) { - if (first && framesToSkip > 0) { - framesToSkip--; - first = false; - continue; - } - JavaStackFrame frame = new JavaStackFrame(stackFrame, myDebugProcess, myTracker); - if (showLibraryStackframes || (!frame.getDescriptor().isSynthetic() && !frame.getDescriptor().isInLibraryContent())) { - if (framesToSkip > 0) { - framesToSkip--; - continue; - } - frames.add(frame); - } + int added = 0; + Iterator<StackFrameProxyImpl> iterator = myThreadProxy.frames().iterator(); + if (iterator.hasNext() && firstFrameIndex > 0) { + iterator.next(); + added++; } + myDebugProcess.getManagerThread().schedule(new AppendFrameCommand(getSuspendContext(), iterator, container, added, firstFrameIndex)); } catch (EvaluateException e) { container.errorOccurred(e.getMessage()); - return; } } } - container.addStackFrames(frames, true); + else { + container.errorOccurred(DebuggerBundle.message("frame.panel.frames.not.available")); + } } }); } + private class AppendFrameCommand extends SuspendContextCommandImpl { + private final Iterator<StackFrameProxyImpl> myStackFramesIterator; + private final XStackFrameContainer myContainer; + private int myAdded; + private final int mySkip; + + public AppendFrameCommand(SuspendContextImpl suspendContext, + Iterator<StackFrameProxyImpl> stackFramesIterator, + XStackFrameContainer container, + int added, + int skip) { + super(suspendContext); + myStackFramesIterator = stackFramesIterator; + myContainer = container; + myAdded = added; + mySkip = skip; + } + + @Override + public Priority getPriority() { + return myAdded <= 10 ? Priority.NORMAL : Priority.LOW; + } + + @Override + public void contextAction() throws Exception { + if (myStackFramesIterator.hasNext()) { + JavaStackFrame frame = new JavaStackFrame(myStackFramesIterator.next(), myDebugProcess, myTracker); + if (DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES || (!frame.getDescriptor().isSynthetic() && !frame.getDescriptor().isInLibraryContent())) { + if (++myAdded > mySkip) { + myContainer.addStackFrames(Arrays.asList(frame), false); + } + } + myDebugProcess.getManagerThread().schedule( + new AppendFrameCommand(getSuspendContext(), myStackFramesIterator, myContainer, myAdded, mySkip)); + } + else { + myContainer.addStackFrames(Collections.<JavaStackFrame>emptyList(), true); + } + } + } + private static String calcRepresentation(ThreadReferenceProxyImpl thread) { DebuggerManagerThreadImpl.assertIsManagerThread(); String name = thread.name(); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java index 316c49201e4c..ed4d8296c381 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java @@ -151,6 +151,11 @@ public class JavaStackFrame extends XStackFrame { } myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext()) { @Override + public Priority getPriority() { + return Priority.NORMAL; + } + + @Override public void threadAction() { XValueChildrenList children = new XValueChildrenList(); buildVariablesThreadAction(getFrameDebuggerContext(), children, node); @@ -202,8 +207,13 @@ public class JavaStackFrame extends XStackFrame { } } + DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); + if (debugProcess == null) { + return; + } + // add last method return value if any - final Pair<Method, Value> methodValuePair = debuggerContext.getDebugProcess().getLastExecutedMethod(); + final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod(); if (methodValuePair != null) { ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(stackDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond()); children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager)); @@ -222,11 +232,10 @@ public class JavaStackFrame extends XStackFrame { final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer(); if (classRenderer.SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) { - if (thisObjectReference != null && evaluationContext.getDebugProcess().getVirtualMachineProxy().canGetSyntheticAttribute()) { + if (thisObjectReference != null && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) { final ReferenceType thisRefType = thisObjectReference.referenceType(); if (thisRefType instanceof ClassType && thisRefType.equals(location.declaringType()) && thisRefType.name().contains("$")) { // makes sense for nested classes only final ClassType clsType = (ClassType)thisRefType; - final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); final VirtualMachineProxyImpl vm = debugProcess.getVirtualMachineProxy(); for (Field field : clsType.fields()) { if ((!vm.canGetSyntheticAttribute() || field.isSynthetic()) && StringUtil diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java index d1461961be00..6af021c0f9cc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java @@ -29,10 +29,7 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.ui.impl.DebuggerTreeRenderer; import com.intellij.debugger.ui.impl.watch.*; import com.intellij.debugger.ui.tree.*; -import com.intellij.debugger.ui.tree.render.ArrayRenderer; -import com.intellij.debugger.ui.tree.render.ChildrenBuilder; -import com.intellij.debugger.ui.tree.render.DescriptorLabelListener; -import com.intellij.debugger.ui.tree.render.NodeRenderer; +import com.intellij.debugger.ui.tree.render.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -69,17 +66,15 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { myNodeManager = nodeManager; } - private static JavaValue create(JavaValue parent, @NotNull ValueDescriptorImpl valueDescriptor, EvaluationContextImpl evaluationContext, NodeManagerImpl nodeManager) { + private static JavaValue create(JavaValue parent, @NotNull ValueDescriptorImpl valueDescriptor, EvaluationContextImpl evaluationContext, NodeManagerImpl nodeManager, boolean init) { DebuggerManagerThreadImpl.assertIsManagerThread(); - valueDescriptor.setContext(evaluationContext); - valueDescriptor.updateRepresentation(evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); return new JavaValue(parent, valueDescriptor, evaluationContext, nodeManager); } static JavaValue create(@NotNull ValueDescriptorImpl valueDescriptor, EvaluationContextImpl evaluationContext, NodeManagerImpl nodeManager) { - return create(null, valueDescriptor, evaluationContext, nodeManager); + return create(null, valueDescriptor, evaluationContext, nodeManager, true); } public JavaValue getParent() { @@ -100,38 +95,95 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { if (myEvaluationContext.getSuspendContext().isResumed()) return; myEvaluationContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(getDebuggerContext()) { @Override + public Priority getPriority() { + return Priority.NORMAL; + } + + @Override public void threadAction() { - Icon nodeIcon = DebuggerTreeRenderer.getValueIcon(myValueDescriptor); - final String[] strings = splitValue(myValueDescriptor.getValueLabel()); - String value = StringUtil.notNullize(strings[1]); - XValuePresentation presentation = new XRegularValuePresentation(value, strings[0]); - if (myValueDescriptor.isString()) { - presentation = new TypedStringValuePresentation(StringUtil.unquoteString(value), strings[0]); - } - if (value.length() > XValueNode.MAX_VALUE_LENGTH) { - node.setFullValueEvaluator(new XFullValueEvaluator() { - @Override - public void startEvaluation(@NotNull final XFullValueEvaluationCallback callback) { - myEvaluationContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(getDebuggerContext()) { + myValueDescriptor.setContext(myEvaluationContext); + myValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() { + @Override + public void labelChanged() { + Icon nodeIcon = DebuggerTreeRenderer.getValueIcon(myValueDescriptor); + final String[] strings = splitValue(myValueDescriptor.getValueLabel()); + final String value = StringUtil.notNullize(strings[1]); + String type = strings[0]; + XValuePresentation presentation; + if (myValueDescriptor.isString()) { + presentation = new TypedStringValuePresentation(StringUtil.unquoteString(value), type); + } + else { + EvaluateException exception = myValueDescriptor.getEvaluateException(); + if (myValueDescriptor.getLastRenderer() instanceof ToStringRenderer && exception == null) { + presentation = new XRegularValuePresentation(StringUtil.wrapWithDoubleQuote(value), type); + } + else { + presentation = new JavaValuePresentation(value, type, exception != null ? exception.getMessage() : null); + } + } + if (value.length() > XValueNode.MAX_VALUE_LENGTH) { + node.setFullValueEvaluator(new XFullValueEvaluator() { @Override - public void threadAction() { - final String valueAsString = DebuggerUtilsEx.getValueOrErrorAsString(myEvaluationContext, myValueDescriptor.getValue()); - DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { + public void startEvaluation(@NotNull final XFullValueEvaluationCallback callback) { + myEvaluationContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(getDebuggerContext()) { + @Override + public Priority getPriority() { + return Priority.NORMAL; + } + @Override - public void run() { - callback.evaluated(valueAsString); + public void threadAction() { + final String valueAsString = DebuggerUtilsEx.getValueOrErrorAsString(myEvaluationContext, myValueDescriptor.getValue()); + DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { + @Override + public void run() { + callback.evaluated(valueAsString); + } + }); } }); } }); } - }); - } - node.setPresentation(nodeIcon, presentation, myValueDescriptor.isExpandable()); + node.setPresentation(nodeIcon, presentation, myValueDescriptor.isExpandable()); + } + }); } }); } + private static class JavaValuePresentation extends XValuePresentation { + private final String myValue; + private final String myType; + private final String myError; + + public JavaValuePresentation(@NotNull String value, @Nullable String type, @Nullable String error) { + myValue = value; + myType = type; + myError = error; + } + + @Nullable + @Override + public String getType() { + return myType; + } + + @Override + public void renderValue(@NotNull XValueTextRenderer renderer) { + if (myError != null) { + if (myValue.endsWith(myError)) { + renderer.renderValue(myValue.substring(0, myValue.length() - myError.length())); + } + renderer.renderError(myError); + } + else { + renderer.renderValue(myValue); + } + } + } + String getValueString() { return splitValue(myValueDescriptor.getValueLabel())[1]; } @@ -168,6 +220,11 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { if (myEvaluationContext.getSuspendContext().isResumed()) return; myEvaluationContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) { @Override + public Priority getPriority() { + return Priority.NORMAL; + } + + @Override public void contextAction() throws Exception { final XValueChildrenList children = new XValueChildrenList(); final NodeRenderer renderer = myValueDescriptor.getRenderer(myEvaluationContext.getDebugProcess()); @@ -205,7 +262,8 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { for (DebuggerTreeNode node : nodes) { final NodeDescriptor descriptor = node.getDescriptor(); if (descriptor instanceof ValueDescriptorImpl) { - children.add(create(JavaValue.this, (ValueDescriptorImpl)descriptor, myEvaluationContext, myNodeManager)); + // Value is calculated already in NodeManagerImpl + children.add(create(JavaValue.this, (ValueDescriptorImpl)descriptor, myEvaluationContext, myNodeManager, false)); } else if (descriptor instanceof MessageDescriptor) { children.add("", new XValue() { @@ -272,6 +330,11 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess(); debugProcess.getManagerThread().schedule(new JumpToObjectAction.NavigateCommand(getDebuggerContext(), myValueDescriptor, debugProcess, null) { @Override + public Priority getPriority() { + return Priority.HIGH; + } + + @Override protected void doAction(@Nullable final SourcePosition sourcePosition) { if (sourcePosition != null) { ApplicationManager.getApplication().runReadAction(new Runnable() { @@ -301,6 +364,11 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider { DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess(); debugProcess.getManagerThread().invokeAndWait(new DebuggerCommandImpl() { @Override + public Priority getPriority() { + return Priority.HIGH; + } + + @Override protected void action() throws Exception { evaluationExpression = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java index 713b4c9b8dd6..c7e59106beb8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + /* * Class SetValueAction * @author Jeka @@ -231,7 +233,7 @@ public class JavaValueModifier extends XValueModifier { } private Value preprocessValue(EvaluationContextImpl context, Value value, Type varType) throws EvaluateException { - if (value != null && "java.lang.String".equals(varType.name()) && !(value instanceof StringReference)) { + if (value != null && JAVA_LANG_STRING.equals(varType.name()) && !(value instanceof StringReference)) { String v = DebuggerUtilsEx.getValueAsString(context, value); if (v != null) { value = context.getSuspendContext().getDebugProcess().getVirtualMachineProxy().mirrorOf(v); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/actions/FocusOnBreakpointAction.java b/java/debugger/impl/src/com/intellij/debugger/engine/NamedMethodFilter.java index 91b223c613c9..90a5aa2b4927 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/actions/FocusOnBreakpointAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/NamedMethodFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.debugger.ui.breakpoints.actions; +package com.intellij.debugger.engine; -import com.intellij.execution.ui.actions.AbstractFocusOnAction; -import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; - -public class FocusOnBreakpointAction extends AbstractFocusOnAction { - public FocusOnBreakpointAction() { - super(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION); - } -}
\ No newline at end of file +/** + * Nikolay.Tropin + * 2014-06-10 + */ +public interface NamedMethodFilter extends MethodFilter { + String getMethodName(); +} diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java index 0e37ff354e47..2c31e75cc521 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java @@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NullableComputable; import com.intellij.openapi.util.Ref; import com.intellij.psi.*; +import com.intellij.psi.search.FilenameIndex; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiUtil; import com.sun.jdi.AbsentInformationException; @@ -192,6 +193,18 @@ public class PositionManagerImpl implements PositionManager { final PsiElement element = psiClass.getNavigationElement(); return element.getContainingFile(); } + else { + // for now just take the first file with the required name + // TODO: if there are more than one, we can try matching package name and sourcePath if available + try { + PsiFile[] files = FilenameIndex.getFilesByName(project, refType.sourceName(), GlobalSearchScope.allScope(project)); + if (files.length > 0) { + return files[0]; + } + } + catch (AbsentInformationException ignore) { + } + } return null; } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java index 6786078319a5..00aae83904ce 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java @@ -33,9 +33,7 @@ import com.sun.jdi.request.EventRequest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; /** @@ -61,7 +59,7 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp private final HashSet<ObjectReference> myKeptReferences = new HashSet<ObjectReference>(); private EvaluationContextImpl myEvaluationContext = null; - private JavaExecutionStack[] myExecutionStacks; + private JavaExecutionStack myActiveExecutionStack; SuspendContextImpl(@NotNull DebugProcessImpl debugProcess, int suspendPolicy, int eventVotes, EventSet set) { myDebugProcess = debugProcess; @@ -231,27 +229,48 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp @Nullable @Override public XExecutionStack getActiveExecutionStack() { - for (JavaExecutionStack stack : myExecutionStacks) { - if (stack.getThreadProxy().equals(myThread)) { - return stack; - } + return myActiveExecutionStack; + } + + public void initExecutionStacks(ThreadReferenceProxyImpl newThread) { + DebuggerManagerThreadImpl.assertIsManagerThread(); + myThread = newThread; + if (newThread != null) { + myActiveExecutionStack = new JavaExecutionStack(newThread, myDebugProcess, true); } - return null; } @Override - public XExecutionStack[] getExecutionStacks() { - return myExecutionStacks; + public void computeExecutionStacks(final XExecutionStackContainer container) { + myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(this) { + @Override + public void contextAction() throws Exception { + List<JavaExecutionStack> res = new ArrayList<JavaExecutionStack>(); + Collection<ThreadReferenceProxyImpl> threads = getDebugProcess().getVirtualMachineProxy().allThreads(); + JavaExecutionStack currentStack = null; + for (ThreadReferenceProxyImpl thread : threads) { + boolean current = thread == myThread; + JavaExecutionStack stack = new JavaExecutionStack(thread, myDebugProcess, current); + if (!current) { + res.add(stack); + } + else { + currentStack = stack; + } + } + Collections.sort(res, THREADS_COMPARATOR); + if (currentStack != null) { + res.add(0, currentStack); + } + container.addExecutionStack(res, true); + } + }); } - public void initExecutionStacks(ThreadReferenceProxyImpl newThread) { - DebuggerManagerThreadImpl.assertIsManagerThread(); - Collection<JavaExecutionStack> res = new ArrayList<JavaExecutionStack>(); - Collection<ThreadReferenceProxyImpl> threads = getDebugProcess().getVirtualMachineProxy().allThreads(); - for (ThreadReferenceProxyImpl thread : threads) { - res.add(new JavaExecutionStack(thread, myDebugProcess, thread == myThread)); + private static final Comparator<JavaExecutionStack> THREADS_COMPARATOR = new Comparator<JavaExecutionStack>() { + @Override + public int compare(JavaExecutionStack th1, JavaExecutionStack th2) { + return th1.getDisplayName().compareToIgnoreCase(th2.getDisplayName()); } - myExecutionStacks = res.toArray(new JavaExecutionStack[res.size()]); - myThread = newThread; - } + }; } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index d6975e6d021a..45af0e10ac72 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -220,31 +220,11 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { @Override public void visitForStatement(PsiForStatement statement) { - PsiStatement initializer = statement.getInitialization(); - Evaluator initializerEvaluator = null; - if(initializer != null){ - initializer.accept(this); - initializerEvaluator = myResult; - } - - PsiExpression condition = statement.getCondition(); - Evaluator conditionEvaluator = null; - if(condition != null) { - condition.accept(this); - conditionEvaluator = myResult; - } - - PsiStatement update = statement.getUpdate(); - Evaluator updateEvaluator = null; - if(update != null){ - update.accept(this); - updateEvaluator = myResult; - } - - PsiStatement body = statement.getBody(); - if(body == null) return; - body.accept(this); - Evaluator bodyEvaluator = myResult; + Evaluator initializerEvaluator = accept(statement.getInitialization()); + Evaluator conditionEvaluator = accept(statement.getCondition()); + Evaluator updateEvaluator = accept(statement.getUpdate()); + Evaluator bodyEvaluator = accept(statement.getBody()); + if (bodyEvaluator == null) return; String label = null; if(statement.getParent() instanceof PsiLabeledStatement) { @@ -254,6 +234,37 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { } @Override + public void visitForeachStatement(PsiForeachStatement statement) { + try { + String iterationParameterName = statement.getIterationParameter().getName(); + myCurrentFragmentEvaluator.setInitialValue(iterationParameterName, null); + SyntheticVariableEvaluator iterationParameterEvaluator = new SyntheticVariableEvaluator(myCurrentFragmentEvaluator, iterationParameterName); + + Evaluator iteratedValueEvaluator = accept(statement.getIteratedValue()); + Evaluator bodyEvaluator = accept(statement.getBody()); + if (bodyEvaluator == null) return; + + String label = null; + if(statement.getParent() instanceof PsiLabeledStatement) { + label = ((PsiLabeledStatement)statement.getParent()).getLabelIdentifier().getText(); + } + myResult = new ForeachStatementEvaluator(iterationParameterEvaluator, iteratedValueEvaluator, bodyEvaluator, label); + } + catch (EvaluateException e) { + throw new EvaluateRuntimeException(e); + } + } + + @Nullable + private Evaluator accept(@Nullable PsiElement element) { + if (element == null || element instanceof PsiEmptyStatement) { + return null; + } + element.accept(this); + return myResult; + } + + @Override public void visitIfStatement(PsiIfStatement statement) { PsiStatement thenBranch = statement.getThenBranch(); if(thenBranch == null) return; diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java index ff35ef7fe1dd..5914c878086e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java @@ -16,87 +16,67 @@ package com.intellij.debugger.engine.evaluation.expression; import com.intellij.debugger.engine.evaluation.EvaluateException; -import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; -import com.intellij.openapi.util.Comparing; -import com.sun.jdi.BooleanValue; /** * @author lex */ -public class ForStatementEvaluator implements Evaluator { +public class ForStatementEvaluator extends ForStatementEvaluatorBase { private final Evaluator myInitializationEvaluator; private final Evaluator myConditionEvaluator; private final Evaluator myUpdateEvaluator; private final Evaluator myBodyEvaluator; private Modifier myModifier; - private final String myLabelName; public ForStatementEvaluator(Evaluator initializationEvaluator, Evaluator conditionEvaluator, Evaluator updateEvaluator, Evaluator bodyEvaluator, String labelName) { - myInitializationEvaluator = new DisableGC(initializationEvaluator); - myConditionEvaluator = new DisableGC(conditionEvaluator); - myUpdateEvaluator = new DisableGC(updateEvaluator); - myBodyEvaluator = new DisableGC(bodyEvaluator); - myLabelName = labelName; + super(labelName); + myInitializationEvaluator = initializationEvaluator != null ? new DisableGC(initializationEvaluator) : null; + myConditionEvaluator = conditionEvaluator != null ? new DisableGC(conditionEvaluator) : null; + myUpdateEvaluator = updateEvaluator != null ? new DisableGC(updateEvaluator) : null; + myBodyEvaluator = bodyEvaluator != null ? new DisableGC(bodyEvaluator) : null; } public Modifier getModifier() { return myModifier; } - public Object evaluate(EvaluationContextImpl context) throws EvaluateException { - Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOf(); + @Override + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + if (myBodyEvaluator != null) { + myBodyEvaluator.evaluate(context); + } + } + + @Override + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { if (myInitializationEvaluator != null) { value = myInitializationEvaluator.evaluate(context); myModifier = myInitializationEvaluator.getModifier(); } + return value; + } - while (true) { - if (myConditionEvaluator != null) { - value = myConditionEvaluator.evaluate(context); - myModifier = myConditionEvaluator.getModifier(); - if (!(value instanceof BooleanValue)) { - throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; - } - else { - if (!((BooleanValue)value).booleanValue()) { - break; - } - } - } - - try { - myBodyEvaluator.evaluate(context); - } - catch (BreakException e) { - if (Comparing.equal(e.getLabelName(), myLabelName)) { - break; - } - else { - throw e; - } - } - catch (ContinueException e) { - if (Comparing.equal(e.getLabelName(), myLabelName)) { - //continue; - } - else { - throw e; - } - } - - if (myUpdateEvaluator != null) { - value = myUpdateEvaluator.evaluate(context); - myModifier = myUpdateEvaluator.getModifier(); - } + @Override + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + if (myConditionEvaluator != null) { + Object value = myConditionEvaluator.evaluate(context); + myModifier = myConditionEvaluator.getModifier(); + return value; } + return true; + } + @Override + protected Object evaluateUpdate(EvaluationContextImpl context, Object value) throws EvaluateException { + if (myUpdateEvaluator != null) { + value = myUpdateEvaluator.evaluate(context); + myModifier = myUpdateEvaluator.getModifier(); + } return value; } - } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java new file mode 100644 index 000000000000..7af8c894e9b4 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.engine.evaluation.expression; + +import com.intellij.debugger.engine.evaluation.EvaluateException; +import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; +import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; +import com.intellij.openapi.util.Comparing; +import com.sun.jdi.BooleanValue; + +/** + * @author egor + */ +public abstract class ForStatementEvaluatorBase implements Evaluator { + private final String myLabelName; + + public ForStatementEvaluatorBase(String labelName) { + myLabelName = labelName; + } + + public Object evaluate(EvaluationContextImpl context) throws EvaluateException { + Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOf(); + value = evaluateInitialization(context, value); + + while (true) { + // condition + Object codition = evaluateCondition(context); + if (codition instanceof Boolean) { + if (!(Boolean)codition) break; + } + else if (codition instanceof BooleanValue) { + if (!((BooleanValue)codition).booleanValue()) break; + } + else { + throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; + } + + // body + + try { + evaluateBody(context); + } + catch (BreakException e) { + if (Comparing.equal(e.getLabelName(), myLabelName)) { + break; + } + else { + throw e; + } + } + catch (ContinueException e) { + if (Comparing.equal(e.getLabelName(), myLabelName)) { + //continue; + } + else { + throw e; + } + } + + // update + value = evaluateUpdate(context, value); + } + + return value; + } + + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { + return value; + } + + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + return true; + } + + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + } + + protected Object evaluateUpdate(EvaluationContextImpl context, Object value) throws EvaluateException { + return value; + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java new file mode 100644 index 000000000000..7b7b44856155 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.engine.evaluation.expression; + +import com.intellij.debugger.engine.evaluation.EvaluateException; +import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; +import com.sun.jdi.ArrayReference; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.Value; + +/** + * @author egor + */ +public class ForeachStatementEvaluator extends ForStatementEvaluatorBase { + private final Evaluator myIterationParameterEvaluator; + private final Evaluator myIterableEvaluator; + private final Evaluator myBodyEvaluator; + + private Evaluator myConditionEvaluator; + private Evaluator myNextEvaluator; + + private int myArrayLength = -1; + private int myCurrentIndex = 0; + + private Modifier myModifier; + + public ForeachStatementEvaluator(Evaluator iterationParameterEvaluator, + Evaluator iterableEvaluator, + Evaluator bodyEvaluator, + String labelName) { + super(labelName); + myIterationParameterEvaluator = iterationParameterEvaluator; + myIterableEvaluator = new DisableGC(iterableEvaluator); + myBodyEvaluator = bodyEvaluator != null ? new DisableGC(bodyEvaluator) : null; + } + + public Modifier getModifier() { + return myModifier; + } + + @Override + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { + final Object iterable = myIterableEvaluator.evaluate(context); + if (!(iterable instanceof ObjectReference)) { + throw new EvaluateException("Unable to do foreach for" + iterable); + } + IdentityEvaluator iterableEvaluator = new IdentityEvaluator((Value)iterable); + if (iterable instanceof ArrayReference) { + myArrayLength = ((ArrayReference)iterable).length(); + myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, + new Evaluator() { + @Override + public Object evaluate(EvaluationContextImpl context) throws EvaluateException { + return ((ArrayReference)iterable).getValue(myCurrentIndex++); + } + + @Override + public Modifier getModifier() { + return null; + } + }); + } + else { + Object iterator = new MethodEvaluator(iterableEvaluator, null, "iterator", null, new Evaluator[0]).evaluate(context); + IdentityEvaluator iteratorEvaluator = new IdentityEvaluator((Value)iterator); + myConditionEvaluator = new MethodEvaluator(iteratorEvaluator, null, "hasNext", null, new Evaluator[0]); + myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, + new MethodEvaluator(iteratorEvaluator, null, "next", null, new Evaluator[0])); + } + return value; + } + + private boolean isArray() { + return myArrayLength > -1; + } + + @Override + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + if (isArray()) { + return myCurrentIndex < myArrayLength; + } + else { + Object res = myConditionEvaluator.evaluate(context); + myModifier = myConditionEvaluator.getModifier(); + return res; + } + } + + @Override + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + myNextEvaluator.evaluate(context); + if (myBodyEvaluator != null) { + myBodyEvaluator.evaluate(context); + } + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java index c404aef4004c..58296e2b7273 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java @@ -392,42 +392,6 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque public void processAttached(DebugProcessImpl process) { myEventRequestManager = myDebugProcess.getVirtualMachineProxy().eventRequestManager(); - // invoke later, so that requests are for sure created only _after_ 'processAttached()' methods of other listeners are executed - process.getManagerThread().schedule(new DebuggerCommandImpl() { - protected void action() throws Exception { - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - public void run() { - XDebugSession session = myDebugProcess.getSession().getXDebugSession(); - if (session != null) { - session.initBreakpoints(); - } - } - }); - //Project project = myDebugProcess.getProject(); - //final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager(); - //for (final Breakpoint breakpoint : breakpointManager.getBreakpoints()) { - // try { - // breakpoint.createRequest(myDebugProcess); - // } catch (Exception e) { - // LOG.error(e); - // } - //} - - //AccessToken token = ReadAction.start(); - //try { - // JavaBreakpointAdapter adapter = new JavaBreakpointAdapter(project); - // for (XLineBreakpoint breakpoint : XDebuggerManager.getInstance(project).getBreakpointManager() - // .getBreakpoints(JavaLineBreakpointType.class)) { - // //new JavaLineBreakpointRequestor(breakpoint).createRequest(myDebugProcess); - // //adapter.getOrCreate(breakpoint).createRequest(myDebugProcess); - // } - //} - //finally { - // token.finish(); - //} - } - }); } public void processClassPrepared(final ClassPrepareEvent event) { diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/JavaEditorTextProviderImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/JavaEditorTextProviderImpl.java index c04c5e4e4817..11b077340eb7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/JavaEditorTextProviderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/JavaEditorTextProviderImpl.java @@ -84,10 +84,6 @@ public class JavaEditorTextProviderImpl implements EditorTextProvider { @Nullable public Pair<PsiElement, TextRange> findExpression(PsiElement element, boolean allowMethodCalls) { - if (!(element instanceof PsiIdentifier || element instanceof PsiKeyword)) { - return null; - } - PsiElement expression = null; PsiElement parent = element.getParent(); if (parent instanceof PsiVariable) { @@ -98,6 +94,12 @@ public class JavaEditorTextProviderImpl implements EditorTextProvider { if (pparent instanceof PsiCallExpression) { parent = pparent; } + else if (pparent instanceof PsiReferenceExpression) { + PsiElement resolve = ((PsiReferenceExpression)parent).resolve(); + if (resolve instanceof PsiClass) { + parent = pparent; + } + } if (allowMethodCalls || !DebuggerUtils.hasSideEffects(parent)) { expression = parent; } @@ -105,6 +107,19 @@ public class JavaEditorTextProviderImpl implements EditorTextProvider { else if (parent instanceof PsiThisExpression) { expression = parent; } + else if (parent instanceof PsiInstanceOfExpression || parent instanceof PsiBinaryExpression || parent instanceof PsiPolyadicExpression) { + if (allowMethodCalls || !DebuggerUtils.hasSideEffects(parent)) { + expression = parent; + } + } + else if (allowMethodCalls) { + PsiElement e = PsiTreeUtil.getParentOfType(element, PsiVariable.class, PsiExpression.class, PsiMethod.class); + if (e instanceof PsiNewExpression) { + if (((PsiNewExpression)e).getAnonymousClass() == null) { + expression = e; + } + } + } if (expression != null) { try { diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java index 0f813d0bf167..e570b642b2bd 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java @@ -25,12 +25,14 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.ui.DebuggerExpressionTextField; import com.intellij.debugger.ui.JavaDebuggerSupport; import com.intellij.debugger.ui.tree.render.*; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.editor.Document; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; @@ -141,10 +143,17 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable { } } }, myProject); - myClassNameField.getEditorTextField().addFocusListener(new FocusAdapter() { + final EditorTextField textField = myClassNameField.getEditorTextField(); + final FocusAdapter updateContextListener = new FocusAdapter() { public void focusLost(FocusEvent e) { - final String qName = myClassNameField.getText(); - updateContext(qName); + updateContext(myClassNameField.getText()); + } + }; + textField.addFocusListener(updateContextListener); + Disposer.register(myClassNameField, new Disposable() { + @Override + public void dispose() { + textField.removeFocusListener(updateContextListener); } }); @@ -388,10 +397,12 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable { myChildrenEditor.dispose(); myChildrenExpandedEditor.dispose(); myListChildrenEditor.dispose(); + Disposer.dispose(myClassNameField); myLabelEditor = null; myChildrenEditor = null; myChildrenExpandedEditor = null; myListChildrenEditor = null; + myClassNameField = null; myProject = null; } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java index a43ca7e9eae3..e1d80414f0e6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java @@ -33,6 +33,7 @@ import com.intellij.openapi.components.*; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.CommonClassNames; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiElementFactory; @@ -546,7 +547,12 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> { } static String constructLabelText(final String keylabel, final String valueLabel) { - return keylabel + " -> " + valueLabel; + StringBuilder sb = new StringBuilder(); + sb.append('\"').append(keylabel).append("\" -> "); + if (!StringUtil.isEmpty(valueLabel)) { + sb.append('\"').append(valueLabel).append('\"'); + } + return sb.toString(); } private static String getDescriptorLabel(final ValueDescriptorImpl keyDescriptor) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java index 3c78eaefaea5..6879407b3c9a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java @@ -502,19 +502,23 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements if (getProperties() == null) { return false; } - return getProperties().COUNT_FILTER_ENABLED; + return getProperties().isCOUNT_FILTER_ENABLED(); } public void setCountFilterEnabled(boolean enabled) { - getProperties().COUNT_FILTER_ENABLED = enabled; + if (getProperties().setCOUNT_FILTER_ENABLED(enabled)) { + fireBreakpointChanged(); + } } @Override public int getCountFilter() { - return getProperties().COUNT_FILTER; + return getProperties().getCOUNT_FILTER(); } public void setCountFilter(int filter) { - getProperties().COUNT_FILTER = filter; + if (getProperties().setCOUNT_FILTER(filter)) { + fireBreakpointChanged(); + } } @Override @@ -522,11 +526,13 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements if (getProperties() == null) { return false; } - return getProperties().CLASS_FILTERS_ENABLED; + return getProperties().isCLASS_FILTERS_ENABLED(); } public void setClassFiltersEnabled(boolean enabled) { - getProperties().CLASS_FILTERS_ENABLED = enabled; + if (getProperties().setCLASS_FILTERS_ENABLED(enabled)) { + fireBreakpointChanged(); + } } @Override @@ -535,7 +541,9 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements } public void setClassFilters(ClassFilter[] filters) { - getProperties().setClassFilters(filters); + if (getProperties().setClassFilters(filters)) { + fireBreakpointChanged(); + } } @Override @@ -544,7 +552,9 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements } protected void setClassExclusionFilters(ClassFilter[] filters) { - getProperties().setClassExclusionFilters(filters); + if (getProperties().setClassExclusionFilters(filters)) { + fireBreakpointChanged(); + } } @Override @@ -552,11 +562,13 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements if (getProperties() == null) { return false; } - return getProperties().INSTANCE_FILTERS_ENABLED; + return getProperties().isINSTANCE_FILTERS_ENABLED(); } public void setInstanceFiltersEnabled(boolean enabled) { - getProperties().INSTANCE_FILTERS_ENABLED = enabled; + if (getProperties().setINSTANCE_FILTERS_ENABLED(enabled)) { + fireBreakpointChanged(); + } } @Override @@ -565,7 +577,9 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements } public void setInstanceFilters(InstanceFilter[] filters) { - getProperties().setInstanceFilters(filters); + if (getProperties().setInstanceFilters(filters)) { + fireBreakpointChanged(); + } } private static String getSuspendPolicy(XBreakpoint breakpoint) { @@ -622,4 +636,8 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements protected void addInstanceFilter(long l) { getProperties().addInstanceFilter(l); } + + protected void fireBreakpointChanged() { + ((XBreakpointBase)myXBreakpoint).fireBreakpointChanged(); + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java index b8fa39e399c7..87453ef57f98 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java @@ -689,34 +689,6 @@ public class BreakpointManager { } } - // copied from XDebugSessionImpl processDependencies - public void processBreakpointHit(@NotNull final Breakpoint breakpoint) { - XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager(); - XBreakpoint xBreakpoint = breakpoint.myXBreakpoint; - if (!dependentBreakpointManager.isMasterOrSlave(xBreakpoint)) { - return; - } - List<XBreakpoint<?>> breakpoints = dependentBreakpointManager.getSlaveBreakpoints(xBreakpoint); - for (final XBreakpoint<?> slaveBreakpoint : breakpoints) { - DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { - @Override - public void run() { - slaveBreakpoint.setEnabled(true); - } - }); - } - - if (dependentBreakpointManager.getMasterBreakpoint(xBreakpoint) != null && !dependentBreakpointManager.isLeaveEnabled(xBreakpoint)) { - DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { - @Override - public void run() { - breakpoint.setEnabled(false); - } - }); - //myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate(breakpoint); - } - } - @Nullable public Breakpoint findMasterBreakpoint(@NotNull Breakpoint dependentBreakpoint) { XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java index 4af7275d1258..0bd7d9fc9826 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java @@ -25,6 +25,7 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties; @@ -107,7 +108,12 @@ public class ExceptionBreakpointPropertiesPanel extends XBreakpointCustomPropert @Override public void saveTo(@NotNull XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) { + boolean changed = breakpoint.getProperties().NOTIFY_CAUGHT != myNotifyCaughtCheckBox.isSelected(); breakpoint.getProperties().NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected(); + changed = breakpoint.getProperties().NOTIFY_UNCAUGHT != myNotifyUncaughtCheckBox.isSelected() || changed; breakpoint.getProperties().NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected(); + if (changed) { + ((XBreakpointBase)breakpoint).fireBreakpointChanged(); + } } }
\ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java index 4d0bec2e165b..41f5417799b6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java @@ -25,6 +25,7 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties; @@ -100,7 +101,12 @@ public class FieldBreakpointPropertiesPanel extends XBreakpointCustomPropertiesP @Override public void saveTo(@NotNull XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) { + boolean changed = breakpoint.getProperties().WATCH_ACCESS != myWatchAccessCheckBox.isSelected(); breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected(); + changed = breakpoint.getProperties().WATCH_MODIFICATION != myWatchModificationCheckBox.isSelected() || changed; breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected(); + if (changed) { + ((XBreakpointBase)breakpoint).fireBreakpointChanged(); + } } }
\ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java index 8731329275e9..23b18cb4f306 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java @@ -31,6 +31,7 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.intellij.debugger.engine.requests.RequestManagerImpl; import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.impl.PositionUtil; +import com.intellij.debugger.requests.Requestor; import com.intellij.icons.AllIcons; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -146,7 +147,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp RequestManagerImpl requestManager = debugProcess.getRequestsManager(); if (isWatchEntry()) { - MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class); + MethodEntryRequest entryRequest = findRequest(debugProcess, MethodEntryRequest.class, this); if (entryRequest == null) { entryRequest = requestManager.createMethodEntryRequest(this); } @@ -159,7 +160,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp debugProcess.getRequestsManager().enableRequest(entryRequest); } if (isWatchExit()) { - MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class); + MethodExitRequest exitRequest = findRequest(debugProcess, MethodExitRequest.class, this); if (exitRequest == null) { exitRequest = requestManager.createMethodExitRequest(this); } @@ -353,15 +354,13 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp } @Nullable - private EventRequest findRequest(@NotNull DebugProcessImpl debugProcess, Class requestClass) { - Set reqSet = debugProcess.getRequestsManager().findRequests(this); - for (Iterator iterator = reqSet.iterator(); iterator.hasNext();) { - EventRequest eventRequest = (EventRequest) iterator.next(); - if(eventRequest.getClass().equals(requestClass)) { - return eventRequest; + static <T extends EventRequest> T findRequest(@NotNull DebugProcessImpl debugProcess, Class<T> requestClass, Requestor requestor) { + Set<EventRequest> requests = debugProcess.getRequestsManager().findRequests(requestor); + for (EventRequest eventRequest : requests) { + if (eventRequest.getClass().equals(requestClass)) { + return (T)eventRequest; } } - return null; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java index bf7419264105..c9026d152e99 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java @@ -25,6 +25,7 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties; @@ -100,7 +101,12 @@ public class MethodBreakpointPropertiesPanel extends XBreakpointCustomProperties @Override public void saveTo(@NotNull XBreakpoint<JavaMethodBreakpointProperties> breakpoint) { + boolean changed = breakpoint.getProperties().WATCH_ENTRY != myWatchEntryCheckBox.isSelected(); breakpoint.getProperties().WATCH_ENTRY = myWatchEntryCheckBox.isSelected(); + changed = breakpoint.getProperties().WATCH_EXIT != myWatchExitCheckBox.isSelected() || changed; breakpoint.getProperties().WATCH_EXIT = myWatchExitCheckBox.isSelected(); + if (changed) { + ((XBreakpointBase)breakpoint).fireBreakpointChanged(); + } } }
\ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java index 295fddbaf187..c106f65cab81 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java @@ -135,7 +135,7 @@ public class WildcardMethodBreakpoint extends Breakpoint<JavaMethodBreakpointPro try { RequestManagerImpl requestManager = debugProcess.getRequestsManager(); if (isWatchEntry()) { - MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class); + MethodEntryRequest entryRequest = MethodBreakpoint.findRequest(debugProcess, MethodEntryRequest.class, this); if (entryRequest == null) { entryRequest = requestManager.createMethodEntryRequest(this); } @@ -146,7 +146,7 @@ public class WildcardMethodBreakpoint extends Breakpoint<JavaMethodBreakpointPro debugProcess.getRequestsManager().enableRequest(entryRequest); } if (isWatchExit()) { - MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class); + MethodExitRequest exitRequest = MethodBreakpoint.findRequest(debugProcess, MethodExitRequest.class, this); if (exitRequest == null) { exitRequest = requestManager.createMethodExitRequest(this); } @@ -162,18 +162,6 @@ public class WildcardMethodBreakpoint extends Breakpoint<JavaMethodBreakpointPro } } - private EventRequest findRequest(DebugProcessImpl debugProcess, Class requestClass) { - Set reqSet = debugProcess.getRequestsManager().findRequests(this); - for (Iterator iterator = reqSet.iterator(); iterator.hasNext();) { - EventRequest eventRequest = (EventRequest) iterator.next(); - if(eventRequest.getClass().equals(requestClass)) { - return eventRequest; - } - } - - return null; - } - public void processClassPrepare(DebugProcess debugProcess, ReferenceType refType) { // should be emty - does not make sense for this breakpoint } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java index ae2f2c115d82..d72c967f67be 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java @@ -22,15 +22,14 @@ import com.intellij.debugger.ui.impl.watch.*; import com.intellij.debugger.ui.tree.ValueDescriptor; import com.intellij.icons.AllIcons; import com.intellij.ide.highlighter.JavaHighlightingColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.util.PlatformIcons; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; import com.intellij.xdebugger.impl.ui.tree.ValueMarkup; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -119,18 +118,6 @@ public class DebuggerTreeRenderer extends ColoredTreeCellRenderer { return nodeIcon; } - @NotNull - public static EditorColorsScheme getColorScheme(@Nullable JComponent component) { - EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); - if (component != null && ColorUtil.isDark(component.getBackground()) != ColorUtil.isDark(globalScheme.getDefaultBackground())) { - EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME); - if (scheme != null) { - return scheme; - } - } - return globalScheme; - } - public static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor, EditorColorsScheme colorsScheme, @@ -139,11 +126,11 @@ public class DebuggerTreeRenderer extends ColoredTreeCellRenderer { } public static SimpleColoredText getDescriptorText(final DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor, boolean multiline) { - return getDescriptorText(debuggerContext, descriptor, getColorScheme(null), multiline, true); + return getDescriptorText(debuggerContext, descriptor, DebuggerUIUtil.getColorScheme(null), multiline, true); } public static SimpleColoredText getDescriptorTitle(final DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor) { - return getDescriptorText(debuggerContext, descriptor, getColorScheme(null), false, false); + return getDescriptorText(debuggerContext, descriptor, DebuggerUIUtil.getColorScheme(null), false, false); } private static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext, diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java index 554e5f117bcb..8cb6828d26e8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java @@ -273,6 +273,9 @@ public class FrameVariablesTree extends DebuggerTree { } catch (UnsupportedOperationException ignored) { } + catch (InternalException e) { + LOG.info(e); + } return Collections.emptyList(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java index dd8f17895522..87b0275e9139 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java @@ -36,6 +36,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.ui.SimpleColoredText; import com.intellij.util.containers.HashMap; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.intellij.xdebugger.impl.ui.tree.ValueMarkup; import org.jetbrains.annotations.Nullable; @@ -93,7 +94,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre final NodeDescriptorImpl descriptor = getDescriptor(); myIcon = DebuggerTreeRenderer.getDescriptorIcon(descriptor); final DebuggerContextImpl context = getTree().getDebuggerContext(); - myText = DebuggerTreeRenderer.getDescriptorText(context, descriptor, DebuggerTreeRenderer.getColorScheme(myTree), false); + myText = DebuggerTreeRenderer.getDescriptorText(context, descriptor, DebuggerUIUtil.getColorScheme(myTree), false); if (descriptor instanceof ValueDescriptor) { final ValueMarkup markup = ((ValueDescriptor)descriptor).getMarkup(context.getDebugProcess()); myMarkupTooltipText = markup != null? markup.getToolTipText() : null; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java index 8547e48d3a46..0662112bca6a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java @@ -26,6 +26,7 @@ import java.util.Map; */ public class MethodsTracker { private final Map<Method, Integer> myMethodToOccurrenceMap = new HashMap<Method, Integer>(); + private final Map<Integer, MethodOccurrence> myOccurences = new HashMap<Integer, MethodOccurrence>(); public final class MethodOccurrence { private final Method myMethod; @@ -49,8 +50,13 @@ public class MethodsTracker { } } - public MethodOccurrence getMethodOccurrence(Method method) { - return new MethodOccurrence(method, assignOccurrenceIndex(method)); + public MethodOccurrence getMethodOccurrence(int frameIndex, Method method) { + MethodOccurrence occurrence = myOccurences.get(frameIndex); + if (occurrence == null) { + occurrence = new MethodOccurrence(method, assignOccurrenceIndex(method)); + myOccurences.put(frameIndex, occurrence); + } + return occurrence; } private int getOccurrenceCount(Method method) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java index 28062f09c3d0..08f2e05c2835 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java @@ -58,6 +58,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac private boolean myIsInLibraryContent; private ObjectReference myThisObject; private Color myBackgroundColor; + private SourcePosition mySourcePosition; private Icon myIcon = AllIcons.Debugger.StackFrame; @@ -68,13 +69,13 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac myUiIndex = frame.getFrameIndex(); myLocation = frame.location(); myThisObject = frame.thisObject(); - myMethodOccurrence = tracker.getMethodOccurrence(myLocation.method()); + myMethodOccurrence = tracker.getMethodOccurrence(myUiIndex, myLocation.method()); myIsSynthetic = DebuggerUtils.isSynthetic(myMethodOccurrence.getMethod()); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - final SourcePosition position = ContextUtil.getSourcePosition(StackFrameDescriptorImpl.this); - final PsiFile file = position != null? position.getFile() : null; + mySourcePosition = ContextUtil.getSourcePosition(StackFrameDescriptorImpl.this); + final PsiFile file = mySourcePosition != null? mySourcePosition.getFile() : null; if (file == null) { myIsInLibraryContent = true; } @@ -91,14 +92,14 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac catch (InternalException e) { LOG.info(e); myLocation = null; - myMethodOccurrence = tracker.getMethodOccurrence(null); + myMethodOccurrence = tracker.getMethodOccurrence(0, null); myIsSynthetic = false; myIsInLibraryContent = false; } catch (EvaluateException e) { LOG.info(e); myLocation = null; - myMethodOccurrence = tracker.getMethodOccurrence(null); + myMethodOccurrence = tracker.getMethodOccurrence(0, null); myIsSynthetic = false; myIsInLibraryContent = false; } @@ -273,6 +274,10 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac return myLocation; } + public SourcePosition getSourcePosition() { + return mySourcePosition; + } + private Icon calcIcon() { try { if(myFrame.isObsolete()) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java index 403015474caa..abda6968def4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java @@ -51,6 +51,8 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements NodeRenderer myAutoRenderer = null; private Value myValue; + private boolean myValueReady; + private EvaluateException myValueException; protected EvaluationContextImpl myStoredEvaluationContext = null; @@ -69,38 +71,51 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements protected ValueDescriptorImpl(Project project, Value value) { myProject = project; myValue = value; + myValueReady = true; } protected ValueDescriptorImpl(Project project) { myProject = project; } + private void assertValueReady() { + if (!myValueReady) { + LOG.error("Value is not yet calculated for " + getClass()); + } + } + @Override public boolean isArray() { + assertValueReady(); return myValue instanceof ArrayReference; } - public boolean isDirty() { + public boolean isDirty() { + assertValueReady(); return myIsDirty; } @Override public boolean isLvalue() { + assertValueReady(); return myIsLvalue; } @Override public boolean isNull() { + assertValueReady(); return myValue == null; } @Override public boolean isString() { + assertValueReady(); return myValue instanceof StringReference; } @Override public boolean isPrimitive() { + assertValueReady(); return myValue instanceof PrimitiveValue; } @@ -147,7 +162,8 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements semaphore.waitFor(); } } - + + assertValueReady(); return myValue; } @@ -190,6 +206,9 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements myValue = getTargetExceptionWithStackTraceFilled(evaluationContext, e); myIsExpandable = false; } + finally { + myValueReady = true; + } myIsNew = false; } @@ -239,7 +258,11 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements public void setAncestor(NodeDescriptor oldDescriptor) { super.setAncestor(oldDescriptor); myIsNew = false; - myValue = ((ValueDescriptorImpl)oldDescriptor).getValue(); + ValueDescriptorImpl other = (ValueDescriptorImpl)oldDescriptor; + if (other.myValueReady) { + myValue = other.getValue(); + myValueReady = true; + } } protected void setLvalue(boolean value) { @@ -282,8 +305,8 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements private String getCustomLabel(String label) { //translate only strings in quotes String customLabel = null; - final Value value = getValue(); - if(isShowIdLabel()) { + if(isShowIdLabel() && myValueReady) { + final Value value = getValue(); Renderer lastRenderer = getLastRenderer(); final EvaluationContextImpl evalContext = myStoredEvaluationContext; final String idLabel = evalContext != null && lastRenderer != null && !evalContext.getSuspendContext().isResumed()? diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java index 38cba3c27981..9615aae98233 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java @@ -19,6 +19,7 @@ import com.intellij.debugger.DebuggerContext; import com.intellij.debugger.engine.DebuggerManagerThreadImpl; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluationContext; +import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.intellij.debugger.settings.ViewsGeneralSettings; import com.intellij.debugger.ui.impl.watch.ArrayElementDescriptorImpl; import com.intellij.debugger.ui.impl.watch.MessageDescriptor; @@ -126,7 +127,12 @@ public class ArrayRenderer extends NodeRendererImpl{ DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext); if (arrayItemNode == null) continue; - if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && ((ValueDescriptorImpl)arrayItemNode.getDescriptor()).isNull()) continue; + if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS) { + // need to init value to be able to ask for null + ValueDescriptorImpl descriptor = (ValueDescriptorImpl)arrayItemNode.getDescriptor(); + descriptor.setContext((EvaluationContextImpl)evaluationContext); + if (descriptor.isNull()) continue; + } //if(added >= (ENTRIES_LIMIT + 1)/ 2) break; children.add(arrayItemNode); added++; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java index bdf89a5c79b9..bd14ef55b054 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java @@ -110,9 +110,11 @@ public class ClassRenderer extends NodeRendererImpl{ final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { if (value instanceof StringReference) { - buf.append('\"'); - buf.append(DebuggerUtils.convertToPresentationString(((StringReference)value).value())); - buf.append('\"'); + // no need to add quotes and escape characters here, XValueTextRendererImpl handles the presentation + //buf.append('\"'); + //buf.append(DebuggerUtils.convertToPresentationString(((StringReference)value).value())); + //buf.append('\"'); + buf.append(((StringReference)value).value()); } else if (value instanceof ClassObjectReference) { ReferenceType type = ((ClassObjectReference)value).reflectedType(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ToStringRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ToStringRenderer.java index 6a967533f304..fd77aa900a7c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ToStringRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ToStringRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,8 @@ import org.jetbrains.annotations.NonNls; import java.util.Iterator; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public class ToStringRenderer extends NodeRendererImpl { public static final @NonNls String UNIQUE_ID = "ToStringRenderer"; @@ -76,7 +78,8 @@ public class ToStringRenderer extends NodeRendererImpl { BatchEvaluator.getBatchEvaluator(evaluationContext.getDebugProcess()).invoke(new ToStringCommand(evaluationContext, value) { public void evaluationResult(String message) { valueDescriptor.setValueLabel( - message == null? "" : "\"" + DebuggerUtils.convertToPresentationString(DebuggerUtilsEx.truncateString(message)) + "\"" + // no need to add quotes and escape characters here, XValueTextRendererImpl handles the presentation + message == null? "" : /*"\"" + DebuggerUtils.convertToPresentationString(*/DebuggerUtilsEx.truncateString(message)/*) + "\""*/ ); labelListener.labelChanged(); } @@ -103,7 +106,7 @@ public class ToStringRenderer extends NodeRendererImpl { return false; } - if(type.name().equals("java.lang.String")) { + if(JAVA_LANG_STRING.equals(type.name())) { return false; // do not render 'String' objects for performance reasons } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java index 2afcf0fd339f..a4bac85f4995 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java @@ -28,6 +28,7 @@ import com.intellij.ui.classFilter.ClassFilter; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; @@ -138,7 +139,7 @@ public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B ex public boolean isVisibleOnPopup(@NotNull B breakpoint) { JavaBreakpointProperties properties = breakpoint.getProperties(); if (properties != null) { - return properties.COUNT_FILTER_ENABLED || properties.CLASS_FILTERS_ENABLED || properties.INSTANCE_FILTERS_ENABLED; + return properties.isCOUNT_FILTER_ENABLED() || properties.isCLASS_FILTERS_ENABLED() || properties.isINSTANCE_FILTERS_ENABLED(); } return false; } @@ -150,27 +151,30 @@ public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B ex return; } + boolean changed = false; try { String text = myPassCountField.getText().trim(); - properties.COUNT_FILTER = !text.isEmpty() ? Integer.parseInt(text) : 0; - if (properties.COUNT_FILTER < 0) { - properties.COUNT_FILTER = 0; - } + int filter = !text.isEmpty() ? Integer.parseInt(text) : 0; + if (filter < 0) filter = 0; + changed = properties.setCOUNT_FILTER(filter); } catch (Exception ignored) { } - properties.COUNT_FILTER_ENABLED = properties.COUNT_FILTER > 0 && myPassCountCheckbox.isSelected(); + changed = properties.setCOUNT_FILTER_ENABLED(properties.getCOUNT_FILTER() > 0 && myPassCountCheckbox.isSelected()) || changed; reloadInstanceFilters(); reloadClassFilters(); updateInstanceFilterEditor(true); updateClassFilterEditor(true); - properties.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected(); - properties.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected(); - properties.setClassFilters(myClassFilters); - properties.setClassExclusionFilters(myClassExclusionFilters); - properties.setInstanceFilters(myInstanceFilters); + changed = properties.setINSTANCE_FILTERS_ENABLED(myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected()) || changed; + changed = properties.setCLASS_FILTERS_ENABLED(myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected()) || changed; + changed = properties.setClassFilters(myClassFilters) || changed; + changed = properties.setClassExclusionFilters(myClassExclusionFilters) || changed; + changed = properties.setInstanceFilters(myInstanceFilters) || changed; + if (changed) { + ((XBreakpointBase)breakpoint).fireBreakpointChanged(); + } } private static void insert(JPanel panel, JComponent component) { @@ -182,24 +186,24 @@ public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B ex public void loadFrom(@NotNull B breakpoint) { JavaBreakpointProperties properties = breakpoint.getProperties(); if (properties != null) { - if (properties.COUNT_FILTER > 0) { - myPassCountField.setText(Integer.toString(properties.COUNT_FILTER)); + if (properties.getCOUNT_FILTER() > 0) { + myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER())); } else { myPassCountField.setText(""); } - myPassCountCheckbox.setSelected(properties.COUNT_FILTER_ENABLED); + myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED()); - myInstanceFiltersCheckBox.setSelected(properties.INSTANCE_FILTERS_ENABLED); - myInstanceFiltersField.setEnabled(properties.INSTANCE_FILTERS_ENABLED); - myInstanceFiltersField.getTextField().setEditable(properties.INSTANCE_FILTERS_ENABLED); + myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED()); + myInstanceFiltersField.setEnabled(properties.isINSTANCE_FILTERS_ENABLED()); + myInstanceFiltersField.getTextField().setEditable(properties.isINSTANCE_FILTERS_ENABLED()); myInstanceFilters = properties.getInstanceFilters(); updateInstanceFilterEditor(true); - myClassFiltersCheckBox.setSelected(properties.CLASS_FILTERS_ENABLED); - myClassFiltersField.setEnabled(properties.CLASS_FILTERS_ENABLED); - myClassFiltersField.getTextField().setEditable(properties.CLASS_FILTERS_ENABLED); + myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED()); + myClassFiltersField.setEnabled(properties.isCLASS_FILTERS_ENABLED()); + myClassFiltersField.getTextField().setEditable(properties.isCLASS_FILTERS_ENABLED()); myClassFilters = properties.getClassFilters(); myClassExclusionFilters = properties.getClassExclusionFilters(); updateClassFilterEditor(true); diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java index daab63a93265..599aed3dd0dd 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java @@ -16,6 +16,7 @@ package org.jetbrains.java.debugger.breakpoints.properties; import com.intellij.debugger.InstanceFilter; +import com.intellij.openapi.util.Comparing; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.OptionTag; @@ -27,18 +28,14 @@ import org.jetbrains.annotations.Nullable; * @author egor */ public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extends XBreakpointProperties<T> { - @OptionTag("count-filter-enabled") - public boolean COUNT_FILTER_ENABLED = false; - @OptionTag("count-filter") - public int COUNT_FILTER = 0; + private boolean COUNT_FILTER_ENABLED = false; + private int COUNT_FILTER = 0; - @OptionTag("class-filters-enabled") - public boolean CLASS_FILTERS_ENABLED = false; + private boolean CLASS_FILTERS_ENABLED = false; private ClassFilter[] myClassFilters; private ClassFilter[] myClassExclusionFilters; - @OptionTag("instance-filters-enabled") - public boolean INSTANCE_FILTERS_ENABLED = false; + private boolean INSTANCE_FILTERS_ENABLED = false; private InstanceFilter[] myInstanceFilters; @Tag("instance-filters") @@ -47,8 +44,10 @@ public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extend return myInstanceFilters != null ? myInstanceFilters : InstanceFilter.EMPTY_ARRAY; } - public void setInstanceFilters(InstanceFilter[] instanceFilters) { + public boolean setInstanceFilters(InstanceFilter[] instanceFilters) { + boolean changed = !Comparing.equal(myInstanceFilters, instanceFilters); myInstanceFilters = instanceFilters; + return changed; } public void addInstanceFilter(long l) { @@ -64,8 +63,10 @@ public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extend return myClassFilters != null ? myClassFilters : ClassFilter.EMPTY_ARRAY; } - public final void setClassFilters(ClassFilter[] classFilters) { + public final boolean setClassFilters(ClassFilter[] classFilters) { + boolean changed = !Comparing.equal(myClassFilters, classFilters); myClassFilters = classFilters; + return changed; } @Tag("class-exclusion-filters") @@ -74,8 +75,10 @@ public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extend return myClassExclusionFilters != null ? myClassExclusionFilters : ClassFilter.EMPTY_ARRAY; } - public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) { + public boolean setClassExclusionFilters(ClassFilter[] classExclusionFilters) { + boolean changed = !Comparing.equal(myClassExclusionFilters, classExclusionFilters); myClassExclusionFilters = classExclusionFilters; + return changed; } @Nullable @@ -86,14 +89,58 @@ public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extend @Override public void loadState(T state) { - COUNT_FILTER_ENABLED = state.COUNT_FILTER_ENABLED; - COUNT_FILTER = state.COUNT_FILTER; + setCOUNT_FILTER_ENABLED(state.isCOUNT_FILTER_ENABLED()); + setCOUNT_FILTER(state.getCOUNT_FILTER()); - CLASS_FILTERS_ENABLED = state.CLASS_FILTERS_ENABLED; + setCLASS_FILTERS_ENABLED(state.isCLASS_FILTERS_ENABLED()); myClassFilters = state.getClassFilters(); myClassExclusionFilters = state.getClassExclusionFilters(); - INSTANCE_FILTERS_ENABLED = state.INSTANCE_FILTERS_ENABLED; + setINSTANCE_FILTERS_ENABLED(state.isINSTANCE_FILTERS_ENABLED()); myInstanceFilters = state.getInstanceFilters(); } + + @OptionTag("count-filter-enabled") + public boolean isCOUNT_FILTER_ENABLED() { + return COUNT_FILTER_ENABLED; + } + + public boolean setCOUNT_FILTER_ENABLED(boolean COUNT_FILTER_ENABLED) { + boolean changed = this.COUNT_FILTER_ENABLED != COUNT_FILTER_ENABLED; + this.COUNT_FILTER_ENABLED = COUNT_FILTER_ENABLED; + return changed; + } + + @OptionTag("count-filter") + public int getCOUNT_FILTER() { + return COUNT_FILTER; + } + + public boolean setCOUNT_FILTER(int COUNT_FILTER) { + boolean changed = this.COUNT_FILTER != COUNT_FILTER; + this.COUNT_FILTER = COUNT_FILTER; + return changed; + } + + @OptionTag("class-filters-enabled") + public boolean isCLASS_FILTERS_ENABLED() { + return CLASS_FILTERS_ENABLED; + } + + public boolean setCLASS_FILTERS_ENABLED(boolean CLASS_FILTERS_ENABLED) { + boolean changed = this.CLASS_FILTERS_ENABLED != CLASS_FILTERS_ENABLED; + this.CLASS_FILTERS_ENABLED = CLASS_FILTERS_ENABLED; + return changed; + } + + @OptionTag("instance-filters-enabled") + public boolean isINSTANCE_FILTERS_ENABLED() { + return INSTANCE_FILTERS_ENABLED; + } + + public boolean setINSTANCE_FILTERS_ENABLED(boolean INSTANCE_FILTERS_ENABLED) { + boolean changed = this.INSTANCE_FILTERS_ENABLED != INSTANCE_FILTERS_ENABLED; + this.INSTANCE_FILTERS_ENABLED = INSTANCE_FILTERS_ENABLED; + return changed; + } } diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java index 9da05817277c..ed150d588c3c 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java @@ -291,30 +291,37 @@ public abstract class DebuggerUtils { } if (subType instanceof ClassType) { - result = getSuperType(((ClassType)subType).superclass(), superType); - if (result != null) { - return result; - } + try { + final ClassType clsType = (ClassType)subType; + result = getSuperType(clsType.superclass(), superType); + if (result != null) { + return result; + } - List ifaces = ((ClassType)subType).allInterfaces(); - for (Object iface : ifaces) { - InterfaceType interfaceType = (InterfaceType)iface; - if (typeEquals(interfaceType, superType)) { - return interfaceType; + for (InterfaceType iface : clsType.allInterfaces()) { + if (typeEquals(iface, superType)) { + return iface; + } } } + catch (ClassNotPreparedException e) { + LOG.info(e); + } return null; } if (subType instanceof InterfaceType) { - List ifaces = ((InterfaceType)subType).superinterfaces(); - for (Object iface : ifaces) { - InterfaceType interfaceType = (InterfaceType)iface; - result = getSuperType(interfaceType, superType); - if (result != null) { - return result; + try { + for (InterfaceType iface : ((InterfaceType)subType).superinterfaces()) { + result = getSuperType(iface, superType); + if (result != null) { + return result; + } } } + catch (ClassNotPreparedException e) { + LOG.info(e); + } } else if (subType instanceof ArrayType) { if (superType.endsWith("[]")) { @@ -324,7 +331,7 @@ public abstract class DebuggerUtils { return instanceOf(subTypeItem, superTypeItem) ? subType : null; } catch (ClassNotLoadedException e) { - LOG.debug(e); + LOG.info(e); } } } diff --git a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java index 605248782288..9891d983c328 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java +++ b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.TextComponentAccessor; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.GuiUtils; @@ -33,6 +34,7 @@ import net.miginfocom.swing.MigLayout; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; import java.util.ArrayList; /** @@ -49,16 +51,34 @@ public class AlternativeJREPanel extends JPanel implements PanelWithAnchor { myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); myFieldWithHistory = new TextFieldWithHistory(); + myFieldWithHistory.setHistorySize(-1); final ArrayList<String> foundJDKs = new ArrayList<String>(); + final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks(); + + for (Sdk sdk : allJDKs) { + foundJDKs.add(sdk.getName()); + } + for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { foundJDKs.add(path); } } - final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks(); + for (Sdk jdk : allJDKs) { - foundJDKs.add(jdk.getHomePath()); + String homePath = jdk.getHomePath(); + + if (!SystemInfo.isMac) { + final File jre = new File(jdk.getHomePath(), "jre"); + if (jre.isDirectory()) { + homePath = jre.getPath(); + } + } + + if (!foundJDKs.contains(homePath)) { + foundJDKs.add(homePath); + } } myFieldWithHistory.setHistory(foundJDKs); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); diff --git a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java index 8abf465104dd..18aead7fe7f1 100644 --- a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java +++ b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java @@ -27,6 +27,8 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdk; +import com.intellij.openapi.projectRoots.JavaSdkType; +import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.ex.PathUtilEx; import com.intellij.openapi.roots.*; @@ -36,6 +38,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiFile; import org.intellij.lang.annotations.MagicConstant; +import java.io.File; import java.util.List; import java.util.Map; @@ -128,6 +131,14 @@ public class JavaParametersUtil { } private static Sdk createAlternativeJdk(final String jreHome) throws CantRunException { + final Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jreHome); + if (configuredJdk != null) { + return configuredJdk; + } + final boolean isJdk = JavaSdk.checkForJdk(new File(jreHome)); + if (isJdk) { + throw new CantRunException("Jre expected but jdk found"); + } final Sdk jdk = JavaSdk.getInstance().createJdk("", jreHome); if (jdk == null) throw CantRunException.noJdkConfigured(); return jdk; @@ -135,11 +146,12 @@ public class JavaParametersUtil { public static void checkAlternativeJRE(CommonJavaRunConfigurationParameters configuration) throws RuntimeConfigurationWarning { if (configuration.isAlternativeJrePathEnabled()) { - if (configuration.getAlternativeJrePath() == null || - configuration.getAlternativeJrePath().length() == 0 || - !JavaSdk.checkForJre(configuration.getAlternativeJrePath())) { + final String alternativeJrePath = configuration.getAlternativeJrePath(); + if (alternativeJrePath == null || + alternativeJrePath.length() == 0 || + ProjectJdkTable.getInstance().findJdk(alternativeJrePath) == null && !JavaSdk.checkForJre(alternativeJrePath)) { throw new RuntimeConfigurationWarning( - ExecutionBundle.message("jre.path.is.not.valid.jre.home.error.mesage", configuration.getAlternativeJrePath())); + ExecutionBundle.message("jre.path.is.not.valid.jre.home.error.mesage", alternativeJrePath)); } } } diff --git a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java index 5f6f18def730..8a4c380a669a 100644 --- a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java +++ b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -79,13 +79,14 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi }); } + @NotNull @Override public Key<EditorNotificationPanel> getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(final VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) { if (file.getFileType() != JavaClassFileType.INSTANCE) return null; final List<LibraryOrderEntry> libraries = findOrderEntriesContainingFile(file); if (libraries == null) return null; @@ -240,7 +241,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi if (modelsToCommit.isEmpty()) return new ActionCallback.Rejected(); new WriteAction() { @Override - protected void run(final Result result) { + protected void run(@NotNull final Result result) { for (Library.ModifiableModel model : modelsToCommit) { model.commit(); } @@ -253,7 +254,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi @Nullable private VirtualFile findRoot(Library library) { for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) { - if (VfsUtil.isAncestor(classesRoot, myClassFile, true)) { + if (VfsUtilCore.isAncestor(classesRoot, myClassFile, true)) { return classesRoot; } } diff --git a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java index 178c85584ae2..668f2cc97577 100644 --- a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java +++ b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,13 +53,14 @@ public class SetupSDKNotificationProvider extends EditorNotifications.Provider<E }); } + @NotNull @Override public Key<EditorNotificationPanel> getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { if (file.getFileType() == JavaClassFileType.INSTANCE) return null; final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); diff --git a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java index 9b803f5d8d6e..e3570c2c0fe5 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,22 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.options.ShowSettingsUtil; +import com.intellij.openapi.options.ex.SingleConfigurableEditor; import com.intellij.openapi.options.newEditor.OptionsEditorDialog; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; +import com.intellij.openapi.util.registry.Registry; +import com.intellij.ui.Gray; +import com.intellij.ui.border.CustomLineBorder; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; public class ShowStructureSettingsAction extends AnAction implements DumbAware { public void actionPerformed(AnActionEvent e) { @@ -33,6 +42,27 @@ public class ShowStructureSettingsAction extends AnAction implements DumbAware { project = ProjectManager.getInstance().getDefaultProject(); } - ShowSettingsUtil.getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(project)); + if (Registry.is("ide.new.project.settings")) { + new SingleConfigurableEditor(project, ProjectStructureConfigurable.getInstance(project), OptionsEditorDialog.DIMENSION_KEY) { + @Nullable + @Override + protected Border createContentPaneBorder() { + return new EmptyBorder(0,0,0,0); + } + + @Nullable + @Override + protected JComponent createSouthPanel() { + JComponent panel = super.createSouthPanel(); + assert panel != null; + CustomLineBorder line = new CustomLineBorder(Gray._153, 1, 0, 0, 0); + panel.setBorder(new CompoundBorder(line, new EmptyBorder(10, 5, 5, 5))); + return panel; + } + }.show(); + } else { + ShowSettingsUtil + .getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(project)); + } } }
\ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/ide/projectView/actions/CreateLibraryFromFilesDialog.java b/java/idea-ui/src/com/intellij/ide/projectView/actions/CreateLibraryFromFilesDialog.java index a75eb5d5ce5a..0b35148283dc 100644 --- a/java/idea-ui/src/com/intellij/ide/projectView/actions/CreateLibraryFromFilesDialog.java +++ b/java/idea-ui/src/com/intellij/ide/projectView/actions/CreateLibraryFromFilesDialog.java @@ -26,7 +26,7 @@ import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.roots.impl.libraries.LibraryTypeServiceImpl; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.ui.OrderRoot; -import com.intellij.openapi.roots.ui.configuration.ModulesCombobox; +import com.intellij.application.options.ModulesComboBox; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryNameAndLevelPanel; import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory; @@ -50,7 +50,7 @@ import java.util.List; */ public class CreateLibraryFromFilesDialog extends DialogWrapper { private final LibraryNameAndLevelPanel myNameAndLevelPanel; - private final ModulesCombobox myModulesCombobox; + private final ModulesComboBox myModulesComboBox; private final Project myProject; private final List<OrderRoot> myRoots; private final JPanel myPanel; @@ -67,10 +67,10 @@ public class CreateLibraryFromFilesDialog extends DialogWrapper { myNameAndLevelPanel = new LibraryNameAndLevelPanel(builder, myDefaultName, Arrays.asList(LibrariesContainer.LibraryLevel.values()), LibrariesContainer.LibraryLevel.PROJECT); myNameAndLevelPanel.setDefaultName(myDefaultName); - myModulesCombobox = new ModulesCombobox(); - myModulesCombobox.fillModules(myProject); - myModulesCombobox.setSelectedModule(findModule(roots)); - builder.addLabeledComponent("&Add to module:", myModulesCombobox); + myModulesComboBox = new ModulesComboBox(); + myModulesComboBox.fillModules(myProject); + myModulesComboBox.setSelectedModule(findModule(roots)); + builder.addLabeledComponent("&Add to module:", myModulesComboBox); myPanel = builder.getPanel(); myNameAndLevelPanel.getLibraryNameField().selectAll(); myNameAndLevelPanel.getLevelComboBox().addActionListener(new ActionListener() { @@ -134,7 +134,7 @@ public class CreateLibraryFromFilesDialog extends DialogWrapper { final LibrariesContainer.LibraryLevel level = myNameAndLevelPanel.getLibraryLevel(); AccessToken token = WriteAction.start(); try { - final Module module = myModulesCombobox.getSelectedModule(); + final Module module = myModulesComboBox.getSelectedModule(); final String libraryName = myNameAndLevelPanel.getLibraryName(); if (level == LibrariesContainer.LibraryLevel.MODULE) { final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel(); diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java index e7e172c0c117..fbe8636ee360 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java @@ -21,6 +21,7 @@ import com.intellij.ide.util.newProjectWizard.StepSequence; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; +import com.intellij.openapi.util.Disposer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,6 +47,7 @@ public class NewProjectWizard extends AbstractProjectWizard { protected void init(@NotNull ModulesProvider modulesProvider) { myWizardContext.setNewWizard(true); ProjectTypeStep projectTypeStep = new ProjectTypeStep(myWizardContext, this, modulesProvider); + Disposer.register(getDisposable(), projectTypeStep); mySequence.addCommonStep(projectTypeStep); ChooseTemplateStep chooseTemplateStep = new ChooseTemplateStep(myWizardContext, projectTypeStep); mySequence.addCommonStep(chooseTemplateStep); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java index 4de1dda33846..0b83da74e9f5 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,6 +132,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS return path; } + @Override protected void updateStep() { if (!mySteps.isEmpty()) { getCurrentStepObject().updateStep(); @@ -140,6 +141,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS myIcon.setIcon(null); } + @Override protected void dispose() { StepSequence sequence = getSequence(); if (sequence != null) { @@ -150,7 +152,13 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS super.dispose(); } + @Override protected final void doOKAction() { + if (!doFinishAction()) return; + super.doOKAction(); + } + + public boolean doFinishAction() { int idx = getCurrentStep(); try { do { @@ -159,7 +167,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS step.updateStep(); } if (!commitStepData(step)) { - return; + return false; } step.onStepLeaving(); try { @@ -167,18 +175,19 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS } catch (CommitStepException e) { handleCommitException(e); - return; + return false; } if (!isLastStep(idx)) { idx = getNextStep(idx); - } else { + } + else { for (ModuleWizardStep wizardStep : mySteps) { try { wizardStep.onWizardFinished(); } catch (CommitStepException e) { handleCommitException(e); - return; + return false; } } break; @@ -189,7 +198,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS myCurrentStep = idx; updateStep(); } - super.doOKAction(); + return true; } private void handleCommitException(CommitStepException e) { @@ -213,6 +222,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS return true; } + @Override public void doNextAction() { final ModuleWizardStep step = getCurrentStepObject(); if (!commitStepData(step)) { @@ -223,6 +233,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS } + @Override protected String getHelpID() { ModuleWizardStep step = getCurrentStepObject(); if (step != null) { @@ -232,11 +243,6 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS } @TestOnly - public void doOk() { - doOKAction(); - } - - @TestOnly public boolean isLast() { return isLastStep(); } @@ -246,12 +252,14 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS return myWizardContext.getProjectFileDirectory() + File.separator + myWizardContext.getProjectName() + ModuleFileType.DOT_DEFAULT_EXTENSION; } + @Override protected void doPreviousAction() { final ModuleWizardStep step = getCurrentStepObject(); step.onStepLeaving(); super.doPreviousAction(); } + @Override public void doCancelAction() { final ModuleWizardStep step = getCurrentStepObject(); step.onStepLeaving(); @@ -262,6 +270,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS return getNextStep(step) == step; } + @Override protected final int getNextStep(final int step) { ModuleWizardStep nextStep = null; final StepSequence stepSequence = getSequence(); @@ -275,6 +284,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS return nextStep == null ? step : mySteps.indexOf(nextStep); } + @Override protected final int getPreviousStep(final int step) { ModuleWizardStep previousStep = null; final StepSequence stepSequence = getSequence(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index 47e901512ed5..10df2939f6e7 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.navigation.History; import com.intellij.ui.navigation.Place; import com.intellij.util.EventDispatcher; @@ -238,9 +239,10 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { createEditors(getModule()); - JPanel northPanel = new JPanel(new GridBagLayout()); - - myGenericSettingsPanel.add(northPanel, BorderLayout.NORTH); + if (!Registry.is("ide.new.project.settings")) { + JPanel northPanel = new JPanel(new GridBagLayout()); + myGenericSettingsPanel.add(northPanel, BorderLayout.NORTH); + } final JComponent component = createCenterPanel(); myGenericSettingsPanel.add(component, BorderLayout.CENTER); @@ -332,7 +334,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { private final ModifiableRootModel myDelegateModel; @NonNls private final Set<String> myCheckedNames = new HashSet<String>( Arrays.asList("addOrderEntry", "addLibraryEntry", "addInvalidLibrary", "addModuleOrderEntry", "addInvalidModuleEntry", - "removeOrderEntry", "setSdk", "inheritSdk", "inheritCompilerOutputPath", "setExcludeOutput", "replaceEntryOfType")); + "removeOrderEntry", "setSdk", "inheritSdk", "inheritCompilerOutputPath", "setExcludeOutput", "replaceEntryOfType", "rearrangeOrderEntries")); ModifiableRootModelInvocationHandler(ModifiableRootModel model) { myDelegateModel = model; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index af34e4092d32..d007c3650642 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,11 +38,13 @@ import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureC import com.intellij.openapi.roots.ui.configuration.projectRoot.*; import com.intellij.openapi.ui.DetailsComponent; import com.intellij.openapi.ui.MasterDetailsComponent; -import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy; import com.intellij.packaging.artifacts.Artifact; +import com.intellij.ui.Gray; +import com.intellij.ui.JBSplitter; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.navigation.BackAction; import com.intellij.ui.navigation.ForwardAction; @@ -67,7 +69,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se public static final DataKey<ProjectStructureConfigurable> KEY = DataKey.create("ProjectStructureConfiguration"); protected final UIState myUiState = new UIState(); - private Splitter mySplitter; + private JBSplitter mySplitter; private JComponent myToolbarComponent; @NonNls public static final String CATEGORY = "category"; private JComponent myToFocus; @@ -173,8 +175,16 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se public JComponent createComponent() { myComponent = new MyPanel(); - mySplitter = new Splitter(false, .15f); + mySplitter = new JBSplitter(false, .15f); + mySplitter.setSplitterProportionKey("ProjectStructure.TopLevelElements"); mySplitter.setHonorComponentsMinimumSize(true); + if (Registry.is("ide.new.project.settings")) { + mySplitter.setDividerWidth(1); + mySplitter.setShowDividerIcon(false); + mySplitter.getDivider().setBackground(Gray._153.withAlpha(128)); + mySplitter.setShowDividerControls(false); + mySplitter.setOrientation(mySplitter.getOrientation()); + } initSidePanel(); @@ -192,7 +202,11 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarGroup, true); toolbar.setTargetComponent(myComponent); myToolbarComponent = toolbar.getComponent(); - left.add(myToolbarComponent, BorderLayout.NORTH); + if (Registry.is("ide.new.project.settings")) { + left.setBackground(new Color(0xD2D6DD)); + } else { + left.add(myToolbarComponent, BorderLayout.NORTH); + } left.add(mySidePanel, BorderLayout.CENTER); mySplitter.setFirstComponent(left); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/SidePanel.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/SidePanel.java index 193ce66a8f36..a2d1e4e0489d 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/SidePanel.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/SidePanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,17 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.ui.popup.ListItemDescriptor; +import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBList; import com.intellij.ui.navigation.History; import com.intellij.ui.navigation.Place; import com.intellij.ui.popup.list.GroupedItemsListRenderer; +import com.intellij.util.ui.EmptyIcon; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import javax.swing.border.EmptyBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; @@ -52,7 +55,10 @@ public class SidePanel extends JPanel { myModel = new DefaultListModel(); myList = new JBList(myModel); - + if (Registry.is("ide.new.project.settings")) { + myList.setBackground(new Color(0xD2D6DD)); + myList.setBorder(new EmptyBorder(5, 0, 0, 0)); + } final ListItemDescriptor descriptor = new ListItemDescriptor() { @Override public String getTextFor(final Object value) { @@ -66,7 +72,7 @@ public class SidePanel extends JPanel { @Override public Icon getIconFor(final Object value) { - return null; + return Registry.is("ide.new.project.settings") ? EmptyIcon.create(16, 20) : null; //return myPlace2Presentation.get(value).getIcon(); } @@ -78,14 +84,22 @@ public class SidePanel extends JPanel { @Override public String getCaptionAboveOf(final Object value) { - return myIndex2Separator.get(myPlaces.indexOf(value)); + String text = myIndex2Separator.get(myPlaces.indexOf(value)); + return text != null && Registry.is("ide.new.project.settings") ? text.toUpperCase() : text; } }; - myList.setCellRenderer(new GroupedItemsListRenderer(descriptor)); - + myList.setCellRenderer(new GroupedItemsListRenderer(descriptor) { + { + mySeparatorComponent.setCaptionCentered(false); + } + @Override + protected Color getBackground() { + return Registry.is("ide.new.project.settings") ? new Color(0xD2D6DD) : super.getBackground(); + } + }); - add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER); + add(ScrollPaneFactory.createScrollPane(myList, Registry.is("ide.new.project.settings")), BorderLayout.CENTER); myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myList.addListSelectionListener(new ListSelectionListener() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java index 15a9cee022e8..69b490828f0b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java @@ -235,7 +235,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { label.setBorder(HintUtil.createHintBorder()); label.setBackground(HintUtil.INFORMATION_COLOR); label.setOpaque(true); - HintManager.getInstance().showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); + HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); } }); labelPanel.add(link); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java index 046157ef3bc7..0a162f49bb90 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java @@ -103,7 +103,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction { } } - final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(dialog.getLibraryName(), library.getKind()); + final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(StringUtil.nullize(dialog.getLibraryName()), library.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)copied.getModifiableModel(); LibraryEditingUtil.copyLibrary(library, copiedFiles, model); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelInClasspathAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelInClasspathAction.java index 2b42fd3158e4..9a670be8f458 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelInClasspathAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelInClasspathAction.java @@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.classpath; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.OrderEntry; +import com.intellij.openapi.roots.impl.OrderEntryUtil; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil; import com.intellij.openapi.roots.libraries.Library; @@ -43,15 +44,18 @@ class ChangeLibraryLevelInClasspathAction extends ChangeLibraryLevelActionBase { public void actionPerformed(AnActionEvent event) { final OrderEntry entry = myPanel.getSelectedEntry(); if (!(entry instanceof LibraryOrderEntry)) return; - final LibraryEx library = (LibraryEx)((LibraryOrderEntry)entry).getLibrary(); + LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry; + final LibraryEx library = (LibraryEx)libraryEntry.getLibrary(); if (library == null) return; final Library copied = doCopy(library); if (copied == null) return; - myPanel.getRootModel().removeOrderEntry(entry); if (!isConvertingToModuleLibrary()) { - myPanel.getRootModel().addLibraryEntry(copied); + OrderEntryUtil.replaceLibrary(myPanel.getRootModel(), library, copied); + } + else { + OrderEntryUtil.replaceLibraryEntryByAdded(myPanel.getRootModel(), libraryEntry); } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ClassesOrderRootTypeUIFactory.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ClassesOrderRootTypeUIFactory.java index 92b110caef43..c2d3d801a211 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ClassesOrderRootTypeUIFactory.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ClassesOrderRootTypeUIFactory.java @@ -13,11 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * User: anna - * Date: 26-Dec-2007 - */ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.icons.AllIcons; @@ -30,11 +25,15 @@ import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory; import javax.swing.*; +/** + * @author anna + * @since 26-Dec-2007 + */ public class ClassesOrderRootTypeUIFactory implements OrderRootTypeUIFactory { - @Override public SdkPathEditor createPathEditor(Sdk sdk) { - return new SdkPathEditor(ProjectBundle.message("sdk.configure.classpath.tab"), OrderRootType.CLASSES, new FileChooserDescriptor(true, true, true, false, true, true)); + FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true); + return new SdkPathEditor(ProjectBundle.message("sdk.configure.classpath.tab"), OrderRootType.CLASSES, descriptor); } @Override diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java index bf4f67c0c824..b88f92474fcf 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,8 @@ import com.intellij.openapi.ui.NamedConfigurable; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.packaging.artifacts.Artifact; import com.intellij.ui.TreeSpeedSearch; import com.intellij.ui.awt.RelativePoint; @@ -300,7 +302,9 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i result.addAll(copyActions); result.add(Separator.getInstance()); - result.add(new MyFindUsagesAction(myTree)); + if (fromPopup || !(SystemInfo.isMac && Registry.is("ide.new.project.settings"))) { + result.add(new MyFindUsagesAction(myTree)); + } return result; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java index 44d7820feb88..1c313c1077ee 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,9 @@ import com.intellij.openapi.ui.*; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.NullableComputable; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -149,7 +151,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple final ArrayList<AnAction> result = super.createActions(fromPopup); result.add(Separator.getInstance()); result.add(new MyGroupAction()); - addCollapseExpandActions(result); + if (fromPopup || !(SystemInfo.isMac && Registry.is("ide.new.project.settings"))) { + addCollapseExpandActions(result); + } return result; } diff --git a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java index 231e61a85b6d..59b1b9601d90 100644 --- a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java +++ b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java @@ -19,8 +19,8 @@ package com.intellij.util.descriptors.impl; import com.intellij.openapi.Disposable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.MultiValuesMap; +import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.vfs.*; import com.intellij.util.EventDispatcher; import com.intellij.util.descriptors.*; @@ -35,14 +35,13 @@ import java.util.Set; /** * @author nik */ -public class ConfigFileContainerImpl implements ConfigFileContainer { +public class ConfigFileContainerImpl extends SimpleModificationTracker implements ConfigFileContainer { private final Project myProject; private final EventDispatcher<ConfigFileListener> myDispatcher = EventDispatcher.create(ConfigFileListener.class); private final MultiValuesMap<ConfigFileMetaData, ConfigFile> myConfigFiles = new MultiValuesMap<ConfigFileMetaData, ConfigFile>(); private ConfigFile[] myCachedConfigFiles; private final ConfigFileMetaDataProvider myMetaDataProvider; private final ConfigFileInfoSetImpl myConfiguration; - private long myModificationCount; public ConfigFileContainerImpl(final Project project, final ConfigFileMetaDataProvider descriptorMetaDataProvider, final ConfigFileInfoSetImpl configuration) { @@ -50,10 +49,12 @@ public class ConfigFileContainerImpl implements ConfigFileContainer { myMetaDataProvider = descriptorMetaDataProvider; myProject = project; VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() { + @Override public void propertyChanged(@NotNull final VirtualFilePropertyEvent event) { fileChanged(event.getFile()); } + @Override public void fileMoved(@NotNull final VirtualFileMoveEvent event) { fileChanged(event.getFile()); } @@ -61,25 +62,17 @@ public class ConfigFileContainerImpl implements ConfigFileContainer { myConfiguration.setContainer(this); } - public void incModificationCount() { - myModificationCount ++; - } - - @Override - public long getModificationCount() { - return myModificationCount; - } - private void fileChanged(final VirtualFile file) { for (ConfigFile descriptor : myConfigFiles.values()) { final VirtualFile virtualFile = descriptor.getVirtualFile(); - if (virtualFile != null && VfsUtil.isAncestor(file, virtualFile, false)) { + if (virtualFile != null && VfsUtilCore.isAncestor(file, virtualFile, false)) { myConfiguration.updateConfigFile(descriptor); fireDescriptorChanged(descriptor); } } } + @Override @Nullable public ConfigFile getConfigFile(ConfigFileMetaData metaData) { final Collection<ConfigFile> descriptors = myConfigFiles.get(metaData); @@ -89,6 +82,7 @@ public class ConfigFileContainerImpl implements ConfigFileContainer { return descriptors.iterator().next(); } + @Override public ConfigFile[] getConfigFiles() { if (myCachedConfigFiles == null) { final Collection<ConfigFile> descriptors = myConfigFiles.values(); @@ -97,10 +91,12 @@ public class ConfigFileContainerImpl implements ConfigFileContainer { return myCachedConfigFiles; } + @Override public Project getProject() { return myProject; } + @Override public void addListener(final ConfigFileListener listener, final Disposable parentDisposable) { myDispatcher.addListener(listener, parentDisposable); } @@ -111,18 +107,21 @@ public class ConfigFileContainerImpl implements ConfigFileContainer { } + @Override public ConfigFileInfoSet getConfiguration() { return myConfiguration; } + @Override public void dispose() { - int i = 0; } + @Override public void addListener(final ConfigFileListener listener) { myDispatcher.addListener(listener); } + @Override public void removeListener(final ConfigFileListener listener) { myDispatcher.removeListener(listener); } diff --git a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileImpl.java b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileImpl.java index db9b58b575ba..00be712070ae 100644 --- a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileImpl.java +++ b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.util.descriptors.impl; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.pointers.VirtualFilePointer; import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener; @@ -36,13 +37,12 @@ import java.lang.ref.SoftReference; /** * @author nik */ -public class ConfigFileImpl implements ConfigFile { +public class ConfigFileImpl extends SimpleModificationTracker implements ConfigFile { @NotNull private ConfigFileInfo myInfo; private final VirtualFilePointer myFilePointer; private volatile Reference<PsiFile> myPsiFile; private final ConfigFileContainerImpl myContainer; private final Project myProject; - private long myModificationCount; public ConfigFileImpl(@NotNull final ConfigFileContainerImpl container, @NotNull final ConfigFileInfo configuration) { myContainer = container; @@ -64,7 +64,7 @@ public class ConfigFileImpl implements ConfigFile { } private void onChange() { - myModificationCount++; + incModificationCount(); myContainer.fireDescriptorChanged(this); } @@ -138,10 +138,4 @@ public class ConfigFileImpl implements ConfigFile { public ConfigFileMetaData getMetaData() { return myInfo.getMetaData(); } - - - @Override - public long getModificationCount() { - return myModificationCount; - } } diff --git a/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java b/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java index 1a54284d17a3..5e1cb191ecdd 100644 --- a/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java +++ b/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java @@ -262,4 +262,7 @@ public abstract class QuickFixFactory { @NotNull Collection<String> missedElements); @NotNull public abstract IntentionAction createSurroundWithQuotesAnnotationParameterValueFix(@NotNull PsiAnnotationMemberValue value, @NotNull PsiType expectedType); + + @NotNull + public abstract IntentionAction addMethodQualifierFix(@NotNull PsiMethodCallExpression methodCall); } diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java index 18f1c5128ab6..4b585c30cf83 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java @@ -26,18 +26,8 @@ import org.jetbrains.annotations.Nullable; * - work with PSI or document only and * - don't provide {@link com.intellij.codeInsight.intention.IntentionAction} for quick fixes/suppression, making do with {@link LocalQuickFix} only. */ -public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements BatchSuppressableTool { - @NotNull - @Override - public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) { - return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName())); - } - - @Override - public boolean isSuppressedFor(@NotNull PsiElement element) { - return isSuppressedFor(element, this); - } - +public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool { + @Deprecated public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) { BatchSuppressManager manager = BatchSuppressManager.SERVICE.getInstance(); String alternativeId; diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java index ab807d608579..df0085fff6de 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java @@ -42,11 +42,7 @@ public abstract class BaseJavaLocalInspectionTool extends AbstractBaseJavaLocalI return SuppressManager.getInstance().createSuppressActions(key); } - @Override - public boolean isSuppressedFor(@NotNull PsiElement element) { - return isSuppressedFor(element, this); - } - + @Deprecated public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) { return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool); } diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaBatchInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaBatchInspectionTool.java index 8c2726e77bef..5ac743d212ce 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaBatchInspectionTool.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaBatchInspectionTool.java @@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool implements BatchSuppressableTool { +public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool { @Override public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager, @NotNull final GlobalInspectionContext globalContext, @@ -38,14 +38,4 @@ public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool return false; } - @NotNull - @Override - public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) { - return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName())); - } - - @Override - public boolean isSuppressedFor(@NotNull final PsiElement element) { - return BatchSuppressManager.SERVICE.getInstance().isSuppressedFor(element, getShortName()); - } } diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaInspectionTool.java index 1d9ff9c4a6cc..f50d998124c0 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaInspectionTool.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/GlobalJavaInspectionTool.java @@ -20,13 +20,10 @@ */ package com.intellij.codeInspection; -import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.reference.RefManager; -import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool implements CustomSuppressableInspectionTool { +public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool { @Override public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager, @NotNull final GlobalInspectionContext globalContext, @@ -37,15 +34,4 @@ public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool impl protected boolean queryExternalUsagesRequests(@NotNull RefManager manager, @NotNull GlobalJavaInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor processor) { return false; } - - @Override - @Nullable - public SuppressIntentionAction[] getSuppressActions(final PsiElement element) { - return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName())); - } - - @Override - public boolean isSuppressedFor(@NotNull final PsiElement element) { - return SuppressManager.getInstance().isSuppressedFor(element, getShortName()); - } }
\ No newline at end of file diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/SuppressManager.java b/java/java-analysis-api/src/com/intellij/codeInspection/SuppressManager.java index 2eaa94be3b03..5500f2430e72 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/SuppressManager.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/SuppressManager.java @@ -29,7 +29,7 @@ import com.intellij.psi.PsiLiteralExpression; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; -public abstract class SuppressManager implements BatchSuppressManager { +public abstract class SuppressManager implements BatchSuppressManager, InspectionSuppressor { public static SuppressManager getInstance() { return ServiceManager.getService(SuppressManager.class); diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 410be64ee738..b567ce41325a 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -446,7 +446,7 @@ public class HighlightMethodUtil { final String message = JavaErrorMessages .message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType.getCanonicalText()); - return XmlStringUtil.wrapInHtml("<body>" + message + + return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) + " <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip(candidateInfo, list)) + "\"" + (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") + ">" + DaemonBundle.message("inspection.extended.description") + "</a></body>"); @@ -670,6 +670,7 @@ public class HighlightMethodUtil { registerChangeParameterClassFix(methodCall, list, highlightInfo); if (methodCandidates.length == 0) { QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createStaticImportMethodFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.addMethodQualifierFix(methodCall)); } for (IntentionAction action : QUICK_FIX_FACTORY.getVariableTypeFromCallFixes(methodCall, list)) { QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, action); diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 0dc8e3df8fec..7404d1fbfae3 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -1181,7 +1181,7 @@ public class HighlightUtil extends HighlightUtilBase { final PsiType caughtType = parameter.getType(); if (caughtType instanceof PsiClassType) { HighlightInfo info = checkSimpleCatchParameter(parameter, thrownTypes, (PsiClassType)caughtType); - return info == null ? null : Collections.<HighlightInfo>singletonList(info); + return info == null ? null : Collections.singletonList(info); } if (caughtType instanceof PsiDisjunctionType) { return checkMultiCatchParameter(parameter, thrownTypes); @@ -1796,12 +1796,19 @@ public class HighlightUtil extends HighlightUtilBase { */ @Nullable public static HighlightInfo checkIllegalForwardReferenceToField(@NotNull PsiReferenceExpression expression, @NotNull PsiField referencedField) { + final Boolean isIllegalForwardReference = isIllegalForwardReferenceToField(expression, referencedField, false); + if (isIllegalForwardReference == null) return null; + String description = isIllegalForwardReference ? JavaErrorMessages.message("illegal.forward.reference") : JavaErrorMessages.message("illegal.self.reference"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); + } + + public static Boolean isIllegalForwardReferenceToField(@NotNull PsiReferenceExpression expression, @NotNull PsiField referencedField, boolean acceptQualified) { PsiClass containingClass = referencedField.getContainingClass(); if (containingClass == null) return null; if (expression.getContainingFile() != referencedField.getContainingFile()) return null; if (expression.getTextRange().getStartOffset() >= referencedField.getTextRange().getEndOffset()) return null; // only simple reference can be illegal - if (expression.getQualifierExpression() != null) return null; + if (!acceptQualified && expression.getQualifierExpression() != null) return null; PsiField initField = findEnclosingFieldInitializer(expression); PsiClassInitializer classInitializer = findParentClassInitializer(expression); if (initField == null && classInitializer == null) return null; @@ -1814,8 +1821,7 @@ public class HighlightUtil extends HighlightUtilBase { if (!containingClass.getManager().areElementsEquivalent(containingClass, PsiTreeUtil.getParentOfType(expression, PsiClass.class))) { return null; } - String description = JavaErrorMessages.message("illegal.forward.reference"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); + return initField != referencedField; } /** diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java index 19fcc3b9fcc3..367f28719d1b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,8 @@ import org.jetbrains.annotations.Nullable; import java.util.HashSet; import java.util.Set; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction { private final PsiLiteralExpression myLiteral; private final PsiCall myCall; @@ -171,6 +173,6 @@ public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction } private static boolean isString(final PsiType type) { - return type != null && "java.lang.String".equals(type.getCanonicalText()); + return type != null && type.equalsToText(JAVA_LANG_STRING); } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/intention/EmptyQuickFixFactory.java b/java/java-analysis-impl/src/com/intellij/codeInsight/intention/EmptyQuickFixFactory.java index a69603bdcecd..e886be781eab 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/intention/EmptyQuickFixFactory.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/intention/EmptyQuickFixFactory.java @@ -602,4 +602,10 @@ public class EmptyQuickFixFactory extends QuickFixFactory { @NotNull PsiType expectedType) { return QuickFixes.EMPTY_FIX; } + + @NotNull + @Override + public IntentionAction addMethodQualifierFix(@NotNull PsiMethodCallExpression methodCall) { + return QuickFixes.EMPTY_FIX; + } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java index 87ad7d9f6756..96066c34eefe 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java @@ -433,6 +433,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) { final PsiExpression initializer = ((PsiField)resolved).getInitializer(); if (initializer == null || + resolved == field || initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) { myBodyContainsForbiddenRefs = true; return; diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java index 6fb217eaa4e9..1e887030dcb4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java @@ -112,7 +112,6 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp containingClass = psiMethod.getContainingClass(); isConstructor = psiMethod.isConstructor(); } - if (containingClass == null) return null; boolean isReceiverType = PsiMethodReferenceUtil.isReceiverType(functionalInterfaceType, containingClass, psiMethod); if (isReceiverType && psiMethod != null) { PsiMethod nonAmbiguousMethod = ensureNonAmbiguousMethod(parameters, psiMethod); @@ -120,6 +119,7 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp psiMethod = nonAmbiguousMethod; containingClass = nonAmbiguousMethod.getContainingClass(); } + if (containingClass == null) return null; final boolean staticOrValidConstructorRef; if (isConstructor) { staticOrValidConstructorRef = @@ -182,6 +182,8 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp } }); if (usedInQualifier.get()) return null; + } else if (containingClass != PsiTreeUtil.getParentOfType(body, PsiClass.class) && containingClass.getName() == null) { + return null; } return methodCall; } else if (methodCall instanceof PsiNewExpression) { @@ -275,8 +277,16 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp methodRefText = qualifier + "::" + ((PsiMethodCallExpression)element).getTypeArgumentList().getText() + methodReferenceName; } else { - methodRefText = - (psiMethod.hasModifierProperty(PsiModifier.STATIC) ? getClassReferenceName(containingClass) : "this") + "::" + methodReferenceName; + if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) { + methodRefText = getClassReferenceName(containingClass); + } else { + if (containingClass != PsiTreeUtil.getParentOfType(element, PsiClass.class) ) { + methodRefText = containingClass.getName() + ".this"; + } else { + methodRefText = "this"; + } + } + methodRefText += "::" + methodReferenceName; } } else if (element instanceof PsiNewExpression) { @@ -343,7 +353,13 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp private static String getClassReferenceName(PsiClass containingClass) { final String qualifiedName = containingClass.getQualifiedName(); - return qualifiedName != null ? qualifiedName : containingClass.getName(); + if (qualifiedName != null) { + return qualifiedName; + } + else { + final String containingClassName = containingClass.getName(); + return containingClassName != null ? containingClassName : ""; + } } private static class ReplaceWithMethodRefFix implements LocalQuickFix { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java index 6136e01f85d8..5f8e43d24ef8 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java @@ -38,6 +38,11 @@ public class SuppressManagerImpl extends SuppressManager { } @Override + public SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, String toolShortName) { + return createBatchSuppressActions(HighlightDisplayKey.find(toolShortName)); + } + + @Override public boolean isSuppressedFor(@NotNull final PsiElement element, final String toolId) { return JavaSuppressionUtil.getElementToolSuppressedIn(element, toolId) != null; } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java index b76177e58880..534d65b07531 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java @@ -16,10 +16,15 @@ package com.intellij.codeInspection.dataFlow; import com.intellij.codeInspection.dataFlow.MethodContract.ValueConstraint; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.RecursionManager; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; import com.intellij.util.Function; +import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,8 +40,14 @@ import static com.intellij.codeInspection.dataFlow.MethodContract.ValueConstrain public class ContractInference { @NotNull - public static List<MethodContract> inferContracts(@NotNull PsiMethod method) { - return new ContractInferenceInterpreter(method).inferContracts(); + public static List<MethodContract> inferContracts(@NotNull final PsiMethod method) { + return CachedValuesManager.getCachedValue(method, new CachedValueProvider<List<MethodContract>>() { + @Nullable + @Override + public Result<List<MethodContract>> compute() { + return Result.create(new ContractInferenceInterpreter(method).inferContracts(), method); + } + }); } } @@ -49,15 +60,78 @@ class ContractInferenceInterpreter { List<MethodContract> inferContracts() { PsiCodeBlock body = myMethod.getBody(); - if (body == null) return Collections.emptyList(); - - PsiStatement[] statements = body.getStatements(); + PsiStatement[] statements = body == null ? PsiStatement.EMPTY_ARRAY : body.getStatements(); if (statements.length == 0) return Collections.emptyList(); + if (statements.length == 1) { + if (statements[0] instanceof PsiReturnStatement) { + List<MethodContract> result = handleDelegation(((PsiReturnStatement)statements[0]).getReturnValue(), false); + if (result != null) return result; + } + else if (statements[0] instanceof PsiExpressionStatement && ((PsiExpressionStatement)statements[0]).getExpression() instanceof PsiMethodCallExpression) { + List<MethodContract> result = handleDelegation(((PsiExpressionStatement)statements[0]).getExpression(), false); + if (result != null) return result; + } + } + ValueConstraint[] emptyState = MethodContract.createConstraintArray(myMethod.getParameterList().getParametersCount()); return visitStatements(Collections.singletonList(emptyState), statements); } + @Nullable + private List<MethodContract> handleDelegation(final PsiExpression expression, final boolean negated) { + if (expression instanceof PsiParenthesizedExpression) { + return handleDelegation(((PsiParenthesizedExpression)expression).getExpression(), negated); + } + + if (expression instanceof PsiPrefixExpression && ((PsiPrefixExpression)expression).getOperationTokenType() == JavaTokenType.EXCL) { + return handleDelegation(((PsiPrefixExpression)expression).getOperand(), !negated); + } + + if (expression instanceof PsiMethodCallExpression) { + return handleCallDelegation((PsiMethodCallExpression)expression, negated); + } + + return null; + } + + private List<MethodContract> handleCallDelegation(PsiMethodCallExpression expression, final boolean negated) { + final PsiMethod targetMethod = expression.resolveMethod(); + if (targetMethod == null) return Collections.emptyList(); + + final PsiExpression[] arguments = expression.getArgumentList().getExpressions(); + return RecursionManager.doPreventingRecursion(myMethod, true, new Computable<List<MethodContract>>() { + @Override + public List<MethodContract> compute() { + List<MethodContract> delegateContracts = ContractInference.inferContracts(targetMethod); //todo use explicit contracts, too + return ContainerUtil.mapNotNull(delegateContracts, new NullableFunction<MethodContract, MethodContract>() { + @Nullable + @Override + public MethodContract fun(MethodContract delegateContract) { + ValueConstraint[] answer = MethodContract.createConstraintArray(myMethod.getParameterList().getParametersCount()); + for (int i = 0; i < delegateContract.arguments.length; i++) { + if (i >= arguments.length) return null; + + ValueConstraint argConstraint = delegateContract.arguments[i]; + if (argConstraint != ANY_VALUE) { + int paramIndex = resolveParameter(arguments[i]); + if (paramIndex < 0) { + if (argConstraint != getLiteralConstraint(arguments[i])) { + return null; + } + } + else { + answer = withConstraint(answer, paramIndex, argConstraint); + } + } + } + return new MethodContract(answer, negated ? negateConstraint(delegateContract.returnValue) : delegateContract.returnValue); + } + }); + } + }); + } + @NotNull private List<MethodContract> visitExpression(final List<ValueConstraint[]> states, @Nullable PsiExpression expr) { if (states.isEmpty()) return Collections.emptyList(); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index 3b44c82f9398..1b6d1dfedfec 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -583,7 +583,14 @@ public class DfaMemoryStateImpl implements DfaMemoryState { if (dfaLeft instanceof DfaVariableValue) { DfaVariableValue dfaVar = (DfaVariableValue)dfaLeft; if (isUnknownState(dfaVar)) return true; - + + if (!dfaRelation.isInstanceOf()) { + if (((DfaTypeValue)dfaRight).isNotNull() && isNull(dfaVar)) { + return isNegated; + } + return true; + } + if (isNegated) { DfaVariableState newState = getVariableState(dfaVar).withNotInstanceofValue((DfaTypeValue)dfaRight); if (newState != null) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java index 29bcecd0a53f..522bd34a9cf7 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java @@ -254,7 +254,9 @@ public class StandardInstructionVisitor extends InstructionVisitor { DfaValue condition = factory.getRelationFactory().createRelation(argValue, expectedValue, EQEQ, invertCondition); if (condition == null) { if (!(argValue instanceof DfaConstValue)) { - falseStates.addAll(states); + for (DfaMemoryState state : states) { + falseStates.add(state.createCopy()); + } continue; } condition = constFactory.createFromValue((argValue == expectedValue) != invertCondition, PsiType.BOOLEAN, null); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java index b187d80a3957..9d2530cd2eff 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java @@ -20,7 +20,7 @@ import com.intellij.psi.*; import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.Processor; +import com.intellij.util.CommonProcessors; import com.intellij.util.containers.hash.HashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -161,18 +161,20 @@ public class StringExpressionHelper { @NotNull public static Set<PsiMethodCallExpression> searchMethodCalls(@NotNull final PsiMethod psiMethod, @NotNull SearchScope searchScope) { final Set<PsiMethodCallExpression> callExpressions = new com.intellij.util.containers.HashSet<PsiMethodCallExpression>(); - MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(new Processor<PsiReference>() { - @Override - public boolean process(PsiReference psiReference) { - final PsiMethodCallExpression methodCallExpression = - PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class); - - if (methodCallExpression != null) { - callExpressions.add(methodCallExpression); - } - return true; + final CommonProcessors.CollectUniquesProcessor<PsiReference> consumer = new CommonProcessors.CollectUniquesProcessor<PsiReference>(); + + MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(consumer); + + for (PsiReference psiReference : consumer.getResults()) { + final PsiMethodCallExpression methodCallExpression = + PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class); + + if (methodCallExpression != null) { + callExpressions.add(methodCallExpression); } - }); + } + + return callExpressions; } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java index 8343fc9e6a2c..3e70b2d4b673 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java @@ -52,7 +52,6 @@ public class DfaRelationValue extends DfaValue { } public DfaRelationValue createRelation(DfaValue dfaLeft, DfaValue dfaRight, IElementType relation, boolean negated) { - if (dfaRight instanceof DfaTypeValue && INSTANCEOF_KEYWORD != relation) return null; if (PLUS == relation) return null; if (dfaLeft instanceof DfaVariableValue || dfaLeft instanceof DfaBoxedValue || dfaLeft instanceof DfaUnboxedValue @@ -169,6 +168,10 @@ public class DfaRelationValue extends DfaValue { return myRelation == EQEQ && myIsNegated || myRelation == GT && !myIsNegated || myRelation == GE && myIsNegated; } + public boolean isInstanceOf() { + return myRelation == INSTANCEOF_KEYWORD; + } + @NonNls public String toString() { return (isNegated() ? "not " : "") + myLeftOperand + " " + myRelation + " " + myRightOperand; } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspectionBase.java index 29169ddaf5a2..006e5d946c22 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspectionBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class Java15APIUsageInspectionBase extends BaseJavaBatchLocalInspectionTo loadForbiddenApi("ignore16List.txt", ourIgnored16ClassesAPI); } - private static Set<String> ourGenerifiedClasses = new HashSet<String>(); + private static final Set<String> ourGenerifiedClasses = new HashSet<String>(); static { ourGenerifiedClasses.add("javax.swing.JComboBox"); ourGenerifiedClasses.add("javax.swing.ListModel"); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java index ecf21db51d47..d725158a5201 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java @@ -18,11 +18,9 @@ package com.intellij.codeInspection.miscGenerics; import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.psi.*; -import com.intellij.psi.impl.PsiImplUtil; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.*; import com.intellij.util.containers.IntArrayList; -import com.sun.corba.se.impl.corba.TCUtility; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,10 +45,12 @@ public class SuspiciousMethodCallUtil { PsiMethod contains = MethodSignatureUtil.findMethodBySignature(collectionClass, containsSignature, false); addMethod(contains, 0, patternMethods, indices); - PsiClassType wildcardCollection = javaPsiFacade.getElementFactory().createType(collectionClass, PsiWildcardType.createUnbounded(manager)); - MethodSignature removeAllSignature = MethodSignatureUtil.createMethodSignature("removeAll", new PsiType[] {wildcardCollection}, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY); - PsiMethod removeAll = MethodSignatureUtil.findMethodBySignature(collectionClass, removeAllSignature, false); - addMethod(removeAll, 0, patternMethods, indices); + if (PsiUtil.isLanguageLevel5OrHigher(collectionClass)) { + PsiClassType wildcardCollection = javaPsiFacade.getElementFactory().createType(collectionClass, PsiWildcardType.createUnbounded(manager)); + MethodSignature removeAllSignature = MethodSignatureUtil.createMethodSignature("removeAll", new PsiType[] {wildcardCollection}, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY); + PsiMethod removeAll = MethodSignatureUtil.findMethodBySignature(collectionClass, removeAllSignature, false); + addMethod(removeAll, 0, patternMethods, indices); + } } final PsiClass listClass = javaPsiFacade.findClass(CommonClassNames.JAVA_UTIL_LIST, searchScope); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspectionBase.java index dc28a7b340c0..14da43194fe7 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspectionBase.java @@ -15,14 +15,11 @@ */ package com.intellij.codeInspection.unusedSymbol; -import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInspection.*; -import com.intellij.psi.PsiElement; +import com.intellij.codeInspection.BaseJavaLocalInspectionTool; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -public class UnusedSymbolLocalInspectionBase extends AbstractBaseJavaLocalInspectionTool implements CustomSuppressableInspectionTool { +public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool { @NonNls public static final String SHORT_NAME = HighlightInfoType.UNUSED_SYMBOL_SHORT_NAME; @NonNls public static final String DISPLAY_NAME = HighlightInfoType.UNUSED_SYMBOL_DISPLAY_NAME; @NonNls public static final String UNUSED_PARAMETERS_SHORT_NAME = "UnusedParameters"; @@ -33,22 +30,4 @@ public class UnusedSymbolLocalInspectionBase extends AbstractBaseJavaLocalInspec public boolean CLASS = true; public boolean PARAMETER = true; public boolean REPORT_PARAMETER_FOR_PUBLIC_METHODS = true; - - @Override - public boolean isSuppressedFor(@NotNull PsiElement element) { - return isSuppressedFor(element, this); - } - public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) { - return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool); - } - @Override - public SuppressIntentionAction[] getSuppressActions(final PsiElement element) { - String shortName = getShortName(); - HighlightDisplayKey key = HighlightDisplayKey.find(shortName); - if (key == null) { - throw new AssertionError("HighlightDisplayKey.find(" + shortName + ") is null. Inspection: "+getClass()); - } - SuppressQuickFix[] batchSuppressActions = BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(key); - return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions); - } } diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index f9eca174d12c..cf601bbd0f76 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -48,13 +48,14 @@ <orderEntry type="module" module-name="jps-model-impl" /> <orderEntry type="module" module-name="java-analysis-impl" exported="" /> <orderEntry type="module" module-name="external-system-api" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> <orderEntry type="library" name="Guava" level="project" /> <orderEntry type="library" name="Xerces" level="project" /> <orderEntry type="library" name="Velocity" level="project" /> <orderEntry type="module" module-name="testFramework-java" scope="TEST" /> <orderEntry type="module" module-name="java-structure-view" exported="" /> <orderEntry type="module" module-name="spellchecker" /> + <orderEntry type="library" name="nekohtml" level="project" /> </component> <component name="copyright"> <Base> diff --git a/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingOptionsProvider.java b/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingOptionsProvider.java index 7657ea05396d..7a9aed06479c 100644 --- a/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingOptionsProvider.java +++ b/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingOptionsProvider.java @@ -27,6 +27,7 @@ import com.intellij.openapi.options.BeanConfigurable; public class JavaCodeFoldingOptionsProvider extends BeanConfigurable<JavaCodeFoldingSettings> implements CodeFoldingOptionsProvider { public JavaCodeFoldingOptionsProvider() { super(JavaCodeFoldingSettings.getInstance()); + checkBox("INLINE_PARAMETER_NAMES_FOR_LITERAL_CALL_ARGUMENTS", ApplicationBundle.message("checkbox.collapse.boolean.parameters")); checkBox("COLLAPSE_ONE_LINE_METHODS", ApplicationBundle.message("checkbox.collapse.one.line.methods")); checkBox("COLLAPSE_ACCESSORS", ApplicationBundle.message("checkbox.collapse.simple.property.accessors")); checkBox("COLLAPSE_INNER_CLASSES", ApplicationBundle.message("checkbox.collapse.inner.classes")); diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index 81968fed0a5d..af5f14e25131 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -509,11 +509,9 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM if (entry instanceof LibraryOrderEntry) { Library library = ((LibraryOrderEntry)entry).getLibrary(); LOG.assertTrue(library != null); - final ModifiableRootModel rootModel = ModuleRootManager.getInstance(entry.getOwnerModule()).getModifiableModel(); final Library.ModifiableModel model = library.getModifiableModel(); model.addRoot(vFile, AnnotationOrderRootType.getInstance()); model.commit(); - rootModel.commit(); } else if (entry instanceof ModuleSourceOrderEntry) { final ModifiableRootModel model = ModuleRootManager.getInstance(entry.getOwnerModule()).getModifiableModel(); @@ -558,7 +556,6 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM annotation.delete(); break; } - if (compare < 0) break; anchor = annotation; } XmlTag newTag = XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText( diff --git a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java index 88c1aa63eb9b..59521b1d6c47 100644 --- a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -250,7 +250,7 @@ public class TargetElementUtil extends TargetElementUtilBase { } @Override - public boolean includeSelfInGotoImplementation(final PsiElement element) { + public boolean includeSelfInGotoImplementation(@NotNull final PsiElement element) { if (element instanceof PsiModifierListOwner && ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.ABSTRACT)) { return false; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java index df113a5a77a1..2fc06a2dabd5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java @@ -52,7 +52,7 @@ public class JavaClassNameCompletionContributor extends CompletionContributor { psiElement(PsiReferenceList.class).withParent(PsiTypeParameter.class)); @Override - public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet _result) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet _result) { if (parameters.getCompletionType() == CompletionType.CLASS_NAME || parameters.isExtendedCompletion() && mayContainClassName(parameters)) { addAllClasses(parameters, _result); @@ -151,9 +151,11 @@ public class JavaClassNameCompletionContributor extends CompletionContributor { if (withInners && name != null) { for (PsiClass inner : psiClass.getInnerClasses()) { if (inner.hasModifierProperty(PsiModifier.STATIC)) { - for (JavaPsiClassReferenceElement lookupInner : createClassLookupItems(inner, withInners, insertHandler, condition)) { + for (JavaPsiClassReferenceElement lookupInner : createClassLookupItems(inner, true, insertHandler, condition)) { String forced = lookupInner.getForcedPresentableName(); - lookupInner.setForcedPresentableName(name + "." + (forced != null ? forced : inner.getName())); + String qualifiedName = name + "." + (forced != null ? forced : inner.getName()); + lookupInner.setForcedPresentableName(qualifiedName); + lookupInner.setLookupString(qualifiedName); result.add(lookupInner); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java index d80b6b590c98..be6d8146ce3d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java @@ -53,6 +53,8 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE } PsiElement position = file.findElementAt(offset); + PsiJavaCodeReferenceElement ref = position != null && position.getParent() instanceof PsiJavaCodeReferenceElement ? + (PsiJavaCodeReferenceElement) position.getParent() : null; PsiClass psiClass = item.getObject(); final Project project = context.getProject(); @@ -75,14 +77,8 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE return; } - if (position != null) { - PsiElement parent = position.getParent(); - if (parent instanceof PsiJavaCodeReferenceElement) { - final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)parent; - if (PsiTreeUtil.getParentOfType(position, PsiDocTag.class) != null && ref.isReferenceTo(psiClass)) { - return; - } - } + if (ref != null && PsiTreeUtil.getParentOfType(position, PsiDocTag.class) != null && ref.isReferenceTo(psiClass)) { + return; } OffsetKey refEnd = context.trackOffset(context.getTailOffset(), false); @@ -92,7 +88,9 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE context.setAddCompletionChar(false); } - PsiTypeLookupItem.addImportForItem(context, psiClass); + if (ref == null || !ref.isQualified()) { + PsiTypeLookupItem.addImportForItem(context, psiClass); + } if (context.getOffset(refEnd) < 0) { return; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java index e84eb2646ec0..f6871faea16e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java @@ -41,7 +41,7 @@ public class JavaClassReferenceCompletionContributor extends CompletionContribut } @Override - public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition(); JavaClassReference reference = findJavaClassReference(position.getContainingFile(), parameters.getOffset()); if (reference == null) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index 20615a027a42..7310227a80f0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java @@ -53,6 +53,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.Consumer; +import com.intellij.util.ObjectUtils; import com.intellij.util.PairConsumer; import com.intellij.util.ProcessingContext; import org.jetbrains.annotations.NotNull; @@ -196,7 +197,7 @@ public class JavaCompletionContributor extends CompletionContributor { } @Override - public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet _result) { + public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet _result) { if (parameters.getCompletionType() != CompletionType.BASIC) { return; } @@ -340,6 +341,7 @@ public class JavaCompletionContributor extends CompletionContributor { } final Object[] variants = reference.getVariants(); + //noinspection ConstantConditions if (variants == null) { LOG.error("Reference=" + reference); } @@ -365,6 +367,7 @@ public class JavaCompletionContributor extends CompletionContributor { } else { + //noinspection deprecation LookupElement element = LookupItemUtil.objectToLookupItem(completion); usedWords.add(element.getLookupString()); result.addElement(element); @@ -434,7 +437,7 @@ public class JavaCompletionContributor extends CompletionContributor { private static void completeAnnotationAttributeName(CompletionResultSet result, PsiElement insertedElement, CompletionParameters parameters) { PsiNameValuePair pair = PsiTreeUtil.getParentOfType(insertedElement, PsiNameValuePair.class); - PsiAnnotationParameterList parameterList = (PsiAnnotationParameterList)pair.getParent(); + PsiAnnotationParameterList parameterList = (PsiAnnotationParameterList)ObjectUtils.assertNotNull(pair).getParent(); PsiAnnotation anno = (PsiAnnotation)parameterList.getParent(); boolean showClasses = psiElement().afterLeaf("(").accepts(insertedElement); PsiClass annoClass = null; @@ -507,7 +510,7 @@ public class JavaCompletionContributor extends CompletionContributor { if (psiElement().withParent(psiReferenceExpression().withFirstChild(psiReferenceExpression().referencing(psiClass()))).accepts(position)) { if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.GLOBAL_MEMBER_NAME)) { final String shortcut = getActionShortcut(IdeActions.ACTION_CODE_COMPLETION); - if (shortcut != null) { + if (StringUtil.isNotEmpty(shortcut)) { return "Pressing " + shortcut + " twice without a class qualifier would show all accessible static methods"; } } @@ -517,7 +520,7 @@ public class JavaCompletionContributor extends CompletionContributor { if (parameters.getCompletionType() != CompletionType.SMART && shouldSuggestSmartCompletion(parameters.getPosition())) { if (CompletionUtil.shouldShowFeature(parameters, CodeCompletionFeatures.EDITING_COMPLETION_SMARTTYPE_GENERAL)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); - if (shortcut != null) { + if (StringUtil.isNotEmpty(shortcut)) { return CompletionBundle.message("completion.smart.hint", shortcut); } } @@ -528,7 +531,7 @@ public class JavaCompletionContributor extends CompletionContributor { if (psiTypes.length > 0) { if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_TOAR)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); - if (shortcut != null) { + if (StringUtil.isNotEmpty(shortcut)) { for (final PsiType psiType : psiTypes) { final PsiType type = PsiUtil.extractIterableTypeParameter(psiType, false); if (type != null) { @@ -539,7 +542,7 @@ public class JavaCompletionContributor extends CompletionContributor { } if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_ASLIST)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); - if (shortcut != null) { + if (StringUtil.isNotEmpty(shortcut)) { for (final PsiType psiType : psiTypes) { if (psiType instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)psiType).getComponentType(); @@ -553,7 +556,7 @@ public class JavaCompletionContributor extends CompletionContributor { if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_CHAIN)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); - if (shortcut != null) { + if (StringUtil.isNotEmpty(shortcut)) { return CompletionBundle.message("completion.smart.chain.hint", shortcut); } } @@ -639,9 +642,12 @@ public class JavaCompletionContributor extends CompletionContributor { final PsiFile file = context.getFile(); if (file instanceof PsiJavaFile) { - JavaCompletionUtil.initOffsets(file, context.getOffsetMap()); + if (context.getInvocationCount() > 0) { + autoImport(file, context.getStartOffset() - 1, context.getEditor()); + PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getEditor().getDocument()); + } - autoImport(file, context.getStartOffset() - 1, context.getEditor()); + JavaCompletionUtil.initOffsets(file, context.getOffsetMap()); if (context.getCompletionType() == CompletionType.BASIC) { if (semicolonNeeded(context.getEditor(), file, context.getStartOffset())) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index d5b16a9bbcb5..1112738c5464 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -56,7 +56,6 @@ import com.intellij.util.PairConsumer; import com.intellij.util.PairFunction; import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -447,8 +446,10 @@ public class JavaCompletionUtil { PsiSubstitutor plainSub = plainResult.getSubstitutor(); PsiSubstitutor castSub = TypeConversionUtil.getSuperClassSubstitutor(plainClass, (PsiClassType)castType); + PsiType returnType = method.getReturnType(); if (method.getSignature(plainSub).equals(method.getSignature(castSub)) && - Comparing.equal(plainSub.substitute(method.getReturnType()), castSub.substitute(method.getReturnType())) && + returnType != null && + castSub.substitute(returnType).isAssignableFrom(plainSub.substitute(returnType)) && processor.isAccessible(plainClass.findMethodBySignature(method, true)) ) { return item; @@ -600,12 +601,7 @@ public class JavaCompletionUtil { } public static LookupItem setShowFQN(final LookupItem ret) { - final PsiClass psiClass = (PsiClass)ret.getObject(); - @NonNls String packageName = PsiFormatUtil.getPackageDisplayName(psiClass); - - final String tailText = (String)ret.getAttribute(LookupItem.TAIL_TEXT_ATTR); - ret.setAttribute(LookupItem.TAIL_TEXT_ATTR, StringUtil.notNullize(tailText) + " (" + packageName + ")"); - ret.setAttribute(LookupItem.TAIL_TEXT_SMALL_ATTR, ""); + ret.setAttribute(JavaPsiClassReferenceElement.PACKAGE_NAME, PsiFormatUtil.getPackageDisplayName((PsiClass)ret.getObject())); return ret; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java index 7e7e0955b560..49379c2c4f3e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java @@ -140,7 +140,7 @@ public class JavaDocCompletionContributor extends CompletionContributor { } @Override - public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) { + public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result) { PsiElement position = parameters.getPosition(); if (PsiJavaPatterns.psiElement(JavaDocTokenType.DOC_COMMENT_DATA).accepts(position)) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java index a484e4b1f4f9..a1d4a6f8ac81 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java @@ -39,6 +39,7 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.PlatformIcons; import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -63,7 +64,7 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor { static final int MAX_SCOPE_SIZE_TO_SEARCH_UNRESOLVED = 50000; @Override - public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { if (parameters.getCompletionType() != CompletionType.BASIC && parameters.getCompletionType() != CompletionType.SMART) { return; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodMergingContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodMergingContributor.java index 74bdc7ccc0a5..b409014c1fe8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodMergingContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodMergingContributor.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupItem; import com.intellij.psi.PsiMethod; import com.intellij.psi.ResolveResult; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -28,7 +29,7 @@ import java.util.ArrayList; public class JavaMethodMergingContributor extends CompletionContributor { @Override - public AutoCompletionDecision handleAutoCompletionPossibility(AutoCompletionContext context) { + public AutoCompletionDecision handleAutoCompletionPossibility(@NotNull AutoCompletionContext context) { final CompletionParameters parameters = context.getParameters(); if (parameters.getCompletionType() != CompletionType.SMART && parameters.getCompletionType() != CompletionType.BASIC) { return null; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java index a174ef437acf..f36f567199a0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java @@ -27,6 +27,7 @@ import com.intellij.psi.filters.ElementFilter; import com.intellij.psi.search.PsiShortNamesCache; import com.intellij.util.CollectConsumer; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -42,7 +43,7 @@ import static com.intellij.patterns.PsiJavaPatterns.psiElement; public class JavaNoVariantsDelegator extends CompletionContributor { @Override - public void fillCompletionVariants(final CompletionParameters parameters, CompletionResultSet result) { + public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull CompletionResultSet result) { LinkedHashSet<CompletionResult> plainResults = result.runRemainingContributors(parameters, true); final boolean empty = containsOnlyPackages(plainResults) || suggestMetaAnnotations(parameters); diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java index 43c19b0483b5..9934cddc90ff 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java @@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.PsiTypeLookupItem; import com.intellij.codeInsight.lookup.impl.JavaElementLookupRenderer; import com.intellij.openapi.util.ClassConditionKey; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; @@ -41,6 +42,7 @@ import java.util.Set; * @author peter */ public class JavaPsiClassReferenceElement extends LookupItem<Object> { + public static final Key<String> PACKAGE_NAME = Key.create("PACKAGE_NAME"); public static final ClassConditionKey<JavaPsiClassReferenceElement> CLASS_CONDITION_KEY = ClassConditionKey.create(JavaPsiClassReferenceElement.class); private final Object myClass; private volatile Reference<PsiClass> myCache; @@ -171,8 +173,9 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> { presentation.setTailText(tailText, true); } - public static String getLocationString(LookupItem item) { - return StringUtil.notNullize((String)item.getAttribute(LookupItem.TAIL_TEXT_ATTR)); + public static String getLocationString(LookupItem<?> item) { + String pkgName = item.getAttribute(PACKAGE_NAME); + return pkgName == null ? "" : " (" + pkgName + ")"; } private static String getName(final PsiClass psiClass, final LookupItem<?> item, boolean diamond) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java index 37dc0829f969..61d8abe18368 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java @@ -352,7 +352,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor { } @Override - public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { super.fillCompletionVariants(parameters, JavaCompletionSorting.addJavaSorting(parameters, result)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java index 2960bd797dea..b60094ffbd6f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInsight.completion; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementWeigher; @@ -29,8 +30,10 @@ import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.proximity.KnownElementWeigher; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.Set; import static com.intellij.patterns.PsiJavaPatterns.psiElement; @@ -69,10 +72,32 @@ public class PreferByKindWeigher extends LookupElementWeigher { } private static Condition<PsiClass> createSuitabilityCondition(final PsiElement position) { - if (IN_CATCH_TYPE.accepts(position) || - IN_MULTI_CATCH_TYPE.accepts(position) || - JavaSmartCompletionContributor.AFTER_THROW_NEW.accepts(position) || - INSIDE_METHOD_THROWS_CLAUSE.accepts(position)) { + if (IN_CATCH_TYPE.accepts(position) || IN_MULTI_CATCH_TYPE.accepts(position)) { + PsiTryStatement tryStatement = PsiTreeUtil.getParentOfType(position, PsiTryStatement.class); + final List<PsiClass> thrownExceptions = ContainerUtil.newArrayList(); + if (tryStatement != null && tryStatement.getTryBlock() != null) { + for (PsiClassType type : ExceptionUtil.getThrownExceptions(tryStatement.getTryBlock())) { + ContainerUtil.addIfNotNull(thrownExceptions, type.resolve()); + } + } + if (thrownExceptions.isEmpty()) { + ContainerUtil.addIfNotNull(thrownExceptions, + JavaPsiFacade.getInstance(position.getProject()).findClass( + CommonClassNames.JAVA_LANG_THROWABLE, position.getResolveScope())); + } + return new Condition<PsiClass>() { + @Override + public boolean value(PsiClass psiClass) { + for (PsiClass exception : thrownExceptions) { + if (InheritanceUtil.isInheritorOrSelf(psiClass, exception, true)) { + return true; + } + } + return false; + } + }; + } + else if (JavaSmartCompletionContributor.AFTER_THROW_NEW.accepts(position) || INSIDE_METHOD_THROWS_CLAUSE.accepts(position)) { return new Condition<PsiClass>() { @Override public boolean value(PsiClass psiClass) { @@ -120,6 +145,7 @@ public class PreferByKindWeigher extends LookupElementWeigher { collectionFactory, expectedTypeMethod, suitableClass, + improbableKeyword, nonInitialized, classLiteral, classNameOrGlobalStatic, @@ -138,10 +164,13 @@ public class PreferByKindWeigher extends LookupElementWeigher { if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) { return MyResult.probableKeyword; } - if (PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) { - boolean inReturn = PsiTreeUtil.getParentOfType(myPosition, PsiReturnStatement.class, false, PsiMember.class) != null; + if ((PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) && myCompletionType == CompletionType.SMART) { + boolean inReturn = psiElement().withParents(PsiReferenceExpression.class, PsiReturnStatement.class).accepts(myPosition); return inReturn ? MyResult.probableKeyword : MyResult.normal; } + if (PsiKeyword.INTERFACE.equals(keyword) && psiElement().afterLeaf("@").accepts(myPosition)) { + return MyResult.improbableKeyword; + } } if (object instanceof PsiLocalVariable || object instanceof PsiParameter || object instanceof PsiThisExpression) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/RefactoringCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/RefactoringCompletionContributor.java index 62dbd0df8f79..9264599a4e1b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/RefactoringCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/RefactoringCompletionContributor.java @@ -24,13 +24,14 @@ import com.intellij.openapi.module.ModuleUtil; import com.intellij.psi.PsiClass; import com.intellij.refactoring.ui.ClassNameReferenceEditor; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; /** * @author peter */ public class RefactoringCompletionContributor extends CompletionContributor { @Override - public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet resultSet) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet resultSet) { if (parameters.getOriginalFile().getUserData(ClassNameReferenceEditor.CLASS_NAME_REFERENCE_FRAGMENT) == null) { return; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java index a57303044485..310cf1444e88 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java @@ -21,6 +21,7 @@ import com.intellij.lang.StdLanguages; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; /** * @author peter @@ -28,7 +29,7 @@ import com.intellij.util.Consumer; public class XmlBasicToClassNameDelegator extends CompletionContributor { @Override - public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet result) { + public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet result) { PsiElement position = parameters.getPosition(); PsiFile file = position.getContainingFile(); if (parameters.getCompletionType() != CompletionType.BASIC || diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddMethodQualifierFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddMethodQualifierFix.java new file mode 100644 index 000000000000..ff851372e208 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddMethodQualifierFix.java @@ -0,0 +1,162 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.quickfix; + +import com.intellij.codeInsight.daemon.QuickFixBundle; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.popup.PopupStep; +import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.psi.*; +import com.intellij.ui.popup.list.ListPopupImpl; +import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Dmitry Batkovich + */ +public class AddMethodQualifierFix implements IntentionAction { + private static final boolean UNIT_TEST_MODE = ApplicationManager.getApplication().isUnitTestMode(); + + private final SmartPsiElementPointer<PsiMethodCallExpression> myMethodCall; + private List<PsiVariable> myCandidates = null; + + public AddMethodQualifierFix(final PsiMethodCallExpression methodCallExpression) { + myMethodCall = SmartPointerManager.getInstance(methodCallExpression.getProject()).createSmartPsiElementPointer(methodCallExpression); + } + + @NotNull + @Override + public String getText() { + String text = QuickFixBundle.message("add.method.qualifier.fix.text", myCandidates.size() > 1 ? "" : myCandidates.get(0).getName()); + if (myCandidates.size() > 1) { + text += "..."; + } + return text; + } + + @NotNull + @Override + public String getFamilyName() { + return getText(); + } + + @Override + public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { + final PsiMethodCallExpression element = myMethodCall.getElement(); + if (element == null || !element.isValid()) { + return false; + } + if (myCandidates == null) { + findCandidates(); + } + return myCandidates.size() != 0; + } + + private void findCandidates() { + myCandidates = new ArrayList<PsiVariable>(); + final PsiMethodCallExpression methodCallElement = myMethodCall.getElement(); + final String methodName = methodCallElement.getMethodExpression().getReferenceName(); + if (methodName == null) { + return; + } + + for (final PsiVariable var : CreateFromUsageUtils.guessMatchingVariables(methodCallElement)) { + final PsiType type = var.getType(); + if (!(type instanceof PsiClassType)) { + continue; + } + final PsiClass resolvedClass = ((PsiClassType)type).resolve(); + if (resolvedClass == null) { + continue; + } + if (resolvedClass.findMethodsByName(methodName, true).length > 0) { + myCandidates.add(var); + } + } + } + + @TestOnly + public List<PsiVariable> getCandidates() { + return myCandidates; + } + + @Override + public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { + if (myCandidates.size() == 1 || UNIT_TEST_MODE) { + qualify(myCandidates.get(0), editor); + } + else { + chooseAndQualify(editor); + } + } + + private void chooseAndQualify(final Editor editor) { + final BaseListPopupStep<PsiVariable> step = + new BaseListPopupStep<PsiVariable>(QuickFixBundle.message("add.qualifier"), myCandidates) { + @Override + public PopupStep onChosen(final PsiVariable selectedValue, final boolean finalChoice) { + if (selectedValue != null && finalChoice) { + WriteCommandAction.runWriteCommandAction(selectedValue.getProject(), new Runnable() { + @Override + public void run() { + qualify(selectedValue, editor); + } + }); + } + return FINAL_CHOICE; + } + + @NotNull + @Override + public String getTextFor(final PsiVariable value) { + return ObjectUtils.assertNotNull(value.getName()); + } + + @Override + public Icon getIconFor(final PsiVariable aValue) { + return aValue.getIcon(0); + } + }; + + final ListPopupImpl popup = new ListPopupImpl(step); + popup.showInBestPositionFor(editor); + } + + private void qualify(final PsiVariable qualifier, final Editor editor) { + final String qualifierPresentableText = qualifier.getName(); + final PsiMethodCallExpression oldExpression = myMethodCall.getElement(); + final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(qualifier.getProject()); + final PsiExpression expression = elementFactory + .createExpressionFromText(qualifierPresentableText + "." + oldExpression.getMethodExpression().getReferenceName() + "()", null); + final PsiElement replacedExpression = oldExpression.replace(expression); + editor.getCaretModel().moveToOffset(replacedExpression.getTextOffset() + replacedExpression.getTextLength()); + } + + @Override + public boolean startInWriteAction() { + return true; + } +}
\ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java index 348d052a81b4..f3b95702eac7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInsight.daemon.impl.quickfix; +import com.intellij.application.options.ModuleListCellRenderer; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.actions.AddImportAction; import com.intellij.compiler.ModuleCompilerUtil; @@ -22,7 +23,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; @@ -32,13 +32,11 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; -import com.intellij.ui.ListCellRendererWrapper; import com.intellij.ui.components.JBList; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -115,15 +113,7 @@ class AddModuleDependencyFix extends OrderEntryFix { } else { final JBList list = new JBList(myModules); - list.setCellRenderer(new ListCellRendererWrapper<Module>() { - @Override - public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) { - if (module != null) { - setIcon(ModuleType.get(module).getIcon()); - setText(module.getName()); - } - } - }); + list.setCellRenderer(new ModuleListCellRenderer()); final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setTitle("Choose Module to Add Dependency on") .setMovable(false) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeExtendsToImplementsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeExtendsToImplementsFix.java index 8e3fe5158d13..dce0d54e405b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeExtendsToImplementsFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeExtendsToImplementsFix.java @@ -33,7 +33,8 @@ public class ChangeExtendsToImplementsFix extends ExtendsListFix { public ChangeExtendsToImplementsFix(@NotNull PsiClass aClass, @NotNull PsiClassType classToExtendFrom) { super(aClass, classToExtendFrom, true); - myName = QuickFixBundle.message("exchange.extends.implements.keyword", + myName = myClassToExtendFrom == null ? getFamilyName() : + QuickFixBundle.message("exchange.extends.implements.keyword", aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.IMPLEMENTS : PsiKeyword.EXTENDS, aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.EXTENDS : PsiKeyword.IMPLEMENTS, myClassToExtendFrom.getName()); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java index dab9a3bb6208..72df2025348f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + /** * User: anna * Date: 2/22/12 @@ -82,7 +84,7 @@ public class ConvertSwitchToIfIntention implements IntentionAction { return; } final boolean isSwitchOnString = - switchExpressionType.equalsToText("java.lang.String"); + switchExpressionType.equalsToText(JAVA_LANG_STRING); boolean useEquals = isSwitchOnString; if (!useEquals) { final PsiClass aClass = PsiUtil.resolveClassInType(switchExpressionType); diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java index ee371f8e1206..e2dedf5ea3ec 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java @@ -131,7 +131,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate { return Result.CONTINUE; } if (PsiTreeUtil.getParentOfType(leaf, PsiCodeBlock.class, false, PsiMember.class) != null) { - EditorModificationUtil.typeInStringAtCaretHonorMultipleCarets(editor, "{"); + EditorModificationUtil.insertStringAtCaret(editor, "{"); TypedHandler.indentOpenedBrace(project, editor); return Result.STOP; } @@ -169,7 +169,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate { char charAt = editor.getDocument().getCharsSequence().charAt(offset); if (charAt != ';') return false; - EditorModificationUtil.moveAllCaretsRelatively(editor, 1); + EditorModificationUtil.moveCaretRelatively(editor, 1); return true; } @@ -209,7 +209,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate { } if (balance == 0) { - EditorModificationUtil.moveAllCaretsRelatively(editor, 1); + EditorModificationUtil.moveCaretRelatively(editor, 1); return true; } @@ -248,12 +248,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate { } if (balance == 1) { - if (editor.getCaretModel().supportsMultipleCarets()) { - EditorModificationUtil.typeInStringAtCaretHonorMultipleCarets(editor, ">", 0); - } - else { - editor.getDocument().insertString(offset, ">"); - } + editor.getDocument().insertString(offset, ">"); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/AfterSemicolonEnterProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/AfterSemicolonEnterProcessor.java index ff2f19d465c0..9d43379ce920 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/AfterSemicolonEnterProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/AfterSemicolonEnterProcessor.java @@ -44,8 +44,8 @@ public class AfterSemicolonEnterProcessor implements EnterProcessor { ((PsiMethod) psiElement).hasModifierProperty(PsiModifier.NATIVE))) { int errorOffset = getErrorElementOffset(psiElement); int elementEndOffset = psiElement.getTextRange().getEndOffset(); - final CharSequence text = editor.getDocument().getCharsSequence(); if (psiElement instanceof PsiEnumConstant) { + final CharSequence text = editor.getDocument().getCharsSequence(); final int commaOffset = CharArrayUtil.shiftForwardUntil(text, elementEndOffset, ","); if (commaOffset < text.length()) { elementEndOffset = commaOffset + 1; @@ -53,18 +53,13 @@ public class AfterSemicolonEnterProcessor implements EnterProcessor { } if (errorOffset >= 0 && errorOffset < elementEndOffset) { + final CharSequence text = editor.getDocument().getCharsSequence(); if (text.charAt(errorOffset) == ' ' && text.charAt(errorOffset + 1) == ';') { errorOffset++; } } editor.getCaretModel().moveToOffset(errorOffset >= 0 ? errorOffset : elementEndOffset); - if (errorOffset < 0 && - isModified && - (elementEndOffset == text.length() || text.charAt(elementEndOffset) == '\n') && - (psiElement instanceof PsiExpressionStatement || psiElement instanceof PsiDeclarationStatement)) { - JavaSmartEnterProcessor.plainEnter(editor); - } return isModified; } return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java index 1c51da143810..6d903cafb418 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,12 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLiteralExpression; +import com.intellij.psi.PsiType; import java.util.List; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public class LiteralSelectioner extends BasicSelectioner { @Override public boolean canSelect(PsiElement e) { @@ -34,8 +37,10 @@ public class LiteralSelectioner extends BasicSelectioner { } private static boolean isStringLiteral(PsiElement element) { - return element instanceof PsiLiteralExpression && - ((PsiLiteralExpression)element).getType().equalsToText("java.lang.String") && element.getText().startsWith("\"") && element.getText().endsWith("\""); + final PsiType type = element instanceof PsiLiteralExpression ? ((PsiLiteralExpression)element).getType() : null; + return type != null && type.equalsToText(JAVA_LANG_STRING) + && element.getText().startsWith("\"") + && element.getText().endsWith("\""); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java index daf5aa5eac74..899da3035ce5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java @@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; +import com.intellij.psi.util.PsiUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; @@ -64,6 +65,11 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction { return returnType != null && !(returnType instanceof PsiPrimitiveType); } + + if (owner instanceof PsiClass) { + return PsiUtil.isLanguageLevel8OrHigher(owner); + } + return true; } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddJavadocIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddJavadocIntention.java index a26e78ac85c7..22abefb01c98 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddJavadocIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddJavadocIntention.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.intention.impl; import com.intellij.codeInsight.editorActions.FixDocCommentAction; +import com.intellij.codeInsight.intention.LowPriorityAction; import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull; /** * @author Dmitry Batkovich */ -public class AddJavadocIntention extends PsiElementBaseIntentionAction { +public class AddJavadocIntention extends PsiElementBaseIntentionAction implements LowPriorityAction { @Override public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiDocCommentOwner docCommentOwner = (PsiDocCommentOwner)element.getParent(); diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/DeannotateIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/DeannotateIntentionAction.java index 84831e2dc6e2..4fba52583963 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/DeannotateIntentionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/DeannotateIntentionAction.java @@ -48,7 +48,7 @@ public class DeannotateIntentionAction implements IntentionAction { @Override @NotNull public String getText() { - return CodeInsightBundle.message("deannotate.intention.action.text") + (myAnnotationName != null ? " " + myAnnotationName : ""); + return CodeInsightBundle.message("deannotate.intention.action.text") + (myAnnotationName != null ? " " + myAnnotationName : "..."); } @Override @@ -59,6 +59,7 @@ public class DeannotateIntentionAction implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + myAnnotationName = null; PsiModifierListOwner listOwner = getContainer(editor, file); if (listOwner != null) { final ExternalAnnotationsManager externalAnnotationsManager = ExternalAnnotationsManager.getInstance(project); diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SwapIfStatementsIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SwapIfStatementsIntentionAction.java new file mode 100644 index 000000000000..cd8ce8dd1dce --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SwapIfStatementsIntentionAction.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.intention.impl; + +import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Dmitry Batkovich + */ +public class SwapIfStatementsIntentionAction extends PsiElementBaseIntentionAction { + @Override + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { + final PsiIfStatement ifStatement = (PsiIfStatement)element.getParent(); + final PsiIfStatement nestedIfStatement = (PsiIfStatement) ifStatement.getElseBranch(); + assert nestedIfStatement != null; + + final PsiExpression condition = ifStatement.getCondition(); + final PsiExpression nestedCondition = nestedIfStatement.getCondition(); + + final PsiStatement thenBranch = ifStatement.getThenBranch(); + final PsiStatement nestedThenBranch = nestedIfStatement.getThenBranch(); + + assert condition != null; + assert nestedCondition != null; + assert thenBranch != null; + assert nestedThenBranch != null; + + final PsiElement conditionCopy = condition.copy(); + condition.replace(nestedCondition); + nestedCondition.replace(conditionCopy); + + final PsiElement thenBranchCopy = thenBranch.copy(); + thenBranch.replace(nestedThenBranch); + nestedThenBranch.replace(thenBranchCopy); + } + + @Override + public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) { + if (!(element instanceof PsiKeyword) || !PsiKeyword.ELSE.equals(element.getText())) { + return false; + } + final PsiElement parent = element.getParent(); + return parent instanceof PsiIfStatement && ((PsiIfStatement)parent).getElseBranch() instanceof PsiIfStatement; + } + + @NotNull + @Override + public String getFamilyName() { + return "Swap If Statements"; + } + + @NotNull + @Override + public String getText() { + return getFamilyName(); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java index e934a9f387cf..81f0204049b6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java @@ -762,6 +762,12 @@ public class QuickFixFactoryImpl extends QuickFixFactory { return new SurroundWithQuotesAnnotationParameterValueFix(value, expectedType); } + @NotNull + @Override + public IntentionAction addMethodQualifierFix(@NotNull PsiMethodCallExpression methodCall) { + return new AddMethodQualifierFix(methodCall); + } + private static boolean timeToOptimizeImports(@NotNull PsiFile file) { if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java index 49befb363437..a6d734b92d8e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java +++ b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java @@ -103,10 +103,11 @@ public class PsiTypeLookupItem extends LookupItem { myImportFixer.handleInsert(context, this); PsiElement position = context.getFile().findElementAt(context.getStartOffset()); - assert position != null; - int genericsStart = context.getTailOffset(); - context.getDocument().insertString(genericsStart, JavaCompletionUtil.escapeXmlIfNeeded(context, calcGenerics(position, context))); - JavaCompletionUtil.shortenReference(context.getFile(), genericsStart - 1); + if (position != null) { + int genericsStart = context.getTailOffset(); + context.getDocument().insertString(genericsStart, JavaCompletionUtil.escapeXmlIfNeeded(context, calcGenerics(position, context))); + JavaCompletionUtil.shortenReference(context.getFile(), genericsStart - 1); + } int tail = context.getTailOffset(); String braces = StringUtil.repeat("[]", getBracketsCount()); diff --git a/java/java-impl/src/com/intellij/codeInspection/RemoveAssignmentFix.java b/java/java-impl/src/com/intellij/codeInspection/RemoveAssignmentFix.java index b80e3a07121d..9db065ad321f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/RemoveAssignmentFix.java +++ b/java/java-impl/src/com/intellij/codeInspection/RemoveAssignmentFix.java @@ -40,7 +40,7 @@ public class RemoveAssignmentFix extends RemoveInitializerFix { if (!(parent instanceof PsiAssignmentExpression)) return; final PsiExpression rExpression = ((PsiAssignmentExpression)parent).getRExpression(); final PsiElement gParent = parent.getParent(); - if (gParent instanceof PsiExpression && rExpression != null) { + if ((gParent instanceof PsiExpression || gParent instanceof PsiExpressionList) && rExpression != null) { if (!FileModificationService.getInstance().prepareFileForWrite(gParent.getContainingFile())) return; if (gParent instanceof PsiParenthesizedExpression) { gParent.replace(rExpression); diff --git a/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java b/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java index c3d61021c0d0..f9127f0b48a5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java +++ b/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,6 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { @Override protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) { - PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, String.valueOf(myAnnotateLocalVariablesCb.isSelected())); final ProgressManager progressManager = ProgressManager.getInstance(); @@ -174,7 +173,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { final String path = dialog.getResultingLibraryPath(); new WriteCommandAction(project) { @Override - protected void run(final Result result) throws Throwable { + protected void run(@NotNull final Result result) throws Throwable { for (Module module : modulesWithoutAnnotations) { OrderEntryFix.addBundledJarToRoots(project, null, module, null, AnnotationUtil.NOT_NULL, path); } @@ -206,8 +205,8 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { } } - private UsageInfo[] findUsages(final Project project, - final AnalysisScope scope) { + private UsageInfo[] findUsages(@NotNull final Project project, + @NotNull final AnalysisScope scope) { final NullityInferrer inferrer = new NullityInferrer(myAnnotateLocalVariablesCb.isSelected(), project); final PsiManager psiManager = PsiManager.getInstance(project); final Runnable searchForUsages = new Runnable() { @@ -257,7 +256,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { try { new WriteCommandAction(project, INFER_NULLITY_ANNOTATIONS) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { final UsageInfo[] infos = computable.compute(); if (infos.length > 0) { final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, INFER_NULLITY_ANNOTATIONS, false); @@ -287,7 +286,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { } - private void showUsageView(final Project project, final UsageInfo[] usageInfos, AnalysisScope scope) { + private void showUsageView(@NotNull Project project, final UsageInfo[] usageInfos, @NotNull AnalysisScope scope) { final UsageTarget[] targets = UsageTarget.EMPTY_ARRAY; final Ref<Usage[]> convertUsagesRef = new Ref<Usage[]>(); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @@ -326,7 +325,8 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { usageView.addPerformOperationAction(refactoringRunnable, INFER_NULLITY_ANNOTATIONS, canNotMakeString, INFER_NULLITY_ANNOTATIONS, false); } - private Factory<UsageSearcher> rerunFactory(final Project project, final AnalysisScope scope) { + @NotNull + private Factory<UsageSearcher> rerunFactory(@NotNull final Project project, @NotNull final AnalysisScope scope) { return new Factory<UsageSearcher>() { @Override public UsageSearcher create() { diff --git a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicCompletionContributor.java b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicCompletionContributor.java index 4f9fa882be6e..8150b618f8dc 100644 --- a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicCompletionContributor.java @@ -25,6 +25,7 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -46,7 +47,7 @@ public class MagicCompletionContributor extends CompletionContributor { private static final int PRIORITY = 100; @Override - public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) { + public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result) { //if (parameters.getCompletionType() != CompletionType.SMART) return; PsiElement pos = parameters.getPosition(); MagicConstantInspection.AllowedValues allowedValues = null; diff --git a/java/java-impl/src/com/intellij/find/findUsages/FindThrowUsagesDialog.java b/java/java-impl/src/com/intellij/find/findUsages/FindThrowUsagesDialog.java index 400acce6d8c2..e9c059eff080 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/FindThrowUsagesDialog.java +++ b/java/java-impl/src/com/intellij/find/findUsages/FindThrowUsagesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.psi.impl.search.ThrowSearchUtil; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.StateRestoringCheckBox; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -32,9 +33,13 @@ public class FindThrowUsagesDialog extends JavaFindUsagesDialog<JavaThrowFindUsa private boolean myHasFindWhatPanel; private ThrowSearchUtil.Root [] myRoots; - public FindThrowUsagesDialog(final PsiElement element, final Project project, - final FindUsagesOptions findUsagesOptions, boolean toShowInNewTab, boolean mustOpenInNewTab, - boolean isSingleFile, FindUsagesHandler handler){ + public FindThrowUsagesDialog(@NotNull PsiElement element, + @NotNull Project project, + @NotNull JavaThrowFindUsagesOptions findUsagesOptions, + boolean toShowInNewTab, + boolean mustOpenInNewTab, + boolean isSingleFile, + @NotNull FindUsagesHandler handler) { super(element, project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, handler); } @@ -92,7 +97,7 @@ public class FindThrowUsagesDialog extends JavaFindUsagesDialog<JavaThrowFindUsa @Override protected void doOKAction() { - myFindUsagesOptions.putUserData(ThrowSearchUtil.THROW_SEARCH_ROOT_KEY, (ThrowSearchUtil.Root)myCbExns.getSelectedItem()); + getFindUsagesOptions().setRoot((ThrowSearchUtil.Root)myCbExns.getSelectedItem()); super.doOKAction(); } @@ -102,7 +107,7 @@ public class FindThrowUsagesDialog extends JavaFindUsagesDialog<JavaThrowFindUsa setOKActionEnabled(true); } else{ - myFindUsagesOptions.putUserData(ThrowSearchUtil.THROW_SEARCH_ROOT_KEY, (ThrowSearchUtil.Root)myCbExns.getSelectedItem()); + getFindUsagesOptions().setRoot((ThrowSearchUtil.Root)myCbExns.getSelectedItem()); final boolean hasSelected = isSelected(myCbUsages); setOKActionEnabled(hasSelected); } diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesDialog.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesDialog.java index 17f9650b3b24..65528fb8a921 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesDialog.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte boolean toShowInNewTab, boolean mustOpenInNewTab, boolean isSingleFile, - FindUsagesHandler handler) { + @NotNull FindUsagesHandler handler) { super(element, project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, handler); } @@ -82,10 +82,12 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte } } + @NotNull protected final PsiElement getPsiElement() { return myPsiElement; } + @NotNull protected T getFindUsagesOptions() { return (T)myFindUsagesOptions; } diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java index 3fd1161bb0ed..1791fd0d6e8e 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java @@ -220,9 +220,10 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } @Override - protected Set<String> getStringsToSearch(final PsiElement element) { + protected Set<String> getStringsToSearch(@NotNull final PsiElement element) { if (element instanceof PsiDirectory) { // normalize a directory to a corresponding package - return getStringsToSearch(JavaDirectoryService.getInstance().getPackage((PsiDirectory)element)); + PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory)element); + return aPackage == null ? Collections.<String>emptySet() : getStringsToSearch(aPackage); } final Set<String> result = new HashSet<String>(); @@ -264,7 +265,8 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } else if (element instanceof XmlAttributeValue) { ContainerUtil.addIfNotNull(result, ((XmlAttributeValue)element).getValue()); - } else { + } + else { LOG.error("Unknown element type: " + element); } } @@ -306,7 +308,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ @Override public Boolean compute() { if (ThrowSearchUtil.isSearchable (element) && options instanceof JavaThrowFindUsagesOptions && options.isUsages) { - ThrowSearchUtil.Root root = options.getUserData(ThrowSearchUtil.THROW_SEARCH_ROOT_KEY); + ThrowSearchUtil.Root root = ((JavaThrowFindUsagesOptions)options).getRoot(); if (root == null) { final ThrowSearchUtil.Root[] roots = ThrowSearchUtil.getSearchRoots(element); if (roots != null && roots.length > 0) { @@ -346,6 +348,9 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } else if (classOptions.isImplementingClasses){ if (!addImplementingClasses(psiClass, processor, classOptions)) return false; + } + + if (classOptions.isImplementingClasses) { FunctionalExpressionSearch.search(psiClass, classOptions.searchScope).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>( new PsiElementProcessor<PsiFunctionalExpression>() { @Override @@ -755,6 +760,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } + @NotNull @Override public Collection<PsiReference> findReferencesToHighlight(@NotNull final PsiElement target, @NotNull final SearchScope searchScope) { if (target instanceof PsiMethod) { diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesOptions.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesOptions.java index 2d28a8ddf57c..b78dfca59fe5 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesOptions.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesOptions.java @@ -34,6 +34,7 @@ public abstract class JavaFindUsagesOptions extends FindUsagesOptions { isUsages = true; } + @Override public boolean equals(final Object o) { if (this == o) return true; if (!super.equals(this)) return false; @@ -42,6 +43,7 @@ public abstract class JavaFindUsagesOptions extends FindUsagesOptions { return isSkipImportStatements == ((JavaFindUsagesOptions)o).isSkipImportStatements; } + @Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (isSkipImportStatements ? 1 : 0); diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaThrowFindUsagesOptions.java b/java/java-impl/src/com/intellij/find/findUsages/JavaThrowFindUsagesOptions.java index c90c6a675dee..4ccc0c4aef6e 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaThrowFindUsagesOptions.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaThrowFindUsagesOptions.java @@ -1,16 +1,40 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.find.findUsages; import com.intellij.openapi.project.Project; +import com.intellij.psi.impl.search.ThrowSearchUtil; import org.jetbrains.annotations.NotNull; /** * @author peter */ public class JavaThrowFindUsagesOptions extends JavaFindUsagesOptions { + private ThrowSearchUtil.Root root; public JavaThrowFindUsagesOptions(@NotNull Project project) { super(project); isSearchForTextOccurrences = false; } + public ThrowSearchUtil.Root getRoot() { + return root; + } + + public void setRoot(ThrowSearchUtil.Root root) { + this.root = root; + } } diff --git a/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java b/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java index 688788ae3c16..ee203e34deac 100644 --- a/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java +++ b/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java @@ -31,7 +31,7 @@ import com.intellij.util.NotNullFunction; import com.intellij.util.PlatformIcons; import com.intellij.util.download.DownloadableFileDescription; import com.intellij.util.download.DownloadableFileService; -import org.apache.xerces.parsers.DOMParser; +import org.cyberneko.html.parsers.DOMParser; import org.jetbrains.annotations.NotNull; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; @@ -40,11 +40,8 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import javax.swing.*; -import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.net.URL; import java.util.*; /** @@ -129,22 +126,9 @@ public abstract class FindJarFix<T extends PsiElement> implements IntentionActio final Runnable runnable = new Runnable() { public void run() { try { - Document doc; - - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); - builderFactory.setExpandEntityReferences(false); - builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - - URL url = new URL(CLASS_ROOT_URL + fqn.replace('.', '/') + CLASS_PAGE_EXT); - - InputStream stream = url.openStream(); - try { - doc = builderFactory.newDocumentBuilder().parse(stream); - } - finally { - stream.close(); - } - + final DOMParser parser = new DOMParser(); + parser.parse(CLASS_ROOT_URL + fqn.replace('.', '/') + CLASS_PAGE_EXT); + final Document doc = parser.getDocument(); if (doc != null) { final NodeList links = doc.getElementsByTagName(LINK_TAG_NAME); for (int i = 0; i < links.getLength(); i++) { diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/JavaLanguageLevelPusher.java b/java/java-impl/src/com/intellij/openapi/roots/impl/JavaLanguageLevelPusher.java index 6daedef21ef9..d933576fc697 100644 --- a/java/java-impl/src/com/intellij/openapi/roots/impl/JavaLanguageLevelPusher.java +++ b/java/java-impl/src/com/intellij/openapi/roots/impl/JavaLanguageLevelPusher.java @@ -37,7 +37,7 @@ import java.io.IOException; * @author Gregory.Shrago */ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel> { - public static void pushLanguageLevel(final Project project) { + public static void pushLanguageLevel(@NotNull final Project project) { PushedFilePropertiesUpdater.getInstance(project).pushAll(new JavaLanguageLevelPusher()); } diff --git a/java/java-impl/src/com/intellij/psi/NonClasspathResolveScopeEnlarger.java b/java/java-impl/src/com/intellij/psi/NonClasspathResolveScopeEnlarger.java index 01114788ac9d..b7b5a05aef28 100644 --- a/java/java-impl/src/com/intellij/psi/NonClasspathResolveScopeEnlarger.java +++ b/java/java-impl/src/com/intellij/psi/NonClasspathResolveScopeEnlarger.java @@ -5,7 +5,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.NonClasspathDirectoryScope; +import com.intellij.psi.search.NonClasspathDirectoriesScope; import com.intellij.psi.search.SearchScope; import org.jetbrains.annotations.NotNull; @@ -25,7 +25,7 @@ public class NonClasspathResolveScopeEnlarger extends ResolveScopeEnlarger { final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots(); for (VirtualFile root : roots) { if (VfsUtil.isAncestor(root, file, true)) { - return NonClasspathDirectoryScope.compose(roots); + return NonClasspathDirectoriesScope.compose(roots); } } } diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/FieldDependenciesManager.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/FieldDependenciesManager.java new file mode 100644 index 000000000000..cea1c9e07f4c --- /dev/null +++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/FieldDependenciesManager.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.codeStyle.arrangement; + +import com.intellij.psi.PsiField; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class FieldDependenciesManager { + private final Map<PsiField, Set<PsiField>> myFieldDependencies; + private final Map<PsiField, ArrangementEntryDependencyInfo> myFieldInfosMap = ContainerUtil.newHashMap(); + + public FieldDependenciesManager(@NotNull Map<PsiField, Set<PsiField>> fieldDependencies, @NotNull Map<PsiField, JavaElementArrangementEntry> fields) { + myFieldDependencies = fieldDependencies; + for (PsiField field : fields.keySet()) { + JavaElementArrangementEntry entry = fields.get(field); + myFieldInfosMap.put(field, new ArrangementEntryDependencyInfo(entry)); + } + } + + @NotNull + public List<ArrangementEntryDependencyInfo> getRoots() { + List<ArrangementEntryDependencyInfo> list = ContainerUtil.newArrayList(); + + for (Map.Entry<PsiField, Set<PsiField>> entry : myFieldDependencies.entrySet()) { + ArrangementEntryDependencyInfo currentInfo = myFieldInfosMap.get(entry.getKey()); + + for (PsiField usedInInitialization : entry.getValue()) { + ArrangementEntryDependencyInfo fieldInfo = myFieldInfosMap.get(usedInInitialization); + if (fieldInfo != null) + currentInfo.addDependentEntryInfo(fieldInfo); + } + + list.add(currentInfo); + } + + return list; + } +}
\ No newline at end of file diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaArrangementParseInfo.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaArrangementParseInfo.java index 2796fecea024..f042bb316c40 100644 --- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaArrangementParseInfo.java +++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaArrangementParseInfo.java @@ -27,8 +27,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; -import java.util.HashMap; -import java.util.HashSet; /** * @author Denis Zhdanov @@ -36,28 +34,22 @@ import java.util.HashSet; */ public class JavaArrangementParseInfo { - @NotNull private final List<JavaElementArrangementEntry> myEntries = new ArrayList<JavaElementArrangementEntry>(); + private final List<JavaElementArrangementEntry> myEntries = new ArrayList<JavaElementArrangementEntry>(); - @NotNull private final Map<Pair<String/* property name */, String/* class name */>, JavaArrangementPropertyInfo> myProperties - = new HashMap<Pair<String, String>, JavaArrangementPropertyInfo>(); + private final Map<Pair<String/* property name */, String/* class name */>, JavaArrangementPropertyInfo> myProperties = new HashMap<Pair<String, String>, JavaArrangementPropertyInfo>(); - @NotNull private final List<ArrangementEntryDependencyInfo> myMethodDependencyRoots - = new ArrayList<ArrangementEntryDependencyInfo>(); + private final List<ArrangementEntryDependencyInfo> myMethodDependencyRoots = new ArrayList<ArrangementEntryDependencyInfo>(); + private final Map<PsiMethod /* anchor */, Set<PsiMethod /* dependencies */>> myMethodDependencies = new HashMap<PsiMethod, Set<PsiMethod>>(); - @NotNull private final Map<PsiMethod /* anchor */, Set<PsiMethod /* dependencies */>> myMethodDependencies - = new HashMap<PsiMethod, Set<PsiMethod>>(); + private final Map<PsiMethod, JavaElementArrangementEntry> myMethodEntriesMap = new HashMap<PsiMethod, JavaElementArrangementEntry>(); + private final Map<PsiClass, List<Pair<PsiMethod/*overridden*/, PsiMethod/*overriding*/>>> myOverriddenMethods = new LinkedHashMap<PsiClass, List<Pair<PsiMethod, PsiMethod>>>(); - @NotNull private final Map<PsiMethod, JavaElementArrangementEntry> myMethodEntriesMap = - new HashMap<PsiMethod, JavaElementArrangementEntry>(); - - @NotNull private final Map<PsiClass, List<Pair<PsiMethod/*overridden*/, PsiMethod/*overriding*/>>> myOverriddenMethods - = new LinkedHashMap<PsiClass, List<Pair<PsiMethod, PsiMethod>>>(); - - @NotNull private final Set<PsiMethod> myTmpMethodDependencyRoots = new LinkedHashSet<PsiMethod>(); - @NotNull private final Set<PsiMethod> myDependentMethods = new HashSet<PsiMethod>(); + private final Set<PsiMethod> myTmpMethodDependencyRoots = new LinkedHashSet<PsiMethod>(); + private final Set<PsiMethod> myDependentMethods = new HashSet<PsiMethod>(); private boolean myRebuildMethodDependencies; - @NotNull private FieldDependenciesManager myFieldDependenciesManager = new FieldDependenciesManager(); + private final HashMap<PsiField, JavaElementArrangementEntry> myFields = ContainerUtil.newLinkedHashMap(); + private final Map<PsiField, Set<PsiField>> myFieldDependencies = ContainerUtil.newHashMap(); @NotNull public List<JavaElementArrangementEntry> getEntries() { @@ -96,8 +88,7 @@ public class JavaArrangementParseInfo { @Nullable private ArrangementEntryDependencyInfo buildMethodDependencyInfo(@NotNull final PsiMethod method, - @NotNull Map<PsiMethod, ArrangementEntryDependencyInfo> cache) - { + @NotNull Map<PsiMethod, ArrangementEntryDependencyInfo> cache) { JavaElementArrangementEntry entry = myMethodEntriesMap.get(method); if (entry == null) { return null; @@ -158,7 +149,7 @@ public class JavaArrangementParseInfo { } public void onFieldEntryCreated(@NotNull PsiField field, @NotNull JavaElementArrangementEntry entry) { - myFieldDependenciesManager.registerFieldAndEntry(field, entry); + myFields.put(field, entry); } public void onOverriddenMethod(@NotNull PsiMethod baseMethod, @NotNull PsiMethod overridingMethod) { @@ -201,7 +192,7 @@ public class JavaArrangementParseInfo { result.add(info); } } - + return result; } @@ -226,49 +217,21 @@ public class JavaArrangementParseInfo { } public void registerFieldInitializationDependency(@NotNull PsiField fieldToInitialize, @NotNull PsiField usedInInitialization) { - myFieldDependenciesManager.registerInitializationDependency(fieldToInitialize, usedInInitialization); + Set<PsiField> fields = myFieldDependencies.get(fieldToInitialize); + if (fields == null) { + fields = ContainerUtil.newHashSet(); + myFieldDependencies.put(fieldToInitialize, fields); + } + fields.add(usedInInitialization); } @NotNull public List<ArrangementEntryDependencyInfo> getFieldDependencyRoots() { - return myFieldDependenciesManager.getRoots(); + return new FieldDependenciesManager(myFieldDependencies, myFields).getRoots(); } - private static class FieldDependenciesManager { - private final Map<PsiField, Set<PsiField>> myFieldDependencies = ContainerUtil.newHashMap(); - private final Map<PsiField, ArrangementEntryDependencyInfo> myFieldInfosMap = ContainerUtil.newHashMap(); - - - public void registerFieldAndEntry(@NotNull PsiField field, @NotNull JavaElementArrangementEntry entry) { - myFieldInfosMap.put(field, new ArrangementEntryDependencyInfo(entry)); - } - - public void registerInitializationDependency(@NotNull PsiField fieldToInitialize, @NotNull PsiField usedInInitialization) { - Set<PsiField> fields = myFieldDependencies.get(fieldToInitialize); - if (fields == null) { - fields = new HashSet<PsiField>(); - myFieldDependencies.put(fieldToInitialize, fields); - } - fields.add(usedInInitialization); - } - - @NotNull - public List<ArrangementEntryDependencyInfo> getRoots() { - List<ArrangementEntryDependencyInfo> list = ContainerUtil.newArrayList(); - - for (Map.Entry<PsiField, Set<PsiField>> entry : myFieldDependencies.entrySet()) { - ArrangementEntryDependencyInfo currentInfo = myFieldInfosMap.get(entry.getKey()); - - for (PsiField usedInInitialization : entry.getValue()) { - ArrangementEntryDependencyInfo fieldInfo = myFieldInfosMap.get(usedInInitialization); - if (fieldInfo != null) - currentInfo.addDependentEntryInfo(fieldInfo); - } - - list.add(currentInfo); - } - - return list; - } + @NotNull + public Collection<JavaElementArrangementEntry> getFields() { + return myFields.values(); } }
\ No newline at end of file diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java index e35cc50379dd..9e23eadc3073 100644 --- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java +++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java @@ -27,6 +27,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.psi.codeStyle.arrangement.engine.ArrangementEngine; import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule; import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryMatcher; import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher; @@ -34,8 +35,6 @@ import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule; import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition; import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition; import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition; -import com.intellij.psi.codeStyle.arrangement.std.ArrangementColorsAware; -import com.intellij.psi.codeStyle.arrangement.std.ArrangementStandardSettingsAware; import com.intellij.psi.codeStyle.arrangement.std.*; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; @@ -46,10 +45,10 @@ import java.util.*; import java.util.List; import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.EntryType.*; +import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.General.*; import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Grouping.*; import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Modifier.*; import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Order.*; -import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.General.*; /** * @author Denis Zhdanov @@ -250,16 +249,29 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>, setupOverriddenMethods(parseInfo); } } - setupFieldInitializationDependencies(parseInfo.getFieldDependencyRoots()); + List<ArrangementEntryDependencyInfo> fieldDependencyRoots = parseInfo.getFieldDependencyRoots(); + if (!fieldDependencyRoots.isEmpty()) { + setupFieldInitializationDependencies(fieldDependencyRoots, settings, parseInfo); + } return parseInfo.getEntries(); } + public void setupFieldInitializationDependencies(@NotNull List<ArrangementEntryDependencyInfo> fieldDependencyRoots, + @NotNull ArrangementSettings settings, + @NotNull JavaArrangementParseInfo parseInfo) + { + Collection<JavaElementArrangementEntry> fields = parseInfo.getFields(); + List<JavaElementArrangementEntry> arrangedFields = ArrangementEngine.arrange(fields, settings.getSections(), settings.getRulesSortedByPriority(), null); + + for (ArrangementEntryDependencyInfo root : fieldDependencyRoots) { + JavaElementArrangementEntry anchorField = root.getAnchorEntry(); + final int anchorEntryIndex = arrangedFields.indexOf(anchorField); - public void setupFieldInitializationDependencies(@NotNull List<ArrangementEntryDependencyInfo> list) { - for (ArrangementEntryDependencyInfo info : list) { - JavaElementArrangementEntry anchorField = info.getAnchorEntry(); - for (ArrangementEntryDependencyInfo fieldUsedInInitialization : info.getDependentEntriesInfos()) { - anchorField.addDependency(fieldUsedInInitialization.getAnchorEntry()); + for (ArrangementEntryDependencyInfo fieldInInitializerInfo : root.getDependentEntriesInfos()) { + JavaElementArrangementEntry fieldInInitializer = fieldInInitializerInfo.getAnchorEntry(); + if (arrangedFields.indexOf(fieldInInitializer) > anchorEntryIndex) { + anchorField.addDependency(fieldInInitializer); + } } } } diff --git a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java index 053a534e0c98..a53bd1c9d187 100644 --- a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java +++ b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + /** * @author Dmitry Avdeev */ @@ -59,7 +61,7 @@ public abstract class CreateBeanPropertyFix implements LocalQuickFix, IntentionA if (type == null) { final Project project = psiClass.getProject(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); - final PsiClass aClass = facade.findClass("java.lang.String", GlobalSearchScope.allScope(project)); + final PsiClass aClass = facade.findClass(JAVA_LANG_STRING, GlobalSearchScope.allScope(project)); if (aClass == null) { return NO_FIXES; } diff --git a/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java b/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java index f3adf354de41..9375561d92e1 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package com.intellij.psi.impl.search; import com.intellij.find.findUsages.FindUsagesOptions; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Key; import com.intellij.psi.*; import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.util.PsiFormatUtil; @@ -34,34 +33,29 @@ import java.util.Set; * Author: msk */ public class ThrowSearchUtil { - private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.search.ThrowSearchUtil"); private ThrowSearchUtil() { } public static class Root { - final PsiElement myElement; - final PsiType myType; - final boolean isExact; + @NotNull private final PsiElement myElement; + @NotNull private final PsiType myType; + private final boolean isExact; - public Root(final PsiElement root, final PsiType type, final boolean exact) { + public Root(@NotNull PsiElement root, @NotNull PsiType type, final boolean exact) { myElement = root; myType = type; isExact = exact; } + @Override public String toString() { return PsiFormatUtil.formatType(myType, PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES, PsiSubstitutor.EMPTY); } } - public static Key<Root> THROW_SEARCH_ROOT_KEY = Key.create("ThrowSearchUtil.root"); - /** - * @param aCatch - * @param processor - * @param root * @return true, if we should continue processing */ private static boolean processExn(@NotNull PsiParameter aCatch, @NotNull Processor<UsageInfo> processor, @NotNull Root root) { @@ -123,7 +117,6 @@ public class ThrowSearchUtil { } /** - * @param exn * @return is type of exn exactly known */ diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java new file mode 100644 index 000000000000..db1a385d5137 --- /dev/null +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl; + +import com.intellij.codeInsight.daemon.impl.analysis.encoding.EncodingReference; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.impl.manipulators.StringLiteralManipulator; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; + +import java.nio.charset.Charset; + +import static com.intellij.patterns.PsiJavaPatterns.literalExpression; +import static com.intellij.patterns.PsiJavaPatterns.psiMethod; +import static com.intellij.patterns.StandardPatterns.string; + +/** + * @author peter + */ +public class JavaCharsetReferenceContributor extends PsiReferenceContributor { + @Override + public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { + registrar.registerReferenceProvider( + literalExpression().methodCallParameter( + 0, psiMethod().withName(string().oneOf("forName", "isSupported")).inClass(Charset.class.getName())), + new PsiReferenceProvider() { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { + PsiLiteralExpression literal = (PsiLiteralExpression)element; + Object value = literal.getValue(); + if (value instanceof String) { + return new PsiReference[]{new EncodingReference(element, (String)value, StringLiteralManipulator.getValueRange(literal))}; + } + return PsiReference.EMPTY_ARRAY; + } + }); + } +} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java index 06e5d4a672f4..dbcc03041c6f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.patterns.PsiJavaElementPattern; import com.intellij.psi.PsiLiteral; import com.intellij.psi.PsiReferenceContributor; import com.intellij.psi.PsiReferenceRegistrar; +import org.jetbrains.annotations.NotNull; import static com.intellij.patterns.PsiJavaPatterns.psiExpression; import static com.intellij.patterns.PsiJavaPatterns.psiLiteral; @@ -38,7 +39,7 @@ public class JavaReflectionReferenceContributor extends PsiReferenceContributor .definedInClass(JAVA_LANG_CLASS))); @Override - public void registerReferenceProviders(PsiReferenceRegistrar registrar) { + public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PATTERN, new JavaReflectionReferenceProvider()); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java index 7b85d17470ed..ce56ac3a36ad 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,11 @@ import java.util.ArrayList; * @author Gregory.Shrago */ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileSystemItem, PackagePrefixFileSystemItem { - private final PsiDirectory myDirectory; + @NotNull private final PsiDirectory myDirectory; private final int myIndex; private final PsiPackage[] myPackages; - public static PackagePrefixFileSystemItemImpl create(final PsiDirectory directory) { + public static PackagePrefixFileSystemItemImpl create(@NotNull PsiDirectory directory) { final ArrayList<PsiPackage> packages = new ArrayList<PsiPackage>(); for (PsiPackage cur = JavaDirectoryService.getInstance().getPackage(directory); cur != null; cur = cur.getParentPackage()) { packages.add(0, cur); @@ -49,7 +49,7 @@ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileS return new PackagePrefixFileSystemItemImpl(directory, 0, packages.toArray(new PsiPackage[packages.size()])); } - private PackagePrefixFileSystemItemImpl(final PsiDirectory directory, int index, final PsiPackage[] packages) { + private PackagePrefixFileSystemItemImpl(@NotNull PsiDirectory directory, int index, final PsiPackage[] packages) { myDirectory = directory; myIndex = index; myPackages = packages; @@ -249,6 +249,7 @@ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileS return myDirectory.getIcon(flags); } + @NotNull @Override public PsiDirectory getDirectory() { return myDirectory; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java index 5ffbaec2217d..195f06fb9cd3 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.PsiParameterizedCachedValue; @@ -38,9 +38,8 @@ import java.util.List; /** * @author cdr */ -public class JavaConcatenationInjectorManager implements ModificationTracker { +public class JavaConcatenationInjectorManager extends SimpleModificationTracker { public static final ExtensionPointName<ConcatenationAwareInjector> CONCATENATION_INJECTOR_EP_NAME = ExtensionPointName.create("com.intellij.concatenationAwareInjector"); - private volatile long myModificationCounter; public JavaConcatenationInjectorManager(Project project, PsiManagerEx psiManagerEx) { final ExtensionPoint<ConcatenationAwareInjector> concatPoint = Extensions.getArea(project).getExtensionPoint(CONCATENATION_INJECTOR_EP_NAME); @@ -58,7 +57,7 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { psiManagerEx.registerRunnableToRunOnAnyChange(new Runnable() { @Override public void run() { - myModificationCounter++; // clear caches even on non-physical changes + incModificationCount(); // clear caches even on non-physical changes } }); } @@ -67,11 +66,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { return ServiceManager.getService(project, JavaConcatenationInjectorManager.class); } - @Override - public long getModificationCount() { - return myModificationCounter; - } - private static Pair<PsiElement,PsiElement[]> computeAnchorAndOperandsImpl(@NotNull PsiElement context) { PsiElement element = context; PsiElement parent = context.getParent(); @@ -228,6 +222,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { } private void concatenationInjectorsChanged() { - myModificationCounter++; + incModificationCount(); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java index 271eb0ca87b6..e9b8da7f7d20 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,6 +160,7 @@ public class MyTestInjector { private static void injectVariousStuffEverywhere(Disposable parent, final PsiManager psiManager) { final Language ql = Language.findLanguageByID("JPAQL"); final Language js = Language.findLanguageByID("JavaScript"); + final Language html = Language.findLanguageByID("HTML"); if (ql == null || js == null) return; final Language ecma4 = Language.findLanguageByID("ECMA Script Level 4"); @@ -216,6 +217,7 @@ public class MyTestInjector { inject(host, placesToInject, js); return; } + if ("jsprefix".equals(attrName)) { inject(host, placesToInject, js, "function foo(doc, window){", "}"); return; @@ -235,6 +237,10 @@ public class MyTestInjector { inject(host, placesToInject, js); return; } + if ("htmlInject".equals(tag.getLocalName())) { + inject(host, placesToInject, html); + return; + } if (ecma4 != null && "ecma4".equals(tag.getLocalName())) { inject(host, placesToInject, ecma4); return; diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index a9fe12d19126..75544f9d8ab9 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -244,8 +244,6 @@ public class ExtractMethodProcessor implements MatchProvider { myOutputVariables = myControlFlowWrapper.getOutputVariables(); - checkCanBeChainedConstructor(); - return chooseTargetClass(codeFragment, pass); } @@ -1287,6 +1285,9 @@ public class ExtractMethodProcessor implements MatchProvider { if (!checkExitPoints()){ return false; } + + checkCanBeChainedConstructor(); + if (extractPass != null) { extractPass.pass(this); } diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalDialog.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalDialog.java index 78d96096a8e7..f994eeb07db0 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalDialog.java @@ -23,15 +23,15 @@ import com.intellij.refactoring.HelpID; import com.intellij.refactoring.JavaRefactoringSettings; import com.intellij.refactoring.RefactoringBundle; -public class InlineLocalDialog extends InlineOptionsDialog { +public class InlineLocalDialog extends AbstractInlineLocalDialog { public static final String REFACTORING_NAME = RefactoringBundle.message("inline.method.title"); private final PsiVariable myVariable; private int myOccurrencesNumber = -1; - public InlineLocalDialog(Project project, PsiVariable variable, PsiJavaCodeReferenceElement ref, int occurrencesCount) { - super(project, true, variable); + public InlineLocalDialog(Project project, PsiVariable variable, final PsiJavaCodeReferenceElement ref, int occurrencesCount) { + super(project, variable, ref, occurrencesCount); myVariable = variable; myInvokedOnReference = ref != null; diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java index 44fd8cb8f724..78e99d94ef51 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java @@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; @@ -147,15 +148,18 @@ public class InlineLocalHandler extends JavaInlineActionHandler { final Ref<Boolean> inlineAll = new Ref<Boolean>(true); if (editor != null && !ApplicationManager.getApplication().isUnitTestMode()) { int occurrencesCount = refsToInlineList.size(); - final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount); - inlineLocalDialog.show(); - if (!inlineLocalDialog.isOK()){ - WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); - return; - } - if (refExpr != null && inlineLocalDialog.isInlineThis()) { - refsToInlineList = Collections.<PsiElement>singletonList(refExpr); - inlineAll.set(false); + if (refExpr != null && occurrencesCount > 1 || EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog()) { + final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount); + inlineLocalDialog.show(); + if (!inlineLocalDialog.isOK()){ + WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); + return; + } + + if (refExpr != null && inlineLocalDialog.isInlineThis()) { + refsToInlineList = Collections.<PsiElement>singletonList(refExpr); + inlineAll.set(false); + } } } @@ -280,7 +284,7 @@ public class InlineLocalHandler extends JavaInlineActionHandler { finally { final RefactoringEventData afterData = new RefactoringEventData(); afterData.addElement(containingClass); - project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, afterData); + project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, afterData); } } }; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java index 071e2cf59bbc..4bae67e08f16 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -268,7 +268,7 @@ class IntroduceConstantDialog extends DialogWrapper { } final PsiManager psiManager = PsiManager.getInstance(myProject); - if ((myTypeSelectorManager.isSuggestedType("java.lang.String") || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false, false)))&& + if ((myTypeSelectorManager.isSuggestedType(CommonClassNames.JAVA_LANG_STRING) || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false, false)))&& LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) && JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) { final PropertiesComponent component = PropertiesComponent.getInstance(myProject); diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java index e24c40dbfe32..5bd1c20a0b1e 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java @@ -180,7 +180,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler { } else { final PsiReferenceParameterList parameterList = refExpr.getParameterList(); - if (parameterList != null && parameterList.getTypeArguments().length == 0){ + if (parameterList != null && parameterList.getTypeArguments().length == 0 && !(refExpr instanceof PsiMethodReferenceExpression)){ refExpr.setQualifierExpression(null); } else { final Project project = element.getProject(); diff --git a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java index 4f3bf58ab4ab..9e19232ede36 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java @@ -20,10 +20,7 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiParameter; +import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.codeStyle.VariableKind; import com.intellij.psi.impl.beanProperties.BeanProperty; @@ -56,7 +53,11 @@ public abstract class BeanPropertyRenameHandler implements RenameHandler { private void performInvoke(@Nullable Editor editor, DataContext dataContext) { final BeanProperty property = getProperty(dataContext); - new PropertyRenameDialog(property, editor).show(); + assert property != null; + PsiNamedElement element = property.getPsiElement(); + if (PsiElementRenameHandler.canRename(element.getProject(), editor, element)) { + new PropertyRenameDialog(property, editor).show(); + } } public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) { diff --git a/java/java-impl/src/com/intellij/slicer/SliceUtil.java b/java/java-impl/src/com/intellij/slicer/SliceUtil.java index f27701a88c67..6d556b5f9681 100644 --- a/java/java-impl/src/com/intellij/slicer/SliceUtil.java +++ b/java/java-impl/src/com/intellij/slicer/SliceUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,14 +64,25 @@ public class SliceUtil { expression = ((PsiArrayAccessExpression)expression).getArrayExpression(); indexNesting++; } - if (expression instanceof PsiExpressionList && indexNesting != 0 && expression.getParent() instanceof PsiMethodCallExpression) { + PsiElement par = expression == null ? null : expression.getParent(); + if (expression instanceof PsiExpressionList && par instanceof PsiMethodCallExpression) { // expression list ends up here if we track varargs - // unfold varargs list into individual expressions - PsiExpression[] expressions = ((PsiExpressionList)expression).getExpressions(); - for (PsiExpression arg : expressions) { - if (!handToProcessor(arg, processor, parent, parentSubstitutor, indexNesting -1, syntheticField)) return false; + PsiMethod method = ((PsiMethodCallExpression)par).resolveMethod(); + if (method != null) { + int parametersCount = method.getParameterList().getParametersCount(); + if (parametersCount != 0) { + // unfold varargs list into individual expressions + PsiExpression[] expressions = ((PsiExpressionList)expression).getExpressions(); + if (indexNesting != 0) { + // should skip not-vararg arguments + for (int i = parametersCount-1; i < expressions.length; i++) { + PsiExpression arg = expressions[i]; + if (!handToProcessor(arg, processor, parent, parentSubstitutor, indexNesting - 1, syntheticField)) return false; + } + } + return true; + } } - return true; } boolean needToReportDeclaration = false; @@ -409,7 +420,6 @@ public class SliceUtil { PsiType actualExpressionType; if (actualParameterType instanceof PsiEllipsisType) { passExpression = argumentList; - //passExpression = createArrayInitializerFromExpressions(argumentList, ((PsiEllipsisType)actualType).getComponentType(), expressions); actualExpressionType = expressions[paramSeqNo].getType(); } else { @@ -446,6 +456,10 @@ public class SliceUtil { if (substituted == null) return true; PsiType typeToCheck; if (actualParameterType instanceof PsiEllipsisType) { + // there may be the case of passing the vararg argument to the other vararg method: foo(int... ints) { bar(ints); } bar(int... ints) {} + if (TypeConversionUtil.areTypesConvertible(substituted, actualParameterType)) { + return handToProcessor(expressions[paramSeqNo], processor, parent, combined, indexNesting, syntheticField); + } typeToCheck = ((PsiEllipsisType)actualParameterType).getComponentType(); } else { diff --git a/java/java-impl/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java b/java/java-impl/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java index ee198727ffa8..0086b72ea0b1 100644 --- a/java/java-impl/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java +++ b/java/java-impl/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java @@ -15,23 +15,20 @@ */ package com.intellij.spellchecker; -import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInspection.BatchSuppressManager; import com.intellij.codeInspection.SuppressManager; -import com.intellij.codeInspection.SuppressQuickFix; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLiteralExpression; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy; +import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy; import com.intellij.spellchecker.tokenizer.Tokenizer; import org.jetbrains.annotations.NotNull; /** * @author shkate@jetbrains.com */ -public class JavaSpellcheckingStrategy extends SuppressibleSpellcheckingStrategy { +public class JavaSpellcheckingStrategy extends SpellcheckingStrategy { private final MethodNameTokenizerJava myMethodNameTokenizer = new MethodNameTokenizerJava(); private final DocCommentTokenizer myDocCommentTokenizer = new DocCommentTokenizer(); private final LiteralExpressionTokenizer myLiteralExpressionTokenizer = new LiteralExpressionTokenizer(); @@ -58,14 +55,4 @@ public class JavaSpellcheckingStrategy extends SuppressibleSpellcheckingStrategy return super.getTokenizer(element); } - - @Override - public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String name) { - return SuppressManager.getInstance().isSuppressedFor(element, name); - } - - @Override - public SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) { - return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(name)); - } } diff --git a/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java b/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java index 77246ec92763..2eade6903cd2 100644 --- a/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java +++ b/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java @@ -17,8 +17,10 @@ package com.intellij.spellchecker; import com.intellij.codeInsight.AnnotationUtil; import com.intellij.psi.JavaTokenType; +import com.intellij.psi.PsiLanguageInjectionHost; import com.intellij.psi.PsiLiteralExpression; import com.intellij.psi.PsiModifierListOwner; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.impl.source.tree.java.PsiLiteralExpressionImpl; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.spellchecker.inspections.PlainTextSplitter; @@ -30,8 +32,6 @@ import org.jetbrains.annotations.NotNull; import java.util.Collections; /** - * Created by IntelliJ IDEA. - * * @author shkate@jetbrains.com */ public class LiteralExpressionTokenizer extends Tokenizer<PsiLiteralExpression> { @@ -42,6 +42,8 @@ public class LiteralExpressionTokenizer extends Tokenizer<PsiLiteralExpression> return; // not a string literal } + if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) return; + final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class); if (listOwner != null && AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS), false, false)) { return; diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/AllClassesSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/AllClassesSearch.java index 21027204c180..db8c54d08d69 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/AllClassesSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/AllClassesSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class AllClassesSearch extends ExtensibleQueryFactory<PsiClass, AllClasse return myProject; } - public boolean nameMatches(String name) { + public boolean nameMatches(@NotNull String name) { return myShortNameCondition.value(name); } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java index abedbcbbda23..abca8f160a3d 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java @@ -54,6 +54,7 @@ public class VariableInIncompleteCodeSearcher extends QueryExecutorBase<PsiRefer if (element instanceof PsiJavaCodeReferenceElement) { final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)element; if (!ref.isQualified() && name.equals(ref.getText()) && + !(ref.getParent() instanceof PsiMethodCallExpression) && ref.resolve() == null && ref.advancedResolve(true).getElement() == refElement) { consumer.process(ref); } diff --git a/java/java-psi-api/src/com/intellij/codeInsight/folding/JavaCodeFoldingSettings.java b/java/java-psi-api/src/com/intellij/codeInsight/folding/JavaCodeFoldingSettings.java index 360b9832431d..5e45853f2f0f 100644 --- a/java/java-psi-api/src/com/intellij/codeInsight/folding/JavaCodeFoldingSettings.java +++ b/java/java-psi-api/src/com/intellij/codeInsight/folding/JavaCodeFoldingSettings.java @@ -64,4 +64,7 @@ public abstract class JavaCodeFoldingSettings { public abstract boolean isCollapseEndOfLineComments(); public abstract void setCollapseEndOfLineComments(boolean value); + + public abstract boolean isInlineParameterNamesForLiteralCallArguments(); + public abstract void setInlineParameterNamesForLiteralCallArguments(boolean value); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java index 55a5e9d55260..d1a1d7299d15 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java @@ -19,7 +19,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.Function; -import gnu.trove.THashSet; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -52,7 +52,7 @@ public class PsiIntersectionType extends PsiType.Stub { private static PsiType[] flattenAndRemoveDuplicates(PsiType[] conjuncts) { try { - Set<PsiType> flattened = flatten(conjuncts, new THashSet<PsiType>()); + Set<PsiType> flattened = flatten(conjuncts, ContainerUtil.<PsiType>newLinkedHashSet()); return flattened.toArray(createArray(flattened.size())); } catch (NoSuchElementException e) { diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java index 4c0e4be87185..fe45c66cf024 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java @@ -33,6 +33,7 @@ public class PsiMethodReferenceUtil { public static boolean hasReceiver(PsiType[] parameterTypes, QualifierResolveResult qualifierResolveResult, PsiMethodReferenceExpression methodRef) { if (parameterTypes.length > 0 && + !methodRef.isConstructor() && isReceiverType(parameterTypes[0], qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor()) && isStaticallyReferenced(methodRef)) { return true; diff --git a/java/java-psi-api/src/com/intellij/psi/PsiParameter.java b/java/java-psi-api/src/com/intellij/psi/PsiParameter.java index dc8b0aefdabc..b7ad72a17c29 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiParameter.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiParameter.java @@ -37,7 +37,7 @@ public interface PsiParameter extends PsiVariable { }; /** - * Returns the element (method, foreach statement or catch block) in which the + * Returns the element (method, lambda expression, foreach statement or catch block) in which the * parameter is declared. * * @return the declaration scope for the parameter. diff --git a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java index 917a88888d40..e7506ebd92fd 100644 --- a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java +++ b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java @@ -158,6 +158,7 @@ public class MethodCandidateInfo extends CandidateInfo{ return level; } + @NotNull public PsiSubstitutor getSiteSubstitutor() { PsiSubstitutor incompleteSubstitutor = super.getSubstitutor(); if (myTypeArguments != null) { diff --git a/java/java-psi-api/src/com/intellij/psi/search/PackageScope.java b/java/java-psi-api/src/com/intellij/psi/search/PackageScope.java index 19f72a8f91d5..a03f8849daa7 100644 --- a/java/java-psi-api/src/com/intellij/psi/search/PackageScope.java +++ b/java/java-psi-api/src/com/intellij/psi/search/PackageScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,10 +96,12 @@ public class PackageScope extends GlobalSearchScope { ", includeSubpackages = " + myIncludeSubpackages; } + @NotNull public static GlobalSearchScope packageScope(@NotNull PsiPackage aPackage, boolean includeSubpackages) { return new PackageScope(aPackage, includeSubpackages, true); } + @NotNull public static GlobalSearchScope packageScopeWithoutLibraries(@NotNull PsiPackage aPackage, boolean includeSubpackages) { return new PackageScope(aPackage, includeSubpackages, false); } diff --git a/java/java-psi-api/src/com/intellij/psi/search/searches/SuperMethodsSearch.java b/java/java-psi-api/src/com/intellij/psi/search/searches/SuperMethodsSearch.java index 877094929876..dba92bebcb65 100644 --- a/java/java-psi-api/src/com/intellij/psi/search/searches/SuperMethodsSearch.java +++ b/java/java-psi-api/src/com/intellij/psi/search/searches/SuperMethodsSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; import com.intellij.psi.util.MethodSignatureUtil; import com.intellij.util.Query; import com.intellij.util.QueryExecutor; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -38,8 +39,8 @@ public class SuperMethodsSearch extends ExtensibleQueryFactory<MethodSignatureBa private final boolean myCheckBases; private final boolean myAllowStaticMethod; - public SearchParameters(final PsiMethod method, - @Nullable final PsiClass aClass, + public SearchParameters(@NotNull PsiMethod method, + @Nullable PsiClass aClass, final boolean checkBases, final boolean allowStaticMethod) { myCheckBases = checkBases; @@ -52,6 +53,7 @@ public class SuperMethodsSearch extends ExtensibleQueryFactory<MethodSignatureBa return myCheckBases; } + @NotNull public final PsiMethod getMethod() { return myMethod; } @@ -69,7 +71,11 @@ public class SuperMethodsSearch extends ExtensibleQueryFactory<MethodSignatureBa private SuperMethodsSearch() { } - public static Query<MethodSignatureBackedByPsiMethod> search(final PsiMethod derivedMethod, @Nullable final PsiClass psiClass, boolean checkBases, boolean allowStaticMethod) { + @NotNull + public static Query<MethodSignatureBackedByPsiMethod> search(@NotNull PsiMethod derivedMethod, + @Nullable final PsiClass psiClass, + boolean checkBases, + boolean allowStaticMethod) { final SearchParameters parameters = new SearchParameters(derivedMethod, psiClass, checkBases, allowStaticMethod); return SUPER_METHODS_SEARCH_INSTANCE.createUniqueResultsQuery(parameters, MethodSignatureUtil.METHOD_BASED_HASHING_STRATEGY); } diff --git a/java/java-psi-api/src/com/intellij/psi/util/IsConstantExpressionVisitor.java b/java/java-psi-api/src/com/intellij/psi/util/IsConstantExpressionVisitor.java index 531edd732fae..be304ff5396f 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/IsConstantExpressionVisitor.java +++ b/java/java-psi-api/src/com/intellij/psi/util/IsConstantExpressionVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ import gnu.trove.THashMap; import java.util.Map; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public class IsConstantExpressionVisitor extends JavaElementVisitor { protected boolean myIsConstant; private final Map<PsiVariable, Boolean> varIsConst = new THashMap<PsiVariable, Boolean>(); @@ -63,7 +65,7 @@ public class IsConstantExpressionVisitor extends JavaElementVisitor { } PsiType type = element.getType(); if (type instanceof PsiPrimitiveType) return; - if (type.equalsToText("java.lang.String")) return; + if (type.equalsToText(JAVA_LANG_STRING)) return; myIsConstant = false; } @@ -88,7 +90,7 @@ public class IsConstantExpressionVisitor extends JavaElementVisitor { operand.accept(this); if (!myIsConstant) return; final PsiType type = operand.getType(); - if (type != null && !(type instanceof PsiPrimitiveType) && !type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { + if (type != null && !(type instanceof PsiPrimitiveType) && !type.equalsToText(JAVA_LANG_STRING)) { myIsConstant = false; return; } diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java index adc9306ec962..5d11f1fb5005 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java +++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,10 +66,12 @@ public class MethodSignatureBackedByPsiMethod extends MethodSignatureBase { return myMethod; } + @NotNull public static MethodSignatureBackedByPsiMethod create(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) { return create(method, substitutor, PsiUtil.isRawSubstitutor(method, substitutor)); } + @NotNull public static MethodSignatureBackedByPsiMethod create(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, boolean isRaw) { PsiTypeParameter[] methodTypeParameters = method.getTypeParameters(); if (isRaw) { diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiConcatenationUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiConcatenationUtil.java index feeb28037a5b..70c97495995b 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiConcatenationUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiConcatenationUtil.java @@ -22,6 +22,8 @@ import com.intellij.util.IncorrectOperationException; import java.util.List; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + /** * User: cdr */ @@ -42,11 +44,11 @@ public class PsiConcatenationUtil { formatString.append(formatText); } else if (expression instanceof PsiPolyadicExpression) { final PsiType type = expression.getType(); - if (type != null && type.equalsToText("java.lang.String")) { + if (type != null && type.equalsToText(JAVA_LANG_STRING)) { final PsiPolyadicExpression binaryExpression = (PsiPolyadicExpression) expression; PsiExpression[] operands = binaryExpression.getOperands(); PsiType left = operands[0].getType(); - boolean stringStarted = left != null && left.equalsToText("java.lang.String"); + boolean stringStarted = left != null && left.equalsToText(JAVA_LANG_STRING); if (stringStarted) { buildFormatString(operands[0], formatString, formatParameters, printfFormat); } @@ -54,7 +56,7 @@ public class PsiConcatenationUtil { PsiExpression op = operands[i]; PsiType optype = op.getType(); PsiType r = TypeConversionUtil.calcTypeForBinaryExpression(left, optype, binaryExpression.getOperationTokenType(), true); - if (r != null && r.equalsToText("java.lang.String") && !stringStarted) { + if (r != null && r.equalsToText(JAVA_LANG_STRING) && !stringStarted) { stringStarted = true; PsiElement element = binaryExpression.getTokenBeforeOperand(op); if (element.getPrevSibling() instanceof PsiWhiteSpace) element = element.getPrevSibling(); @@ -64,7 +66,7 @@ public class PsiConcatenationUtil { addFormatParameter(subExpression, formatString, formatParameters, printfFormat); } if (stringStarted) { - if (optype != null && (optype.equalsToText("java.lang.String") || optype == PsiType.CHAR)) { + if (optype != null && (optype.equalsToText(JAVA_LANG_STRING) || optype == PsiType.CHAR)) { buildFormatString(op, formatString, formatParameters, printfFormat); } else { diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index c63a1373b00b..b71214f907f0 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -39,12 +39,15 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.EmptyIterable; import com.intellij.util.containers.HashMap; import gnu.trove.THashSet; +import org.intellij.lang.annotations.MagicConstant; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public final class PsiUtil extends PsiUtilCore { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.util.PsiUtil"); @@ -311,19 +314,18 @@ public final class PsiUtil extends PsiUtilCore { return false; } + @MagicConstant(intValues = {ACCESS_LEVEL_PUBLIC, ACCESS_LEVEL_PROTECTED, ACCESS_LEVEL_PACKAGE_LOCAL, ACCESS_LEVEL_PRIVATE}) public static int getAccessLevel(@NotNull PsiModifierList modifierList) { if (modifierList.hasModifierProperty(PsiModifier.PRIVATE)) { return ACCESS_LEVEL_PRIVATE; } - else if (modifierList.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) { + if (modifierList.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) { return ACCESS_LEVEL_PACKAGE_LOCAL; } - else if (modifierList.hasModifierProperty(PsiModifier.PROTECTED)) { + if (modifierList.hasModifierProperty(PsiModifier.PROTECTED)) { return ACCESS_LEVEL_PROTECTED; } - else { - return ACCESS_LEVEL_PUBLIC; - } + return ACCESS_LEVEL_PUBLIC; } @PsiModifier.ModifierConstant @@ -590,7 +592,7 @@ public final class PsiUtil extends PsiUtilCore { */ public static boolean isCompileTimeConstant(@NotNull final PsiField field) { return field.hasModifierProperty(PsiModifier.FINAL) - && (TypeConversionUtil.isPrimitiveAndNotNull(field.getType()) || field.getType().equalsToText("java.lang.String")) + && (TypeConversionUtil.isPrimitiveAndNotNull(field.getType()) || field.getType().equalsToText(JAVA_LANG_STRING)) && field.hasInitializer() && isConstantExpression(field.getInitializer()); } diff --git a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java index 0fbfa4a059f9..d4382b40db7a 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java @@ -504,8 +504,22 @@ public class RedundantCastUtil { return; } if (parent instanceof PsiForeachStatement) { - if (InheritanceUtil.isInheritor(PsiUtil.resolveClassInType(opType), false, CommonClassNames.JAVA_LANG_ITERABLE)) { - addToResults(typeCast); + final PsiClassType.ClassResolveResult castResolveResult = PsiUtil.resolveGenericsClassInType(opType); + final PsiClass psiClass = castResolveResult.getElement(); + if (psiClass != null) { + final PsiClass iterableClass = JavaPsiFacade.getInstance(parent.getProject()).findClass(CommonClassNames.JAVA_LANG_ITERABLE, psiClass.getResolveScope()); + if (iterableClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, iterableClass, true)) { + final PsiTypeParameter[] iterableTypeParameters = iterableClass.getTypeParameters(); + if (iterableTypeParameters.length == 1) { + final PsiType resultedParamType = TypeConversionUtil.getSuperClassSubstitutor(iterableClass, psiClass, castResolveResult.getSubstitutor()).substitute(iterableTypeParameters[0]); + if (resultedParamType != null && + TypeConversionUtil.isAssignable(((PsiForeachStatement)parent).getIterationParameter().getType(), resultedParamType)) { + addToResults(typeCast); + return; + } + } + } + } else { return; } } diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index 5a793b9ef340..477a74e64b2e 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,8 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + public class TypeConversionUtil { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.util.TypeConversionUtil"); @@ -469,7 +471,7 @@ public class TypeConversionUtil { int rank = TYPE_TO_RANK_MAP.get(type); if (rank != 0) return rank; - if (type.equalsToText("java.lang.String")) return STRING_RANK; + if (type.equalsToText(JAVA_LANG_STRING)) return STRING_RANK; return Integer.MAX_VALUE; } @@ -531,12 +533,12 @@ public class TypeConversionUtil { } } else if (tokenType == JavaTokenType.PLUS) { - if (ltype.equalsToText("java.lang.String")) { + if (ltype.equalsToText(JAVA_LANG_STRING)) { isApplicable = !isVoidType(rtype); resultTypeRank = STRING_RANK; break Label; } - else if (rtype.equalsToText("java.lang.String")) { + else if (rtype.equalsToText(JAVA_LANG_STRING)) { isApplicable = !isVoidType(ltype); resultTypeRank = STRING_RANK; break Label; @@ -1370,7 +1372,7 @@ public class TypeConversionUtil { public static Object computeCastTo(final Object operand, final PsiType castType) { if (operand == null || castType == null) return null; Object value; - if (operand instanceof String && castType.equalsToText("java.lang.String")) { + if (operand instanceof String && castType.equalsToText(JAVA_LANG_STRING)) { value = operand; } else if (operand instanceof Boolean && PsiType.BOOLEAN.equals(castType)) { @@ -1444,12 +1446,12 @@ public class TypeConversionUtil { if (sign == JavaTokenType.PLUS) { // evaluate right argument first, since '+-/*%' is left associative and left operand tends to be bigger if (rType == null) return null; - if (rType.equalsToText("java.lang.String")) { + if (rType.equalsToText(JAVA_LANG_STRING)) { return rType; } if (!accessLType) return NULL_TYPE; if (lType == null) return null; - if (lType.equalsToText("java.lang.String")) { + if (lType.equalsToText(JAVA_LANG_STRING)) { return lType; } return unboxAndBalanceTypes(lType, rType); diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java b/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java index 81dda5863402..5e13c8f780fc 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java @@ -57,7 +57,7 @@ public class TypesDistinctProver { final PsiClass boundClass1 = PsiUtil.resolveClassInType(extendsBound); if (boundClass1 == null) return false; - if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass2.getQualifiedName())) { + if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass2.getQualifiedName()) && !(boundClass1 instanceof PsiTypeParameter)) { return !CommonClassNames.JAVA_LANG_OBJECT.equals(boundClass1.getQualifiedName()); } @@ -121,7 +121,7 @@ public class TypesDistinctProver { if (substitutedType1 instanceof PsiWildcardType && !((PsiWildcardType)substitutedType1).isBounded()) return true; } } - return false; + if (level < 2) return false; } final PsiClass boundClass1 = classResolveResult1.getElement(); diff --git a/java/java-psi-api/src/com/intellij/util/VisibilityIcons.java b/java/java-psi-api/src/com/intellij/util/VisibilityIcons.java index 1988e63586a8..96d903a1a1b9 100644 --- a/java/java-psi-api/src/com/intellij/util/VisibilityIcons.java +++ b/java/java-psi-api/src/com/intellij/util/VisibilityIcons.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.psi.PsiModifierList; import com.intellij.psi.util.PsiUtil; import com.intellij.ui.RowIcon; import com.intellij.util.ui.EmptyIcon; +import org.intellij.lang.annotations.MagicConstant; import javax.swing.*; @@ -55,7 +56,7 @@ public class VisibilityIcons { } } - public static void setVisibilityIcon(int accessLevel, RowIcon baseIcon) { + public static void setVisibilityIcon(@MagicConstant(intValues = {PsiUtil.ACCESS_LEVEL_PUBLIC, PsiUtil.ACCESS_LEVEL_PROTECTED, PsiUtil.ACCESS_LEVEL_PACKAGE_LOCAL, PsiUtil.ACCESS_LEVEL_PRIVATE}) int accessLevel, RowIcon baseIcon) { Icon icon; switch (accessLevel) { case PsiUtil.ACCESS_LEVEL_PUBLIC: diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaCodeFoldingSettingsBase.java b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaCodeFoldingSettingsBase.java index ee3ff0c3ffd8..647a1e45ac13 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaCodeFoldingSettingsBase.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaCodeFoldingSettingsBase.java @@ -14,6 +14,7 @@ public class JavaCodeFoldingSettingsBase extends JavaCodeFoldingSettings { @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_I18N_MESSAGES = true; @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_SUPPRESS_WARNINGS = true; @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_END_OF_LINE_COMMENTS = false; + @SuppressWarnings({"WeakerAccess"}) public boolean INLINE_PARAMETER_NAMES_FOR_LITERAL_CALL_ARGUMENTS = true; @Override public boolean isCollapseImports() { @@ -148,4 +149,14 @@ public class JavaCodeFoldingSettingsBase extends JavaCodeFoldingSettings { public void setCollapseEndOfLineComments(boolean value) { COLLAPSE_END_OF_LINE_COMMENTS = value; } + + @Override + public boolean isInlineParameterNamesForLiteralCallArguments() { + return INLINE_PARAMETER_NAMES_FOR_LITERAL_CALL_ARGUMENTS; + } + + @Override + public void setInlineParameterNamesForLiteralCallArguments(boolean value) { + INLINE_PARAMETER_NAMES_FOR_LITERAL_CALL_ARGUMENTS = value; + } } diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java index 15d40f1baf4b..9f5ecb109fd5 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java @@ -41,13 +41,11 @@ import com.intellij.psi.impl.source.tree.JavaDocElementType; import com.intellij.psi.impl.source.tree.JavaElementType; import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PropertyUtil; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.PsiUtilCore; +import com.intellij.psi.util.*; import com.intellij.util.Function; import com.intellij.util.ObjectUtils; import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -703,6 +701,12 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem else if (element instanceof PsiComment) { return settings.isCollapseEndOfLineComments(); } + else if (isLiteralExpression(element) + && element.getParent() instanceof PsiExpressionList + && (element.getParent().getParent() instanceof PsiCallExpression + || element.getParent().getParent() instanceof PsiAnonymousClass)) { + return settings.isInlineParameterNamesForLiteralCallArguments(); + } else { LOG.error("Unknown element:" + element); return false; @@ -725,6 +729,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem public void visitMethodCallExpression(PsiMethodCallExpression expression) { if (!dumb) { addMethodGenericParametersFolding(expression, foldElements, document, quick); + inlineLiteralArgumentsNames(expression, foldElements, quick); } super.visitMethodCallExpression(expression); @@ -734,6 +739,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem public void visitNewExpression(PsiNewExpression expression) { if (!dumb) { addGenericParametersFolding(expression, foldElements, document, quick); + inlineLiteralArgumentsNames(expression, foldElements, quick); } super.visitNewExpression(expression); @@ -747,6 +753,64 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem }); } + private static void inlineLiteralArgumentsNames(@NotNull PsiCallExpression expression, + @NotNull List<FoldingDescriptor> foldElements, + boolean quick) + { + if (quick || !JavaCodeFoldingSettings.getInstance().isInlineParameterNamesForLiteralCallArguments()) { + return; + } + PsiExpressionList callArgumentsList = expression.getArgumentList(); + if (callArgumentsList == null) { + return; + } + + PsiExpression[] callArguments = callArgumentsList.getExpressions(); + if (callArguments.length > 1) { + PsiParameter[] parameters = null; + boolean isResolved = false; + + for (int i = 0; i < callArguments.length; i++) { + PsiExpression callArgument = callArguments[i]; + + if (callArgument.getType() != null && isLiteralExpression(callArgument)) { + if (!isResolved) { + PsiMethod method = expression.resolveMethod(); + isResolved = true; + if (method == null) { + return; + } + parameters = method.getParameterList().getParameters(); + if (parameters.length != callArguments.length) { + return; + } + } + + PsiParameter methodParam = parameters[i]; + if (TypeConversionUtil.isAssignable(methodParam.getType(), callArgument.getType())) { + TextRange range = callArgument.getTextRange(); + String placeholderText = methodParam.getName() + ": " + callArgument.getText(); + foldElements.add(new NamedFoldingDescriptor(callArgument, range.getStartOffset(), range.getEndOffset(), null, placeholderText)); + } + } + } + } + } + + @Contract("null -> false") + private static boolean isLiteralExpression(@Nullable PsiElement callArgument) { + if (callArgument instanceof PsiLiteralExpression) + return true; + + if (callArgument instanceof PsiPrefixExpression) { + PsiPrefixExpression expr = (PsiPrefixExpression)callArgument; + IElementType tokenType = expr.getOperationTokenType(); + return JavaTokenType.MINUS.equals(tokenType) && expr.getOperand() instanceof PsiLiteralExpression; + } + + return false; + } + private boolean addClosureFolding(final PsiClass aClass, final Document document, final List<FoldingDescriptor> foldElements, @NotNull Set<PsiElement> processedComments, final boolean quick) { if (!JavaCodeFoldingSettings.getInstance().isCollapseLambdas()) { diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index 7b154bd5383c..0052dd5bb8b9 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -253,13 +253,13 @@ public class JavaDocInfoGenerator { public static String generateSignature(PsiElement element) { StringBuilder buf = new StringBuilder(); if (element instanceof PsiClass) { - if (generateClassSignature(buf, (PsiClass)element)) return null; + if (generateClassSignature(buf, (PsiClass)element, false)) return null; } else if (element instanceof PsiField) { - generateFieldSignature(buf, (PsiField)element); + generateFieldSignature(buf, (PsiField)element, false); } else if (element instanceof PsiMethod) { - generateMethodSignature(buf, (PsiMethod)element); + generateMethodSignature(buf, (PsiMethod)element, false); } return buf.toString(); } @@ -291,7 +291,6 @@ public class JavaDocInfoGenerator { private void generateClassJavaDoc(@NonNls StringBuilder buffer, PsiClass aClass, boolean generatePrologueAndEpilogue) { if (aClass instanceof PsiAnonymousClass) return; - PsiManager manager = aClass.getManager(); if (generatePrologueAndEpilogue) generatePrologue(buffer); @@ -307,7 +306,7 @@ public class JavaDocInfoGenerator { } buffer.append("<PRE>"); - if (generateClassSignature(buffer, aClass)) return; + if (generateClassSignature(buffer, aClass, true)) return; buffer.append("</PRE>"); //buffer.append("<br>"); @@ -321,8 +320,8 @@ public class JavaDocInfoGenerator { generateEpilogue(buffer); } - private static boolean generateClassSignature(StringBuilder buffer, PsiClass aClass) { - generateAnnotations(buffer, aClass); + private static boolean generateClassSignature(StringBuilder buffer, PsiClass aClass, boolean generateLink) { + generateAnnotations(buffer, aClass, generateLink); String modifiers = PsiFormatUtil.formatModifiers(aClass, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY); if (!modifiers.isEmpty()) { buffer.append(modifiers); @@ -355,7 +354,7 @@ public class JavaDocInfoGenerator { } else { for (int i = 0; i < refs.length; i++) { - generateType(buffer, refs[i], aClass); + generateType(buffer, refs[i], aClass, generateLink); if (i < refs.length - 1) { buffer.append(", "); } @@ -369,7 +368,7 @@ public class JavaDocInfoGenerator { if (refs.length > 0) { buffer.append("implements "); for (int i = 0; i < refs.length; i++) { - generateType(buffer, refs[i], aClass); + generateType(buffer, refs[i], aClass, generateLink); if (i < refs.length - 1) { buffer.append(", "); } @@ -472,7 +471,7 @@ public class JavaDocInfoGenerator { } buffer.append("<PRE>"); - generateFieldSignature(buffer, field); + generateFieldSignature(buffer, field, true); buffer.append("</PRE>"); //buffer.append("<br>"); @@ -487,14 +486,14 @@ public class JavaDocInfoGenerator { generateEpilogue(buffer); } - private static void generateFieldSignature(StringBuilder buffer, PsiField field) { - generateAnnotations(buffer, field); + private static void generateFieldSignature(StringBuilder buffer, PsiField field, boolean generateLink) { + generateAnnotations(buffer, field, generateLink); String modifiers = PsiFormatUtil.formatModifiers(field, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY); if (!modifiers.isEmpty()) { buffer.append(modifiers); buffer.append(" "); } - generateType(buffer, field.getType(), field); + generateType(buffer, field.getType(), field, generateLink); buffer.append(" "); buffer.append("<b>"); buffer.append(field.getName()); @@ -696,14 +695,21 @@ public class JavaDocInfoGenerator { } } - private static void generateAnnotations(@NonNls @NotNull StringBuilder buffer, @NotNull PsiModifierListOwner owner) { + private static void generateAnnotations(@NonNls @NotNull StringBuilder buffer, @NotNull PsiModifierListOwner owner, boolean generateLink) { final PsiModifierList ownerModifierList = owner.getModifierList(); if (ownerModifierList == null) return; - PsiAnnotation[] annotations = ownerModifierList.getAnnotations(); + generateAnnotations(buffer, owner, ownerModifierList.getAnnotations(), false, generateLink); final PsiAnnotation[] externalAnnotations = ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotations(owner); if (externalAnnotations != null) { - annotations = ArrayUtil.mergeArrays(annotations, externalAnnotations, PsiAnnotation.ARRAY_FACTORY); + generateAnnotations(buffer, owner, externalAnnotations, true, generateLink); } + } + + private static void generateAnnotations(StringBuilder buffer, + PsiModifierListOwner owner, + PsiAnnotation[] annotations, + boolean external, + boolean generateLink) { PsiManager manager = owner.getManager(); for (PsiAnnotation annotation : annotations) { @@ -715,7 +721,7 @@ public class JavaDocInfoGenerator { if (AnnotationUtil.isAnnotated(annotationType, "java.lang.annotation.Documented", false)) { final PsiClassType type = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(annotationType, PsiSubstitutor.EMPTY); buffer.append("@"); - generateType(buffer, type, owner); + generateType(buffer, type, owner, generateLink); final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes(); if (attributes.length > 0) { buffer.append("("); @@ -737,12 +743,17 @@ public class JavaDocInfoGenerator { } buffer.append(" "); } - } else { + } else if (external) { + buffer.append(annotation.getText()); + buffer.append(" "); + } + else { buffer.append("<font color=red>"); buffer.append(annotation.getText()); buffer.append("</font>"); buffer.append(" "); } + buffer.append("\n"); } } @@ -756,7 +767,7 @@ public class JavaDocInfoGenerator { buffer.append(modifiers); buffer.append(" "); } - generateAnnotations(buffer, parameter); + generateAnnotations(buffer, parameter, true); generateType(buffer, parameter.getType(), parameter); buffer.append(" "); buffer.append("<b>"); @@ -801,7 +812,7 @@ public class JavaDocInfoGenerator { } buffer.append("<PRE>"); - generateMethodSignature(buffer, method); + generateMethodSignature(buffer, method, true); buffer.append("</PRE>"); //buffer.append("<br>"); @@ -831,8 +842,8 @@ public class JavaDocInfoGenerator { generateEpilogue(buffer); } - private static void generateMethodSignature(StringBuilder buffer, PsiMethod method) { - generateAnnotations(buffer, method); + private static void generateMethodSignature(StringBuilder buffer, PsiMethod method, boolean generateLink) { + generateAnnotations(buffer, method, generateLink); String modifiers = PsiFormatUtil.formatModifiers(method, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY); int indent = 0; if (!modifiers.isEmpty()) { @@ -850,7 +861,7 @@ public class JavaDocInfoGenerator { } if (method.getReturnType() != null) { - indent += generateType(buffer, method.getReturnType(), method); + indent += generateType(buffer, method.getReturnType(), method, generateLink); buffer.append(" "); indent++; } @@ -865,8 +876,8 @@ public class JavaDocInfoGenerator { PsiParameter[] parms = method.getParameterList().getParameters(); for (int i = 0; i < parms.length; i++) { PsiParameter parm = parms[i]; - generateAnnotations(buffer, parm); - generateType(buffer, parm.getType(), method); + generateAnnotations(buffer, parm, generateLink); + generateType(buffer, parm.getType(), method, generateLink); buffer.append(" "); if (parm.getName() != null) { buffer.append(parm.getName()); @@ -1862,9 +1873,11 @@ public class JavaDocInfoGenerator { return null; } - @Nullable private <T> Pair<T, InheritDocProvider<T>> searchDocTagInSupers(PsiClassType[] supers, + @Nullable + private <T> Pair<T, InheritDocProvider<T>> searchDocTagInSupers(PsiClassType[] supers, PsiMethod method, - DocTagLocator<T> loc) { + DocTagLocator<T> loc, + Set<PsiClass> visitedClasses) { for (PsiClassType superType : supers) { PsiClass aSuper = superType.resolve(); @@ -1878,8 +1891,8 @@ public class JavaDocInfoGenerator { for (PsiClassType superType : supers) { PsiClass aSuper = superType.resolve(); - if (aSuper != null) { - Pair<T, InheritDocProvider<T>> tag = findInheritDocTagInClass(method, aSuper, loc); + if (aSuper != null && visitedClasses.add(aSuper)) { + Pair<T, InheritDocProvider<T>> tag = findInheritDocTagInClass(method, aSuper, loc, visitedClasses); if (tag != null) { return tag; @@ -1892,20 +1905,21 @@ public class JavaDocInfoGenerator { private <T> Pair<T, InheritDocProvider<T>> findInheritDocTagInClass(PsiMethod aMethod, PsiClass aClass, - DocTagLocator<T> loc) { + DocTagLocator<T> loc, + Set<PsiClass> visitedClasses) { if (aClass == null) { return null; } PsiClassType[] implementsTypes = aClass.getImplementsListTypes(); - Pair<T, InheritDocProvider<T>> tag = searchDocTagInSupers(implementsTypes, aMethod, loc); + Pair<T, InheritDocProvider<T>> tag = searchDocTagInSupers(implementsTypes, aMethod, loc, visitedClasses); if (tag != null) { return tag; } PsiClassType[] extendsTypes = aClass.getExtendsListTypes(); - return searchDocTagInSupers(extendsTypes, aMethod, loc); + return searchDocTagInSupers(extendsTypes, aMethod, loc, visitedClasses); } @Nullable private <T> Pair<T, InheritDocProvider<T>> findInheritDocTag(PsiMethod method, DocTagLocator<T> loc) { @@ -1913,7 +1927,7 @@ public class JavaDocInfoGenerator { if (aClass == null) return null; - return findInheritDocTagInClass(method, aClass, loc); + return findInheritDocTagInClass(method, aClass, loc, new HashSet<PsiClass>()); } private static class ReturnTagLocator implements DocTagLocator<PsiDocTag> { diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java index a012988edf08..0cfb60b3ae69 100644 --- a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -181,6 +181,7 @@ public class CoreJavaFileManager implements JavaFileManager { return null; } + @NotNull @Override public PsiClass[] findClasses(@NotNull String qName, @NotNull GlobalSearchScope scope) { List<PsiClass> result = new ArrayList<PsiClass>(); @@ -193,6 +194,7 @@ public class CoreJavaFileManager implements JavaFileManager { return result.toArray(new PsiClass[result.size()]); } + @NotNull @Override public Collection<String> getNonTrivialPackagePrefixes() { return Collections.emptyList(); diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java index b71bdefee9be..d676f03f611a 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java @@ -39,10 +39,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.psi.*; import com.intellij.psi.augment.PsiAugmentProvider; +import com.intellij.psi.compiled.ClassFileDecompilers; import com.intellij.psi.impl.EmptySubstitutorImpl; import com.intellij.psi.impl.LanguageConstantExpressionEvaluator; import com.intellij.psi.impl.PsiExpressionEvaluator; import com.intellij.psi.impl.compiled.ClassFileStubBuilder; +import com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy; import com.intellij.psi.impl.compiled.ClsStubBuilderFactory; import com.intellij.psi.impl.file.PsiPackageImplementationHelper; import com.intellij.psi.impl.source.tree.CoreJavaASTFactory; @@ -54,6 +56,7 @@ import org.jetbrains.annotations.NotNull; /** * @author yole */ +@SuppressWarnings("UnusedDeclaration") // Upsource and Kotlin public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { public JavaCoreApplicationEnvironment(@NotNull Disposable parentDisposable) { super(parentDisposable); @@ -105,8 +108,12 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { return false; } }); + + registerExtensionPoint(Extensions.getRootArea(), ClsCustomNavigationPolicy.EP_NAME, ClsCustomNavigationPolicy.class); + registerExtensionPoint(Extensions.getRootArea(), ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class); } + @SuppressWarnings("MethodMayBeStatic") // overridden in upsource protected CoreJavaDirectoryService createJavaDirectoryService() { return new CoreJavaDirectoryService(); } diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java index de870b9cfcbf..4a73a85da0bc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java @@ -28,6 +28,7 @@ import static com.intellij.psi.compiled.ClassFileDecompilers.Full; * @author max */ public class ClassFileViewProviderFactory implements FileViewProviderFactory { + @NotNull @Override public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); diff --git a/java/java-psi-impl/src/com/intellij/psi/NonClasspathClassFinder.java b/java/java-psi-impl/src/com/intellij/psi/NonClasspathClassFinder.java index 2d11fc963cec..59a4e10d40fe 100644 --- a/java/java-psi-impl/src/com/intellij/psi/NonClasspathClassFinder.java +++ b/java/java-psi-impl/src/com/intellij/psi/NonClasspathClassFinder.java @@ -23,7 +23,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.impl.file.PsiPackageImpl; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.NonClasspathDirectoryScope; +import com.intellij.psi.search.NonClasspathDirectoriesScope; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; @@ -252,7 +252,7 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder { GlobalSearchScope scope = base; for (PsiElementFinder finder : Extensions.getExtensions(EP_NAME, project)) { if (finder instanceof NonClasspathClassFinder) { - scope = scope.uniteWith(NonClasspathDirectoryScope.compose(((NonClasspathClassFinder)finder).getClassRoots())); + scope = scope.uniteWith(NonClasspathDirectoriesScope.compose(((NonClasspathClassFinder)finder).getClassRoots())); } } return scope; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 107bff5e60f2..3496b98f5ddf 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -760,7 +760,6 @@ public class PsiClassImplUtil { @NotNull private static PsiClass[] getSupersInner(@NotNull PsiClass psiClass) { PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes(); - PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes(); if (psiClass.isInterface()) { return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), true); @@ -792,6 +791,7 @@ public class PsiClassImplUtil { return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); } + PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes(); PsiClass[] interfaces = resolveClassReferenceList(implementsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); PsiClass superClass = getSuperClass(psiClass); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java index e5080d3dfafe..514087492300 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java @@ -537,8 +537,10 @@ public class PsiImplUtil { @NotNull public static SearchScope getMemberUseScope(@NotNull PsiMember member) { - final GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(member); PsiFile file = member.getContainingFile(); + PsiElement topElement = file == null ? member : file; + Project project = topElement.getProject(); + final GlobalSearchScope maximalUseScope = ResolveScopeManager.getInstance(project).getUseScope(topElement); if (isInServerPage(file)) return maximalUseScope; PsiClass aClass = member.getContainingClass(); @@ -549,28 +551,23 @@ public class PsiImplUtil { return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass); } - if (member.hasModifierProperty(PsiModifier.PUBLIC)) { + PsiModifierList modifierList = member.getModifierList(); + int accessLevel = modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList); + if (accessLevel == PsiUtil.ACCESS_LEVEL_PUBLIC || accessLevel == PsiUtil.ACCESS_LEVEL_PROTECTED) { return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass } - else if (member.hasModifierProperty(PsiModifier.PROTECTED)) { - return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass - } - else if (member.hasModifierProperty(PsiModifier.PRIVATE)) { + if (accessLevel == PsiUtil.ACCESS_LEVEL_PRIVATE) { PsiClass topClass = PsiUtil.getTopLevelClass(member); - return topClass != null ? new LocalSearchScope(topClass) : file != null ? new LocalSearchScope(file) : maximalUseScope; + return topClass != null ? new LocalSearchScope(topClass) : file == null ? maximalUseScope : new LocalSearchScope(file); } - else { - if (file instanceof PsiJavaFile) { - PsiPackage aPackage = JavaPsiFacade.getInstance(member.getProject()).findPackage(((PsiJavaFile)file).getPackageName()); - if (aPackage != null) { - SearchScope scope = PackageScope.packageScope(aPackage, false); - scope = scope.intersectWith(maximalUseScope); - return scope; - } + if (file instanceof PsiJavaFile) { + PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(((PsiJavaFile)file).getPackageName()); + if (aPackage != null) { + SearchScope scope = PackageScope.packageScope(aPackage, false); + return scope.intersectWith(maximalUseScope); } - - return maximalUseScope; } + return maximalUseScope; } public static boolean isInServerPage(@Nullable final PsiElement element) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index e2065ce3d46c..7c597e495f2e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -158,10 +158,16 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { } if (newBound instanceof PsiCapturedWildcardType) { final PsiWildcardType wildcard = ((PsiCapturedWildcardType)newBound).getWildcard(); - if (wildcardType.isExtends() != wildcard.isExtends() && wildcard.isBounded()) { - return wildcardType.isExtends() ? PsiWildcardType.createExtends(wildcardType.getManager(), newBound) - : PsiWildcardType.createSuper(wildcardType.getManager(), newBound); + if (wildcardType.isExtends() != wildcard.isExtends()) { + if (wildcard.isBounded()) { + return wildcardType.isExtends() ? PsiWildcardType.createExtends(wildcardType.getManager(), newBound) + : PsiWildcardType.createSuper(wildcardType.getManager(), newBound); + } + else { + return newBound; + } } + if (!wildcard.isBounded()) return PsiWildcardType.createUnbounded(wildcardType.getManager()); return newBound; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java index d70fa1f4be4b..f1d847cb24c2 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java @@ -17,15 +17,16 @@ package com.intellij.psi.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl; +import com.intellij.psi.impl.source.PsiClassImpl; import com.intellij.psi.search.searches.DeepestSuperMethodsSearch; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.*; -import com.intellij.util.NotNullFunction; -import com.intellij.util.Processor; -import com.intellij.util.SmartList; +import com.intellij.util.*; import gnu.trove.THashMap; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; @@ -36,8 +37,8 @@ import java.util.*; public class PsiSuperMethodImplUtil { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiSuperMethodImplUtil"); - private static final PsiCacheKey<Map<MethodSignature, HierarchicalMethodSignature>, PsiClass> SIGNATURES_KEY = PsiCacheKey - .create("SIGNATURES_KEY", new NotNullFunction<PsiClass, Map<MethodSignature, HierarchicalMethodSignature>>() { + private static final PsiCacheKey<Map<MethodSignature, HierarchicalMethodSignature>, PsiClass> SIGNATURES_FOR_CLASS_KEY = PsiCacheKey + .create("SIGNATURES_FOR_CLASS_KEY", new NotNullFunction<PsiClass, Map<MethodSignature, HierarchicalMethodSignature>>() { @NotNull @Override public Map<MethodSignature, HierarchicalMethodSignature> fun(PsiClass dom) { @@ -49,46 +50,45 @@ public class PsiSuperMethodImplUtil { } @NotNull - public static PsiMethod[] findSuperMethods(PsiMethod method) { + public static PsiMethod[] findSuperMethods(@NotNull PsiMethod method) { return findSuperMethods(method, null); } @NotNull - public static PsiMethod[] findSuperMethods(PsiMethod method, boolean checkAccess) { + public static PsiMethod[] findSuperMethods(@NotNull PsiMethod method, boolean checkAccess) { if (!canHaveSuperMethod(method, checkAccess, false)) return PsiMethod.EMPTY_ARRAY; return findSuperMethodsInternal(method, null); } @NotNull - public static PsiMethod[] findSuperMethods(PsiMethod method, PsiClass parentClass) { + public static PsiMethod[] findSuperMethods(@NotNull PsiMethod method, PsiClass parentClass) { if (!canHaveSuperMethod(method, true, false)) return PsiMethod.EMPTY_ARRAY; return findSuperMethodsInternal(method, parentClass); } @NotNull - private static PsiMethod[] findSuperMethodsInternal(PsiMethod method, PsiClass parentClass) { + private static PsiMethod[] findSuperMethodsInternal(@NotNull PsiMethod method, PsiClass parentClass) { List<MethodSignatureBackedByPsiMethod> outputMethods = findSuperMethodSignatures(method, parentClass, false); return MethodSignatureUtil.convertMethodSignaturesToMethods(outputMethods); } @NotNull - public static List<MethodSignatureBackedByPsiMethod> findSuperMethodSignaturesIncludingStatic(PsiMethod method, - boolean checkAccess) { + public static List<MethodSignatureBackedByPsiMethod> findSuperMethodSignaturesIncludingStatic(@NotNull PsiMethod method, + boolean checkAccess) { if (!canHaveSuperMethod(method, checkAccess, true)) return Collections.emptyList(); return findSuperMethodSignatures(method, null, true); } @NotNull - private static List<MethodSignatureBackedByPsiMethod> findSuperMethodSignatures(PsiMethod method, + private static List<MethodSignatureBackedByPsiMethod> findSuperMethodSignatures(@NotNull PsiMethod method, PsiClass parentClass, boolean allowStaticMethod) { - return new ArrayList<MethodSignatureBackedByPsiMethod>(SuperMethodsSearch.search(method, parentClass, true, allowStaticMethod).findAll()); } - private static boolean canHaveSuperMethod(PsiMethod method, boolean checkAccess, boolean allowStaticMethod) { + private static boolean canHaveSuperMethod(@NotNull PsiMethod method, boolean checkAccess, boolean allowStaticMethod) { if (method.isConstructor()) return false; if (!allowStaticMethod && method.hasModifierProperty(PsiModifier.STATIC)) return false; if (checkAccess && method.hasModifierProperty(PsiModifier.PRIVATE)) return false; @@ -97,21 +97,23 @@ public class PsiSuperMethodImplUtil { } @Nullable - public static PsiMethod findDeepestSuperMethod(PsiMethod method) { + public static PsiMethod findDeepestSuperMethod(@NotNull PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return null; return DeepestSuperMethodsSearch.search(method).findFirst(); } - public static PsiMethod[] findDeepestSuperMethods(PsiMethod method) { + @NotNull + public static PsiMethod[] findDeepestSuperMethods(@NotNull PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return PsiMethod.EMPTY_ARRAY; Collection<PsiMethod> collection = DeepestSuperMethodsSearch.search(method).findAll(); return collection.toArray(new PsiMethod[collection.size()]); } - private static Map<MethodSignature, HierarchicalMethodSignature> buildMethodHierarchy(PsiClass aClass, - PsiSubstitutor substitutor, + @NotNull + private static Map<MethodSignature, HierarchicalMethodSignature> buildMethodHierarchy(@NotNull PsiClass aClass, + @NotNull PsiSubstitutor substitutor, final boolean includePrivates, - final Set<PsiClass> visited, + @NotNull final Set<PsiClass> visited, boolean isInRawContext) { ProgressManager.checkCanceled(); Map<MethodSignature, HierarchicalMethodSignature> result = new LinkedHashMap<MethodSignature, HierarchicalMethodSignature>(); @@ -140,7 +142,15 @@ public class PsiSuperMethodImplUtil { } }); - for (PsiMethod method : aClass.getMethods()) { + PsiMethod[] methods = aClass.getMethods(); + if (aClass instanceof PsiClassImpl) { + final PsiMethod valuesMethod = ((PsiClassImpl)aClass).getValuesMethod(); + if (valuesMethod != null) { + methods = ArrayUtil.append(methods, valuesMethod); + } + } + + for (PsiMethod method : methods) { if (!method.isValid()) { throw new PsiInvalidElementAccessException(method, "class.valid=" + aClass.isValid() + "; name=" + method.getName()); } @@ -207,11 +217,11 @@ public class PsiSuperMethodImplUtil { return result; } - private static void putInMap(PsiClass aClass, - Map<MethodSignature, HierarchicalMethodSignature> result, - Map<MethodSignature, HierarchicalMethodSignatureImpl> map, - HierarchicalMethodSignature hierarchicalMethodSignature, - MethodSignature signature) { + private static void putInMap(@NotNull PsiClass aClass, + @NotNull Map<MethodSignature, HierarchicalMethodSignature> result, + @NotNull Map<MethodSignature, HierarchicalMethodSignatureImpl> map, + @NotNull HierarchicalMethodSignature hierarchicalMethodSignature, + @NotNull MethodSignature signature) { if (!PsiUtil.isAccessible(aClass.getProject(), hierarchicalMethodSignature.getMethod(), aClass, aClass)) return; HierarchicalMethodSignatureImpl existing = map.get(signature); if (existing == null) { @@ -241,7 +251,7 @@ public class PsiSuperMethodImplUtil { return thatRet != null && thisRet != null && !thatRet.equals(thisRet) && TypeConversionUtil.isAssignable(thatRet, thisRet, false); } - private static void mergeSupers(final HierarchicalMethodSignatureImpl existing, final HierarchicalMethodSignature superSignature) { + private static void mergeSupers(@NotNull HierarchicalMethodSignatureImpl existing, @NotNull HierarchicalMethodSignature superSignature) { for (HierarchicalMethodSignature existingSuper : existing.getSuperSignatures()) { if (existingSuper.getMethod() == superSignature.getMethod()) { for (HierarchicalMethodSignature signature : superSignature.getSuperSignatures()) { @@ -262,9 +272,9 @@ public class PsiSuperMethodImplUtil { } } - private static boolean isSuperMethod(PsiClass aClass, - HierarchicalMethodSignature hierarchicalMethodSignature, - HierarchicalMethodSignature superSignatureHierarchical) { + private static boolean isSuperMethod(@NotNull PsiClass aClass, + @NotNull HierarchicalMethodSignature hierarchicalMethodSignature, + @NotNull HierarchicalMethodSignature superSignatureHierarchical) { PsiMethod superMethod = superSignatureHierarchical.getMethod(); PsiClass superClass = superMethod.getContainingClass(); PsiClass containingClass = hierarchicalMethodSignature.getMethod().getContainingClass(); @@ -302,7 +312,8 @@ public class PsiSuperMethodImplUtil { return false; } - private static HierarchicalMethodSignatureImpl copy(HierarchicalMethodSignature hi) { + @NotNull + private static HierarchicalMethodSignatureImpl copy(@NotNull HierarchicalMethodSignature hi) { HierarchicalMethodSignatureImpl hierarchicalMethodSignature = new HierarchicalMethodSignatureImpl(hi); for (HierarchicalMethodSignature his : hi.getSuperSignatures()) { hierarchicalMethodSignature.addSuperSignature(copy(his)); @@ -310,9 +321,11 @@ public class PsiSuperMethodImplUtil { return hierarchicalMethodSignature; } - private static PsiSubstitutor obtainFinalSubstitutor(PsiClass superClass, - PsiSubstitutor superSubstitutor, - PsiSubstitutor derivedSubstitutor, boolean inRawContext) { + @NotNull + private static PsiSubstitutor obtainFinalSubstitutor(@NotNull PsiClass superClass, + @NotNull PsiSubstitutor superSubstitutor, + @NotNull PsiSubstitutor derivedSubstitutor, + boolean inRawContext) { if (inRawContext) { Set<PsiTypeParameter> typeParams = superSubstitutor.getSubstitutionMap().keySet(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(superClass.getProject()); @@ -331,35 +344,40 @@ public class PsiSuperMethodImplUtil { return map == null ? PsiSubstitutor.EMPTY : JavaPsiFacade.getInstance(superClass.getProject()).getElementFactory().createSubstitutor(map); } - public static Collection<HierarchicalMethodSignature> getVisibleSignatures(PsiClass aClass) { + @NotNull + public static Collection<HierarchicalMethodSignature> getVisibleSignatures(@NotNull PsiClass aClass) { Map<MethodSignature, HierarchicalMethodSignature> map = getSignaturesMap(aClass); return map.values(); } @NotNull - public static HierarchicalMethodSignature getHierarchicalMethodSignature(final PsiMethod method) { - return CachedValuesManager - .getCachedValue(method, new CachedValueProvider<HierarchicalMethodSignature>() { - @Nullable - @Override - public Result<HierarchicalMethodSignature> compute() { - PsiClass aClass = method.getContainingClass(); - HierarchicalMethodSignature result = null; - if (aClass != null) { - result = getSignaturesMap(aClass).get(method.getSignature(PsiSubstitutor.EMPTY)); - } - if (result == null) { - result = new HierarchicalMethodSignatureImpl((MethodSignatureBackedByPsiMethod)method.getSignature(PsiSubstitutor.EMPTY)); - } - return Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT); - } - }); + public static HierarchicalMethodSignature getHierarchicalMethodSignature(@NotNull final PsiMethod method) { + Project project = method.getProject(); + return CachedValuesManager.getManager(project).getParameterizedCachedValue(method, HIERARCHICAL_SIGNATURE_KEY, + HIERARCHICAL_SIGNATURE_PROVIDER, false, method); } - private static Map<MethodSignature, HierarchicalMethodSignature> getSignaturesMap(final PsiClass aClass) { - return SIGNATURES_KEY.getValue(aClass); - } + private static final Key<ParameterizedCachedValue<HierarchicalMethodSignature, PsiMethod>> HIERARCHICAL_SIGNATURE_KEY = Key.create("HierarchicalMethodSignature"); + private static final ParameterizedCachedValueProvider<HierarchicalMethodSignature, PsiMethod> HIERARCHICAL_SIGNATURE_PROVIDER = + new ParameterizedCachedValueProvider<HierarchicalMethodSignature, PsiMethod>() { + @Override + public CachedValueProvider.Result<HierarchicalMethodSignature> compute(PsiMethod method) { + PsiClass aClass = method.getContainingClass(); + HierarchicalMethodSignature result = null; + if (aClass != null) { + result = getSignaturesMap(aClass).get(method.getSignature(PsiSubstitutor.EMPTY)); + } + if (result == null) { + result = new HierarchicalMethodSignatureImpl((MethodSignatureBackedByPsiMethod)method.getSignature(PsiSubstitutor.EMPTY)); + } + return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT); + } + }; + @NotNull + private static Map<MethodSignature, HierarchicalMethodSignature> getSignaturesMap(@NotNull PsiClass aClass) { + return SIGNATURES_FOR_CLASS_KEY.getValue(aClass); + } // uses hierarchy signature tree if available, traverses class structure by itself otherwise public static boolean processDirectSuperMethodsSmart(@NotNull PsiMethod method, @NotNull Processor<PsiMethod> superMethodProcessor) { @@ -370,7 +388,7 @@ public class PsiSuperMethodImplUtil { if (!canHaveSuperMethod(method, true, false)) return false; - Map<MethodSignature, HierarchicalMethodSignature> cachedMap = SIGNATURES_KEY.getCachedValueOrNull(aClass); + Map<MethodSignature, HierarchicalMethodSignature> cachedMap = SIGNATURES_FOR_CLASS_KEY.getCachedValueOrNull(aClass); if (cachedMap != null) { HierarchicalMethodSignature signature = cachedMap.get(method.getSignature(PsiSubstitutor.EMPTY)); if (signature != null) { @@ -420,7 +438,7 @@ public class PsiSuperMethodImplUtil { if (!canHaveSuperMethod(method, true, false)) return false; PsiMethod[] superMethods = null; - Map<MethodSignature, HierarchicalMethodSignature> cachedMap = SIGNATURES_KEY.getCachedValueOrNull(aClass); + Map<MethodSignature, HierarchicalMethodSignature> cachedMap = SIGNATURES_FOR_CLASS_KEY.getCachedValueOrNull(aClass); if (cachedMap != null) { HierarchicalMethodSignature signature = cachedMap.get(method.getSignature(PsiSubstitutor.EMPTY)); if (signature != null) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/file/impl/JavaFileManager.java b/java/java-psi-impl/src/com/intellij/psi/impl/file/impl/JavaFileManager.java index fc883fe34b56..22b4104fb8c9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/file/impl/JavaFileManager.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/file/impl/JavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,10 @@ public interface JavaFileManager { @Nullable PsiClass findClass(@NotNull String qName, @NotNull GlobalSearchScope scope); + @NotNull PsiClass[] findClasses(@NotNull String qName, @NotNull GlobalSearchScope scope); + @NotNull Collection<String> getNonTrivialPackagePrefixes(); }
\ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/ClassInnerStuffCache.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/ClassInnerStuffCache.java index 429c276303c9..544925856a52 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/ClassInnerStuffCache.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/ClassInnerStuffCache.java @@ -93,15 +93,13 @@ public class ClassInnerStuffCache { if (checkBases) { return PsiClassImplUtil.findFieldByName(myClass, name, true); } - else { - return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiField>>() { - @Nullable - @Override - public Result<Map<String, PsiField>> compute() { - return Result.create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker); - } - }).get(name); - } + return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiField>>() { + @Nullable + @Override + public Result<Map<String, PsiField>> compute() { + return Result.create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker); + } + }).get(name); } @NotNull @@ -109,16 +107,14 @@ public class ClassInnerStuffCache { if (checkBases) { return PsiClassImplUtil.findMethodsByName(myClass, name, true); } - else { - PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiMethod[]>>() { - @Nullable - @Override - public Result<Map<String, PsiMethod[]>> compute() { - return Result.create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker); - } - }).get(name); - return methods != null ? methods : PsiMethod.EMPTY_ARRAY; - } + PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiMethod[]>>() { + @Nullable + @Override + public Result<Map<String, PsiMethod[]>> compute() { + return Result.create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker); + } + }).get(name); + return methods == null ? PsiMethod.EMPTY_ARRAY : methods; } @Nullable @@ -167,24 +163,28 @@ public class ClassInnerStuffCache { }); } + @NotNull private PsiField[] getAllFields() { List<PsiField> own = myClass.getOwnFields(); List<PsiField> ext = PsiAugmentProvider.collectAugments(myClass, PsiField.class); return ArrayUtil.mergeCollections(own, ext, PsiField.ARRAY_FACTORY); } + @NotNull private PsiMethod[] getAllMethods() { List<PsiMethod> own = myClass.getOwnMethods(); List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class); return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY); } + @NotNull private PsiClass[] getAllInnerClasses() { List<PsiClass> own = myClass.getOwnInnerClasses(); List<PsiClass> ext = PsiAugmentProvider.collectAugments(myClass, PsiClass.class); return ArrayUtil.mergeCollections(own, ext, PsiClass.ARRAY_FACTORY); } + @NotNull private Map<String, PsiField> getFieldsMap() { PsiField[] fields = getFields(); if (fields.length == 0) return Collections.emptyMap(); @@ -199,6 +199,7 @@ public class ClassInnerStuffCache { return cachedFields; } + @NotNull private Map<String, PsiMethod[]> getMethodsMap() { PsiMethod[] methods = getMethods(); if (methods.length == 0) return Collections.emptyMap(); @@ -220,6 +221,7 @@ public class ClassInnerStuffCache { return cachedMethods; } + @NotNull private Map<String, PsiClass> getInnerClassesMap() { PsiClass[] classes = getInnerClasses(); if (classes.length == 0) return Collections.emptyMap(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java index 60cb54cefe6b..55b760031646 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java @@ -882,7 +882,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme if (superParent instanceof PsiCodeBlock || superParent instanceof PsiLocalVariable) { return true; } - if (superParent instanceof PsiClass) { + if (superParent instanceof PsiClass || superParent instanceof PsiCatchSection) { return false; } superParent = superParent.getParent(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java index cd2e27f27b11..175f083ce319 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java @@ -23,6 +23,7 @@ import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.containers.ContainerUtil; import java.util.List; @@ -66,10 +67,18 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm } } } else { - final PsiMethodReferenceUtil.QualifierResolveResult qualifierResolveResult = PsiMethodReferenceUtil.getQualifierResolveResult(myExpression); - PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor(); final PsiMember applicableMember = myExpression.getPotentiallyApplicableMember(); LOG.assertTrue(applicableMember != null); + + final PsiMethodReferenceUtil.QualifierResolveResult qualifierResolveResult = PsiMethodReferenceUtil.getQualifierResolveResult(myExpression); + final PsiClass applicableMemberContainingClass = applicableMember.getContainingClass(); + final PsiClass containingClass = qualifierResolveResult.getContainingClass(); + + PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor(); + psiSubstitutor = applicableMemberContainingClass == null || containingClass == null || myExpression.isConstructor() + ? psiSubstitutor + : TypeConversionUtil.getSuperClassSubstitutor(applicableMemberContainingClass, containingClass, psiSubstitutor); + PsiType applicableMethodReturnType = applicableMember instanceof PsiMethod ? ((PsiMethod)applicableMember).getReturnType() : null; int idx = 0; for (PsiTypeParameter param : ((PsiTypeParameterListOwner)applicableMember).getTypeParameters()) { @@ -99,7 +108,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm constraints.add(new TypeCompatibilityConstraint(returnType, psiSubstitutor.substitute(applicableMethodReturnType))); } else if (applicableMember instanceof PsiClass || applicableMember instanceof PsiMethod && ((PsiMethod)applicableMember).isConstructor()) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(applicableMember.getProject()); - final PsiClass containingClass = qualifierResolveResult.getContainingClass(); + if (containingClass != null) { final PsiClassType classType = elementFactory.createType(containingClass, psiSubstitutor); constraints.add(new TypeCompatibilityConstraint(returnType, classType)); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java index 49012290e52b..f01c82cae769 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java @@ -75,8 +75,6 @@ public class TypeCompatibilityConstraint implements ConstraintFormula { if (sSubstitutor != null && PsiUtil.isRawSubstitutor(tClass, sSubstitutor)) { return true; } - //comment in 18.2.2. Type Compatibility Constraints - if (tClass instanceof PsiTypeParameter && ((PsiClassType)s).isRaw()) return true; } } else if (t instanceof PsiArrayType && t.getArrayDimensions() == s.getArrayDimensions()) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java index 9d9b1f1ce9e2..e359f7531757 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java @@ -49,7 +49,8 @@ public class StringLiteralManipulator extends AbstractElementManipulator<PsiLite return getValueRange(element); } - public static TextRange getValueRange(PsiLiteralExpression element) { + @NotNull + public static TextRange getValueRange(@NotNull PsiLiteralExpression element) { final Object value = element.getValue(); if (!(value instanceof String || value instanceof Character)) return TextRange.from(0, element.getTextLength()); return new TextRange(1, Math.max(1, element.getTextLength() - 1)); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java index 9e31f7b88656..4066c6cc4a78 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java @@ -219,7 +219,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR } @Override - protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) { + protected int getPertinentApplicabilityLevel(@NotNull MethodCandidateInfo conflict) { return conflict.isVarargs() ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY; } @@ -299,7 +299,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR } @Override - protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) { + protected boolean nonComparable(@NotNull CandidateInfo method, @NotNull CandidateInfo conflict) { if (method == conflict) return true; PsiElement psiElement = method.getElement(); PsiElement conflictElement = conflict.getElement(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java index 36a97157a8a1..73639b26c945 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java @@ -73,8 +73,12 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement if (type2 instanceof PsiClassType && type1.equals(PsiPrimitiveType.getUnboxedType(type2))) return type1; if (TypeConversionUtil.isNumericType(typeRank1) && TypeConversionUtil.isNumericType(typeRank2)){ - if (typeRank1 == TypeConversionUtil.BYTE_RANK && typeRank2 == TypeConversionUtil.SHORT_RANK) return type2; - if (typeRank1 == TypeConversionUtil.SHORT_RANK && typeRank2 == TypeConversionUtil.BYTE_RANK) return type1; + if (typeRank1 == TypeConversionUtil.BYTE_RANK && typeRank2 == TypeConversionUtil.SHORT_RANK) { + return type2 instanceof PsiPrimitiveType ? type2 : PsiPrimitiveType.getUnboxedType(type2); + } + if (typeRank1 == TypeConversionUtil.SHORT_RANK && typeRank2 == TypeConversionUtil.BYTE_RANK) { + return type1 instanceof PsiPrimitiveType ? type1 : PsiPrimitiveType.getUnboxedType(type1); + } if (typeRank2 == TypeConversionUtil.INT_RANK && (typeRank1 == TypeConversionUtil.BYTE_RANK || typeRank1 == TypeConversionUtil.SHORT_RANK || typeRank1 == TypeConversionUtil.CHAR_RANK)){ if (TypeConversionUtil.areTypesAssignmentCompatible(type1, expr2)) return type1; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLiteralExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLiteralExpressionImpl.java index cf099fb33304..e5892be2fb4d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLiteralExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLiteralExpressionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -370,6 +370,7 @@ public class PsiLiteralExpressionImpl } } + @Override public String toString() { return "PsiLiteralExpression:" + getText(); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index 94cce501d521..2209efe4141b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java @@ -22,7 +22,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; -import com.intellij.psi.impl.source.resolve.JavaResolveUtil; import com.intellij.psi.impl.source.resolve.ResolveCache; import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil; import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession; @@ -45,7 +44,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -228,7 +226,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase @Override public void setQualifierExpression(@Nullable PsiExpression newQualifier) throws IncorrectOperationException { if (newQualifier == null) { - super.setQualifierExpression(newQualifier); + LOG.error("Forbidden null qualifier"); return; } final PsiExpression expression = getQualifierExpression(); diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java index aa18e6e6b8a4..f136c843aa87 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java @@ -131,9 +131,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ private static PsiLambdaExpression findNestedLambdaExpression(PsiExpression expression) { if (expression instanceof PsiLambdaExpression) { return (PsiLambdaExpression)expression; - } else if (expression instanceof PsiParenthesizedExpression) { + } + else if (expression instanceof PsiParenthesizedExpression) { return findNestedLambdaExpression(((PsiParenthesizedExpression)expression).getExpression()); - } else if (expression instanceof PsiConditionalExpression) { + } + else if (expression instanceof PsiConditionalExpression) { PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(((PsiConditionalExpression)expression).getThenExpression()); if (lambdaExpression != null) { return lambdaExpression; @@ -143,7 +145,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return null; } - private static void checkLambdaApplicable(List<CandidateInfo> conflicts, int i, PsiLambdaExpression lambdaExpression) { + private static void checkLambdaApplicable(@NotNull List<CandidateInfo> conflicts, int i, @NotNull PsiLambdaExpression lambdaExpression) { for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) { ProgressManager.checkCanceled(); final CandidateInfo conflict = iterator.next(); @@ -192,12 +194,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ } } - protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) { + protected boolean nonComparable(@NotNull CandidateInfo method, @NotNull CandidateInfo conflict) { assert method != conflict; return false; } - protected static void checkAccessStaticLevels(List<CandidateInfo> conflicts, boolean checkAccessible) { + protected static void checkAccessStaticLevels(@NotNull List<CandidateInfo> conflicts, boolean checkAccessible) { int conflictsCount = conflicts.size(); int maxCheckLevel = -1; @@ -350,13 +352,13 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ } } - private static boolean areTypeParametersAgree(CandidateInfo info) { + private static boolean areTypeParametersAgree(@NotNull CandidateInfo info) { return ((MethodCandidateInfo)info).getPertinentApplicabilityLevel() != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE; } - private static boolean checkParametersNumber(final List<CandidateInfo> conflicts, - final int argumentsCount, - boolean ignoreIfStaticsProblem) { + private static boolean checkParametersNumber(@NotNull List<CandidateInfo> conflicts, + final int argumentsCount, + boolean ignoreIfStaticsProblem) { boolean atLeastOneMatch = false; TIntArrayList unmatchedIndices = null; for (int i = 0; i < conflicts.size(); i++) { @@ -392,7 +394,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ } @MethodCandidateInfo.ApplicabilityLevelConstant - protected int checkApplicability(List<CandidateInfo> conflicts) { + protected int checkApplicability(@NotNull List<CandidateInfo> conflicts) { @MethodCandidateInfo.ApplicabilityLevelConstant int maxApplicabilityLevel = 0; boolean toFilter = false; for (CandidateInfo conflict : conflicts) { @@ -420,27 +422,29 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return maxApplicabilityLevel; } - protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) { + protected int getPertinentApplicabilityLevel(@NotNull MethodCandidateInfo conflict) { return conflict.getPertinentApplicabilityLevel(); } - private static int getCheckAccessLevel(MethodCandidateInfo method){ + private static int getCheckAccessLevel(@NotNull MethodCandidateInfo method){ boolean visible = method.isAccessible(); return visible ? 1 : 0; } - private static int getCheckStaticLevel(MethodCandidateInfo method){ + private static int getCheckStaticLevel(@NotNull MethodCandidateInfo method){ boolean available = method.isStaticsScopeCorrect(); return (available ? 1 : 0) << 1 | (method.getCurrentFileResolveScope() instanceof PsiImportStaticStatement ? 0 : 1); } + @NotNull private PsiType[] getActualParameterTypes() { - if (myActualParameterTypes == null) { + PsiType[] types = myActualParameterTypes; + if (types == null) { LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList); - myActualParameterTypes = getArgumentTypes(); + myActualParameterTypes = types = getArgumentTypes(); } - return myActualParameterTypes; + return types; } private int getActualParametersLength() { @@ -451,6 +455,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return myActualParameterTypes.length; } + @NotNull protected PsiType[] getArgumentTypes() { return ((PsiExpressionList)myArgumentsList).getExpressionTypes(); } @@ -470,8 +475,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return TypeConversionUtil.boxingConversionApplicable(parameterType, argType); } - private Specifics isMoreSpecific(final MethodCandidateInfo info1, - final MethodCandidateInfo info2, + private Specifics isMoreSpecific(@NotNull MethodCandidateInfo info1, + @NotNull MethodCandidateInfo info2, @MethodCandidateInfo.ApplicabilityLevelConstant int applicabilityLevel, @NotNull LanguageLevel languageLevel) { PsiMethod method1 = info1.getElement(); @@ -684,11 +689,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return Specifics.NEITHER; } - private boolean isApplicableTo(PsiType[] types2AtSite, - PsiMethod method1, - LanguageLevel languageLevel, + private boolean isApplicableTo(@NotNull PsiType[] types2AtSite, + @NotNull PsiMethod method1, + @NotNull LanguageLevel languageLevel, boolean varargsPosition, - final PsiSubstitutor methodSubstitutor1, + @NotNull PsiSubstitutor methodSubstitutor1, PsiMethod method2, PsiSubstitutor siteSubstitutor1) { if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method2 != null && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) { @@ -701,7 +706,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE; } - private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1) { + @NotNull + private static PsiType[] typesAtSite(@NotNull PsiType[] types1, @NotNull PsiSubstitutor siteSubstitutor1) { final PsiType[] types = PsiType.createArray(types1.length); for (int i = 0; i < types1.length; i++) { types[i] = siteSubstitutor1.substitute(types1[i]); @@ -709,11 +715,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return types; } - private static PsiSubstitutor calculateMethodSubstitutor(final PsiTypeParameter[] typeParameters, - final PsiMethod method, - final PsiSubstitutor siteSubstitutor, - final PsiType[] types1, - final PsiType[] types2, + @NotNull + private static PsiSubstitutor calculateMethodSubstitutor(@NotNull PsiTypeParameter[] typeParameters, + @NotNull PsiMethod method, + @NotNull PsiSubstitutor siteSubstitutor, + @NotNull PsiType[] types1, + @NotNull PsiType[] types2, @NotNull LanguageLevel languageLevel) { PsiSubstitutor substitutor = PsiResolveHelper.SERVICE.getInstance(method.getProject()) .inferTypeArguments(typeParameters, types1, types2, languageLevel); @@ -742,7 +749,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return substitutor; } - public void checkPrimitiveVarargs(final List<CandidateInfo> conflicts, + public void checkPrimitiveVarargs(@NotNull List<CandidateInfo> conflicts, final int argumentsCount) { if (JavaVersionService.getInstance().isAtLeast(myArgumentsList, JavaSdkVersion.JDK_1_7)) return; CandidateInfo objectVararg = null; @@ -778,7 +785,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ } @Nullable - private static PsiType getFunctionalType(int functionalTypeIdx, CandidateInfo candidateInfo) { + private static PsiType getFunctionalType(int functionalTypeIdx, @NotNull CandidateInfo candidateInfo) { final PsiMethod psiMethod = (PsiMethod)candidateInfo.getElement(); LOG.assertTrue(true); final PsiParameter[] methodParameters = psiMethod.getParameterList().getParameters(); @@ -787,8 +794,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return ((MethodCandidateInfo)candidateInfo).getSiteSubstitutor().substitute(param.getType()); } - private static Specifics isFunctionalTypeMoreSpecific(CandidateInfo method, - CandidateInfo conflict, + @NotNull + private static Specifics isFunctionalTypeMoreSpecific(@NotNull CandidateInfo method, + @NotNull CandidateInfo conflict, PsiExpression expr, int functionalInterfaceIdx) { if (expr instanceof PsiParenthesizedExpression) { diff --git a/java/java-psi-impl/src/messages/JavaErrorMessages.properties b/java/java-psi-impl/src/messages/JavaErrorMessages.properties index cfc556c4c55c..e4e2303a2be4 100644 --- a/java/java-psi-impl/src/messages/JavaErrorMessages.properties +++ b/java/java-psi-impl/src/messages/JavaErrorMessages.properties @@ -242,6 +242,7 @@ duplicate.switch.label=Duplicate label ''{0}'' switch.colon.expected.after.case.label=':' expected illegal.forward.reference=Illegal forward reference +illegal.self.reference=Illegal self reference unknown.class=Unknown class: ''{0}'' illegal.type.void=Illegal type: 'void' diff --git a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java index f30025eeb12b..6ef47262a4c2 100644 --- a/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java +++ b/java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java @@ -20,10 +20,12 @@ import com.intellij.rt.execution.junit.segments.SegmentedOutputStream; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.reflect.Field; public final class IdeaAntLogger2 extends DefaultLogger { static SegmentedOutputStream ourErr; @@ -82,7 +84,7 @@ public final class IdeaAntLogger2 extends DefaultLogger { } public synchronized void targetFinished(BuildEvent event) { - sendException(event); + sendException(event, true); myTargetPriority.sendMessage(TARGET_END, event.getPriority(), event.getException()); } @@ -91,25 +93,56 @@ public final class IdeaAntLogger2 extends DefaultLogger { } public synchronized void taskFinished(BuildEvent event) { - sendException(event); + sendException(event, true); myTaskPriority.sendMessage(TASK_END, event.getPriority(), event.getException()); } public synchronized void messageLogged(BuildEvent event) { - if (sendException(event)) return; + final boolean failOnError = isFailOnError(event); + if (sendException(event, failOnError)) { + return; + } + int priority = event.getPriority(); - String message = event.getMessage(); - if (priority == Project.MSG_ERR) + if (priority == Project.MSG_ERR && !failOnError) { + // some ant tasks (like Copy) with 'failOnError' attribute set to 'false' + // send warnings with priority level = Project.MSG_ERR + // this heuristic corrects the priority level, so that IDEA considers the message not as an error but as a warning + priority = Project.MSG_WARN; + } + + final String message = event.getMessage(); + + if (priority == Project.MSG_ERR) { myMessagePriority.sendMessage(ERROR, priority, message); - else + } + else { myMessagePriority.sendMessage(MESSAGE, priority, message); + } } - private boolean sendException(BuildEvent event) { + private static boolean isFailOnError(BuildEvent event) { + final Task task = event.getTask(); + if (task != null) { + try { + final Field field = task.getClass().getDeclaredField("failonerror"); + field.setAccessible(true); + return !Boolean.FALSE.equals(field.get(task)); + } + catch (Exception ignored) { + } + } + return true; // default value + } + + private boolean sendException(BuildEvent event, boolean isFailOnError) { Throwable exception = event.getException(); if (exception != null) { - myAlwaysSend.sendMessage(EXCEPTION, event.getPriority(), exception); - return true; + if (isFailOnError) { + myAlwaysSend.sendMessage(EXCEPTION, event.getPriority(), exception); + return true; + } + myMessagePriority.sendMessage(MESSAGE, Project.MSG_WARN, exception.getMessage()); } return false; } diff --git a/java/java-tests/java-tests.iml b/java/java-tests/java-tests.iml index 248b1d3b1836..09b0e28aa3fd 100644 --- a/java/java-tests/java-tests.iml +++ b/java/java-tests/java-tests.iml @@ -16,7 +16,7 @@ <orderEntry type="library" name="Velocity" level="project" /> <orderEntry type="module" module-name="java-i18n" exported="" /> <orderEntry type="module" module-name="compiler-impl" /> - <orderEntry type="library" name="asm4" level="project" /> + <orderEntry type="library" name="asm5" level="project" /> <orderEntry type="module" module-name="instrumentation-util" /> <orderEntry type="library" name="Groovy" level="project" /> <orderEntry type="module" module-name="IntelliLang-java" scope="RUNTIME" /> diff --git a/java/java-tests/testData/codeInsight/completeStatement/AddMissingParen_after.java b/java/java-tests/testData/codeInsight/completeStatement/AddMissingParen_after.java index d53d73ed7770..3cf8eb4381a0 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/AddMissingParen_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/AddMissingParen_after.java @@ -3,7 +3,6 @@ class Foo { abstract void a(); { - a(); - <caret> + a();<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/AddMissingSemicolon_after.java b/java/java-tests/testData/codeInsight/completeStatement/AddMissingSemicolon_after.java index d53d73ed7770..3cf8eb4381a0 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/AddMissingSemicolon_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/AddMissingSemicolon_after.java @@ -3,7 +3,6 @@ class Foo { abstract void a(); { - a(); - <caret> + a();<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/ArrayInitializerRBracket_after.java b/java/java-tests/testData/codeInsight/completeStatement/ArrayInitializerRBracket_after.java index d766b4a44036..2a09299fe603 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/ArrayInitializerRBracket_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/ArrayInitializerRBracket_after.java @@ -1,6 +1,5 @@ public class Foo { public void fails() { - boolean[] a = new boolean[f()]; - <caret> + boolean[] a = new boolean[f()];<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/BraceFixeNewLine_after.java b/java/java-tests/testData/codeInsight/completeStatement/BraceFixeNewLine_after.java index 059822dba58b..7a129a9e7cd4 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/BraceFixeNewLine_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/BraceFixeNewLine_after.java @@ -3,7 +3,6 @@ public class test { int k1 = 1; int k2 = 2; int[] array = new int[]{k1, k2}; - <caret> System.out.print(k1); } diff --git a/java/java-tests/testData/codeInsight/completeStatement/CdrEndlessLoop_after.java b/java/java-tests/testData/codeInsight/completeStatement/CdrEndlessLoop_after.java index 07d76498a979..b690a469b8f6 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/CdrEndlessLoop_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/CdrEndlessLoop_after.java @@ -1,6 +1,5 @@ public class Test { public int foo(int i) { - int ii = foo(0); - <caret> + int ii = foo(0);<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/FollowedByComment_after.java b/java/java-tests/testData/codeInsight/completeStatement/FollowedByComment_after.java index f146a881244e..209898fbdac0 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/FollowedByComment_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/FollowedByComment_after.java @@ -1,7 +1,6 @@ public class Foo { public void foo() { - foo(); - <caret> + foo();<caret> // some line comment } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/IDEA22125_after.java b/java/java-tests/testData/codeInsight/completeStatement/IDEA22125_after.java index 3579bfdb17f1..61fca2462f1b 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/IDEA22125_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/IDEA22125_after.java @@ -1,7 +1,6 @@ public class Junk { public static void main(String[] args) { - int i = 1; // comment - <caret> + int i = 1; // comment<caret> } } diff --git a/java/java-tests/testData/codeInsight/completeStatement/IDEADEV40479_after.java b/java/java-tests/testData/codeInsight/completeStatement/IDEADEV40479_after.java index 89767d3ba494..c61c4caa18c1 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/IDEADEV40479_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/IDEADEV40479_after.java @@ -1,7 +1,6 @@ public class Junk { public static void main(String[] args) { - int[] arr = new int[]{1, 2, 3}; - <caret> + int[] arr = new int[]{1, 2, 3};<caret> } } diff --git a/java/java-tests/testData/codeInsight/completeStatement/IncompleteCall_after.java b/java/java-tests/testData/codeInsight/completeStatement/IncompleteCall_after.java index 2aa9baa41b11..608de1eeac93 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/IncompleteCall_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/IncompleteCall_after.java @@ -1,8 +1,7 @@ public class Foo { { - foo(); - <caret> + foo();<caret> foo(); } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/MultilineCall_after.java b/java/java-tests/testData/codeInsight/completeStatement/MultilineCall_after.java index 77770c0d371c..1d2e3fc6be6f 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/MultilineCall_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/MultilineCall_after.java @@ -1,7 +1,6 @@ class Test { Object method() { method( - factory()); - <caret> + factory());<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/NewInParentheses_after.java b/java/java-tests/testData/codeInsight/completeStatement/NewInParentheses_after.java index b7512bcd17c2..0bdd9c0d5a21 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/NewInParentheses_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/NewInParentheses_after.java @@ -1,7 +1,6 @@ class foo { { - Object d = ((String) new String()); - <caret> + Object d = ((String) new String());<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/Parenthesized_after.java b/java/java-tests/testData/codeInsight/completeStatement/Parenthesized_after.java index 9b159d219f4a..cecc090aecc5 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/Parenthesized_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/Parenthesized_after.java @@ -1,7 +1,6 @@ class Foo { { - tx2 = (long) (vcx + vw); - <caret> + tx2 = (long) (vcx + vw);<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/StringLiteral_after.java b/java/java-tests/testData/codeInsight/completeStatement/StringLiteral_after.java index 977a63e23430..b76baf554d45 100644 --- a/java/java-tests/testData/codeInsight/completeStatement/StringLiteral_after.java +++ b/java/java-tests/testData/codeInsight/completeStatement/StringLiteral_after.java @@ -1,7 +1,6 @@ class foo { { - String s = "a"; - <caret> + String s = "a";<caret> } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/CharsetName.java b/java/java-tests/testData/codeInsight/completion/normal/CharsetName.java new file mode 100644 index 000000000000..c932c81751d6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/CharsetName.java @@ -0,0 +1,7 @@ +import java.nio.charset.Charset; + +public final class FileAttributes { + { + Charset.forName("utf<caret>") + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/DeepInner.java b/java/java-tests/testData/codeInsight/completion/normal/DeepInner.java new file mode 100644 index 000000000000..33d1ac441a68 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/DeepInner.java @@ -0,0 +1,13 @@ +class ClassMain{ + public static class ClassInner1{ + public static class ClassInner2{ + + } + } +} + +class Foo { + { + new ClassMain.Cla<caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/DeepInner_after.java b/java/java-tests/testData/codeInsight/completion/normal/DeepInner_after.java new file mode 100644 index 000000000000..f46d6f10dc00 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/DeepInner_after.java @@ -0,0 +1,13 @@ +class ClassMain{ + public static class ClassInner1{ + public static class ClassInner2{ + + } + } +} + +class Foo { + { + new ClassMain.ClassInner1.ClassInner2()<caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/SmartEnterWrapsConstructorCall_after.java b/java/java-tests/testData/codeInsight/completion/normal/SmartEnterWrapsConstructorCall_after.java index 4761cce70c89..43e916863b55 100644 --- a/java/java-tests/testData/codeInsight/completion/normal/SmartEnterWrapsConstructorCall_after.java +++ b/java/java-tests/testData/codeInsight/completion/normal/SmartEnterWrapsConstructorCall_after.java @@ -8,7 +8,6 @@ class Tester { } public void test1() { - build(new EntityBuilder()); - <caret> + build(new EntityBuilder());<caret> } } diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/HonorFirstLetterCase.java b/java/java-tests/testData/codeInsight/completion/normalSorting/HonorFirstLetterCase.java new file mode 100644 index 000000000000..7edb9cd571f3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/HonorFirstLetterCase.java @@ -0,0 +1,11 @@ +import java.io.*; + +class Foo { + { + pim<caret> + } +} + +class PNGImageDecoder {} +class PImageDecoder {} +class posIdMap {} diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferAnnotationsToInterfaceKeyword.java b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferAnnotationsToInterfaceKeyword.java new file mode 100644 index 000000000000..7d1d4ff899ef --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferAnnotationsToInterfaceKeyword.java @@ -0,0 +1,4 @@ +class A { + @<caret> + void foo(){} +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferThrownExceptionsInCatch.java b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferThrownExceptionsInCatch.java new file mode 100644 index 000000000000..c1d412270715 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferThrownExceptionsInCatch.java @@ -0,0 +1,15 @@ +import java.io.*; + +class Foo { + { + try { + foo(); + } catch (<caret>) + } + + private void foo() throws FileNotFoundException { + } + + private void bar() throws ArrayIndexOutOfBoundsException { + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ConstructorArgsSmartEnter-out.java b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorArgsSmartEnter-out.java index 484b537fe6de..9d25f937591d 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/ConstructorArgsSmartEnter-out.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorArgsSmartEnter-out.java @@ -5,7 +5,6 @@ public class MyJavaClass { { - List l = new ArrayList(239); - <caret> + List l = new ArrayList(239);<caret> } } diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SmartFinish-out.java b/java/java-tests/testData/codeInsight/completion/smartType/SmartFinish-out.java index 1583beea2183..e95297e009b7 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/SmartFinish-out.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/SmartFinish-out.java @@ -2,8 +2,7 @@ public class Foo { { Foo foo = null; - Foo bar = id(foo); - <caret> + Foo bar = id(foo);<caret> } Foo id(Foo foo) {return foo;} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalForwardReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalForwardReference.java index 88dd9534444e..45663a186dda 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalForwardReference.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalForwardReference.java @@ -13,7 +13,7 @@ public class a { int k = 1 + <error descr="Illegal forward reference">ki</error>; int ki; - final int fi5 = <error descr="Illegal forward reference">fi5</error> + 1; + final int fi5 = <error descr="Illegal self reference">fi5</error> + 1; } class a1 { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg1.java index cd9c7e16e415..8ec18fd42521 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg1.java @@ -5,14 +5,14 @@ class Neg01<X extends Number> { <Z> Neg01(X x, Z z) {} void test() { - Neg01<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n1 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; - Neg01<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n2 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; - Neg01<?> n3 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; - Neg01<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n4 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; + Neg01<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n1 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; + Neg01<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n2 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; + Neg01<?> n3 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; + Neg01<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n4 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String)'">("")</error>; - Neg01<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n5 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Neg01<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n6 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Neg01<?> n7 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - <error descr="Cannot resolve symbol 'Foo'">Foo</error><? super String> n8 = new Neg01<><error descr="'Neg01(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Neg01<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n5 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Neg01<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n6 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Neg01<?> n7 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + <error descr="Cannot resolve symbol 'Foo'">Foo</error><? super String> n8 = new Neg01<><error descr="'Neg01(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg01' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg2.java index f1a2f75daed1..045ba94144a5 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg2.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg2.java @@ -6,26 +6,26 @@ class Neg02 { } void testSimple() { - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> f3 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> f3 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> f7 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> f7 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } void testQualified() { - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> f3 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> f3 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> f7 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Neg02.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> f7 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Neg02.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg02.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg3.java index ac66d2a1d4b7..29295ebbc989 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg3.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg3.java @@ -6,38 +6,38 @@ class Neg03<U> { } void testSimple() { - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> f3 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> f3 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> f7 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> f7 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } void testQualified_1() { - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> f3 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> f3 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> f7 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> f7 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = new Neg03<U>.Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } void testQualified_2(Neg03<U> n) { - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> f3 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f1 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f2 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> f3 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f4 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> f7 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = n.new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> f5 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> f6 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> f7 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> f8 = n.new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Neg03.Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg4.java index 55b50c5b457b..ecf72df10521 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg4.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg4.java @@ -5,14 +5,14 @@ class Neg04 { Foo(V x) {} <Z> Foo(V x, Z z) {} } - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n1 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n2 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<?> n3 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n4 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n1 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n2 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<?> n3 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n4 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String)'">("")</error>; - Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n5 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n6 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<?> n7 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; - Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n8 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'">String</error>> n5 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? extends String' is not within its bound; should extend 'java.lang.Number'">? extends String</error>> n6 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<?> n7 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; + Foo<<error descr="Type parameter '? super String' is not within its bound; should extend 'java.lang.Number'">? super String</error>> n8 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String, java.lang.String)' in 'Foo' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg7.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg7.java index 84771a652d90..3d356a9e14fc 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg7.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondNeg7.java @@ -4,5 +4,5 @@ class Neg07 { Foo(X x) {} } - SuperFoo<String> sf1 = new Foo<><error descr="'Foo(java.lang.String & java.lang.Number)' in 'Neg07.Foo' cannot be applied to '(java.lang.String)'">("")</error>; + SuperFoo<String> sf1 = new Foo<><error descr="'Foo(java.lang.Number & java.lang.String)' in 'Neg07.Foo' cannot be applied to '(java.lang.String)'">("")</error>; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java index eafce26dfa17..d5e43e164b85 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java @@ -1,7 +1,7 @@ import java.util.List; public class Test { - private static final <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Cloneable>>', required: 'java.util.List<java.lang.Class<?>>'">List<Class<?>> PRIMITIVE_ARRAY_TYPES = asList(byte[].class, int[].class);</error> + private static final <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.lang.Cloneable & java.io.Serializable>>', required: 'java.util.List<java.lang.Class<?>>'">List<Class<?>> PRIMITIVE_ARRAY_TYPES = asList(byte[].class, int[].class);</error> private static final List<?> PRIMITIVE_ARRAY_TYPES1 = asList(byte[].class, int[].class); public static <T> List<T> asList(T... a) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA124363.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA124363.java new file mode 100644 index 000000000000..577e19a7916d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA124363.java @@ -0,0 +1,16 @@ +import java.util.*; + +class MyTClass { + + <T> void foo(final List<Object> objects){ + Collection<? extends T> collection = (Collection<? extends T>) objects; + } + + <T> void foo1(final List<Object> objects){ + Collection<? super T> collection = (Collection<? super T>) objects; + } + + <T extends String> void bar(final List<Object> objects){ + Collection<? extends T> collection = <error descr="Inconvertible types; cannot cast 'java.util.List<java.lang.Object>' to 'java.util.Collection<? extends T>'">(Collection<? extends T>) objects</error>; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA125423.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA125423.java index d2515eef82eb..868b4dffd7ac 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA125423.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA125423.java @@ -1,6 +1,19 @@ +import java.util.Comparator; +import java.util.List; + +class Test { + public static final Comparator<Object> ORDER_AWARE_COMPARATOR = null; + + public static void orderAwareSort(List<?> data) { + sort(data, ORDER_AWARE_COMPARATOR); + } + + public static <T> void sort(List<T> list, Comparator<? super T> c) {} +} + class FooBar<T> { void foo(final FooBar<?> fooBar){ - fooBar.supertype<error descr="'supertype(java.lang.Class<capture<?>>)' in 'FooBar' cannot be applied to '(java.lang.Class<java.lang.Iterable>)'">(Iterable.class)</error>; + //fooBar.supertype(Iterable.class); } void foo1(final FooBar<? super T> fooBar){ @@ -13,3 +26,4 @@ class FooBar<T> { void supertype(Class<? super T> superclass) {} } + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126633.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126633.java new file mode 100644 index 000000000000..19e79fc0eb95 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126633.java @@ -0,0 +1,15 @@ +import java.util.List; + +class Test { + <T> List<T> test(final List<Object> foo) { + return (List<T>) foo; + } + + <T> List<List<T>> test1(final List<List<Object>> foo) { + return <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.lang.Object>>' to 'java.util.List<java.util.List<T>>'">(List<List<T>>) foo</error>; + } + + <T> List<List<List<T>>> test2(final List<List<List<Object>>> foo) { + return <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.util.List<java.lang.Object>>>' to 'java.util.List<java.util.List<java.util.List<T>>>'">(List<List<List<T>>>) foo</error>; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126697.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126697.java new file mode 100644 index 000000000000..895e5690c68e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA126697.java @@ -0,0 +1,8 @@ +class Test { + private static void <warning descr="Private method 'test(java.lang.Short)' is never used">test</warning>(Short s) { System.out.println("Short:" + s); } + private static void test(short s) { System.out.println("short:" + s); } + + public static void main(String ... args) { + test(true ? new Short((short) 1) : new Byte((byte) 1)); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParent.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParent.java index 49c8f5bbeaad..3e270f73ee0e 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParent.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParent.java @@ -7,7 +7,11 @@ class Foo<T> { List<Foo> elements = getElements(parent); - for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Foo'">Foo foo : getElements(parent)</error>) { + /*for (Foo foo : getElements(parent)) { + System.out.println(foo); + }*/ + + for (Foo foo : getElementsArray(parent)) { System.out.println(foo); } } @@ -15,4 +19,8 @@ class Foo<T> { public static <E extends Foo<E>> List<E> getElements(E parent) { return new ArrayList<>(); } + + public static <E extends Foo<E>> E[] getElementsArray(E parent) { + return null; + } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParentArrayType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParentArrayType.java new file mode 100644 index 000000000000..904e37257721 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/RawTypeFromParentArrayType.java @@ -0,0 +1,14 @@ +import java.util.*; + +class Test { + protected Class[] getAllInterfaces(final Set<Class> interfaces, final Class[] classes) { + return interfaces.toArray(classes); + } + public static <T extends Collection<String>> T get(T out) { + return out; + } + + public static void main(String[] args) { + Set<String> set = get(new HashSet()); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Intersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Intersection.java index 767b54788948..7a6312b3089b 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Intersection.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Intersection.java @@ -13,8 +13,8 @@ class Test { { Object o1 = (Serializable & I) () -> {}; Object o2 = (I & Serializable) () -> {}; - Object o3 = (I & Runnable) <error descr="Multiple non-overriding abstract methods found in Runnable & I">() -> {}</error>; - Object o4 = (A & Runnable) <error descr="Multiple non-overriding abstract methods found in Runnable & A">() -> {}</error>; + Object o3 = (I & Runnable) <error descr="Multiple non-overriding abstract methods found in I & Runnable">() -> {}</error>; + Object o4 = (A & Runnable) <error descr="Multiple non-overriding abstract methods found in A & Runnable">() -> {}</error>; Object o5 = (Runnable & A) <error descr="Multiple non-overriding abstract methods found in Runnable & A">() -> {}</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RecursiveAccess.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RecursiveAccess.java index cf95ac4fbfa6..fce52587f2ae 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RecursiveAccess.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RecursiveAccess.java @@ -1,5 +1,5 @@ public class LambdaTest { - Op lambda_fib = (n) -> (n < 2) ? 1 : <error descr="Illegal forward reference">lambda_fib</error>.op(n - 1) + <error descr="Illegal forward reference">lambda_fib</error>.op(n - 2); + Op lambda_fib = (n) -> (n < 2) ? 1 : <error descr="Illegal self reference">lambda_fib</error>.op(n - 1) + <error descr="Illegal self reference">lambda_fib</error>.op(n - 2); { Op lambda_fib = (n) -> (n < 2) ? 1 : <error descr="Variable 'lambda_fib' might not have been initialized">lambda_fib</error>.op(n - 1) + lambda_fib.op(n - 2); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119003.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119003.java index f56af02e5dd8..01646ddd1896 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119003.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119003.java @@ -3,6 +3,7 @@ package problems; import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.function.*; import static java.util.stream.Collectors.*; @@ -82,3 +83,32 @@ class Dish { return name; } } + +class Test67 { + + static { + collectingAndThen(reducing(), Optional::get); + collectingAndThen(reducing(), o -> o.get()); + } + + static <T> List<Optional<T>> reducing() { + return null; + } + + static <R,RR> void collectingAndThen(List<R> downstream, Function<R,RR> finisher){} +} + +class Test99 { + + { + collectingAndThen(reducing((d1, d2) -> d2), Optional::get); + } + + public static <COL, R, RR> void collectingAndThen(Collector<COL, R> downstream, Function<R, RR> finisher) {} + + public static <RED> Collector<RED, Optional<RED>> reducing(BinaryOperator<RED> op) { + return null; + } + + static class Collector<A, C>{} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124961.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124961.java new file mode 100644 index 000000000000..ab8e99419a27 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124961.java @@ -0,0 +1,16 @@ +import java.util.List; +import java.util.function.Supplier; +import java.util.stream.Stream; + +class Test { + + private static void list(List<? extends CharSequence> l) { + Stream<? extends CharSequence> str = map(() -> l.get(0)); + Stream<? extends CharSequence> str1 = map1(() -> l.get(0)); + Stream<? extends CharSequence> str2 = map1(() -> l.get(0)); + } + + static <M> Stream<M> map (Supplier<? extends M> mapper) { return null;} + static <M> Stream<M> map1(Supplier<? super M> mapper) { return null;} + static <M> Stream<M> map2(Supplier<M> mapper) { return null;} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125254.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125254.java new file mode 100644 index 000000000000..4d74d1424cc3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125254.java @@ -0,0 +1,103 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.BiFunction; + +class Scratch +{ + public static void main(String[] args) + { + final ExecutorService threadPool = Executors.newCachedThreadPool(); + final List<EventObject> events = new ArrayList<>(); + final SoapInterface soap = new SoapInterface(); + + events.stream() + .map(event -> get(event).apply(soap, event)) + .map(threadPool::submit) + .forEachOrdered(future -> { + try + { + if (! future.get().isError()) + { + + } + else + { + ; + } + } + catch (InterruptedException | ExecutionException e) + { + e.printStackTrace(); + } + }); + } + + public static BiFunction<SoapInterface, Object, Callable<Either<Object, Exception>>> get(Object o) + { + return (soap, event) -> toEither( + () -> { + return "value"; + } + ); + } + + private static Callable<Either<Object, Exception>> toEither(Callable<Object> callable) + { + return () -> { + try + { + return Either.value(callable.call()); + } + catch (Exception e) + { + return Either.error(e); + } + }; + } + + public static class EventObject { } + + public static class SoapInterface { } + + public static class Either<V, E> + { + private V value; + + private E error; + + private Either(V value, E error) + { + this.value = value; + this.error = error; + } + + public static <V, E> Either<V, E> value(V value) + { + return new Either<>(value, null); + } + + public static <V, E> Either<V, E> error(E error) + { + return new Either<>(null, error); + } + + public V getValue() + { + return value; + } + + public E getError() + { + return error; + } + + public boolean isError() + { + return error != null; + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126109.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126109.java new file mode 100644 index 000000000000..0fd7c685535a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126109.java @@ -0,0 +1,26 @@ +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +class Test { + void foo(final Stream<Person> stream) { + final Map<String,List<Person>> mapByFirstLetter = stream.collect(Collectors.groupingBy(p -> "" + p.name.charAt(0))); + + final String vV = mapByFirstLetter.values().stream().map(lp -> lp.stream().map(p -> p.name) + .collect(Collectors.joining("/","<",">"))) .collect(Collectors.joining(" : ")); + + final String vV2 = mapByFirstLetter.values().stream() + .map(lp -> lp.stream().map(Person::getName).collect(Collectors.joining("/","<",">"))) + .collect(Collectors.joining(" : ")); + System.out.println("mapByFirstLetter2 : "+ vV2); + } + + public static class Person { + private String name; + public Person(String name) { + this.name = name; + } + public String getName() {return name;} + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126809.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126809.java new file mode 100644 index 000000000000..df910d96e710 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA126809.java @@ -0,0 +1,27 @@ +import java.util.Optional; +import java.util.Set; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toSet; + +class App { + + { + final User user = new User("test", Stream.of("TEST").collect(toSet())); + Optional.of(user).map(u -> new User(u.getName(), + u.getAttributes().stream().filter(a -> !a.equals("TEST")).collect(toSet()))); + } + + private static final class User { + User(final String name, final Set<String> attributes) { + } + + public String getName() { + return null; + } + + public Set<String> getAttributes() { + return null; + } + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java new file mode 100644 index 000000000000..14ad192c8823 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java @@ -0,0 +1,25 @@ +import java.util.function.Supplier; + +class EnumValues { + + { + Supplier<I<ABC>> supplier = () -> new C<>(ABC::values); + } + + private static interface I<T> { + T get(); + } + + private static class C<E> implements I<E> { + C(Supplier<E[]> supplier) {} + + @Override + public E get() { + return null; + } + } + + private static enum ABC { + A, B, C + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MissedApplicableMemberContainingClassSubstitution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MissedApplicableMemberContainingClassSubstitution.java new file mode 100644 index 000000000000..7562e457f9aa --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MissedApplicableMemberContainingClassSubstitution.java @@ -0,0 +1,54 @@ +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +class TestA { + + public static class Entity<K> { + K id; + public K getId() { + return id; + } + } + + public static class EntityVo {} + + public static class Area extends Entity<Integer> { + } + + public static class AreaVo { + public AreaVo(Area area, String lang) { + + } + } + + public static void main(String[] args) { + String language = "da"; + List<Area> areas = new ArrayList<>(); + Map<Integer, AreaVo> areaLookup = areas.stream() + .collect(Collectors.toMap(Area::getId, area -> new AreaVo(area, language))); + } + +} + +class TestSimple { + + public static class Entity<K> { + K id; + public K getId() { + return id; + } + } + + public static class Area extends Entity<Integer> { + } + + public static <M> Set<M> toMap(Function<Area, M> keyMapper) { + return null; + } + + { + Set<Integer> tMapCollector = toMap(Area::getId); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RejectReceiverTypesForConstructorRefs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RejectReceiverTypesForConstructorRefs.java new file mode 100644 index 000000000000..0954ed9a72e3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RejectReceiverTypesForConstructorRefs.java @@ -0,0 +1,21 @@ +import java.util.function.*; + +class ConstructorReferences { + public ConstructorReferences() {} + public ConstructorReferences(String s) {} + public ConstructorReferences(String s1, String s2) {} + public ConstructorReferences(ConstructorReferences other) {} + public ConstructorReferences(ConstructorReferences other1, ConstructorReferences other2) {} + + public static void main(String[] args) { + Supplier<ConstructorReferences> supplier = ConstructorReferences::new; + Function<String,ConstructorReferences> function = ConstructorReferences::new; + BiFunction<String,String,ConstructorReferences> bifunction = ConstructorReferences::new; + UnaryOperator<ConstructorReferences> unaryOperator = ConstructorReferences:: new; + Function<ConstructorReferences,ConstructorReferences> unaryOperatorBaseClass = ConstructorReferences::new; + BinaryOperator<ConstructorReferences> binaryOperator = ConstructorReferences::new; + BiFunction<ConstructorReferences, ConstructorReferences, ConstructorReferences> binaryOperatorBaseClass = ConstructorReferences::new; + Consumer<ConstructorReferences> consumer = ConstructorReferences::new; + BiConsumer<ConstructorReferences,ConstructorReferences> biconsumer = ConstructorReferences::new; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/Constructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/Constructor.java new file mode 100644 index 000000000000..fa782b8f177d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/Constructor.java @@ -0,0 +1,26 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public A() { + + MyElement localElement1 = getElement(); + + getProje<caret>ct(); + + MyElement localElement2 = getElement(); + + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixAfter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixAfter.java new file mode 100644 index 000000000000..171715cd7572 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixAfter.java @@ -0,0 +1,20 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public void m() { + fieldElement.getProject(); + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixBefore.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixBefore.java new file mode 100644 index 000000000000..9996e8aea88e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/FixBefore.java @@ -0,0 +1,20 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public void m() { + getProje<caret>ct(); + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NestedMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NestedMethod.java new file mode 100644 index 000000000000..1135da99aa74 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NestedMethod.java @@ -0,0 +1,36 @@ +import java.lang.Object; + +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public void m(MyElement paramElement) { + + Object o = new Object() { + + private final MyElement nestedField; + + public void targetMethod(MyElement nestedParamElement) { + + final MyElement localElement1 = getElement(); + + getProje<caret>ct (); + + MyElement localElement2 = getElement(); + + } + } + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NonStaticMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NonStaticMethod.java new file mode 100644 index 000000000000..6407fa18e304 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/NonStaticMethod.java @@ -0,0 +1,26 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public void targetMethod(MyElement paramElement) { + + MyElement localElement1 = getElement(); + + getProje<caret>ct(); + + MyElement localElement2 = getElement(); + + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticInitializer.java new file mode 100644 index 000000000000..94faa3139b6c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticInitializer.java @@ -0,0 +1,26 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + static { + + MyElement localElement1 = getElement(); + + getProje<caret>ct(); + + MyElement localElement2 = getElement(); + + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticMethod.java new file mode 100644 index 000000000000..b7f033a546d4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/StaticMethod.java @@ -0,0 +1,26 @@ +public class A { + + Project p; + MyElement fieldElement; + + static MyElement staticElement; + + public static void targetMethod(MyElement paramElement) { + + MyElement localElement1 = getElement(); + + getProje<caret>ct(); + + MyElement localElement2 = getElement(); + + } + + interface Project { + + } + + interface MyElement { + Project getProject(); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeSelfReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeSelfReference.java new file mode 100644 index 000000000000..7160a62ffbc3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeSelfReference.java @@ -0,0 +1,9 @@ +// "Replace with lambda" "false" +class Test { + Runnable runnable = new Runn<caret>able() { + @Override + public void run() { + System.out.println(runnable); + } + }; +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterInsideNestedInner.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterInsideNestedInner.java new file mode 100644 index 000000000000..9e5835481cb9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterInsideNestedInner.java @@ -0,0 +1,18 @@ +// "Replace lambda with method reference" "true" +class Example { + class Bar { + void foo() { + } + + class Foo { + + void bar() { + new Object() { + void baz() { + Runnable runnable = Bar.this::foo; + } + }; + } + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideAnonymous.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideAnonymous.java new file mode 100644 index 000000000000..e6ad36c82c9c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideAnonymous.java @@ -0,0 +1,17 @@ +// "Replace lambda with method reference" "false" +class Example { + { + new Object() { + void foo() { + } + + void bar() { + new Object() { + void baz() { + Runnable runnable = () -> fo<caret>o(); + } + }; + } + }; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideNestedInner.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideNestedInner.java new file mode 100644 index 000000000000..553b4330f222 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeInsideNestedInner.java @@ -0,0 +1,18 @@ +// "Replace lambda with method reference" "true" +class Example { + class Bar { + void foo() { + } + + class Foo { + + void bar() { + new Object() { + void baz() { + Runnable runnable = () -> fo<caret>o(); + } + }; + } + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterBase.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterBase.java new file mode 100644 index 000000000000..da423aee9781 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterBase.java @@ -0,0 +1,16 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (otherCondition) { + doAnotherAction(); + } else if (someCondition) { + doSomeAction(); + } else { + defaultAction(); + } + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterManyStatements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterManyStatements.java new file mode 100644 index 000000000000..2a70fb4ebbef --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterManyStatements.java @@ -0,0 +1,20 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (a) { + System.out.println(1); + } else if (c) { + System.out.println(3); + } else if (b) { + System.out.println(2); + } else if (d) { + System.out.println(4); + } else { + System.out.println(5); + } + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterWithoutBrackets.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterWithoutBrackets.java new file mode 100644 index 000000000000..5c87fbc07eee --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/afterWithoutBrackets.java @@ -0,0 +1,12 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (cond2) m2(); + else if (cond1) m1(); + else if (cond3) m3(); + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeBase.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeBase.java new file mode 100644 index 000000000000..146510c19e0f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeBase.java @@ -0,0 +1,16 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (someCondition) { + doSomeAction(); + } e<caret>lse if (otherCondition) { + doAnotherAction(); + } else { + defaultAction(); + } + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeManyStatements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeManyStatements.java new file mode 100644 index 000000000000..c1e7c1cac24d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeManyStatements.java @@ -0,0 +1,20 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (a) { + System.out.println(1); + } else if (b) { + System.out.println(2); + } el<caret>se if (c) { + System.out.println(3); + } else if (d) { + System.out.println(4); + } else { + System.out.println(5); + } + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeNotAvailable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeNotAvailable.java new file mode 100644 index 000000000000..16a0bc0be56c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeNotAvailable.java @@ -0,0 +1,10 @@ +// "Swap If Statements" "false" +class A { + void m() { + if (someCondition) { + doSomeAction(); + } e<caret>lse { + defaultAction(); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeWithoutBrackets.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeWithoutBrackets.java new file mode 100644 index 000000000000..e7b3ac78e794 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements/beforeWithoutBrackets.java @@ -0,0 +1,12 @@ +// "Swap If Statements" "true" +class A { + + void m() { + + if (cond1) m1(); + el<caret>se if (cond2) m2(); + else if (cond3) m3(); + + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/afterCallAsArgument.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/afterCallAsArgument.java new file mode 100644 index 000000000000..6ef1870458fb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/afterCallAsArgument.java @@ -0,0 +1,11 @@ +// "Remove redundant assignment" "true" +class Test { + void foo() { + String var; + this.bar("someString"); + } + + void bar(String arg) { + + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/beforeCallAsArgument.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/beforeCallAsArgument.java new file mode 100644 index 000000000000..116cc94e30f4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unusedAssignment/beforeCallAsArgument.java @@ -0,0 +1,11 @@ +// "Remove redundant assignment" "true" +class Test { + void foo() { + String var; + this.bar(v<caret>ar = "someString"); + } + + void bar(String arg) { + + } +} diff --git a/java/java-tests/testData/codeInsight/javadocIG/annotations.html b/java/java-tests/testData/codeInsight/javadocIG/annotations.html new file mode 100644 index 000000000000..39e57472104c --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/annotations.html @@ -0,0 +1,3 @@ +<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://Test"><code>Test</code></a></b></small><PRE><font color=red>@Nullable</font> +@<a href="psi_element://java.lang.Deprecated"><code>Deprecated</code></a> +public <a href="psi_element://java.lang.String"><code>String</code></a> <b>field = null</b></PRE></body></html>
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/annotations.java b/java/java-tests/testData/codeInsight/javadocIG/annotations.java new file mode 100644 index 000000000000..2a3a67458649 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/annotations.java @@ -0,0 +1,5 @@ +class Test { + @Nullable + @Deprecated + public String field = null; +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/slice/backward/VarArgsAsAWhole.java b/java/java-tests/testData/codeInsight/slice/backward/VarArgsAsAWhole.java new file mode 100644 index 000000000000..21ba9ba0053a --- /dev/null +++ b/java/java-tests/testData/codeInsight/slice/backward/VarArgsAsAWhole.java @@ -0,0 +1,12 @@ +class VarArgs { + private void g() { + f<flown111>("d",1,2,3); + } + + void f(String value,int... <flown11>i) { + v(value, <flown1>i); + } + + private void v(String value, int... <caret>ints) { + } +} diff --git a/java/java-tests/testData/codeInsight/slice/backward/VarArgsPartial.java b/java/java-tests/testData/codeInsight/slice/backward/VarArgsPartial.java new file mode 100644 index 000000000000..1e59e130fddd --- /dev/null +++ b/java/java-tests/testData/codeInsight/slice/backward/VarArgsPartial.java @@ -0,0 +1,14 @@ +class VarArgs { + private static void foo(String value, int...<flown11>ints) { + System.out.println(value + " " + java.util.Arrays.asList(ints)); + int <caret>anInt = <flown1>ints[1]; + } + + private static void bar(String value, int...<flown1111>ints) { + foo(value, <flown111>ints); + } + + private static void baz(String value) { + bar<flown11111>("d", <flown111111>2, <flown111112>3, <flown111113>4); + } +} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrueNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrueNotComplex.java new file mode 100644 index 000000000000..9eb541c05de6 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrueNotComplex.java @@ -0,0 +1,17 @@ +import org.jetbrains.annotations.Contract; + +import java.util.List; + +abstract class Some { + @Contract("_,false->fail") + abstract void assertTrue(String s, boolean b); + + void assertContainsAllVariants(List<String> actualVariants, String... expectedVariants) { + for (String expectedVariant : expectedVariants) { + assertTrue(expectedVariant, actualVariants.contains(expectedVariant)); + } + } + +} + + diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullToNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullToNotNull.java new file mode 100644 index 000000000000..a9f17f7e9a06 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullToNotNull.java @@ -0,0 +1,14 @@ +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +class Bar3 { + + public void foo(@Nullable Object element) { + final String elementType = element != null ? element.toString() : null; + if (elementType == "") { + System.out.println(element.hashCode()); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToNullable.java new file mode 100644 index 000000000000..5e3ce3c0b69b --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToNullable.java @@ -0,0 +1,16 @@ +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +class Bar3 { + + public void foo(@Nullable Object element) { + final String elementType = element != null ? element.toString() : null; + if (elementType == nullableString()) { + System.out.println(<warning descr="Method invocation 'element.hashCode()' may produce 'java.lang.NullPointerException'">element.hashCode()</warning>); + } + } + + @Nullable String nullableString() { return null; } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToUnknown.java b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToUnknown.java new file mode 100644 index 000000000000..b15c6c7a52f7 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToUnknown.java @@ -0,0 +1,16 @@ +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +class Bar3 { + + public void foo(@Nullable Object element) { + final String elementType = element != null ? element.toString() : null; + if (elementType == someString()) { + System.out.println(<warning descr="Method invocation 'element.hashCode()' may produce 'java.lang.NullPointerException'">element.hashCode()</warning>); + } + } + + String someString() { return <warning descr="'null' is returned by the method which is not declared as @Nullable">null</warning>; } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/offline/project/src/Test.java b/java/java-tests/testData/inspection/offline/project/src/Test.java new file mode 100644 index 000000000000..94e0c00069f6 --- /dev/null +++ b/java/java-tests/testData/inspection/offline/project/src/Test.java @@ -0,0 +1,52 @@ +/** + * User: anna + * Date: 25-Apr-2006 + */ +public class Test { + private boolean myFlag = false; + @SuppressWarnings({"PointlessBooleanExpression"}) + boolean foo(){ + boolean flag = false; + if (flag == false){ + flag = true; + } + int j = 0; + if (myFlag) return false; + return flag; + } + + /*private int bar() { + int i = 0; + return i; + }*/ + + + private void fooo(){ + this.fooo(); + } + + public void deadCode() { + + } + public static void main(String[] args){ + Test test = new Test(); + } + + public void f() { + class D { + void b() { + Runnable r = new Runnable() { + public void run() { + int i = 0; + + } + }; + } + } + } + + void ff() { + long d = 5; + int a = 0; + } +} diff --git a/java/java-tests/testData/inspection/offline/res/UnusedAssignment.xml b/java/java-tests/testData/inspection/offline/res/UnusedAssignment.xml new file mode 100644 index 000000000000..9829cf8555ce --- /dev/null +++ b/java/java-tests/testData/inspection/offline/res/UnusedAssignment.xml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>13</line> + <entry_point TYPE="method" FQNAME="Test boolean foo()"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + <module>javamodule</module> + <method> + <name>boolean foo()</name> + <name>foo()</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>j</code> is never used.</description> + </problem> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>40</line> + <entry_point TYPE="method" FQNAME="Test$2D$1 void run()"> + <entry_point TYPE="class" FQNAME="Test$2D$1"> + <entry_point TYPE="method" FQNAME="Test$2D void b()"> + <entry_point TYPE="class" FQNAME="Test$2D"> + <entry_point TYPE="method" FQNAME="Test void f()"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + </entry_point> + </entry_point> + </entry_point> + </entry_point> + <module>javamodule</module> + <method> + <name>void run()</name> + <name>run()</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>i</code> is never used.</description> + </problem> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>49</line> + <entry_point TYPE="method" FQNAME="Test void ff()"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + <module>javamodule</module> + <method> + <name>void ff()</name> + <name>ff()</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>d</code> is never used.</description> + </problem> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>50</line> + <entry_point TYPE="method" FQNAME="Test void ff()"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + <module>javamodule</module> + <method> + <name>void ff()</name> + <name>ff()</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>a</code> is never used.</description> + </problem> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>32</line> + <entry_point TYPE="method" FQNAME="Test void main(java.lang.String[] args)"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + <module>javamodule</module> + <method> + <name>void main(String[] args)</name> + <name>main(String[])</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>test</code> is never used.</description> + </problem> + <problem> + <file>file://$PROJECT_DIR$/javamodule/src/Test.java</file> + <line>38</line> + <entry_point TYPE="method" FQNAME="Test$2D void b()"> + <entry_point TYPE="class" FQNAME="Test$2D"> + <entry_point TYPE="method" FQNAME="Test void f()"> + <entry_point TYPE="class" FQNAME="Test" /> + </entry_point> + </entry_point> + </entry_point> + <module>javamodule</module> + <method> + <name>void b()</name> + <name>b()</name> + <package><default></package> + <class> + <name>Test</name> + <display_name>Test</display_name> + </class> + </method> + <problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused assignment</problem_class> + <description>Variable <code>r</code> is never used.</description> + </problem> +</problems> + diff --git a/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/expected.xml b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/expected.xml new file mode 100644 index 000000000000..4704d91e891d --- /dev/null +++ b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/expected.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems/>
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/src/Test.java new file mode 100644 index 000000000000..18bf47f111b5 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValueIDEA126166/src/Test.java @@ -0,0 +1,11 @@ +import java.util.ArrayList; +import java.util.List; + +class SomeClass { + public void test() { + List<?> objects = new ArrayList<>(); + for (String value : (Iterable<? extends String>) objects) { + System.out.println(value); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/expected.xml b/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/expected.xml new file mode 100644 index 000000000000..4704d91e891d --- /dev/null +++ b/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/expected.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems/>
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/src/Test.java b/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/src/Test.java new file mode 100644 index 000000000000..bd2236cfe9f1 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantCast/lambda/ForeachValue/src/Test.java @@ -0,0 +1,10 @@ +import java.util.Arrays; +import java.util.Iterator; + +class IterableMain { + public static void main(final String... args) { + for (final String s : (Iterable<String>) XIterator::new) {} + } + + public static interface XIterator extends Iterator<String> {} +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/suspiciousCalls/RemoveAll14.java b/java/java-tests/testData/inspection/suspiciousCalls/RemoveAll14.java new file mode 100644 index 000000000000..f6e2c033b6fc --- /dev/null +++ b/java/java-tests/testData/inspection/suspiciousCalls/RemoveAll14.java @@ -0,0 +1,14 @@ +import java.util.*; + + +class Simple { + public static void main(Set set, Set setO) { + class O {} + + Map someData = new HashMap(); + + set.removeAll(someData.keySet()); + setO.removeAll(someData.keySet()); + + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/stubBuilder/UtilCollections.txt b/java/java-tests/testData/psi/cls/stubBuilder/UtilCollections.txt index 82d04fec4659..d64c31b56472 100644 --- a/java/java-tests/testData/psi/cls/stubBuilder/UtilCollections.txt +++ b/java/java-tests/testData/psi/cls/stubBuilder/UtilCollections.txt @@ -4,6 +4,910 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiRefListStub[EXTENDS_LIST:] PsiRefListStub[IMPLEMENTS_LIST:] + PsiClassStub[name=AsLIFOQueue fqn=java.util.Collections.AsLIFOQueue] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.AbstractQueue<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Queue<E>, java.io.Serializable] + PsiFieldStub[serialVersionUID:long=1802017725587941708L] + PsiModifierListStub[mask=26] + PsiFieldStub[q:java.util.Deque<E>] + PsiModifierListStub[mask=18] + PsiMethodStub[cons AsLIFOQueue:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Deque<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[offer:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[poll:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[peek:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[element:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[clear:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[size:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[contains:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[removeAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[retainAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedCollection fqn=java.util.Collections.CheckedCollection] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Collection<E>, java.io.Serializable] + PsiFieldStub[serialVersionUID:long=1578914078182001775L] + PsiModifierListStub[mask=26] + PsiFieldStub[c:java.util.Collection<E>] + PsiModifierListStub[mask=4112] + PsiFieldStub[type:java.lang.Class<E>] + PsiModifierListStub[mask=4112] + PsiFieldStub[zeroLengthElementArray:E[]] + PsiModifierListStub[mask=2] + PsiMethodStub[typeCheck:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[badElementMsg:java.lang.String] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[cons CheckedCollection:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<E>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[size:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[contains:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[clear:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[removeAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[retainAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[zeroLengthElementArray:E[]] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[checkedCopyOf:java.util.Collection<E>] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<? extends E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[addAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<? extends E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedList fqn=java.util.Collections.CheckedList] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.CheckedCollection<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.List<E>] + PsiFieldStub[serialVersionUID:long=65247728283967356L] + PsiModifierListStub[mask=26] + PsiFieldStub[list:java.util.List<E>] + PsiModifierListStub[mask=4112] + PsiMethodStub[cons CheckedList:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.List<E>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[get:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[indexOf:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[lastIndexOf:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[set:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[addAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.util.Collection<? extends E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[listIterator:java.util.ListIterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[listIterator:java.util.ListIterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[subList:java.util.List<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedMap fqn=java.util.Collections.CheckedMap] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Map<K,V>, java.io.Serializable] + PsiClassStub[name=CheckedEntrySet fqn=java.util.Collections.CheckedMap.CheckedEntrySet] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Set<java.util.Map.Entry<K,V>>] + PsiClassStub[name=CheckedEntry fqn=java.util.Collections.CheckedMap.CheckedEntrySet.CheckedEntry] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Map.Entry<K,V>] + PsiFieldStub[e:java.util.Map.Entry<K,V>] + PsiModifierListStub[mask=18] + PsiFieldStub[valueType:java.lang.Class<T>] + PsiModifierListStub[mask=18] + PsiMethodStub[cons CheckedEntry:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Map.Entry<K,V>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<T>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[getKey:K] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[getValue:V] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[setValue:V] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:V] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[badValueMsg:java.lang.String] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiFieldStub[s:java.util.Set<java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=18] + PsiFieldStub[valueType:java.lang.Class<V>] + PsiModifierListStub[mask=18] + PsiMethodStub[cons CheckedEntrySet:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Set<java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<V>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[size:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[clear:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Map.Entry<K,V>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[addAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<? extends java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[contains:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[removeAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[retainAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[batchRemove:boolean] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:boolean] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[checkedEntry:java.util.Collections.CheckedMap.CheckedEntrySet.CheckedEntry<K,V,T>] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:java.util.Map.Entry<K,V>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<T>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiFieldStub[serialVersionUID:long=5742860141034234728L] + PsiModifierListStub[mask=26] + PsiFieldStub[m:java.util.Map<K,V>] + PsiModifierListStub[mask=18] + PsiFieldStub[keyType:java.lang.Class<K>] + PsiModifierListStub[mask=4112] + PsiFieldStub[valueType:java.lang.Class<V>] + PsiModifierListStub[mask=4112] + PsiFieldStub[entrySet:java.util.Set<java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=130] + PsiMethodStub[typeCheck:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[badKeyMsg:java.lang.String] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[badValueMsg:java.lang.String] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[cons CheckedMap:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Map<K,V>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<K>] + PsiModifierListStub[mask=0] + PsiParameterStub[p3:java.lang.Class<V>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[size:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsKey:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsValue:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[get:V] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:V] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[clear:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[keySet:java.util.Set<K>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[values:java.util.Collection<V>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[put:V] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:K] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:V] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[putAll:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Map<? extends K,? extends V>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[entrySet:java.util.Set<java.util.Map.Entry<K,V>>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedRandomAccessList fqn=java.util.Collections.CheckedRandomAccessList] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.CheckedList<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.RandomAccess] + PsiFieldStub[serialVersionUID:long=1638200125423088369L] + PsiModifierListStub[mask=26] + PsiMethodStub[cons CheckedRandomAccessList:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.List<E>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[subList:java.util.List<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedSet fqn=java.util.Collections.CheckedSet] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.CheckedCollection<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Set<E>, java.io.Serializable] + PsiFieldStub[serialVersionUID:long=4694047833775013803L] + PsiModifierListStub[mask=26] + PsiMethodStub[cons CheckedSet:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Set<E>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedSortedMap fqn=java.util.Collections.CheckedSortedMap] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.CheckedMap<K,V>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.SortedMap<K,V>, java.io.Serializable] + PsiFieldStub[serialVersionUID:long=1599671320688067438L] + PsiModifierListStub[mask=26] + PsiFieldStub[sm:java.util.SortedMap<K,V>] + PsiModifierListStub[mask=18] + PsiMethodStub[cons CheckedSortedMap:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.SortedMap<K,V>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<K>] + PsiModifierListStub[mask=0] + PsiParameterStub[p3:java.lang.Class<V>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[comparator:java.util.Comparator<? super K>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[firstKey:K] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[lastKey:K] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[subMap:java.util.SortedMap<K,V>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:K] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:K] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[headMap:java.util.SortedMap<K,V>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:K] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[tailMap:java.util.SortedMap<K,V>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:K] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=CheckedSortedSet fqn=java.util.Collections.CheckedSortedSet] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.CheckedSet<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.SortedSet<E>, java.io.Serializable] + PsiFieldStub[serialVersionUID:long=1599911165492914959L] + PsiModifierListStub[mask=26] + PsiFieldStub[ss:java.util.SortedSet<E>] + PsiModifierListStub[mask=18] + PsiMethodStub[cons CheckedSortedSet:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.SortedSet<E>] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:java.lang.Class<E>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[comparator:java.util.Comparator<? super E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[first:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[last:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[subSet:java.util.SortedSet<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[headSet:java.util.SortedSet<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[tailSet:java.util.SortedSet<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiClassStub[name=CopiesList fqn=java.util.Collections.CopiesList] PsiModifierListStub[mask=10] PsiTypeParameterListStub @@ -12,11 +916,11 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_LIST:java.util.AbstractList<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.RandomAccess, java.io.Serializable] PsiFieldStub[serialVersionUID:long=2739099268398711800L] - PsiModifierListStub[mask=4120] + PsiModifierListStub[mask=26] PsiFieldStub[n:int] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiFieldStub[element:E] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiMethodStub[cons CopiesList:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -38,6 +942,20 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:java.lang.Object] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[indexOf:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[lastIndexOf:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiMethodStub[get:E] PsiModifierListStub[mask=1] PsiTypeParameterListStub @@ -45,10 +963,88 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:int] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[subList:java.util.List<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:int] + PsiModifierListStub[mask=0] + PsiParameterStub[p2:int] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=EmptyEnumeration fqn=java.util.Collections.EmptyEnumeration] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Enumeration<E>] + PsiFieldStub[EMPTY_ENUMERATION:java.util.Collections.EmptyEnumeration<java.lang.Object>] + PsiModifierListStub[mask=4120] + PsiMethodStub[cons EmptyEnumeration:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hasMoreElements:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[nextElement:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=EmptyIterator fqn=java.util.Collections.EmptyIterator] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Iterator<E>] + PsiFieldStub[EMPTY_ITERATOR:java.util.Collections.EmptyIterator<java.lang.Object>] + PsiModifierListStub[mask=4120] + PsiMethodStub[cons EmptyIterator:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hasNext:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[next:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiClassStub[name=EmptyList fqn=java.util.Collections.EmptyList] PsiModifierListStub[mask=10] PsiTypeParameterListStub - PsiRefListStub[EXTENDS_LIST:java.util.AbstractList<java.lang.Object>] + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.AbstractList<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.RandomAccess, java.io.Serializable] PsiFieldStub[serialVersionUID:long=8842843931221139166L] PsiModifierListStub[mask=26] @@ -57,11 +1053,26 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[listIterator:java.util.ListIterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[size:int] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[contains:boolean] PsiModifierListStub[mask=1] PsiTypeParameterListStub @@ -69,22 +1080,107 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:java.lang.Object] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] - PsiMethodStub[get:java.lang.Object] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[get:E] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub PsiParameterStub[p1:int] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[readResolve:java.lang.Object] PsiModifierListStub[mask=2] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiClassStub[name=EmptyListIterator fqn=java.util.Collections.EmptyListIterator] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.Collections.EmptyIterator<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.ListIterator<E>] + PsiFieldStub[EMPTY_ITERATOR:java.util.Collections.EmptyListIterator<java.lang.Object>] + PsiModifierListStub[mask=4120] + PsiMethodStub[cons EmptyListIterator:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hasPrevious:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[previous:E] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[nextIndex:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[previousIndex:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[set:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiClassStub[name=EmptyMap fqn=java.util.Collections.EmptyMap] PsiModifierListStub[mask=10] PsiTypeParameterListStub - PsiRefListStub[EXTENDS_LIST:java.util.AbstractMap<java.lang.Object,java.lang.Object>] + PsiTypeParameter[K] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiTypeParameter[V] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.AbstractMap<K,V>] PsiRefListStub[IMPLEMENTS_LIST:java.io.Serializable] PsiFieldStub[serialVersionUID:long=6428348081105594320L] PsiModifierListStub[mask=26] @@ -117,24 +1213,24 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:java.lang.Object] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] - PsiMethodStub[get:java.lang.Object] + PsiMethodStub[get:V] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub PsiParameterStub[p1:java.lang.Object] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] - PsiMethodStub[keySet:java.util.Set<java.lang.Object>] + PsiMethodStub[keySet:java.util.Set<K>] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] - PsiMethodStub[values:java.util.Collection<java.lang.Object>] + PsiMethodStub[values:java.util.Collection<V>] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] - PsiMethodStub[entrySet:java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>] + PsiMethodStub[entrySet:java.util.Set<java.util.Map.Entry<K,V>>] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub @@ -159,7 +1255,9 @@ PsiJavaFileStub [java.util] PsiClassStub[name=EmptySet fqn=java.util.Collections.EmptySet] PsiModifierListStub[mask=10] PsiTypeParameterListStub - PsiRefListStub[EXTENDS_LIST:java.util.AbstractSet<java.lang.Object>] + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.AbstractSet<E>] PsiRefListStub[IMPLEMENTS_LIST:java.io.Serializable] PsiFieldStub[serialVersionUID:long=1582296315990362920L] PsiModifierListStub[mask=26] @@ -168,7 +1266,7 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] - PsiMethodStub[iterator:java.util.Iterator<java.lang.Object>] + PsiMethodStub[iterator:java.util.Iterator<E>] PsiModifierListStub[mask=1] PsiTypeParameterListStub PsiParameterListStub @@ -178,6 +1276,11 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[contains:boolean] PsiModifierListStub[mask=1] PsiTypeParameterListStub @@ -185,6 +1288,27 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:java.lang.Object] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiMethodStub[readResolve:java.lang.Object] PsiModifierListStub[mask=2] PsiTypeParameterListStub @@ -193,12 +1317,12 @@ PsiJavaFileStub [java.util] PsiClassStub[name=ReverseComparator fqn=java.util.Collections.ReverseComparator] PsiModifierListStub[mask=10] PsiTypeParameterListStub - PsiTypeParameter[T] - PsiRefListStub[EXTENDS_BOUNDS_LIST:] PsiRefListStub[EXTENDS_LIST:] PsiRefListStub[IMPLEMENTS_LIST:java.util.Comparator<java.lang.Comparable<java.lang.Object>>, java.io.Serializable] PsiFieldStub[serialVersionUID:long=7207038068494060240L] PsiModifierListStub[mask=26] + PsiFieldStub[REVERSE_ORDER:java.util.Collections.ReverseComparator] + PsiModifierListStub[mask=4120] PsiMethodStub[cons ReverseComparator:void] PsiModifierListStub[mask=2] PsiTypeParameterListStub @@ -213,6 +1337,11 @@ PsiJavaFileStub [java.util] PsiParameterStub[p2:java.lang.Comparable<java.lang.Object>] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[readResolve:java.lang.Object] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiClassStub[name=ReverseComparator2 fqn=java.util.Collections.ReverseComparator2] PsiModifierListStub[mask=10] PsiTypeParameterListStub @@ -223,7 +1352,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=4374092139857L] PsiModifierListStub[mask=26] PsiFieldStub[cmp:java.util.Comparator<T>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=4112] PsiMethodStub[cons ReverseComparator2:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -240,11 +1369,143 @@ PsiJavaFileStub [java.util] PsiParameterStub[p2:T] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiClassStub[interface name=SelfComparable fqn=java.util.Collections.SelfComparable] PsiModifierListStub[mask=1034] PsiTypeParameterListStub PsiRefListStub[EXTENDS_LIST:java.lang.Comparable<java.util.Collections.SelfComparable>] PsiRefListStub[IMPLEMENTS_LIST:] + PsiClassStub[name=SetFromMap fqn=java.util.Collections.SetFromMap] + PsiModifierListStub[mask=10] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiRefListStub[EXTENDS_LIST:java.util.AbstractSet<E>] + PsiRefListStub[IMPLEMENTS_LIST:java.util.Set<E>, java.io.Serializable] + PsiFieldStub[m:java.util.Map<E,java.lang.Boolean>] + PsiModifierListStub[mask=18] + PsiFieldStub[s:java.util.Set<E>] + PsiModifierListStub[mask=130] + PsiFieldStub[serialVersionUID:long=2454657854757543876L] + PsiModifierListStub[mask=26] + PsiMethodStub[cons SetFromMap:void] + PsiModifierListStub[mask=4096] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Map<E,java.lang.Boolean>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[clear:void] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[size:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[isEmpty:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[contains:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[remove:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[add:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:java.lang.Object[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toArray:T[]] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:T[]] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[toString:java.lang.String] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[hashCode:int] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[equals:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.lang.Object] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[containsAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[removeAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[retainAll:boolean] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.util.Collection<?>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[readObject:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.io.ObjectInputStream] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:java.io.IOException, java.lang.ClassNotFoundException] PsiClassStub[name=SingletonList fqn=java.util.Collections.SingletonList] PsiModifierListStub[mask=10] PsiTypeParameterListStub @@ -253,7 +1514,7 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_LIST:java.util.AbstractList<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.RandomAccess, java.io.Serializable] PsiFieldStub[serialVersionUID:long=3093736618740652951L] - PsiModifierListStub[mask=4120] + PsiModifierListStub[mask=26] PsiFieldStub[element:E] PsiModifierListStub[mask=18] PsiMethodStub[cons SingletonList:void] @@ -263,6 +1524,11 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:E] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[iterator:java.util.Iterator<E>] + PsiModifierListStub[mask=1] + PsiTypeParameterListStub + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[size:int] PsiModifierListStub[mask=1] PsiTypeParameterListStub @@ -291,62 +1557,6 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_BOUNDS_LIST:] PsiRefListStub[EXTENDS_LIST:java.util.AbstractMap<K,V>] PsiRefListStub[IMPLEMENTS_LIST:java.io.Serializable] - PsiClassStub[name=ImmutableEntry fqn=java.util.Collections.SingletonMap.ImmutableEntry] - PsiModifierListStub[mask=10] - PsiTypeParameterListStub - PsiTypeParameter[K] - PsiRefListStub[EXTENDS_BOUNDS_LIST:] - PsiTypeParameter[V] - PsiRefListStub[EXTENDS_BOUNDS_LIST:] - PsiRefListStub[EXTENDS_LIST:] - PsiRefListStub[IMPLEMENTS_LIST:java.util.Map.Entry<K,V>] - PsiFieldStub[k:K] - PsiModifierListStub[mask=4112] - PsiFieldStub[v:V] - PsiModifierListStub[mask=4112] - PsiMethodStub[cons ImmutableEntry:void] - PsiModifierListStub[mask=4096] - PsiTypeParameterListStub - PsiParameterListStub - PsiParameterStub[p1:K] - PsiModifierListStub[mask=0] - PsiParameterStub[p2:V] - PsiModifierListStub[mask=0] - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[getKey:K] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[getValue:V] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[setValue:V] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiParameterStub[p1:V] - PsiModifierListStub[mask=0] - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[equals:boolean] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiParameterStub[p1:java.lang.Object] - PsiModifierListStub[mask=0] - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[hashCode:int] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiRefListStub[THROWS_LIST:] - PsiMethodStub[toString:java.lang.String] - PsiModifierListStub[mask=1] - PsiTypeParameterListStub - PsiParameterListStub - PsiRefListStub[THROWS_LIST:] PsiFieldStub[serialVersionUID:long=-6979724477215052911L] PsiModifierListStub[mask=26] PsiFieldStub[k:K] @@ -459,9 +1669,9 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=3053995032091335093L] PsiModifierListStub[mask=26] PsiFieldStub[c:java.util.Collection<E>] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiFieldStub[mutex:java.lang.Object] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiMethodStub[cons SynchronizedCollection:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -566,6 +1776,13 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiMethodStub[writeObject:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.io.ObjectOutputStream] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:java.io.IOException] PsiClassStub[name=SynchronizedList fqn=java.util.Collections.SynchronizedList] PsiModifierListStub[mask=4104] PsiTypeParameterListStub @@ -574,9 +1791,9 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_LIST:java.util.Collections.SynchronizedCollection<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.List<E>] PsiFieldStub[serialVersionUID:long=-7754090372962971524L] - PsiModifierListStub[mask=4120] + PsiModifierListStub[mask=26] PsiFieldStub[list:java.util.List<E>] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiMethodStub[cons SynchronizedList:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -698,9 +1915,9 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=1978198479659022715L] PsiModifierListStub[mask=26] PsiFieldStub[m:java.util.Map<K,V>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=18] PsiFieldStub[mutex:java.lang.Object] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiFieldStub[keySet:java.util.Set<K>] PsiModifierListStub[mask=130] PsiFieldStub[entrySet:java.util.Set<java.util.Map.Entry<K,V>>] @@ -814,6 +2031,13 @@ PsiJavaFileStub [java.util] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] + PsiMethodStub[writeObject:void] + PsiModifierListStub[mask=2] + PsiTypeParameterListStub + PsiParameterListStub + PsiParameterStub[p1:java.io.ObjectOutputStream] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:java.io.IOException] PsiClassStub[name=SynchronizedRandomAccessList fqn=java.util.Collections.SynchronizedRandomAccessList] PsiModifierListStub[mask=4104] PsiTypeParameterListStub @@ -822,7 +2046,7 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_LIST:java.util.Collections.SynchronizedList<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.RandomAccess] PsiFieldStub[serialVersionUID:long=1530674583602358482L] - PsiModifierListStub[mask=4120] + PsiModifierListStub[mask=26] PsiMethodStub[cons SynchronizedRandomAccessList:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -902,7 +2126,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=-8798146769416483793L] PsiModifierListStub[mask=26] PsiFieldStub[sm:java.util.SortedMap<K,V>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=18] PsiMethodStub[cons SynchronizedSortedMap:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -967,7 +2191,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=8695801310862127406L] PsiModifierListStub[mask=26] PsiFieldStub[ss:java.util.SortedSet<E>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=18] PsiMethodStub[cons SynchronizedSortedSet:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -1032,7 +2256,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=1820017752578914078L] PsiModifierListStub[mask=26] PsiFieldStub[c:java.util.Collection<? extends E>] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiMethodStub[cons UnmodifiableCollection:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -1136,9 +2360,9 @@ PsiJavaFileStub [java.util] PsiRefListStub[EXTENDS_LIST:java.util.Collections.UnmodifiableCollection<E>] PsiRefListStub[IMPLEMENTS_LIST:java.util.List<E>] PsiFieldStub[serialVersionUID:long=-283967356065247728L] - PsiModifierListStub[mask=4120] + PsiModifierListStub[mask=26] PsiFieldStub[list:java.util.List<? extends E>] - PsiModifierListStub[mask=4096] + PsiModifierListStub[mask=4112] PsiMethodStub[cons UnmodifiableList:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -1536,7 +2760,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=-8806743815996713206L] PsiModifierListStub[mask=26] PsiFieldStub[sm:java.util.SortedMap<K,? extends V>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=18] PsiMethodStub[cons UnmodifiableSortedMap:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -1592,7 +2816,7 @@ PsiJavaFileStub [java.util] PsiFieldStub[serialVersionUID:long=-4929149591599911165L] PsiModifierListStub[mask=26] PsiFieldStub[ss:java.util.SortedSet<E>] - PsiModifierListStub[mask=2] + PsiModifierListStub[mask=18] PsiMethodStub[cons UnmodifiableSortedSet:void] PsiModifierListStub[mask=4096] PsiTypeParameterListStub @@ -1662,8 +2886,6 @@ PsiJavaFileStub [java.util] PsiModifierListStub[mask=25] PsiFieldStub[EMPTY_MAP:java.util.Map] PsiModifierListStub[mask=25] - PsiFieldStub[REVERSE_ORDER:java.util.Comparator] - PsiModifierListStub[mask=26] PsiMethodStub[cons Collections:void] PsiModifierListStub[mask=2] PsiTypeParameterListStub @@ -1693,9 +2915,9 @@ PsiJavaFileStub [java.util] PsiModifierListStub[mask=9] PsiTypeParameterListStub PsiTypeParameter[T] - PsiRefListStub[EXTENDS_BOUNDS_LIST:java.lang.Object, java.lang.Comparable<? super T>] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] PsiParameterListStub - PsiParameterStub[p1:java.util.List<? extends T>] + PsiParameterStub[p1:java.util.List<? extends java.lang.Comparable<? super T>>] PsiModifierListStub[mask=0] PsiParameterStub[p2:T] PsiModifierListStub[mask=0] @@ -1704,9 +2926,9 @@ PsiJavaFileStub [java.util] PsiModifierListStub[mask=10] PsiTypeParameterListStub PsiTypeParameter[T] - PsiRefListStub[EXTENDS_BOUNDS_LIST:java.lang.Object, java.lang.Comparable<? super T>] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] PsiParameterListStub - PsiParameterStub[p1:java.util.List<? extends T>] + PsiParameterStub[p1:java.util.List<? extends java.lang.Comparable<? super T>>] PsiModifierListStub[mask=0] PsiParameterStub[p2:T] PsiModifierListStub[mask=0] @@ -1715,9 +2937,9 @@ PsiJavaFileStub [java.util] PsiModifierListStub[mask=10] PsiTypeParameterListStub PsiTypeParameter[T] - PsiRefListStub[EXTENDS_BOUNDS_LIST:java.lang.Object, java.lang.Comparable<? super T>] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] PsiParameterListStub - PsiParameterStub[p1:java.util.List<? extends T>] + PsiParameterStub[p1:java.util.List<? extends java.lang.Comparable<? super T>>] PsiModifierListStub[mask=0] PsiParameterStub[p2:T] PsiModifierListStub[mask=0] @@ -2099,6 +3321,15 @@ PsiJavaFileStub [java.util] PsiParameterStub[p2:java.lang.Class<E>] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[zeroLengthArray:T[]] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:java.lang.Class<T>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiMethodStub[checkedSet:java.util.Set<E>] PsiModifierListStub[mask=9] PsiTypeParameterListStub @@ -2162,6 +3393,27 @@ PsiJavaFileStub [java.util] PsiParameterStub[p3:java.lang.Class<V>] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[emptyIterator:java.util.Iterator<T>] + PsiModifierListStub[mask=9] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[emptyListIterator:java.util.ListIterator<T>] + PsiModifierListStub[mask=9] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[emptyEnumeration:java.util.Enumeration<T>] + PsiModifierListStub[mask=9] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiRefListStub[THROWS_LIST:] PsiMethodStub[emptySet:java.util.Set<T>] PsiModifierListStub[mask=25] PsiTypeParameterListStub @@ -2194,6 +3446,15 @@ PsiJavaFileStub [java.util] PsiParameterStub[p1:T] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[singletonIterator:java.util.Iterator<E>] + PsiModifierListStub[mask=4104] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:E] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] PsiMethodStub[singletonList:java.util.List<T>] PsiModifierListStub[mask=9] PsiTypeParameterListStub @@ -2262,7 +3523,7 @@ PsiJavaFileStub [java.util] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] PsiMethodStub[eq:boolean] - PsiModifierListStub[mask=10] + PsiModifierListStub[mask=4104] PsiTypeParameterListStub PsiParameterListStub PsiParameterStub[p1:java.lang.Object] @@ -2290,6 +3551,7 @@ PsiJavaFileStub [java.util] PsiRefListStub[THROWS_LIST:] PsiMethodStub[varargs addAll:boolean] PsiModifierListStub[mask=9] + PsiAnnotationStub[@java.lang.SafeVarargs] PsiTypeParameterListStub PsiTypeParameter[T] PsiRefListStub[EXTENDS_BOUNDS_LIST:] @@ -2299,3 +3561,21 @@ PsiJavaFileStub [java.util] PsiParameterStub[p2:T...] PsiModifierListStub[mask=0] PsiRefListStub[THROWS_LIST:] + PsiMethodStub[newSetFromMap:java.util.Set<E>] + PsiModifierListStub[mask=9] + PsiTypeParameterListStub + PsiTypeParameter[E] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:java.util.Map<E,java.lang.Boolean>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] + PsiMethodStub[asLifoQueue:java.util.Queue<T>] + PsiModifierListStub[mask=9] + PsiTypeParameterListStub + PsiTypeParameter[T] + PsiRefListStub[EXTENDS_BOUNDS_LIST:] + PsiParameterListStub + PsiParameterStub[p1:java.util.Deque<T>] + PsiModifierListStub[mask=0] + PsiRefListStub[THROWS_LIST:] diff --git a/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java new file mode 100644 index 000000000000..0260f08423c1 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java @@ -0,0 +1,13 @@ +class Test { + public boolean isConsideredFinal(int cl) { + return haveSeenAllExp<caret>ectedAtCl(cl); + } + + private boolean haveSeenAllExpectedAtCl(int cl) { + return cl == cl(); + } + + int cl() { + return 0; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after new file mode 100644 index 000000000000..a7ff12c6344d --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after @@ -0,0 +1,9 @@ +class Test { + public boolean isConsideredFinal(int cl) { + return cl == cl(); + } + + int cl() { + return 0; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/after/Outer.java b/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/after/Outer.java new file mode 100644 index 000000000000..aafb683292a0 --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/after/Outer.java @@ -0,0 +1,10 @@ +class Outer { + static void foo() {} + + static class Inner { + } + + { + Runnable r = Outer::foo; + } +} diff --git a/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/before/Outer.java b/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/before/Outer.java new file mode 100644 index 000000000000..ae82c7498fff --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/fromNestedToOuterMethodRef/before/Outer.java @@ -0,0 +1,9 @@ +class Outer { + static class Inner { + static void foo() {} + } + + { + Runnable r = Inner::foo; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy index 45a3f818df3f..5d0bcd4eaa8c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy @@ -26,6 +26,8 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.util.PsiTreeUtil import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase +import org.jetbrains.annotations.NotNull + /** * @author peter */ @@ -94,7 +96,7 @@ public class HeavyNormalCompletionTest extends JavaCodeInsightFixtureTestCase { static class CacheVerifyingContributor extends CompletionContributor { @Override - void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { + void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { PsiClass psiClass = PsiTreeUtil.getParentOfType(parameters.position, PsiClass) for (ci in OverrideImplementExploreUtil.getMethodsToOverrideImplement(psiClass, true)) { assert ci.element.valid diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index a5397a2de68b..8a54c9594144 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -47,7 +47,9 @@ import com.intellij.openapi.extensions.LoadingOrder import com.intellij.openapi.fileEditor.FileEditor import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.progress.ProgressManager +import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Disposer +import com.intellij.psi.PsiClass import com.intellij.psi.PsiFile import com.intellij.psi.PsiJavaFile import com.intellij.psi.statistics.StatisticsManager @@ -559,7 +561,7 @@ public interface Test { static class LongContributor extends CompletionContributor { @Override - void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { + void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { result.runRemainingContributors(parameters, true) Thread.sleep 500 } @@ -892,9 +894,7 @@ class Foo { void bar(int aaa, int aaaaa) { foo(<caret>) } } """) type 'a' - println myFixture.lookupElementStrings type 'a' - println myFixture.lookupElementStrings type ',' assert myFixture.editor.document.text.contains('foo(aaa, )') } @@ -967,7 +967,12 @@ class Foo { void x__goo() {} } ''' - def cls = ((PsiJavaFile)myFixture.file).getClasses()[0] + PsiClass cls = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() { + @Override + public PsiClass compute() { + return ((PsiJavaFile)myFixture.file).getClasses()[0]; + } + }); def foo = cls.methods[0] def goo = cls.methods[2] type('x') diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java index 8aa780abbaa2..6eb495d27c26 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java @@ -64,6 +64,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testGenerics() throws Exception { + myFixture.addFileToProject("a.properties", "foo=bar"); // check that property variants don't override reflection ones doTest(0, "foo"); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy index c1e6d4182aa5..900555d21ab9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -633,6 +633,19 @@ interface TxANotAnno {} checkPreferredItems 0, 'fact' } + public void testPreferAnnotationsToInterfaceKeyword() { + checkPreferredItems 0, 'Deprecated', 'Override' + } + + public void testPreferThrownExceptionsInCatch() { + checkPreferredItems 0, 'FileNotFoundException', 'File' + } + + public void testHonorFirstLetterCase() { + CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE; + checkPreferredItems 0, 'posIdMap', 'PImageDecoder', 'PNGImageDecoder' + } + public void testGlobalStaticMemberStats() { configureNoCompletion(getTestName(false) + ".java") myFixture.complete(CompletionType.BASIC, 2) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index ba38fd1a45ad..79a94aaa8148 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -792,7 +792,7 @@ public class ListUtils { public void testDoubleFalse() throws Throwable { configureByFile(getTestName(false) + ".java"); - assertFirstStringItems("false", "fefefef", "float", "finalize"); + assertFirstStringItems("fefefef", "false", "float", "finalize"); } public void testSameNamedVariableInNestedClasses() throws Throwable { @@ -938,6 +938,13 @@ public class ListUtils { public void testQualifyInnerMembers() throws Throwable { doTest('\n') } + public void testDeepInner() throws Throwable { + configure() + assert myFixture.lookupElementStrings == ['ClassInner1', 'ClassInner1.ClassInner2'] + selectItem(lookup.items[1]) + checkResult() + } + public void testSuggestExpectedTypeMembers() throws Throwable { doTest('\n') } public void testSuggestExpectedTypeMembersInCall() throws Throwable { doTest('\n') } public void testSuggestExpectedTypeMembersInAnno() throws Throwable { doTest('\n') } @@ -1209,6 +1216,12 @@ class XInternalError {} public void testConstantInAnno() { doTest() } + public void testCharsetName() { + myFixture.addClass("package java.nio.charset; public class Charset { public static Charset forName(String s) {} }") + configureByTestName() + assert myFixture.lookupElementStrings.contains('UTF-8') + } + public void testInnerClassInExtendsGenerics() { def text = "package bar; class Foo extends List<Inne<caret>> { public static class Inner {} }" myFixture.configureFromExistingVirtualFile(myFixture.addClass(text).containingFile.virtualFile) @@ -1240,7 +1253,7 @@ class XInternalError {} configure() def items = myFixture.lookupElements.findAll { it.lookupString == 'String' } assert items.size() == 1 - assert LookupElementPresentation.renderElement(items[0]).tailText?.contains('java.lang') + assert LookupElementPresentation.renderElement(items[0]).tailText == ' (java.lang)' } public void testSameSignature() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 74d2465f43a5..f6be0686d239 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -368,6 +368,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA125816() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testIDEA57338() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); } public void testIDEA67600() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testIDEA126697() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true); } + public void testIDEA126633() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testIDEA124363() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } //jdk should propagate LL 1.4 but actually it provides LL 1.7?! public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index 20a5d5139d99..79506280a778 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -184,6 +184,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testRawTypeFromParentArrayType() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index f5e6a651f167..6bd7654b72af 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -226,6 +226,22 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA125254() throws Exception { + doTest(); + } + + public void testIDEA124961() throws Exception { + doTest(); + } + + public void testIDEA126109() throws Exception { + doTest(); + } + + public void testIDEA126809() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index 16af9001cf43..6860bc0c88fa 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -261,6 +261,18 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testRejectReceiverTypesForConstructorRefs() { + doTest(); + } + + public void testEnumValuesMethod() throws Exception { + doTest(); + } + + public void testMissedApplicableMemberContainingClassSubstitution() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java new file mode 100644 index 000000000000..48572b2c8068 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java @@ -0,0 +1,104 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.quickFix; + +import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodQualifierFix; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.psi.PsiNamedElement; +import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +/** + * @author Dmitry Batkovich + */ +public class AddMethodQualifierTest extends JavaCodeInsightFixtureTestCase { + + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/"; + } + + public void testNonStaticMethod() { + doTest("fieldElement", "staticElement", "localElement1", "paramElement"); + } + + public void testStaticMethod() { + doTest("staticElement", "localElement1", "paramElement"); + } + + public void testNestedMethod() { + doTest("fieldElement", "localElement1", "nestedField", "nestedParamElement", "staticElement", "paramElement"); + } + + public void testConstructor() { + doTest("fieldElement", "staticElement", "localElement1"); + } + + public void testStaticInitializer() { + doTest("staticElement", "localElement1"); + } + + public void testFix() { + doTestFix(); + } + + private void doTestFix() { + myFixture.configureByFile(getTestName(false) + "Before.java"); + final AddMethodQualifierFix quickFix = getQuickFix(); + assertNotNull(quickFix); + myFixture.launchAction(quickFix); + myFixture.checkResultByFile(getTestName(false) + "After.java"); + } + + private void doTest(final String... candidatesNames) { + myFixture.configureByFile(getTestName(false) + ".java"); + final AddMethodQualifierFix addMethodQualifierFix = getQuickFix(); + if (candidatesNames.length == 0) { + assertNull(addMethodQualifierFix); + return; + } + assertNotNull(addMethodQualifierFix); + final Set<String> actualCandidatesNames = new TreeSet<String>(ContainerUtil.map(addMethodQualifierFix.getCandidates(), new Function<PsiNamedElement, String>() { + @Override + public String fun(final PsiNamedElement psiNamedElement) { + final String name = psiNamedElement.getName(); + assertNotNull(name); + return name; + } + })); + final Set<String> expectedCandidatesNames = new TreeSet<String>(ContainerUtil.list(candidatesNames)); + assertEquals(expectedCandidatesNames, actualCandidatesNames); + } + + @Nullable + private AddMethodQualifierFix getQuickFix() { + final List<IntentionAction> availableIntentions = myFixture.getAvailableIntentions(); + AddMethodQualifierFix addMethodQualifierFix = null; + for (final IntentionAction availableIntention : availableIntentions) { + if (availableIntention instanceof AddMethodQualifierFix) { + addMethodQualifierFix = (AddMethodQualifierFix)availableIntention; + break; + } + } + return addMethodQualifierFix; + } + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy index 41d72f7e9a0e..2047f13b795d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy @@ -27,6 +27,7 @@ import com.intellij.openapi.editor.impl.FoldingModelImpl import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass +import com.intellij.psi.PsiLiteralExpression import com.intellij.psi.PsiMethod import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.LightProjectDescriptor @@ -592,6 +593,225 @@ class Test { assert regions[0].placeholderText == '{...}' } + public void "test insert boolean literal argument name"() { + def text = """class Groo { + + public void test() { + boolean testNow = System.currentTimeMillis() > 34000; + int times = 1; + float pi = 4; + String title = "Testing..." + char ch = 'q' + File file; + + configure(true, false, 555, 3.141f, "Huge Title", 'c', null); + configure(testNow, shouldIgnoreRoots(), fourteen, pi, title, c, file); + } + + pubic void configure(boolean testNow, boolean shouldIgnoreRoots, int times, float pi, String title, char terminate, File file) { + System.out.println(); + System.out.println(); + } + +}""" + configure text + PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Groo', GlobalSearchScope.allScope(project)) + + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.size() == 9 + + def literals = fooClass.methods[0].body.statements[6].children[0].children[1].children.findAll { it instanceof PsiLiteralExpression } + def parameters = fooClass.methods[1].parameterList.parameters + + for (int i = 0; i < literals.size(); i++) { + def currentElement = literals[i] + def correspondingFolding = regions[i + 1] + assert correspondingFolding.startOffset == currentElement.textRange.startOffset && correspondingFolding.endOffset == currentElement.textRange.endOffset + assert correspondingFolding.placeholderText == parameters[i].name + ": " + currentElement.text + } + } + + public void "test do not inline name if setter"() { + def text = """class Groo { + + public void test() { + setTestNow(false); + System.out.println(""); + } + + pubic void setTestNow(boolean testNow) { + System.out.println(""); + System.out.println(""); + } + +}""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions + assert regions.size() == 2 + } + + public void "test do not collapse varargs"() { + def text = """ +public class VarArgTest { + + public void main() { + System.out.println("AAA"); + testBooleanVarargs(13, false); + } + + public boolean testBooleanVarargs(int test, boolean... booleans) { + int temp = test; + return false; + } +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.size() == 3 + checkRangeOffsetByPositionInText(regions[1], text, "13") + assert regions[1].placeholderText == "test: 13" + } + + public void "test inline if argument length is one (EA-57555)"() { + def text = """ +public class CharSymbol { + + public void main() { + System.out.println("AAA"); + count(1, false); + } + + public void count(int test, boolean fast) { + int temp = test; + boolean isFast = fast; + } +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.size() == 4 + + checkRangeOffsetByPositionInText(regions[1], text, "1") + assert regions[1].placeholderText == "test: 1" + + checkRangeOffsetByPositionInText(regions[2], text, "false") + assert regions[2].placeholderText == "fast: false" + } + + public void "test inline names if literal expression can be assigned to method parameter"() { + def text = """ +public class CharSymbol { + + public void main() { + Object obj = new Object(); + count(100, false, "Hi!"); + } + + public void count(Integer test, Boolean boo, CharSequence seq) { + int a = test; + Object obj = new Object(); + } +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.size() == 5 + + checkRangeOffsetByPositionInText(regions[1], text, "100") + assert regions[1].placeholderText == "test: 100" + + checkRangeOffsetByPositionInText(regions[2], text, "false") + assert regions[2].placeholderText == "boo: false" + + checkRangeOffsetByPositionInText(regions[3], text, '"Hi!"') + assert regions[3].placeholderText == 'seq: "Hi!"' + } + + public void "test inline negative numbers (IDEA-126753)"() { + def text = """ +public class CharSymbol { + + public void main() { + Object obj = new Object(); + count(-1, obj); + } + + public void count(int test, Object obj) { + Object tmp = obj; + boolean isFast = false; + } +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.size() == 3 + + checkRangeOffsetByPositionInText(regions[1], text, "-1") + assert regions[1].placeholderText == "test: -1" + } + + public void "test inline constructor literal arguments names"() { + def text = """ +public class Test { + + public void main() { + System.out.println("AAA"); + Checker r = new Checker(true, false) { + @Override + void test() { + } + }; + } + + abstract class Checker { + Checker(boolean applyToFirst, boolean applyToSecond) {} + abstract void test(); + } +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.length == 6 + + assert regions[1].placeholderText == "applyToFirst: true" + assert regions[2].placeholderText == "applyToSecond: false" + + checkRangeOffsetByPositionInText(regions[1], text, "true") + checkRangeOffsetByPositionInText(regions[2], text, "false") + } + + public void "test inline anonymous class constructor literal arguments names"() { + def text = """ +public class Test { + + Test(int counter, boolean shouldTest) { + System.out.println(); + System.out.println(); + } + + public static void main() { + System.out.println(); + Test t = new Test(10, false); + } + +} +""" + configure text + def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset } + assert regions.length == 4 + + assert regions[2].placeholderText == "counter: 10" + assert regions[3].placeholderText == "shouldTest: false" + + checkRangeOffsetByPositionInText(regions[2], text, "10") + checkRangeOffsetByPositionInText(regions[3], text, "false") + } + + private static def checkRangeOffsetByPositionInText(FoldRegion region, String text, String foldElement) { + assert region.startOffset == text.indexOf(foldElement) && region.endOffset == text.indexOf(foldElement) + foldElement.length() + } + + private def changeFoldRegions(Closure op) { myFixture.editor.foldingModel.runBatchFoldingOperationDoNotCollapseCaret(op) } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java new file mode 100644 index 000000000000..a973a9775be0 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.intention; + +import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; + +/** + * @author Dmitry Batkovich + */ +public class SwapIfStatementsTest extends LightQuickFixParameterizedTestCase { + + @Override + protected String getBasePath() { + return "/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements"; + } + + @Override + protected boolean shouldBeAvailableAfterExecution() { + return true; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index 6df51f02df15..454bb7f97a58 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -76,6 +76,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { doTestField(); } + public void testAnnotations() throws Exception { + doTestField(); + } + public void testLiteral() throws Exception { doTestField(); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index cc50869bc886..3acb9845df66 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -461,7 +461,7 @@ class Foo { } @Override - protected void invokeTestRunnable(final Runnable runnable) throws Exception { + protected void invokeTestRunnable(@NotNull final Runnable runnable) throws Exception { if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar", "test escape string characters in soutv"]) { runnable.run(); return; diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy index ab9a5660b8ad..32982f3687df 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy @@ -171,6 +171,55 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase { assert c == [] } + public void "test plain delegation"() { + def c = inferContracts(""" + boolean delegating(Object o) { + return smth(o); + } + boolean smth(Object o) { + assert o instanceof String; + return true; + } +""") + assert c == ['null -> fail'] + } + + public void "test arg swapping delegation"() { + def c = inferContracts(""" + boolean delegating(Object o, Object o1) { + return smth(o1, o); + } + boolean smth(Object o, Object o1) { + return o == null && o1 != null; + } +""") + assert c == ['_, !null -> false', 'null, null -> false', '!null, null -> true'] + } + + public void "test negating delegation"() { + def c = inferContracts(""" + boolean delegating(Object o) { + return !smth(o); + } + boolean smth(Object o) { + return o == null; + } +""") + assert c == ['null -> false', '!null -> true'] + } + + public void "test delegation with constant"() { + def c = inferContracts(""" + boolean delegating(Object o) { + return smth(null); + } + boolean smth(Object o) { + return o == null; + } +""") + assert c == ['_ -> true'] + } + private String inferContract(String method) { return assertOneElement(inferContracts(method)) } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index 67987b3ab8eb..833b5196d74a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -71,6 +71,9 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { public void testGeneratedEquals() throws Throwable { doTest(); } public void testIDEA84489() throws Throwable { doTest(); } + public void testComparingNullToNotNull() { doTest(); } + public void testComparingNullableToNullable() { doTest(); } + public void testComparingNullableToUnknown() { doTest(); } public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); } public void testComparingToNullableShouldNotAffectNullity() throws Throwable { doTest(); } public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); } @@ -235,6 +238,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { public void testManySequentialInstanceofsNotComplex() { doTest(); } public void testLongDisjunctionsNotComplex() { doTest(); } public void testWhileNotComplex() { doTest(); } + public void testAssertTrueNotComplex() { doTest(); } public void testManyDisjunctiveFieldAssignmentsInLoopNotComplex() { doTest(); } public void testManyContinuesNotComplex() { doTest(); } public void testFinallyNotComplex() { doTest(); } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java new file mode 100644 index 000000000000..a1f81da5773b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved. + */ + +/* + * User: anna + * Date: 14-Jan-2007 + */ +package com.intellij.codeInspection; + +import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.actions.ViewOfflineResultsAction; +import com.intellij.codeInspection.defUse.DefUseInspection; +import com.intellij.codeInspection.defUse.DefUseInspectionBase; +import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.codeInspection.ex.InspectionToolWrapper; +import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; +import com.intellij.codeInspection.ex.ToolsImpl; +import com.intellij.codeInspection.offline.OfflineProblemDescriptor; +import com.intellij.codeInspection.offlineViewer.OfflineViewParseUtil; +import com.intellij.codeInspection.ui.InspectionResultsView; +import com.intellij.codeInspection.ui.InspectionTree; +import com.intellij.codeInspection.ui.InspectionTreeNode; +import com.intellij.openapi.application.ex.PathManagerEx; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.PsiElement; +import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.testFramework.TestSourceBasedTestCase; +import com.intellij.util.ui.tree.TreeUtil; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class OfflineIRVTest extends TestSourceBasedTestCase { + private InspectionResultsView myView; + private LocalInspectionToolWrapper myToolWrapper; + + private static String varMessage(String name) { + return InspectionsBundle.message("inspection.unused.assignment.problem.descriptor1", "'"+name+"'"); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + HighlightDisplayKey.register(DefUseInspectionBase.SHORT_NAME); + myToolWrapper = new LocalInspectionToolWrapper(new DefUseInspection()); + myView = ViewOfflineResultsAction.showOfflineView(getProject(), parse(), new InspectionProfileImpl("test") { + @Override + public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) { + return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME); + } + + @Override + @NotNull + public InspectionToolWrapper[] getInspectionTools(PsiElement element) { + return new InspectionToolWrapper[]{myToolWrapper}; + } + + @Override + @NotNull + public ModifiableModel getModifiableModel() { + return new InspectionProfileImpl("test") { + @Override + @NotNull + public InspectionToolWrapper[] getInspectionTools(PsiElement element) { + return new InspectionToolWrapper[]{myToolWrapper}; + } + + @Override + public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) { + return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME); + } + }; + } + }, null); + myView.getGlobalInspectionContext().getTools().put( + myToolWrapper.getShortName(), new ToolsImpl(myToolWrapper, myToolWrapper.getDefaultLevel(), true)); + myToolWrapper.initialize(myView.getGlobalInspectionContext()); + } + + private Map<String, Map<String, Set<OfflineProblemDescriptor>>> parse() throws IOException { + final String moduleName = getModule().getName(); + final Map<String, Map<String, Set<OfflineProblemDescriptor>>> map = new HashMap<String, Map<String, Set<OfflineProblemDescriptor>>>(); + final File res = new File(PathManagerEx.getTestDataPath(), getTestPath() + File.separator + "res"); + final File[] files = res.listFiles(); + assert files != null; + for (File file : files) { + final String name = file.getName(); + final String problems = FileUtil.loadFile(file); + final Map<String, Set<OfflineProblemDescriptor>> descriptors = OfflineViewParseUtil.parse(problems); + for (Set<OfflineProblemDescriptor> problemDescriptors : descriptors.values()) { + for (OfflineProblemDescriptor descriptor : problemDescriptors) { + descriptor.setModule(moduleName); + } + } + map.put(name.substring(0, name.lastIndexOf('.')), descriptors); + } + return map; + } + + @Override + protected void tearDown() throws Exception { + Disposer.dispose(myView); + myView = null; + myToolWrapper = null; + super.tearDown(); + } + + public void testOfflineView() throws Exception { + myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true; + InspectionTree tree = updateTree(); + TreeUtil.expandAll(tree); + PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + + " -Probable bugs\n" + + " -" + myToolWrapper + "\n" + + " -" + getModule().toString() + "\n" + + " -<default>\n" + + " -Test\n" + + " -foo()\n" + + " " + varMessage("j") + "\n" + + " -main(String[])\n" + + " " + varMessage("test") + "\n" + + " -f()\n" + + " -D\n" + + " -b()\n" + + " " + varMessage("r") + "\n" + + " -anonymous (java.lang.Runnable)\n" + + " -run()\n" + + " " + varMessage("i") + "\n" + + " -ff()\n" + + " " + varMessage("d") + "\n" + + " " + varMessage("a") + "\n"); + myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = false; + tree = updateTree(); + PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + + " -Probable bugs\n" + + " -" + myToolWrapper + "\n" + + " -Test\n" + + " " + varMessage("j") + "\n" + + " " + varMessage("test") + "\n" + + " " + varMessage("r") + "\n" + + " " + varMessage("i") + "\n" + + " " + varMessage("d") + "\n" + + " " + varMessage("a") + "\n"); + TreeUtil.selectFirstNode(tree); + final InspectionTreeNode root = (InspectionTreeNode)tree.getLastSelectedPathComponent(); + root.ignoreElement(); + TreeUtil.traverse(root, new TreeUtil.Traverse() { + @Override + public boolean accept(final Object node) { + assertTrue(((InspectionTreeNode)node).isResolved()); + return true; + } + }); + myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = true; + tree = updateTree(); + PlatformTestUtil.assertTreeEqual(tree, getProject() + "\n"); + myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = false; + tree = updateTree(); + PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + + " -Probable bugs\n" + + " -" + myToolWrapper + "\n" + + " -Test\n" + + " " + varMessage("j") + "\n" + + " " + varMessage("test") + "\n" + + " " + varMessage("r") + "\n" + + " " + varMessage("i") + "\n" + + " " + varMessage("d") + "\n" + + " " + varMessage("a") + "\n"); + } + + private InspectionTree updateTree() { + myView.update(); + final InspectionTree tree = myView.getTree(); + TreeUtil.expandAll(tree); + return tree; + } + + @Override + protected String getTestPath() { + return "inspection/offline"; + } + + @Override + protected String getTestDirectoryName() { + return "project"; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java index 4dd29648e055..a8b27ab21089 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java @@ -49,6 +49,7 @@ public class RedundantCast15Test extends InspectionTestCase { public void testGetClassProcessing() throws Exception { doTest();} public void testInstanceOfChecks() throws Exception { doTest();} public void testForEachValue() throws Exception { doTest();} + public void testForEachValueIDEA126166() throws Exception { doTest();} public void testCaseThrowable() throws Exception { doTest();} public void testSafeTempVarName() throws Exception { doTest();} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java index 0a0c5396c6c9..6cb52914fe84 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java @@ -18,7 +18,6 @@ package com.intellij.codeInspection; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; @@ -33,6 +32,7 @@ public class RedundantCast18Test extends InspectionTestCase { public void testLambdaContext() throws Exception { doTest(); } public void testMethodRefContext() throws Exception { doTest(); } public void testExpectedSupertype() throws Exception { doTest(); } + public void testForeachValue() throws Exception { doTest(); } @Override protected Sdk getTestProjectSdk() { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java new file mode 100644 index 000000000000..2d30216395ac --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection; + +import com.intellij.JavaTestUtil; +import com.intellij.codeInspection.miscGenerics.SuspiciousCollectionsMethodCallsInspection; +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; + +public class SuspiciousCollectionMethodCalls14Test extends LightCodeInsightFixtureTestCase { + private final SuspiciousCollectionsMethodCallsInspection myTool = new SuspiciousCollectionsMethodCallsInspection(); + + @Override + protected String getBasePath() { + return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/suspiciousCalls"; + } + + private void doTest() throws Exception { + myFixture.enableInspections(myTool); + myFixture.testHighlighting(getTestName(false) + ".java"); + } + + public void testRemoveAll14() throws Exception { doTest(); } + + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_1_4; + } +} diff --git a/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java b/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java index ef4b5ea42d8c..498a1172fa9a 100644 --- a/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java +++ b/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java @@ -27,8 +27,8 @@ import com.intellij.testFramework.fixtures.TestFixtureBuilder; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.ClassReader; -import org.jetbrains.asm4.ClassWriter; +import org.jetbrains.org.objectweb.asm.ClassReader; +import org.jetbrains.org.objectweb.asm.ClassWriter; import java.io.File; import java.io.IOException; diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index 86d79fb41e10..92caad03d8ef 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -53,9 +53,11 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.CommonProcessors; import com.intellij.util.ThrowableRunnable; import com.intellij.util.WaitFor; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -284,6 +286,26 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { assertSize(2, findUsages(findModel)); } + public void testFindInOpenedFilesIncludesNoneProjectButOpenedFile() throws IOException { + File dir = createTempDirectory(); + File file = new File(dir.getPath(), "A.test1234"); + file.createNewFile(); + FileUtil.writeToFile(file, "foo fo foo"); + VirtualFile nonProjectFile = VfsUtil.findFileByIoFile(file, true); + assertNotNull(nonProjectFile); + + FindModel findModel = new FindModel(); + findModel.setStringToFind("fo"); + findModel.setWholeWordsOnly(true); + findModel.setFromCursor(false); + findModel.setGlobal(true); + findModel.setMultipleFiles(true); + findModel.setCustomScope(true); + findModel.setCustomScope(new GlobalSearchScope.FilesScope(myProject, ContainerUtil.list(nonProjectFile))); + + assertSize(1, findUsages(findModel)); + } + public void testWholeWordsInNonIndexedFiles() throws Exception { createFile(myModule, "A.test123", "foo fo foo"); diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy index fad8e4fd94e9..dabe06ba79fa 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy +++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy @@ -1,17 +1,30 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.navigation -import com.intellij.ide.util.gotoByName.ChooseByNameBase -import com.intellij.ide.util.gotoByName.ChooseByNameModel -import com.intellij.ide.util.gotoByName.ChooseByNamePopup -import com.intellij.ide.util.gotoByName.GotoClassModel2 -import com.intellij.ide.util.gotoByName.GotoFileModel -import com.intellij.ide.util.gotoByName.GotoSymbolModel2 +import com.intellij.ide.util.gotoByName.* import com.intellij.openapi.Disposable import com.intellij.openapi.application.ModalityState import com.intellij.openapi.util.Disposer import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.util.Consumer import com.intellij.util.concurrency.Semaphore +import org.jetbrains.annotations.NotNull + /** * @author peter */ @@ -135,24 +148,32 @@ class Intf { } public void "test goto file can go to dir"() { - def fooIndex = myFixture.addFileToProject("foo/index.html", "foo") - def barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo") + PsiFile fooIndex = myFixture.addFileToProject("foo/index.html", "foo") + PsiFile barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo") def popup = createPopup(new GotoFileModel(project), fooIndex) - assert calcPopupElements(popup, "foo/") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "foo\\") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "/foo") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "\\foo") == [fooIndex.containingDirectory] + + def fooDir + def barDir + edt { + fooDir = fooIndex.containingDirectory + barDir = barIndex.containingDirectory + } + + assert calcPopupElements(popup, "foo/") == [fooDir] + assert calcPopupElements(popup, "foo\\") == [fooDir] + assert calcPopupElements(popup, "/foo") == [fooDir] + assert calcPopupElements(popup, "\\foo") == [fooDir] assert calcPopupElements(popup, "foo") == [] assert calcPopupElements(popup, "/index.html") == [fooIndex] assert calcPopupElements(popup, "\\index.html") == [fooIndex] assert calcPopupElements(popup, "index.html/") == [fooIndex] assert calcPopupElements(popup, "index.html\\") == [fooIndex] - assert calcPopupElements(popup, "bar.txt/") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "bar.txt\\") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "/bar.txt") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "\\bar.txt") == [barIndex.containingDirectory] + assert calcPopupElements(popup, "bar.txt/") == [barDir] + assert calcPopupElements(popup, "bar.txt\\") == [barDir] + assert calcPopupElements(popup, "/bar.txt") == [barDir] + assert calcPopupElements(popup, "\\bar.txt") == [barDir] assert calcPopupElements(popup, "bar.txt") == [barIndex] popup.close(false) } @@ -178,7 +199,10 @@ class Intf { public void "test super method in jdk"() { def ourRun = myFixture.addClass("package foo.bar; class Goo implements Runnable { public void run() {} }").methods[0] - def sdkRun = ourRun.containingClass.interfaces[0].methods[0] + def sdkRun + edt { + sdkRun = ourRun.containingClass.interfaces[0].methods[0] + } assert getPopupElements(new GotoSymbolModel2(project), 'run ', true) == [sdkRun] assert getPopupElements(new GotoSymbolModel2(project), 'run ', false) == [ourRun] } @@ -218,7 +242,7 @@ class Intf { } @Override - protected void invokeTestRunnable(Runnable runnable) throws Exception { + protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception { runnable.run() } } diff --git a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java index f40a58b16788..b168bc214014 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java @@ -15,11 +15,8 @@ */ package com.intellij.openapi.editor.impl; -import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.impl.CodeFoldingPassFactory; -import com.intellij.mock.MockProgressIndicator; import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.LightCodeInsightTestCase; @@ -43,14 +40,7 @@ public class FoldingExceptionTest extends LightCodeInsightTestCase { } private static void runFoldingPass() { - PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(getProject()); - psiDocumentManager.commitAllDocuments(); - PsiFile psiFile = psiDocumentManager.getPsiFile(myEditor.getDocument()); - assertNotNull(psiFile); - - CodeFoldingPassFactory factory = getProject().getComponent(CodeFoldingPassFactory.class); - TextEditorHighlightingPass highlightingPass = factory.createHighlightingPass(psiFile, myEditor); - highlightingPass.collectInformation(new MockProgressIndicator()); - highlightingPass.doApplyInformationToEditor(); + PsiDocumentManager.getInstance(ourProject).commitAllDocuments(); + EditorTestUtil.runTextEditorHighlightingPass(myEditor, CodeFoldingPassFactory.class); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java deleted file mode 100644 index dd32222cc7a8..000000000000 --- a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi; - -import com.intellij.JavaTestUtil; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.testFramework.PsiTestCase; -import com.intellij.testFramework.SkipSlowTestLocally; -import com.intellij.usageView.UsageViewLongNameLocation; -import gnu.trove.THashSet; -import gnu.trove.TObjectHashingStrategy; - -import java.util.Set; - -@SkipSlowTestLocally -public class ClsDuplicatesTest extends PsiTestCase { - private Set<PsiNamedElement> myUnique = new THashSet<PsiNamedElement>(new TObjectHashingStrategy<PsiNamedElement>() { - @Override - public int computeHashCode(PsiNamedElement object) { - String name = object.getName(); - return name == null ? 0 : name.hashCode(); - } - - @Override - public boolean equals(PsiNamedElement o1, PsiNamedElement o2) { - return o1.getParent() == o2.getParent() && - o1.getClass() == o2.getClass() && - StringUtil.equals(o1.getName(), o2.getName()) && - StringUtil.equals(o1.getText(), o2.getText()); - } - }); - - @Override - protected void tearDown() throws Exception { - myUnique = null; - super.tearDown(); - } - - @Override - protected Sdk getTestProjectJdk() { - return JavaTestUtil.getTestJdk(); - } - - public void testDuplicates() throws Exception { - final PsiPackage rootPackage = JavaPsiFacade.getInstance(getProject()).findPackage(""); - assert rootPackage != null; - - final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); - JavaRecursiveElementVisitor visitor = new JavaRecursiveElementVisitor() { - @Override - public void visitPackage(PsiPackage aPackage) { - visit(aPackage); - for (PsiPackage subPackage : aPackage.getSubPackages(scope)) { - visitPackage(subPackage); - } - for (PsiClass aClass : aPackage.getClasses(scope)) { - visitClass(aClass); - } - } - - @Override - public void visitElement(PsiElement element) { - if (element instanceof PsiNamedElement) { - visit((PsiNamedElement)element); - } - super.visitElement(element); - } - - @Override - public void visitClass(PsiClass aClass) { - super.visitClass(aClass); - PsiElement parent = aClass.getParent(); - if (parent instanceof PsiFile) { - myUnique.clear(); - } - } - }; - - rootPackage.accept(visitor); - } - - private void visit(PsiNamedElement element) { - if (!myUnique.add(element)) { - String description = ElementDescriptionUtil.getElementDescription(element, UsageViewLongNameLocation.INSTANCE); - fail("Duplicate Element: " + description + ": " + element.getText()); - } - } -} diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index b832e65c7675..c88c8c28c102 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -18,15 +18,18 @@ package com.intellij.psi; import com.intellij.JavaTestUtil; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.impl.compiled.ClsFileImpl; +import com.intellij.psi.impl.compiled.InnerClassSourceStrategy; +import com.intellij.psi.impl.compiled.StubBuildingVisitor; +import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl; import com.intellij.testFramework.LightIdeaTestCase; import com.intellij.testFramework.PlatformTestUtil; +import org.jetbrains.org.objectweb.asm.ClassReader; import java.io.IOException; @@ -75,6 +78,35 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { doTest(clsPath, txtPath); } + public void testStrayInnersFiltering() throws IOException { + String path = JavaTestUtil.getJavaTestDataPath() + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/lang/Class.class"; + VirtualFile file = StandardFileSystems.jar().findFileByPath(path); + assertNotNull(path, file); + + InnerClassSourceStrategy<VirtualFile> strategy = new InnerClassSourceStrategy<VirtualFile>() { + @Override + public VirtualFile findInnerClass(String innerName, VirtualFile outerClass) { + String baseName = outerClass.getNameWithoutExtension(); + VirtualFile child = outerClass.getParent().findChild(baseName + "$" + innerName + ".class"); + // stray inner classes should be filtered out + assert child != null : innerName + " is not an inner class of " + outerClass; + return child; + } + + @Override + public void accept(VirtualFile innerClass, StubBuildingVisitor<VirtualFile> visitor) { + try { + byte[] bytes = innerClass.contentsToByteArray(); + new ClassReader(bytes).accept(visitor, ClassReader.SKIP_FRAMES); + } + catch (IOException ignored) { } + } + }; + PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl("do.not.know.yet", true); + StubBuildingVisitor<VirtualFile> visitor = new StubBuildingVisitor<VirtualFile>(file, strategy, stub, 0, null); + new ClassReader(file.contentsToByteArray()).accept(visitor, ClassReader.SKIP_FRAMES); + } + private void doTest() { doTest(getTestName(false)); } @@ -85,11 +117,9 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { } private static void doTest(String clsPath, String txtPath) { - VirtualFileSystem fs = clsPath.contains("!/") ? JarFileSystem.getInstance() : LocalFileSystem.getInstance(); - VirtualFile vFile = fs.findFileByPath(clsPath); - assertNotNull(clsPath, vFile); - PsiFile clsFile = getPsiManager().findFile(vFile); - assertNotNull(vFile.getPath(), clsFile); + VirtualFileSystem fs = clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local(); + VirtualFile file = fs.findFileByPath(clsPath); + assertNotNull(clsPath, file); String expected; try { @@ -100,6 +130,6 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { return; } - assertEquals(expected, ((ClsFileImpl)clsFile).getMirror().getText()); + assertEquals(expected, ClsFileImpl.decompile(file).toString()); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java index 16392eb601d5..e8317415d8b3 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java @@ -690,7 +690,6 @@ public class ClsRepositoryUseTest extends PsiTestCase { final PsiType returnType = methodsWithReturnType.getReturnType(); assert returnType != null : methodsWithReturnType; assertEquals("pack.Parametrized<? extends T>", returnType.getCanonicalText()); - assertEquals("public pack.Parametrized<? extends T> method() { /* compiled code */ }", methodsWithReturnType.getText()); } private static void checkEnumConstant(String name, PsiField field, PsiClassType type) { @@ -740,19 +739,20 @@ public class ClsRepositoryUseTest extends PsiTestCase { assertEquals(PsiWildcardType.createUnbounded(myPsiManager), substitution); } + @SuppressWarnings("ConstantConditions") public void testModifiers() throws Exception { - final PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE); + PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE); assertNotNull(psiClass); - assertEquals("public class Modifiers {\n" + - " private transient int f1;\n" + - " private volatile int f2;\n" + - "\n" + - " public Modifiers() { /* compiled code */ }\n" + - "\n" + - " private void m1(int... i) { /* compiled code */ }\n" + - "\n" + - " private synchronized void m2() { /* compiled code */ }\n" + - "}", - psiClass.getText().trim()); + + PsiField f1 = psiClass.findFieldByName("f1", false); + assertEquals("private transient", f1.getModifierList().getText()); + PsiField f2 = psiClass.findFieldByName("f2", false); + assertEquals("private volatile", f2.getModifierList().getText()); + PsiMethod init = psiClass.findMethodsByName("Modifiers", false)[0]; + assertEquals("public", init.getModifierList().getText()); + PsiMethod m1 = psiClass.findMethodsByName("m1", false)[0]; + assertEquals("private", m1.getModifierList().getText()); + PsiMethod m2 = psiClass.findMethodsByName("m2", false)[0]; + assertEquals("private synchronized", m2.getModifierList().getText()); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java index 301a99319cbb..096547c4f4db 100644 --- a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java @@ -25,10 +25,11 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.impl.source.tree.LazyParseableElement; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; public class MiscPsiTest extends LightCodeInsightFixtureTestCase { @Override - protected void invokeTestRunnable(final Runnable runnable) throws Exception { + protected void invokeTestRunnable(@NotNull final Runnable runnable) throws Exception { new WriteCommandAction.Simple(getProject()) { @Override protected void run() throws Throwable { diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy index c9153983344a..021f7f95c480 100644 --- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy @@ -73,7 +73,13 @@ class StubAstSwitchTest extends LightCodeInsightFixtureTestCase { } CountDownLatch latch = new CountDownLatch(count) for (c in classList) { - ApplicationManager.application.executeOnPooledThread { Thread.yield(); c.text; latch.countDown() } + ApplicationManager.application.executeOnPooledThread { + Thread.yield(); + ApplicationManager.application.runReadAction { + c.text; + } + latch.countDown() + } for (m in c.methods) { def parameters = m.parameterList.parameters for (i in 0..<parameters.size()) { diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy index 302f1b331530..d11a34f6e376 100644 --- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy @@ -328,9 +328,61 @@ class Second extends First { ) } + void "test IDEA-123875"() { + doTest( + initial: '''\ +public class RearrangeFail { + + public static final byte[] ENTITIES_END = "</entities>".getBytes(); + private final Element entitiesEndElement = new Element(ENTITIES_END); + public static final byte[] ENTITIES_START = "<entities>".getBytes(); + private final Element entitiesStartElement = new Element(ENTITIES_START); + +} +''', + expected: '''\ +public class RearrangeFail { + + public static final byte[] ENTITIES_END = "</entities>".getBytes(); + public static final byte[] ENTITIES_START = "<entities>".getBytes(); + private final Element entitiesEndElement = new Element(ENTITIES_END); + private final Element entitiesStartElement = new Element(ENTITIES_START); + +} +''', + rules: [ + rule(PUBLIC, STATIC, FINAL), + rule(PRIVATE), + ] + ) + } + void "test IDEA-125099"() { + doTest( + initial: '''\ +public class test { + private int a = 2; + public static final String TEST = "1"; + public static final String SHOULD_BE_IN_BETWEEN = "2"; + public static final String USERS_ROLE_ID_COLUMN = TEST; +} +''', + expected: '''\ +public class test { + public static final String TEST = "1"; + public static final String SHOULD_BE_IN_BETWEEN = "2"; + public static final String USERS_ROLE_ID_COLUMN = TEST; + private int a = 2; +} +''', + rules: [ + rule(PUBLIC, STATIC, FINAL), + rule(PRIVATE) + ] + ) + } } diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java index 8ea8d3a77112..2461a4601eba 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.impl.file.impl; @@ -640,4 +655,90 @@ public class PsiEventsTest extends PsiTestCase { getPsiManager().removePsiTreeChangeListener(listener); } } + + public void testPsiEventsComeWhenDocumentAlreadyCommitted() throws Exception { + myFile = createFile("A.java", "class A { int i; }"); + getPsiManager().addPsiTreeChangeListener(new PsiTreeChangeListener() { + @Override + public void beforeChildAddition(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void beforeChildRemoval(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void beforeChildReplacement(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void beforeChildMovement(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void beforeChildrenChange(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void beforePropertyChange(@NotNull PsiTreeChangeEvent event) { + // did not decide whether the doc should be committed at this point + //checkCommitted(false, event); + } + + @Override + public void childAdded(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + + @Override + public void childRemoved(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + + @Override + public void childReplaced(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + + @Override + public void childrenChanged(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + + @Override + public void childMoved(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + + @Override + public void propertyChanged(@NotNull PsiTreeChangeEvent event) { + checkCommitted(true, event); + } + }, myTestRootDisposable); + + PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject()); + Document document = documentManager.getDocument(getFile()); + assertTrue(documentManager.isCommitted(document)); + + document.setText(""); + documentManager.commitAllDocuments(); + assertTrue(documentManager.isCommitted(document)); + } + + private void checkCommitted(boolean shouldBeCommitted, PsiTreeChangeEvent event) { + PsiFile file = event.getFile(); + PsiDocumentManager documentManager = PsiDocumentManager.getInstance(file.getProject()); + Document document = documentManager.getDocument(file); + assertEquals(shouldBeCommitted, documentManager.isCommitted(document)); + } } diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy index 5e6adfdb4f55..ce04dd0ba20c 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy @@ -20,12 +20,12 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiManager import com.intellij.psi.PsiMethod +import com.intellij.psi.impl.source.PsiFileImpl import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.searches.ClassInheritorsSearch import com.intellij.psi.search.searches.OverridingMethodsSearch +import com.intellij.psi.stubs.StubTreeLoader import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase /** @@ -150,14 +150,12 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { Collection<VirtualFile> pkgDirs = pkg.directories.collect { it.virtualFile } Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten() - PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' }) - assert !javaSrc.contentsLoaded - assert !javaSrc.stub + VirtualFile javaSrc = pkgChildren.find { it.name == 'LibraryClass.java' } + checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc) assert pkg.containsClassNamed('LibraryClass') - assert !javaSrc.contentsLoaded - assert !javaSrc.stub - assert !javaSrc.node.parsed + checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc) + assert !((PsiFileImpl)psiManager.findFile(javaSrc)).treeElement } @Override @@ -174,7 +172,7 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { def localFile = myFixture.copyFileToProject(testDataPathForTest + File.separator + "Foo.java", 'Foo.java') assert localFile != null - checkFileIsNotLoadedAndHasNoStub(localFile) + checkFileIsNotLoadedAndHasNoIndexedStub(localFile) assert facade.findClasses('Foo', scope).size() == 0 PsiTestUtil.addLibrary(myModule, 'cas', lib.path, [] as String[], ["/classesAndSources.jar!/"] as String[]) @@ -187,14 +185,16 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { assert facade.findClasses('LibraryClass', scope).size() == 0 - checkFileIsNotLoadedAndHasNoStub(vfile) + checkFileIsNotLoadedAndHasNoIndexedStub(vfile) } - private void checkFileIsNotLoadedAndHasNoStub(VirtualFile vfile) { - def file = PsiManager.getInstance(project).findFile(vfile); + private void checkFileIsNotLoadedAndHasNoIndexedStub(VirtualFile vfile) { + PsiFileImpl file = psiManager.findFile(vfile); assert file != null assert !file.contentsLoaded - assert !file.stub + assert !StubTreeLoader.instance.readFromVFile(project, vfile) + assert !StubTreeLoader.instance.canHaveStub(vfile) + assert file.stub // from text } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java index 83e8fa10aed9..b34486fcf110 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java @@ -187,6 +187,18 @@ public class MoveMembersTest extends MultiFileTestCase { doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0); } + public void testFromNestedToOuterMethodRef() throws Exception { + final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject()); + final LanguageLevel oldLevel = projectExtension.getLanguageLevel(); + try { + projectExtension.setLanguageLevel(LanguageLevel.HIGHEST); + doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0); + } + finally { + projectExtension.setLanguageLevel(oldLevel); + } + } + @NotNull @Override protected String getTestRoot() { diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index c77b344f6722..99de5eb68dc4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -264,6 +264,10 @@ public class InlineMethodTest extends LightRefactoringTestCase { doTest(); } + public void testSameVarMethodNames() throws Exception { + doTest(); + } + private void doTestInlineThisOnly() { @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java"; configureByFile(fileName); diff --git a/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java b/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java index 180a8ee3c66a..514348e5913b 100644 --- a/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java @@ -1,12 +1,29 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.roots; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.StdModuleTypes; +import com.intellij.openapi.module.impl.ModuleEx; import com.intellij.openapi.module.impl.scopes.LibraryScope; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.ModuleTestCase; import com.intellij.testFramework.PsiTestUtil; import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl; @@ -207,4 +224,28 @@ public class ModuleScopesTest extends ModuleTestCase { addLibrary(myModule, DependencyScope.COMPILE); assertTrue(myModule.getModuleWithDependenciesAndLibrariesScope(false).contains(file)); } + + public void testScopeEquality() { + Module module = createModule("a.iml", StdModuleTypes.JAVA); + addDependentModule(module, DependencyScope.COMPILE); + addLibrary(module, DependencyScope.COMPILE); + + GlobalSearchScope deps = module.getModuleWithDependentsScope(); + GlobalSearchScope depsTests = module.getModuleTestsWithDependentsScope(); + + assertFalse(deps.equals(depsTests)); + assertFalse(depsTests.equals(deps)); + + ((ModuleEx)module).clearScopesCache(); + + GlobalSearchScope deps2 = module.getModuleWithDependentsScope(); + GlobalSearchScope depsTests2 = module.getModuleTestsWithDependentsScope(); + + assertFalse(deps2.equals(depsTests2)); + assertFalse(depsTests2.equals(deps2)); + assertNotSame(deps, deps2); + assertNotSame(depsTests, depsTests2); + assertEquals(deps, deps2); + assertEquals(depsTests, depsTests2); + } } diff --git a/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java b/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java index 513fcec9d347..2f6ea959a1a6 100644 --- a/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java +++ b/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,6 +179,8 @@ public class SliceBackwardTest extends SliceTestCase { public void testArrayElements() throws Exception { doTest();} public void testAnonArray() throws Exception { doTest();} public void testVarArgs() throws Exception { doTest();} + public void testVarArgsAsAWhole() throws Exception { doTest();} + public void testVarArgsPartial() throws Exception { doTest();} public void testListTrackToArray() throws Exception { doTest();} } diff --git a/java/jdkAnnotations/java/awt/annotations.xml b/java/jdkAnnotations/java/awt/annotations.xml index 9fbbebaabc5b..a1ea3a596052 100644 --- a/java/jdkAnnotations/java/awt/annotations.xml +++ b/java/jdkAnnotations/java/awt/annotations.xml @@ -71,6 +71,18 @@ <item name="java.awt.CardLayout void show(java.awt.Container, java.lang.String) 1"> <annotation name="org.jetbrains.annotations.NonNls" /> </item> + <item name='java.awt.Component java.awt.Point getLocation()'> + <annotation name='org.jetbrains.annotations.NotNull'/> + </item> + <item name='java.awt.Component java.awt.Point location()'> + <annotation name='org.jetbrains.annotations.NotNull'/> + </item> + <item name='java.awt.Component void setLocation(java.awt.Point) 0'> + <annotation name='org.jetbrains.annotations.NotNull'/> + </item> + <item name='java.awt.Container void add(java.awt.Component, java.lang.Object) 0'> + <annotation name='org.jetbrains.annotations.NotNull'/> + </item> <item name="java.awt.Container void addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) 0"> <annotation name="org.jetbrains.annotations.NonNls" /> </item> @@ -233,5 +245,8 @@ <val name="flagsFromClass" val="java.awt.event.InputEvent.class" /> </annotation> </item> + <item name='java.awt.Window void setLocation(java.awt.Point) 0'> + <annotation name='org.jetbrains.annotations.NotNull'/> + </item> </root> diff --git a/java/mockJDK-1.7/jre/lib/rt.jar b/java/mockJDK-1.7/jre/lib/rt.jar Binary files differindex 83d84402c386..09859acbfcf1 100644 --- a/java/mockJDK-1.7/jre/lib/rt.jar +++ b/java/mockJDK-1.7/jre/lib/rt.jar diff --git a/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy b/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy index 9a05e8d3633c..30b9bfb30c01 100644 --- a/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy +++ b/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy @@ -19,6 +19,8 @@ import com.intellij.codeInsight.lookup.LookupManager import com.intellij.codeInsight.lookup.impl.LookupImpl import com.intellij.testFramework.fixtures.CompletionAutoPopupTester import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.jetbrains.annotations.NotNull + /** * @author peter */ @@ -38,7 +40,7 @@ abstract class CompletionAutoPopupTestCase extends LightCodeInsightFixtureTestCa return false; } - @Override protected void invokeTestRunnable(Runnable runnable) { + @Override protected void invokeTestRunnable(@NotNull Runnable runnable) { myTester.runWithAutoPopupEnabled(runnable) } diff --git a/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java index 952cbc46fdcb..8ec8e3f6ebdd 100644 --- a/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java @@ -485,7 +485,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas return debuggerSession; } - private static class MockConfiguration implements ModuleRunConfiguration { + public static class MockConfiguration implements ModuleRunConfiguration { @Override @NotNull public Module[] getModules() { @@ -521,7 +521,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas @Override @NotNull public ConfigurationType getType() { - return null; //To change body of implemented methods use File | Settings | File Templates. + return UnknownConfigurationType.INSTANCE; } @Override diff --git a/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java index db072f4ce97a..49db796244dd 100644 --- a/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java @@ -27,14 +27,15 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTree; import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; import com.intellij.debugger.ui.impl.watch.LocalVariableDescriptorImpl; import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl; -import com.intellij.debugger.ui.tree.DebuggerTreeNode; import com.intellij.debugger.ui.tree.NodeDescriptor; import com.intellij.debugger.ui.tree.ValueDescriptor; import com.intellij.debugger.ui.tree.render.NodeRenderer; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.util.Pair; +import com.intellij.ui.treeStructure.Tree; import com.sun.jdi.Value; +import javax.swing.tree.TreeNode; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -160,46 +161,52 @@ public abstract class DescriptorTestCase extends DebuggerTestCase { } protected void expandAll(final DebuggerTree tree, final Runnable runnable) { - doExpandAll(tree, runnable, new HashSet<Value>(), null); + expandAll(tree, runnable, new HashSet<Value>(), null); } protected interface NodeFilter { - boolean shouldExpand(DebuggerTreeNode node); + boolean shouldExpand(TreeNode node); } - - protected void expandAll(final DebuggerTree tree, final Runnable runnable, NodeFilter filter) { - doExpandAll(tree, runnable, new HashSet<Value>(), filter); + + protected void expandAll(final DebuggerTree tree, final Runnable runnable, final Set<Value> alreadyExpanded, final NodeFilter filter) { + expandAll(tree, runnable, alreadyExpanded, filter, tree.getDebuggerContext().getSuspendContext()); } - private void doExpandAll(final DebuggerTree tree, final Runnable runnable, final Set<Value> alreadyExpanded, final NodeFilter filter) { - invokeRatherLater(tree.getDebuggerContext().getSuspendContext(), new Runnable() { + protected void expandAll(final Tree tree, + final Runnable runnable, + final Set<Value> alreadyExpanded, + final NodeFilter filter, + final SuspendContextImpl context) { + invokeRatherLater(context, new Runnable() { @Override public void run() { boolean anyCollapsed = false; for(int i = 0; i < tree.getRowCount(); i++) { - final DebuggerTreeNodeImpl treeNode = (DebuggerTreeNodeImpl)tree.getPathForRow(i).getLastPathComponent(); + final TreeNode treeNode = (TreeNode)tree.getPathForRow(i).getLastPathComponent(); if(tree.isCollapsed(i) && !treeNode.isLeaf()) { - final NodeDescriptor nodeDescriptor = treeNode.getDescriptor(); - boolean shouldExpand = filter == null || filter.shouldExpand(treeNode); - if (shouldExpand) { - // additional checks to prevent infinite expand - if (nodeDescriptor instanceof ValueDescriptor) { - final Value value = ((ValueDescriptor)nodeDescriptor).getValue(); - shouldExpand = !alreadyExpanded.contains(value); - if (shouldExpand) { - alreadyExpanded.add(value); + if (treeNode instanceof DebuggerTreeNodeImpl) { + final NodeDescriptor nodeDescriptor = ((DebuggerTreeNodeImpl)treeNode).getDescriptor(); + boolean shouldExpand = filter == null || filter.shouldExpand(treeNode); + if (shouldExpand) { + // additional checks to prevent infinite expand + if (nodeDescriptor instanceof ValueDescriptor) { + final Value value = ((ValueDescriptor)nodeDescriptor).getValue(); + shouldExpand = !alreadyExpanded.contains(value); + if (shouldExpand) { + alreadyExpanded.add(value); + } } } - } - if (shouldExpand) { - anyCollapsed = true; - tree.expandRow(i); + if (shouldExpand) { + anyCollapsed = true; + tree.expandRow(i); + } } } } if (anyCollapsed) { - doExpandAll(tree, runnable, alreadyExpanded, filter); + expandAll(tree, runnable, alreadyExpanded, filter, context); } else { runnable.run(); diff --git a/java/testFramework/src/com/intellij/ide/projectWizard/NewProjectWizardTestCase.java b/java/testFramework/src/com/intellij/ide/projectWizard/NewProjectWizardTestCase.java index 8ae8848fabf1..2125daa8af4d 100644 --- a/java/testFramework/src/com/intellij/ide/projectWizard/NewProjectWizardTestCase.java +++ b/java/testFramework/src/com/intellij/ide/projectWizard/NewProjectWizardTestCase.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.ide.projectWizard; import com.intellij.ide.util.newProjectWizard.AbstractProjectWizard; diff --git a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java index dd94962cddfd..25751535842a 100644 --- a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java +++ b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.ide.projectWizard; import com.intellij.ide.actions.ImportModuleAction; @@ -43,7 +58,6 @@ import java.util.List; */ @SuppressWarnings("unchecked") public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> extends PlatformTestCase { - protected static final String DEFAULT_SDK = "default"; protected final List<Sdk> mySdks = new ArrayList<Sdk>(); protected T myWizard; @@ -118,7 +132,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext throw new RuntimeException(currentStep + " is not validated"); } } - myWizard.doOk(); + myWizard.doFinishAction(); } protected void createWizard(Project project) throws IOException { @@ -147,6 +161,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext for (final Sdk jdk : jdks) { if (projectSdk != jdk) { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { ProjectJdkTable.getInstance().removeJdk(jdk); } @@ -157,6 +172,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext protected void setupJdk() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); Sdk defaultJdk = new SimpleJavaSdkType().createJdk(DEFAULT_SDK, SystemProperties.getJavaHome()); @@ -181,6 +197,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext public void tearDown() throws Exception { if (myWizard != null) { Disposer.dispose(myWizard.getDisposable()); + myWizard = null; } if (myCreatedProject != null) { myProjectManager.closeProject(myCreatedProject); @@ -190,8 +207,10 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext Disposer.dispose(myCreatedProject); } }); + myCreatedProject = null; } ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { for (Sdk sdk : mySdks) { ProjectJdkTable.getInstance().removeJdk(sdk); @@ -199,6 +218,9 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext } }); SelectTemplateSettings.getInstance().setLastTemplate(null, null); + UIUtil.dispatchAllInvocationEvents(); + Thread.sleep(2000); //wait for JBCardLayout release timers + UIUtil.dispatchAllInvocationEvents(); super.tearDown(); } @@ -233,6 +255,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext protected Sdk createSdk(String name, SdkTypeId sdkType) { final Sdk sdk = ProjectJdkTable.getInstance().createSdk(name, sdkType); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { ProjectJdkTable.getInstance().addJdk(sdk); } diff --git a/java/testFramework/src/com/intellij/testFramework/CompilerTester.java b/java/testFramework/src/com/intellij/testFramework/CompilerTester.java index 6af8389b8abe..00780b9b76ce 100644 --- a/java/testFramework/src/com/intellij/testFramework/CompilerTester.java +++ b/java/testFramework/src/com/intellij/testFramework/CompilerTester.java @@ -227,14 +227,11 @@ public class CompilerTester { @Override public void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { - System.out.println("ErrorReportingCallback.finished"); try { for (CompilerMessageCategory category : CompilerMessageCategory.values()) { - System.out.println("category = " + category); CompilerMessage[] messages = compileContext.getMessages(category); for (CompilerMessage message : messages) { final String text = message.getMessage(); - System.out.println("message = " + message); if (category != CompilerMessageCategory.INFORMATION || !(text.startsWith("Compilation completed successfully") || text.startsWith("Using javac"))) { myMessages.add(message); } diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java index 5d986128ee66..3699fe36aff5 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java @@ -36,6 +36,18 @@ import java.io.File; * @author peter */ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase{ + public static final LightProjectDescriptor JAVA_1_4 = new DefaultLightProjectDescriptor() { + @Override + public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) { + model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_1_6); + } + }; + public static final LightProjectDescriptor JAVA_1_5 = new DefaultLightProjectDescriptor() { + @Override + public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) { + model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_1_6); + } + }; public static final LightProjectDescriptor JAVA_1_6 = new DefaultLightProjectDescriptor() { @Override public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) { |