mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 210 KiB |
+2
-2
@@ -22,13 +22,13 @@ package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.ValueHint;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint;
|
||||
import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
|
||||
import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -53,6 +53,6 @@ public class QuickEvaluateActionHandler extends QuickEvaluateHandler {
|
||||
|
||||
@Override
|
||||
public int getValueLookupDelay(final Project project) {
|
||||
return DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY;
|
||||
return XDebuggerSettingsManager.getInstance().getDataViewSettings().getValueLookupDelay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.jdi.*;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.settings.ViewsGeneralSettings;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.impl.FrameVariablesTree;
|
||||
import com.intellij.debugger.ui.impl.watch.*;
|
||||
@@ -47,6 +46,7 @@ import com.intellij.xdebugger.frame.XCompositeNode;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.Event;
|
||||
import com.sun.jdi.event.ExceptionEvent;
|
||||
@@ -271,7 +271,7 @@ public class JavaStackFrame extends XStackFrame {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS && !myAutoWatchMode) {
|
||||
if (!XDebuggerSettingsManager.getInstance().getDataViewSettings().isAutoExpressions() && !myAutoWatchMode) {
|
||||
// optimization
|
||||
superBuildVariables(evaluationContext, children);
|
||||
}
|
||||
|
||||
@@ -232,15 +232,16 @@ class Bytecodes {
|
||||
static {
|
||||
int i;
|
||||
byte[] b = new byte[220];
|
||||
String s = "AAAAAAAAAAAAAAAABCLMMDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADD"
|
||||
+ "DDDEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
+ "AAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJDOPAA"
|
||||
+ "AAAAGGGGGGGHIFBFAAFFAARQJJKKJJJJJJJJJJJJJJJJJJ";
|
||||
for (i = 0; i < b.length; ++i) {
|
||||
b[i] = (byte) (s.charAt(i) - 'A');
|
||||
}
|
||||
TYPE = b;
|
||||
String s =
|
||||
"AAAAAAAAAAAAAAAABCLMMDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADDDDDEE" +
|
||||
"EEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
|
||||
"AAAAAAAAAANAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJDOPAAAAAAGGGGG" +
|
||||
"GGHIFBFAAFFAARQJJKKJLMMGGGGGGGGGGGGHGAFFQFFGGG";
|
||||
for (i = 0; i < b.length; ++i) {
|
||||
b[i] = (byte) (s.charAt(i) - 'A');
|
||||
}
|
||||
TYPE = b;
|
||||
}
|
||||
|
||||
|
||||
static final int NOP = 0; // visitInsn
|
||||
@@ -446,4 +447,139 @@ class Bytecodes {
|
||||
static final int GOTO_W = 200; // -
|
||||
static final int JSR_W = 201; // -
|
||||
|
||||
// JVM runtime-specific and reserved opcodes:
|
||||
// From JVM specification:
|
||||
// In addition to the opcodes of the instructions specified later in this chapter, which are used in class files (§4), three opcodes are reserved for internal use by a Java Virtual Machine implementation. If the instruction set of the Java Virtual Machine is extended in the future, these reserved opcodes are guaranteed not to be used.
|
||||
// Two of the reserved opcodes, numbers 254 (0xfe) and 255 (0xff), have the mnemonics impdep1 and impdep2, respectively. These instructions are intended to provide "back doors" or traps to implementation-specific functionality implemented in software and hardware, respectively. The third reserved opcode, number 202 (0xca), has the mnemonic breakpoint and is intended to be used by debuggers to implement breakpoints.
|
||||
// Although these opcodes have been reserved, they may be used only inside a Java Virtual Machine implementation. They cannot appear in valid class files. Tools such as debuggers or JIT code generators (§2.13) that might directly interact with Java Virtual Machine code that has been already loaded and executed may encounter these opcodes. Such tools should attempt to behave gracefully if they encounter any of these reserved instructions.
|
||||
|
||||
static final int BREAKPOINT = 202;
|
||||
static final int LDC_QUICK = 203;
|
||||
static final int LDC_W_QUICK = 204;
|
||||
static final int LDC2_W_QUICK = 205;
|
||||
static final int GETFIELD_QUICK = 206;
|
||||
static final int PUTFIELD_QUICK = 207;
|
||||
static final int GETFIELD2_QUICK = 208;
|
||||
static final int PUTFIELD2_QUICK = 209;
|
||||
static final int GETSTATIC_QUICK = 210;
|
||||
static final int PUTSTATIC_QUICK = 211;
|
||||
static final int GETSTATIC2_QUICK = 212;
|
||||
static final int PUTSTATIC2_QUICK = 213;
|
||||
static final int INVOKEVIRTUAL_QUICK = 214;
|
||||
static final int INVOKENONVIRTUAL_QUICK = 215;
|
||||
static final int INVOKESUPER_QUICK = 216;
|
||||
static final int INVOKESTATIC_QUICK = 217;
|
||||
static final int INVOKEINTERFACE_QUICK = 218;
|
||||
static final int INVOKEVIRTUALOBJECT_QUICK = 219;
|
||||
static final int NEW_QUICK = 221;
|
||||
static final int ANEWARRAY_QUICK = 222;
|
||||
static final int MULTIANEWARRAY_QUICK = 223;
|
||||
static final int CHECKCAST_QUICK = 224;
|
||||
static final int INSTANCEOF_QUICK = 225;
|
||||
static final int INVOKEVIRTUAL_QUICK_W = 226;
|
||||
static final int GETFIELD_QUICK_W = 227;
|
||||
static final int PUTFIELD_QUICK_W = 228;
|
||||
static final int IMPDEP1 = 254;
|
||||
static final int IMPDEP2 = 255;
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] b = new int[229];
|
||||
//code to generate the above string
|
||||
|
||||
// SBYTE_INSN instructions
|
||||
b[NEWARRAY] = SBYTE_INSN;
|
||||
b[BIPUSH] = SBYTE_INSN;
|
||||
|
||||
// SHORT_INSN instructions
|
||||
b[SIPUSH] = SHORT_INSN;
|
||||
|
||||
// (IMPL)VAR_INSN instructions
|
||||
b[RET] = VAR_INSN;
|
||||
for (int i = ILOAD; i <= ALOAD; ++i) {
|
||||
b[i] = VAR_INSN;
|
||||
}
|
||||
for (int i = ISTORE; i <= ASTORE; ++i) {
|
||||
b[i] = VAR_INSN;
|
||||
}
|
||||
for (int i = 26; i <= 45; ++i) { // ILOAD_0 to ALOAD_3
|
||||
b[i] = IMPLVAR_INSN;
|
||||
}
|
||||
for (int i = 59; i <= 78; ++i) { // ISTORE_0 to ASTORE_3
|
||||
b[i] = IMPLVAR_INSN;
|
||||
}
|
||||
|
||||
// TYPE_INSN instructions
|
||||
b[NEW] = TYPE_INSN;
|
||||
b[ANEWARRAY] = TYPE_INSN;
|
||||
b[CHECKCAST] = TYPE_INSN;
|
||||
b[INSTANCEOF] = TYPE_INSN;
|
||||
|
||||
// (Set)FIELDORMETH_INSN instructions
|
||||
for (int i = GETSTATIC; i <= INVOKESTATIC; ++i) {
|
||||
b[i] = FIELDORMETH_INSN;
|
||||
}
|
||||
b[INVOKEINTERFACE] = ITFMETH_INSN;
|
||||
b[INVOKEDYNAMIC] = INDYMETH_INSN;
|
||||
|
||||
// LABEL(W)_INSN instructions
|
||||
for (int i = IFEQ; i <= JSR; ++i) {
|
||||
b[i] = LABEL_INSN;
|
||||
}
|
||||
b[IFNULL] = LABEL_INSN;
|
||||
b[IFNONNULL] = LABEL_INSN;
|
||||
b[GOTO_W] = LABELW_INSN; // GOTO_W
|
||||
b[JSR_W] = LABELW_INSN; // JSR_W
|
||||
|
||||
b[BREAKPOINT] = LABEL_INSN; // todo: is this correct?
|
||||
|
||||
// LDC(_W) instructions
|
||||
b[LDC] = LDC_INSN;
|
||||
b[LDC_W] = LDCW_INSN; // LDC_W
|
||||
b[LDC2_W] = LDCW_INSN; // LDC2_W
|
||||
|
||||
// special instructions
|
||||
b[IINC] = IINC_INSN;
|
||||
b[TABLESWITCH] = TABL_INSN;
|
||||
b[LOOKUPSWITCH] = LOOK_INSN;
|
||||
b[MULTIANEWARRAY] = MANA_INSN;
|
||||
b[WIDE] = WIDE_INSN; // WIDE
|
||||
|
||||
// runtime-specific
|
||||
|
||||
b[LDC_QUICK] = LDC_INSN; // = 203;
|
||||
b[LDC_W_QUICK] = LDCW_INSN; // = 204;
|
||||
b[LDC2_W_QUICK] = LDCW_INSN; // = 205;
|
||||
b[GETFIELD_QUICK] = FIELDORMETH_INSN; // = 206;
|
||||
b[PUTFIELD_QUICK] = FIELDORMETH_INSN; // = 207;
|
||||
|
||||
b[GETFIELD2_QUICK] = FIELDORMETH_INSN; // = 208;
|
||||
b[PUTFIELD2_QUICK] = FIELDORMETH_INSN; // = 209;
|
||||
b[GETSTATIC_QUICK] = FIELDORMETH_INSN; // = 210;
|
||||
b[PUTSTATIC_QUICK] = FIELDORMETH_INSN; // = 211;
|
||||
b[GETSTATIC2_QUICK] = FIELDORMETH_INSN; // = 212;
|
||||
b[PUTSTATIC2_QUICK] = FIELDORMETH_INSN; // = 213;
|
||||
b[INVOKEVIRTUAL_QUICK] = FIELDORMETH_INSN; // = 214;
|
||||
b[INVOKENONVIRTUAL_QUICK] = FIELDORMETH_INSN; // = 215;
|
||||
b[INVOKESUPER_QUICK] = FIELDORMETH_INSN; // = 216;
|
||||
b[INVOKESTATIC_QUICK] = FIELDORMETH_INSN; // = 217;
|
||||
b[INVOKEINTERFACE_QUICK] = ITFMETH_INSN; // = 218;
|
||||
b[INVOKEVIRTUALOBJECT_QUICK] = FIELDORMETH_INSN; // = 219;
|
||||
b[220] = Bytecodes.NOARG_INSN; // the ID is not used for any opcode
|
||||
b[NEW_QUICK] = TYPE_INSN; // = 221;
|
||||
b[ANEWARRAY_QUICK] = TYPE_INSN; // = 222;
|
||||
b[MULTIANEWARRAY_QUICK] = MANA_INSN; // = 223;
|
||||
b[CHECKCAST_QUICK] = TYPE_INSN; // = 224;
|
||||
b[INSTANCEOF_QUICK] = TYPE_INSN; // = 225;
|
||||
b[INVOKEVIRTUAL_QUICK_W] = FIELDORMETH_INSN; // = 226;
|
||||
b[GETFIELD_QUICK_W] = FIELDORMETH_INSN; // = 227;
|
||||
b[PUTFIELD_QUICK_W] = FIELDORMETH_INSN; // = 228;
|
||||
|
||||
|
||||
for (int i = 0; i < b.length; ++i) {
|
||||
System.err.print((char)('A' + b[i]));
|
||||
}
|
||||
System.err.println();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public class InstructionParser {
|
||||
break;
|
||||
}
|
||||
int opcode = myCode[v] & 0xFF;
|
||||
switch (Bytecodes.TYPE[opcode]) {
|
||||
final byte opcodeType = opcode == Bytecodes.IMPDEP1 || opcode == Bytecodes.IMPDEP2? Bytecodes.NOARG_INSN : Bytecodes.TYPE[opcode];
|
||||
switch (opcodeType) {
|
||||
case Bytecodes.NOARG_INSN:
|
||||
v += 1;
|
||||
break;
|
||||
|
||||
+20
-41
@@ -20,6 +20,7 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.ClassRenderer;
|
||||
import com.intellij.debugger.ui.tree.render.ToStringRenderer;
|
||||
import com.intellij.openapi.options.OptionsBundle;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -45,7 +46,6 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
private JCheckBox myCbAutoscroll;
|
||||
private JCheckBox myCbShowSyntheticFields;
|
||||
private StateRestoringCheckBox myCbShowValFieldsAsLocalVariables;
|
||||
private JCheckBox myCbSort;
|
||||
private JCheckBox myCbHideNullArrayElements;
|
||||
private JCheckBox myCbShowStatic;
|
||||
private JCheckBox myCbShowDeclaredType;
|
||||
@@ -54,15 +54,13 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
private StateRestoringCheckBox myCbShowStaticFinalFields;
|
||||
private final ArrayRendererConfigurable myArrayRendererConfigurable;
|
||||
private JCheckBox myCbEnableAutoExpressions;
|
||||
private JCheckBox myCbEnableAlternateViews;
|
||||
|
||||
private JCheckBox myCbEnableToString;
|
||||
private JRadioButton myRbAllThatOverride;
|
||||
private JRadioButton myRbFromList;
|
||||
private ClassFilterEditor myToStringFilterEditor;
|
||||
private JTextField myValueTooltipDelayField;
|
||||
|
||||
|
||||
private Project myProject;
|
||||
private RegistryCheckBox myAutoTooltip;
|
||||
|
||||
@@ -71,16 +69,19 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myArrayRendererConfigurable.disposeUIResources();
|
||||
myToStringFilterEditor = null;
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return DebuggerBundle.message("base.renderer.configurable.display.name");
|
||||
return OptionsBundle.message("options.java.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
if (myProject == null) {
|
||||
myProject = JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables();
|
||||
@@ -90,13 +91,12 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myCbAutoscroll = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.autoscroll"));
|
||||
myCbShowSyntheticFields = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.synthetic.fields"));
|
||||
myCbShowValFieldsAsLocalVariables = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.val.fields.as.locals"));
|
||||
myCbSort = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.sort.alphabetically"));
|
||||
myCbHideNullArrayElements = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.hide.null.array.elements"));
|
||||
myCbShowStatic = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.fields"));
|
||||
myCbShowStaticFinalFields = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.final.fields"));
|
||||
myCbEnableAlternateViews = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.alternate.view"));
|
||||
myCbEnableAutoExpressions = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.auto.expressions"));
|
||||
myCbShowStatic.addChangeListener(new ChangeListener(){
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if(myCbShowStatic.isSelected()) {
|
||||
myCbShowStaticFinalFields.makeSelectable();
|
||||
@@ -121,14 +121,15 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myCbShowFQNames = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.fq.names"));
|
||||
myCbShowObjectId = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.object.id"));
|
||||
|
||||
myCbEnableToString = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.enable.tostring"));
|
||||
myRbAllThatOverride = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.all.overridding"));
|
||||
myCbEnableToString = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.enable.toString"));
|
||||
myRbAllThatOverride = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.all.overriding"));
|
||||
myRbFromList = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.classes.from.list"));
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(myRbAllThatOverride);
|
||||
group.add(myRbFromList);
|
||||
myToStringFilterEditor = new ClassFilterEditor(myProject, null, "reference.viewBreakpoints.classFilters.newPattern");
|
||||
myCbEnableToString.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
final boolean enabled = myCbEnableToString.isSelected();
|
||||
myRbAllThatOverride.setEnabled(enabled);
|
||||
@@ -137,12 +138,12 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
}
|
||||
});
|
||||
myRbFromList.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
myToStringFilterEditor.setEnabled(myCbEnableToString.isSelected() && myRbFromList.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
panel.add(myCbSort, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
panel.add(myCbAutoscroll, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
|
||||
|
||||
@@ -151,14 +152,6 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
DebuggerBundle.message("label.base.renderer.configurable.autoTooltip.description",
|
||||
Registry.stringValue("ide.forcedShowTooltip")));
|
||||
panel.add(myAutoTooltip, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
|
||||
final JLabel tooltipLabel = new JLabel(DebuggerBundle.message("label.debugger.general.configurable.tooltips.delay"));
|
||||
panel.add(tooltipLabel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
myValueTooltipDelayField = new JTextField(10);
|
||||
myValueTooltipDelayField.setMinimumSize(new Dimension(50, myValueTooltipDelayField.getPreferredSize().height));
|
||||
panel.add(myValueTooltipDelayField, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
tooltipLabel.setLabelFor(myValueTooltipDelayField);
|
||||
|
||||
final JPanel showPanel = new JPanel(new GridBagLayout());
|
||||
showPanel.setBorder(IdeBorderFactory.createTitledBorder("Show", true));
|
||||
|
||||
@@ -174,12 +167,12 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
|
||||
final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
|
||||
assert arraysComponent != null;
|
||||
arraysPanel.add(arraysComponent, BorderLayout.CENTER);
|
||||
arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
|
||||
arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
|
||||
panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
panel.add(myCbEnableAutoExpressions, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
|
||||
panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 10), 0, 0));
|
||||
// starting 4-th row
|
||||
panel.add(myCbEnableToString, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
@@ -191,22 +184,16 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
final ViewsGeneralSettings generalSettings = ViewsGeneralSettings.getInstance();
|
||||
final NodeRendererSettings rendererSettings = NodeRendererSettings.getInstance();
|
||||
|
||||
try {
|
||||
DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY = Integer.parseInt(myValueTooltipDelayField.getText().trim());
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
generalSettings.AUTOSCROLL_TO_NEW_LOCALS = myCbAutoscroll.isSelected();
|
||||
rendererSettings.setAlternateCollectionViewsEnabled(myCbEnableAlternateViews.isSelected());
|
||||
generalSettings.HIDE_NULL_ARRAY_ELEMENTS = myCbHideNullArrayElements.isSelected();
|
||||
generalSettings.ENABLE_AUTO_EXPRESSIONS = myCbEnableAutoExpressions.isSelected();
|
||||
|
||||
final ClassRenderer classRenderer = rendererSettings.getClassRenderer();
|
||||
classRenderer.SORT_ASCENDING = myCbSort.isSelected();
|
||||
classRenderer.SHOW_STATIC = myCbShowStatic.isSelected();
|
||||
classRenderer.SHOW_STATIC_FINAL = myCbShowStaticFinalFields.isSelectedWhenSelectable();
|
||||
classRenderer.SHOW_SYNTHETICS = myCbShowSyntheticFields.isSelected();
|
||||
@@ -227,15 +214,14 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
rendererSettings.fireRenderersChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
final ViewsGeneralSettings generalSettings = ViewsGeneralSettings.getInstance();
|
||||
final NodeRendererSettings rendererSettings = NodeRendererSettings.getInstance();
|
||||
|
||||
myValueTooltipDelayField.setText(Integer.toString(DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY));
|
||||
myCbAutoscroll.setSelected(generalSettings.AUTOSCROLL_TO_NEW_LOCALS);
|
||||
myCbHideNullArrayElements.setSelected(generalSettings.HIDE_NULL_ARRAY_ELEMENTS);
|
||||
myCbEnableAlternateViews.setSelected(rendererSettings.areAlternateCollectionViewsEnabled());
|
||||
myCbEnableAutoExpressions.setSelected(generalSettings.ENABLE_AUTO_EXPRESSIONS);
|
||||
|
||||
ClassRenderer classRenderer = rendererSettings.getClassRenderer();
|
||||
|
||||
@@ -244,7 +230,6 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
if (!classRenderer.SHOW_SYNTHETICS) {
|
||||
myCbShowValFieldsAsLocalVariables.makeUnselectable(false);
|
||||
}
|
||||
myCbSort.setSelected(classRenderer.SORT_ASCENDING);
|
||||
myCbShowStatic.setSelected(classRenderer.SHOW_STATIC);
|
||||
myCbShowStaticFinalFields.setSelected(classRenderer.SHOW_STATIC_FINAL);
|
||||
if(!classRenderer.SHOW_STATIC) {
|
||||
@@ -268,24 +253,15 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myArrayRendererConfigurable.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return areGeneralSettingsModified() || areDefaultRenderersModified() || areDebuggerSettingsModified();
|
||||
}
|
||||
|
||||
private boolean areDebuggerSettingsModified() {
|
||||
try {
|
||||
return DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY != Integer.parseInt(myValueTooltipDelayField.getText().trim());
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
return false;
|
||||
return areGeneralSettingsModified() || areDefaultRenderersModified();
|
||||
}
|
||||
|
||||
private boolean areGeneralSettingsModified() {
|
||||
ViewsGeneralSettings generalSettings = ViewsGeneralSettings.getInstance();
|
||||
return
|
||||
(generalSettings.AUTOSCROLL_TO_NEW_LOCALS != myCbAutoscroll.isSelected()) ||
|
||||
(generalSettings.ENABLE_AUTO_EXPRESSIONS != myCbEnableAutoExpressions.isSelected()) ||
|
||||
(generalSettings.HIDE_NULL_ARRAY_ELEMENTS != myCbHideNullArrayElements.isSelected()) || myAutoTooltip.isChanged();
|
||||
}
|
||||
|
||||
@@ -297,7 +273,6 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
final ClassRenderer classRenderer = rendererSettings.getClassRenderer();
|
||||
final boolean isClassRendererModified=
|
||||
(classRenderer.SORT_ASCENDING != myCbSort.isSelected()) ||
|
||||
(classRenderer.SHOW_STATIC != myCbShowStatic.isSelected()) ||
|
||||
(classRenderer.SHOW_STATIC_FINAL != myCbShowStaticFinalFields.isSelectedWhenSelectable()) ||
|
||||
(classRenderer.SHOW_SYNTHETICS != myCbShowSyntheticFields.isSelected()) ||
|
||||
@@ -325,16 +300,20 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@Override
|
||||
@NotNull
|
||||
public String getHelpTopic() {
|
||||
return "reference.idesettings.debugger.dataviews";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getId() {
|
||||
return getHelpTopic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable enableSearch(String option) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent<Ele
|
||||
@NonNls public static final String RUN_HOTSWAP_ASK = "RunHotswapAsk";
|
||||
|
||||
public boolean TRACING_FILTERS_ENABLED;
|
||||
public int VALUE_LOOKUP_DELAY; // ms
|
||||
public int DEBUGGER_TRANSPORT;
|
||||
public boolean FORCE_CLASSIC_VM;
|
||||
public boolean DISABLE_JIT;
|
||||
@@ -144,7 +143,6 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent<Ele
|
||||
|
||||
return
|
||||
TRACING_FILTERS_ENABLED == secondSettings.TRACING_FILTERS_ENABLED &&
|
||||
VALUE_LOOKUP_DELAY == secondSettings.VALUE_LOOKUP_DELAY &&
|
||||
DEBUGGER_TRANSPORT == secondSettings.DEBUGGER_TRANSPORT &&
|
||||
FORCE_CLASSIC_VM == secondSettings.FORCE_CLASSIC_VM &&
|
||||
DISABLE_JIT == secondSettings.DISABLE_JIT &&
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.intellij.debugger.settings;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.OptionsBundle;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
@@ -75,7 +76,7 @@ public class DebuggerSteppingConfigurable implements SearchableConfigurable, Con
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return DebuggerBundle.message("debugger.stepping.configurable.display.name");
|
||||
return OptionsBundle.message("options.java.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -32,7 +32,6 @@ public class ViewsGeneralSettings implements PersistentStateComponent<Element> {
|
||||
public boolean SHOW_OBJECTID = true;
|
||||
public boolean HIDE_NULL_ARRAY_ELEMENTS = true;
|
||||
public boolean AUTOSCROLL_TO_NEW_LOCALS = true;
|
||||
public boolean ENABLE_AUTO_EXPRESSIONS = true;
|
||||
|
||||
public ViewsGeneralSettings() {
|
||||
}
|
||||
@@ -41,22 +40,22 @@ public class ViewsGeneralSettings implements PersistentStateComponent<Element> {
|
||||
return ServiceManager.getService(ViewsGeneralSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element element) {
|
||||
try {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
// ignore
|
||||
catch (InvalidDataException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element element = new Element("ViewsGeneralSettings");
|
||||
try {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
// ignore
|
||||
catch (WriteExternalException ignored) {
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,14 @@ import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
|
||||
import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
|
||||
import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -333,7 +335,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
//}
|
||||
}
|
||||
|
||||
public static class JavaDebuggerSettingsPanelProvider extends DebuggerSettingsPanelProvider {
|
||||
final static class JavaDebuggerSettingsPanelProvider extends DebuggerSettingsPanelProvider {
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 1;
|
||||
@@ -344,11 +346,10 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
return new DebuggerLaunchingConfigurable();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends Configurable> getConfigurables() {
|
||||
final ArrayList<Configurable> configurables = new ArrayList<Configurable>();
|
||||
configurables.add(new DebuggerDataViewsConfigurable(null));
|
||||
configurables.add(new DebuggerSteppingConfigurable());
|
||||
configurables.add(new UserRenderersConfigurable(null));
|
||||
configurables.add(new DebuggerHotswapConfigurable());
|
||||
return configurables;
|
||||
@@ -358,6 +359,25 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
public void apply() {
|
||||
NodeRendererSettings.getInstance().fireRenderersChanged();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends Configurable> getConfigurable(@NotNull XDebuggerSettings.Category category) {
|
||||
switch (category) {
|
||||
case DATA_VIEWS:
|
||||
return Collections.singletonList(new DebuggerDataViewsConfigurable(null));
|
||||
case STEPPING:
|
||||
return Collections.singletonList(new DebuggerSteppingConfigurable());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applied(@NotNull XDebuggerSettings.Category category) {
|
||||
if (category == XDebuggerSettings.Category.DATA_VIEWS) {
|
||||
NodeRendererSettings.getInstance().fireRenderersChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Project getContextProjectForEditorFieldsInDebuggerConfigurables() {
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.ui.tree.TreeModelAdapter;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import com.sun.jdi.*;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import gnu.trove.TObjectProcedure;
|
||||
@@ -157,7 +158,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS && !myAutoWatchMode) {
|
||||
if (!XDebuggerSettingsManager.getInstance().getDataViewSettings().isAutoExpressions() && !myAutoWatchMode) {
|
||||
// optimization
|
||||
super.buildVariables(stackDescriptor, evaluationContext);
|
||||
}
|
||||
@@ -569,7 +570,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
myVars = vars;
|
||||
myPosition = position;
|
||||
myEvalContext = evalContext;
|
||||
myCollectExpressions = ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS;
|
||||
myCollectExpressions = XDebuggerSettingsManager.getInstance().getDataViewSettings().isAutoExpressions();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.impl;
|
||||
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.ide.FrameStateListener;
|
||||
import com.intellij.ide.FrameStateManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -32,6 +31,7 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
@@ -117,14 +117,17 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
|
||||
myPopupShown = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
|
||||
onPopupClosed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuCanceled(final PopupMenuEvent e) {
|
||||
onPopupClosed(e);
|
||||
}
|
||||
@@ -174,12 +177,13 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
myShowAlarm.cancelAllRequests();
|
||||
myHideAlarm.cancelAllRequests();
|
||||
myShowAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myIsDisposed && !myPopupShown) {
|
||||
showTooltip(e, auto);
|
||||
}
|
||||
}
|
||||
}, auto ? DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY : 10);
|
||||
}, auto ? XDebuggerSettingsManager.getInstance().getDataViewSettings().getValueLookupDelay() : 10);
|
||||
}
|
||||
|
||||
private void showTooltip(InputEvent e, boolean auto) {
|
||||
@@ -245,6 +249,7 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
myCurrentTooltip = null;
|
||||
} else {
|
||||
myHideAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myInsideComponent) {
|
||||
hideTooltip(true);
|
||||
@@ -273,10 +278,12 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
myComponent = component;
|
||||
|
||||
new UiNotifyConnector.Once(component, new Activatable() {
|
||||
@Override
|
||||
public void showNotify() {
|
||||
installListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideNotify() {
|
||||
}
|
||||
});
|
||||
@@ -284,6 +291,7 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
final HideTooltipAction hide = new HideTooltipAction();
|
||||
hide.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), myComponent);
|
||||
Disposer.register(this, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
hide.unregisterCustomShortcutSet(myComponent);
|
||||
}
|
||||
@@ -292,6 +300,7 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
|
||||
|
||||
private class HideTooltipAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
hideTooltip(true);
|
||||
}
|
||||
@@ -316,6 +325,7 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
FrameStateManager.getInstance().addListener(myFrameStateListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
Disposer.dispose(this);
|
||||
|
||||
@@ -333,6 +343,7 @@ public class TipManager implements Disposable, PopupMenuListener {
|
||||
|
||||
private class MyAwtPreprocessor implements AWTEventListener {
|
||||
|
||||
@Override
|
||||
public void eventDispatched(AWTEvent event) {
|
||||
if (event.getID() == MouseEvent.MOUSE_MOVED) {
|
||||
preventFromHideIfInsideTooltip(event);
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SpeedSearchComparator;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.Event;
|
||||
import com.sun.jdi.event.ExceptionEvent;
|
||||
@@ -485,7 +486,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
|
||||
|
||||
try {
|
||||
buildVariables(stackDescriptor, evaluationContext);
|
||||
if (classRenderer.SORT_ASCENDING) {
|
||||
if (XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
|
||||
Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.psi.PsiElementFactory;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import com.sun.jdi.*;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -58,7 +59,6 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
|
||||
public static final @NonNls String UNIQUE_ID = "ClassRenderer";
|
||||
|
||||
public boolean SORT_ASCENDING = false;
|
||||
public boolean SHOW_SYNTHETICS = true;
|
||||
public boolean SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES = true;
|
||||
public boolean SHOW_STATIC = false;
|
||||
@@ -83,22 +83,27 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return UNIQUE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myProperties.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
myProperties.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassRenderer clone() {
|
||||
return (ClassRenderer) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) throws EvaluateException {
|
||||
return calcLabel(descriptor);
|
||||
}
|
||||
@@ -151,6 +156,7 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
final ValueDescriptorImpl parentDescriptor = (ValueDescriptorImpl)builder.getParentDescriptor();
|
||||
@@ -171,7 +177,7 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
children.add(nodeManager.createNode(nodeDescriptorFactory.getFieldDescriptor(parentDescriptor, objRef, field), evaluationContext));
|
||||
}
|
||||
|
||||
if(SORT_ASCENDING) {
|
||||
if (XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
|
||||
Collections.sort(children, NodeManagerImpl.getNodeComparator());
|
||||
}
|
||||
}
|
||||
@@ -211,16 +217,19 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
super.readExternal(element);
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpression getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) throws EvaluateException {
|
||||
FieldDescriptor fieldDescriptor = (FieldDescriptor)node.getDescriptor();
|
||||
|
||||
@@ -251,19 +260,23 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpandable(Value value, EvaluationContext evaluationContext, NodeDescriptor parentDescriptor) {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
return valueExpandable(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Type type) {
|
||||
return type instanceof ReferenceType && !(type instanceof ArrayType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNls String getName() {
|
||||
return "Object";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String text) {
|
||||
LOG.assertTrue(false);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ 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.JBColor;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class ShowStructureSettingsAction extends AnAction implements DumbAware {
|
||||
protected JComponent createSouthPanel() {
|
||||
JComponent panel = super.createSouthPanel();
|
||||
assert panel != null;
|
||||
CustomLineBorder line = new CustomLineBorder(Gray._153, 1, 0, 0, 0);
|
||||
CustomLineBorder line = new CustomLineBorder(new JBColor(Gray._153, Gray._80), 1, 0, 0, 0);
|
||||
panel.setBorder(new CompoundBorder(line, new EmptyBorder(10, 5, 5, 5)));
|
||||
return panel;
|
||||
}
|
||||
|
||||
+10
-1
@@ -45,9 +45,11 @@ public class ErrorPaneConfigurable extends JPanel implements Configurable, Dispo
|
||||
private final Alarm myAlarm;
|
||||
private final ArrayList<ConfigurationError> myErrors = new ArrayList<ConfigurationError>();
|
||||
private final JTextPane myContent = new JTextPane();
|
||||
private Runnable myOnErrorsChanged;
|
||||
|
||||
public ErrorPaneConfigurable(final Project project, StructureConfigurableContext context) {
|
||||
public ErrorPaneConfigurable(final Project project, StructureConfigurableContext context, Runnable onErrorsChanged) {
|
||||
super(new BorderLayout());
|
||||
myOnErrorsChanged = onErrorsChanged;
|
||||
myContent.setEditorKit(UIUtil.getHTMLEditorKit());
|
||||
myContent.setEditable(false);
|
||||
myContent.setBackground(UIUtil.getListBackground());
|
||||
@@ -148,6 +150,9 @@ public class ErrorPaneConfigurable extends JPanel implements Configurable, Dispo
|
||||
}
|
||||
html += "</ol></body></html>";
|
||||
myContent.setText(html);
|
||||
if (myOnErrorsChanged != null) {
|
||||
myOnErrorsChanged.run();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
@@ -205,4 +210,8 @@ public class ErrorPaneConfigurable extends JPanel implements Configurable, Dispo
|
||||
myErrors.remove(error);
|
||||
refresh();
|
||||
}
|
||||
|
||||
public int getErrorsCount() {
|
||||
return myErrors.size();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -302,7 +302,12 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
|
||||
private void addErrorPane() {
|
||||
addConfigurable(new ErrorPaneConfigurable(myProject, myContext), true);
|
||||
addConfigurable(new ErrorPaneConfigurable(myProject, myContext, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mySidePanel.getList().repaint();
|
||||
}
|
||||
}), true);
|
||||
}
|
||||
|
||||
private void addGlobalLibrariesConfig() {
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.openapi.ui.popup.ListItemDescriptor;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.navigation.History;
|
||||
import com.intellij.ui.navigation.Place;
|
||||
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
|
||||
@@ -29,6 +32,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
@@ -94,6 +98,8 @@ public class SidePanel extends JPanel {
|
||||
};
|
||||
|
||||
myList.setCellRenderer(new GroupedItemsListRenderer(descriptor) {
|
||||
JPanel myExtraPanel;
|
||||
CountLabel myCountLabel;
|
||||
{
|
||||
mySeparatorComponent.setCaptionCentered(false);
|
||||
}
|
||||
@@ -136,8 +142,38 @@ public class SidePanel extends JPanel {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
if (Registry.is("ide.new.project.settings")) {
|
||||
myRendererComponent.add(mySeparatorComponent, BorderLayout.NORTH);
|
||||
myExtraPanel.add(myComponent, BorderLayout.CENTER);
|
||||
myExtraPanel.add(myCountLabel, BorderLayout.EAST);
|
||||
myRendererComponent.add(myExtraPanel, BorderLayout.CENTER);
|
||||
} else {
|
||||
super.layout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
myCountLabel.setText("");
|
||||
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if ("Problems".equals(descriptor.getTextFor(value))) {
|
||||
final ErrorPaneConfigurable errorPane = (ErrorPaneConfigurable)((Place)value).getPath("category");
|
||||
if (errorPane != null && errorPane.getErrorsCount() > 0) {
|
||||
myCountLabel.setSelected(isSelected);
|
||||
myCountLabel.setText(String.valueOf(errorPane.getErrorsCount()));
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createItemComponent() {
|
||||
myExtraPanel = new NonOpaquePanel(new BorderLayout());
|
||||
myCountLabel = new CountLabel();
|
||||
|
||||
|
||||
if (Registry.is("ide.new.project.settings")) {
|
||||
myTextLabel = new EngravedLabel();
|
||||
myTextLabel.setFont(myTextLabel.getFont().deriveFont(Font.BOLD));
|
||||
@@ -169,6 +205,10 @@ public class SidePanel extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public JList getList() {
|
||||
return myList;
|
||||
}
|
||||
|
||||
public void addPlace(Place place, @NotNull Presentation presentation) {
|
||||
myModel.addElement(place);
|
||||
myPlaces.add(place);
|
||||
@@ -188,4 +228,51 @@ public class SidePanel extends JPanel {
|
||||
public void select(final Place place) {
|
||||
myList.setSelectedValue(place, true);
|
||||
}
|
||||
|
||||
private static class CountLabel extends JLabel {
|
||||
private boolean mySelected;
|
||||
|
||||
public CountLabel() {
|
||||
super();
|
||||
setBorder(new Border() {
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return StringUtil.isEmpty(getText()) ? new Insets(0,0,0,0) : new Insets(2, 6, 2, 6 + 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setFont(UIUtil.getListFont().deriveFont(Font.BOLD));
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return mySelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
mySelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
g.setColor(isSelected() ? UIUtil.getListSelectionBackground() : UIUtil.getSidePanelColor());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
if (StringUtil.isEmpty(getText())) return;
|
||||
final JBColor deepBlue = new JBColor(new Color(0x97A4B2), new Color(92, 98, 113));
|
||||
g.setColor(isSelected() ? Gray._255.withAlpha(UIUtil.isUnderDarcula() ? 100 : 220) : deepBlue);
|
||||
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
|
||||
g.fillRoundRect(0, 3, getWidth() - 6 -1, getHeight()-6 , (getHeight() - 6), (getHeight() - 6));
|
||||
config.restore();
|
||||
setForeground(isSelected() ? deepBlue.darker() : UIUtil.getListForeground(true));
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<orderEntry type="module" module-name="resources-en" />
|
||||
<orderEntry type="module" module-name="xml-psi-impl" />
|
||||
<orderEntry type="library" exported="" name="asm5" level="project" />
|
||||
<orderEntry type="module" module-name="platform-api" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -91,6 +92,7 @@ public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement
|
||||
String text = "(" + type.getCanonicalText(false) + ")value";
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(original.getProject()).getElementFactory();
|
||||
PsiTypeCastExpression typeCast = (PsiTypeCastExpression)factory.createExpressionFromText(text, original);
|
||||
typeCast = (PsiTypeCastExpression)JavaCodeStyleManager.getInstance(project).shortenClassReferences(typeCast);
|
||||
typeCast = (PsiTypeCastExpression)CodeStyleManager.getInstance(project).reformat(typeCast);
|
||||
|
||||
if (expression instanceof PsiConditionalExpression) {
|
||||
|
||||
+18
-17
@@ -32,10 +32,7 @@ import com.intellij.psi.controlFlow.ControlFlow;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
@@ -91,16 +88,12 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
final PsiMethod[] methods = aClass.getMethods();
|
||||
if (methods.length == 1 && aClass.getFields().length == 0) {
|
||||
final PsiCodeBlock body = methods[0].getBody();
|
||||
if (body != null) {
|
||||
final ForbiddenRefsChecker checker = new ForbiddenRefsChecker(methods[0], aClass);
|
||||
body.accept(checker);
|
||||
if (!checker.hasForbiddenRefs()) {
|
||||
final PsiElement lBrace = aClass.getLBrace();
|
||||
LOG.assertTrue(lBrace != null);
|
||||
final TextRange rangeInElement = new TextRange(0, aClass.getStartOffsetInParent() + lBrace.getStartOffsetInParent());
|
||||
holder.registerProblem(aClass.getParent(), "Anonymous #ref #loc can be replaced with lambda",
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, rangeInElement, new ReplaceWithLambdaFix());
|
||||
}
|
||||
if (body != null && !hasForbiddenRefsInsideBody(methods[0], aClass)) {
|
||||
final PsiElement lBrace = aClass.getLBrace();
|
||||
LOG.assertTrue(lBrace != null);
|
||||
final TextRange rangeInElement = new TextRange(0, aClass.getStartOffsetInParent() + lBrace.getStartOffsetInParent());
|
||||
holder.registerProblem(aClass.getParent(), "Anonymous #ref #loc can be replaced with lambda",
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, rangeInElement, new ReplaceWithLambdaFix());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +103,14 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean hasForbiddenRefsInsideBody(PsiMethod method, PsiAnonymousClass aClass) {
|
||||
final ForbiddenRefsChecker checker = new ForbiddenRefsChecker(method, aClass);
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
LOG.assertTrue(body != null);
|
||||
body.accept(checker);
|
||||
return checker.hasForbiddenRefs();
|
||||
}
|
||||
|
||||
private static PsiType getInferredType(PsiAnonymousClass aClass) {
|
||||
final PsiExpression expression = (PsiExpression)aClass.getParent();
|
||||
final PsiType psiType = PsiTypesUtil.getExpectedTypeByParent(expression);
|
||||
@@ -369,14 +370,14 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
private final PsiMethod myMethod;
|
||||
private final PsiAnonymousClass myAnonymClass;
|
||||
|
||||
private final boolean myRawType;
|
||||
private final boolean myEqualInference;
|
||||
|
||||
public ForbiddenRefsChecker(PsiMethod method,
|
||||
PsiAnonymousClass aClass) {
|
||||
myMethod = method;
|
||||
myAnonymClass = aClass;
|
||||
final PsiType inferredType = getInferredType(aClass);
|
||||
myRawType = inferredType instanceof PsiClassType && ((PsiClassType)inferredType).isRaw();
|
||||
myEqualInference = !aClass.getBaseClassType().equals(inferredType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -467,7 +468,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
}
|
||||
}
|
||||
|
||||
if (myRawType) {
|
||||
if (myEqualInference) {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiParameter && ((PsiParameter)resolved).getDeclarationScope() == myMethod) {
|
||||
final int parameterIndex = myMethod.getParameterList().getParameterIndex((PsiParameter)resolved);
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class AnonymousCanBeMethodReferenceInspection extends BaseJavaBatchLocalI
|
||||
final PsiClassType baseClassType = aClass.getBaseClassType();
|
||||
if (LambdaUtil.isFunctionalType(baseClassType)) {
|
||||
final PsiMethod[] methods = aClass.getMethods();
|
||||
if (methods.length == 1 && aClass.getFields().length == 0) {
|
||||
if (methods.length == 1 && aClass.getFields().length == 0 && !AnonymousCanBeLambdaInspection.hasForbiddenRefsInsideBody(methods[0], aClass)) {
|
||||
final PsiCodeBlock body = methods[0].getBody();
|
||||
final PsiCallExpression callExpression =
|
||||
LambdaCanBeMethodReferenceInspection
|
||||
|
||||
+7
-4
@@ -245,11 +245,14 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
PsiParameter[] candidateParams = method.getParameterList().getParameters();
|
||||
if (candidateParams.length == 1) {
|
||||
if (TypeConversionUtil.areTypesConvertible(candidateParams[0].getType(), parameters[0].getType())) {
|
||||
for (PsiMethod superMethod : psiMethod.findDeepestSuperMethods()) {
|
||||
PsiMethod validSuperMethod = ensureNonAmbiguousMethod(parameters, superMethod);
|
||||
if (validSuperMethod != null) return validSuperMethod;
|
||||
final PsiMethod[] deepestSuperMethods = psiMethod.findDeepestSuperMethods();
|
||||
if (deepestSuperMethods.length > 0) {
|
||||
for (PsiMethod superMethod : deepestSuperMethods) {
|
||||
PsiMethod validSuperMethod = ensureNonAmbiguousMethod(parameters, superMethod);
|
||||
if (validSuperMethod != null) return validSuperMethod;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -263,11 +263,12 @@ public class BytecodeAnalysisConverter implements ApplicationComponent {
|
||||
|
||||
|
||||
private int mkPsiClassKey(PsiClass psiClass, int dimensions) throws IOException {
|
||||
PsiClassOwner psiFile = (PsiClassOwner) psiClass.getContainingFile();
|
||||
if (psiFile == null) {
|
||||
LOG.debug("getContainingFile was null for " + psiClass.getQualifiedName());
|
||||
PsiFile containingFile = psiClass.getContainingFile();
|
||||
if (!(containingFile instanceof PsiClassOwner)) {
|
||||
LOG.debug("containingFile was not resolved for " + psiClass.getQualifiedName());
|
||||
return -1;
|
||||
}
|
||||
PsiClassOwner psiFile = (PsiClassOwner)containingFile;
|
||||
String packageName = psiFile.getPackageName();
|
||||
String qname = psiClass.getQualifiedName();
|
||||
if (qname == null) {
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaClassFileType;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
import com.intellij.util.SystemProperties;
|
||||
@@ -82,7 +82,7 @@ public class BytecodeAnalysisIndex extends FileBasedIndexExtension<Integer, Coll
|
||||
@NotNull
|
||||
@Override
|
||||
public FileBasedIndex.InputFilter getInputFilter() {
|
||||
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.CLASS) {
|
||||
return new DefaultFileTypeSpecificInputFilter(JavaClassFileType.INSTANCE) {
|
||||
@Override
|
||||
public boolean acceptInput(@NotNull VirtualFile file) {
|
||||
return ourEnabled && super.acceptInput(file);
|
||||
|
||||
+8
@@ -141,6 +141,9 @@ public class ProjectBytecodeAnalysis {
|
||||
|
||||
@Nullable
|
||||
public PsiAnnotation findInferredAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) {
|
||||
if (!(listOwner instanceof PsiCompiledElement)) {
|
||||
return null;
|
||||
}
|
||||
if (annotationFQN.equals("org.jetbrains.annotations.NotNull")) {
|
||||
return findNotNullAnnotation(listOwner);
|
||||
}
|
||||
@@ -154,6 +157,9 @@ public class ProjectBytecodeAnalysis {
|
||||
|
||||
@NotNull
|
||||
public PsiAnnotation[] findInferredAnnotations(@NotNull PsiModifierListOwner listOwner) {
|
||||
if (!(listOwner instanceof PsiCompiledElement)) {
|
||||
return PsiAnnotation.EMPTY_ARRAY;
|
||||
}
|
||||
return collectInferredAnnotations(listOwner);
|
||||
}
|
||||
|
||||
@@ -249,6 +255,8 @@ public class ProjectBytecodeAnalysis {
|
||||
}
|
||||
|
||||
public static int getKey(@NotNull PsiModifierListOwner owner) throws IOException {
|
||||
LOG.assertTrue(owner instanceof PsiCompiledElement, owner);
|
||||
|
||||
if (owner instanceof PsiMethod) {
|
||||
return BytecodeAnalysisConverter.getInstance().mkPsiKey((PsiMethod)owner, new Out());
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class CreateAbstractMethodFromUsageFix extends CreateMethodFromUsageFix {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldBeAbstract(PsiClass targetClass) {
|
||||
protected boolean shouldBeAbstract(PsiReferenceExpression expression, PsiClass targetClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -168,6 +168,9 @@ public abstract class CreateFromUsageBaseFix extends BaseIntentionAction {
|
||||
list.deleteChildRange(list.getFirstChild(), list.getLastChild());
|
||||
return;
|
||||
}
|
||||
if (targetClass.isInterface()) {
|
||||
return;
|
||||
}
|
||||
final String visibility = getVisibility(parentClass, targetClass);
|
||||
if (VisibilityUtil.ESCALATE_VISIBILITY.equals(visibility)) {
|
||||
list.setModifierProperty(PsiModifier.PRIVATE, true);
|
||||
|
||||
+10
-9
@@ -120,7 +120,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
PsiMethodCallExpression call = getMethodCall();
|
||||
if (call == null) return Collections.emptyList();
|
||||
for (PsiClass target : targets) {
|
||||
if (target.isInterface() && shouldCreateStaticMember(call.getMethodExpression(), target)) continue;
|
||||
if (target.isInterface() && shouldCreateStaticMember(call.getMethodExpression(), target) && !PsiUtil.isLanguageLevel8OrHigher(target)) continue;
|
||||
if (!isMethodSignatureExists(call, target)) {
|
||||
result.add(target);
|
||||
}
|
||||
@@ -155,7 +155,8 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
|
||||
PsiCodeBlock body = method.getBody();
|
||||
assert body != null;
|
||||
if (shouldBeAbstract(targetClass)) {
|
||||
final boolean shouldBeAbstract = shouldBeAbstract(expression.getMethodExpression(), targetClass);
|
||||
if (shouldBeAbstract) {
|
||||
body.delete();
|
||||
if (!targetClass.isInterface()) {
|
||||
method.getModifierList().setModifierProperty(PsiModifier.ABSTRACT, true);
|
||||
@@ -167,14 +168,14 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
expression = getMethodCall();
|
||||
LOG.assertTrue(expression.isValid());
|
||||
|
||||
if (!targetClass.isInterface() && shouldCreateStaticMember(expression.getMethodExpression(), targetClass) && !shouldBeAbstract(targetClass)) {
|
||||
if ((!targetClass.isInterface() || PsiUtil.isLanguageLevel8OrHigher(targetClass)) && shouldCreateStaticMember(expression.getMethodExpression(), targetClass) && !shouldBeAbstract) {
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);
|
||||
}
|
||||
|
||||
final PsiElement context = PsiTreeUtil.getParentOfType(expression, PsiClass.class, PsiMethod.class);
|
||||
|
||||
PsiExpression[] arguments = expression.getArgumentList().getExpressions();
|
||||
doCreate(targetClass, method, shouldBeAbstract(targetClass),
|
||||
doCreate(targetClass, method, shouldBeAbstract,
|
||||
ContainerUtil.map2List(arguments, Pair.<PsiExpression, PsiType>createFunction(null)),
|
||||
getTargetSubstitutor(expression),
|
||||
CreateFromUsageUtils.guessExpectedTypes(expression, true),
|
||||
@@ -213,7 +214,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
|
||||
public static void doCreate(PsiClass targetClass, PsiMethod method, List<Pair<PsiExpression, PsiType>> arguments, PsiSubstitutor substitutor,
|
||||
ExpectedTypeInfo[] expectedTypes, @Nullable PsiElement context) {
|
||||
doCreate(targetClass, method, shouldBeAbstractImpl(targetClass), arguments, substitutor, expectedTypes, context);
|
||||
doCreate(targetClass, method, shouldBeAbstractImpl(null, targetClass), arguments, substitutor, expectedTypes, context);
|
||||
}
|
||||
|
||||
public static void doCreate(PsiClass targetClass,
|
||||
@@ -340,12 +341,12 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean shouldBeAbstract(PsiClass targetClass) {
|
||||
return shouldBeAbstractImpl(targetClass);
|
||||
protected boolean shouldBeAbstract(PsiReferenceExpression expression, PsiClass targetClass) {
|
||||
return shouldBeAbstractImpl(expression, targetClass);
|
||||
}
|
||||
|
||||
private static boolean shouldBeAbstractImpl(PsiClass targetClass) {
|
||||
return targetClass.isInterface();
|
||||
private static boolean shouldBeAbstractImpl(PsiReferenceExpression expression, PsiClass targetClass) {
|
||||
return targetClass.isInterface() && (expression == null || !shouldCreateStaticMember(expression, targetClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -251,11 +251,22 @@ public class GenerateDelegateHandler implements LanguageCodeInsightActionHandler
|
||||
final Set<MethodSignature> existingSignatures = new HashSet<MethodSignature>(aClass.getVisibleSignatures());
|
||||
final Set<PsiMethodMember> selection = new HashSet<PsiMethodMember>();
|
||||
Map<PsiClass, PsiSubstitutor> superSubstitutors = new HashMap<PsiClass, PsiSubstitutor>();
|
||||
|
||||
final PsiClass containingClass = targetMember.getContainingClass();
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(target.getProject());
|
||||
for (PsiMethod method : allMethods) {
|
||||
final PsiClass superClass = method.getContainingClass();
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) continue;
|
||||
if (method.isConstructor()) continue;
|
||||
|
||||
//do not suggest to override final method
|
||||
if (method.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
PsiMethod overridden = containingClass.findMethodBySignature(method, true);
|
||||
if (overridden != null && overridden.getContainingClass() != containingClass) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
PsiSubstitutor superSubstitutor = superSubstitutors.get(superClass);
|
||||
if (superSubstitutor == null) {
|
||||
superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, targetClass, substitutor);
|
||||
|
||||
+11
-1
@@ -29,15 +29,23 @@ public class JavaMethodParameterUnwrapper extends JavaUnwrapper {
|
||||
super("");
|
||||
}
|
||||
|
||||
private static PsiElement adjustElementToTheLeft(PsiElement element) {
|
||||
if (element instanceof PsiJavaToken && ((PsiJavaToken)element).getTokenType() == JavaTokenType.RPARENTH) {
|
||||
return element.getPrevSibling();
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(PsiElement e) {
|
||||
String text = e.getText();
|
||||
String text = adjustElementToTheLeft(e).getText();
|
||||
if (text.length() > 20) text = text.substring(0, 17) + "...";
|
||||
return CodeInsightBundle.message("unwrap.with.placeholder", text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicableTo(PsiElement e) {
|
||||
e = adjustElementToTheLeft(e);
|
||||
final PsiElement parent = e.getParent();
|
||||
if (e instanceof PsiExpression){
|
||||
if (parent instanceof PsiExpressionList) {
|
||||
@@ -62,6 +70,7 @@ public class JavaMethodParameterUnwrapper extends JavaUnwrapper {
|
||||
|
||||
@Override
|
||||
public PsiElement collectAffectedElements(PsiElement e, List<PsiElement> toExtract) {
|
||||
e = adjustElementToTheLeft(e);
|
||||
super.collectAffectedElements(e, toExtract);
|
||||
return isTopLevelCall(e) ? e.getParent() : e.getParent().getParent();
|
||||
}
|
||||
@@ -73,6 +82,7 @@ public class JavaMethodParameterUnwrapper extends JavaUnwrapper {
|
||||
|
||||
@Override
|
||||
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
|
||||
element = adjustElementToTheLeft(element);
|
||||
PsiElement methodCall = isTopLevelCall(element) ? element.getParent() : element.getParent().getParent();
|
||||
final PsiElement extractedElement = isTopLevelCall(element) ? getArg(element) : element;
|
||||
context.extractElement(extractedElement, methodCall);
|
||||
|
||||
@@ -24,14 +24,12 @@ import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectRootUtil;
|
||||
import com.intellij.openapi.roots.ModulePackageIndex;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.CommonContentEntriesEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -52,13 +50,29 @@ public class PackageUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiDirectory findPossiblePackageDirectoryInModule(Module module, String packageName) {
|
||||
return findPossiblePackageDirectoryInModule(module, packageName, true);
|
||||
}
|
||||
@Nullable
|
||||
public static PsiDirectory findPossiblePackageDirectoryInModule(Module module, String packageName, boolean preferNonGeneratedRoots) {
|
||||
final Project project = module.getProject();
|
||||
PsiDirectory psiDirectory = null;
|
||||
if (!"".equals(packageName)) {
|
||||
PsiPackage rootPackage = findLongestExistingPackage(module.getProject(), packageName);
|
||||
if (!StringUtil.isEmptyOrSpaces(packageName)) {
|
||||
PsiPackage rootPackage = findLongestExistingPackage(project, packageName);
|
||||
if (rootPackage != null) {
|
||||
final PsiDirectory[] psiDirectories = getPackageDirectoriesInModule(rootPackage, module);
|
||||
if (psiDirectories.length > 0) {
|
||||
psiDirectory = psiDirectories[0];
|
||||
|
||||
// If we prefer to find a non-generated PsiDirectory for the given package name, search through all
|
||||
// the directories for the first dir not marked as generated and use that one instead
|
||||
if (preferNonGeneratedRoots && psiDirectories.length > 1) {
|
||||
for (PsiDirectory dir : psiDirectories) {
|
||||
if (!GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(dir.getVirtualFile(), project)) {
|
||||
psiDirectory = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +80,7 @@ public class PackageUtil {
|
||||
if (checkSourceRootsConfigured(module)) {
|
||||
final List<VirtualFile> sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
|
||||
for (VirtualFile sourceRoot : sourceRoots) {
|
||||
final PsiDirectory directory = PsiManager.getInstance(module.getProject()).findDirectory(sourceRoot);
|
||||
final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(sourceRoot);
|
||||
if (directory != null) {
|
||||
psiDirectory = directory;
|
||||
break;
|
||||
|
||||
+1
-1
@@ -102,6 +102,6 @@ public class AutocreatingSingleSourceRootMoveDestination extends AutocreatingMov
|
||||
if (myTargetDirectory == null) {
|
||||
myTargetDirectory = RefactoringUtil.createPackageDirectoryInSourceRoot(myPackage, mySourceRoot);
|
||||
}
|
||||
return RefactoringUtil.createPackageDirectoryInSourceRoot(myPackage, mySourceRoot);
|
||||
return myTargetDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-51
@@ -45,7 +45,6 @@ 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;
|
||||
@@ -701,7 +700,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
|
||||
else if (element instanceof PsiComment) {
|
||||
return settings.isCollapseEndOfLineComments();
|
||||
}
|
||||
else if (isLiteralExpression(element)
|
||||
else if (ParameterNameFoldingManager.isLiteralExpression(element)
|
||||
&& element.getParent() instanceof PsiExpressionList
|
||||
&& (element.getParent().getParent() instanceof PsiCallExpression
|
||||
|| element.getParent().getParent() instanceof PsiAnonymousClass)) {
|
||||
@@ -760,55 +759,8 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
|
||||
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;
|
||||
ParameterNameFoldingManager manager = new ParameterNameFoldingManager(expression);
|
||||
foldElements.addAll(manager.buildDescriptors());
|
||||
}
|
||||
|
||||
private boolean addClosureFolding(final PsiClass aClass, final Document document, final List<FoldingDescriptor> foldElements,
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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.folding.impl;
|
||||
|
||||
import com.intellij.lang.folding.FoldingDescriptor;
|
||||
import com.intellij.lang.folding.NamedFoldingDescriptor;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParameterNameFoldingManager {
|
||||
private static final int MIN_NAME_LENGTH_THRESHOLD = 3;
|
||||
private static final int MIN_ARGS_TO_FOLD = 2;
|
||||
|
||||
private static final String[] RANGE_START_WORDS = {
|
||||
"begin", "start", "from", "first"
|
||||
};
|
||||
private static final String[] RANGE_END_WORDS = {
|
||||
"end", "to", "last"
|
||||
};
|
||||
|
||||
private final PsiCallExpression myCallExpression;
|
||||
|
||||
private PsiExpression[] myCallArguments;
|
||||
private PsiParameter[] myParameters;
|
||||
|
||||
public ParameterNameFoldingManager(@NotNull PsiCallExpression callExpression) {
|
||||
myCallExpression = callExpression;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiExpression[] getArguments(@NotNull PsiCallExpression call) {
|
||||
PsiExpressionList callArgumentsList = call.getArgumentList();
|
||||
return callArgumentsList != null ? callArgumentsList.getExpressions() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<FoldingDescriptor> buildDescriptors() {
|
||||
myCallArguments = getArguments(myCallExpression);
|
||||
|
||||
if (myCallArguments != null && myCallArguments.length >= MIN_ARGS_TO_FOLD && hasLiteralExpression(myCallArguments)) {
|
||||
PsiMethod method = myCallExpression.resolveMethod();
|
||||
|
||||
if (method != null) {
|
||||
myParameters = method.getParameterList().getParameters();
|
||||
if (myParameters.length == myCallArguments.length) {
|
||||
return buildDescriptorsForLiteralArguments();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ContainerUtil.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<FoldingDescriptor> buildDescriptorsForLiteralArguments() {
|
||||
List<FoldingDescriptor> descriptors = ContainerUtil.newArrayList();
|
||||
|
||||
int i = 0;
|
||||
while (i < myCallArguments.length) {
|
||||
if (i + 1 < myCallArguments.length && isCommonlyNamedParameterPair(i, i + 1)) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shouldInlineParameterName(i)) {
|
||||
descriptors.add(createFoldingDescriptor(myCallArguments[i], myParameters[i]));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static NamedFoldingDescriptor createFoldingDescriptor(@NotNull PsiExpression callArgument, @NotNull PsiParameter methodParam) {
|
||||
TextRange range = callArgument.getTextRange();
|
||||
String placeholderText = methodParam.getName() + ": " + callArgument.getText();
|
||||
return new NamedFoldingDescriptor(callArgument, range.getStartOffset(), range.getEndOffset(), null, placeholderText);
|
||||
}
|
||||
|
||||
private boolean isCommonlyNamedParameterPair(int first, int second) {
|
||||
assert first < myParameters.length && second < myParameters.length;
|
||||
|
||||
String firstParamName = myParameters[first].getName();
|
||||
String secondParamName = myParameters[second].getName();
|
||||
if (firstParamName == null || secondParamName == null) return false;
|
||||
|
||||
if (containsAnyWord(firstParamName, RANGE_START_WORDS) && containsAnyWord(secondParamName, RANGE_END_WORDS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean containsAnyWord(@NotNull String str, @NotNull String[] words) {
|
||||
for (String word : words) {
|
||||
if (StringUtil.containsIgnoreCase(str, word)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean shouldInlineParameterName(int paramIndex) {
|
||||
PsiExpression argument = myCallArguments[paramIndex];
|
||||
if (isLiteralExpression(argument) && argument.getType() != null) {
|
||||
PsiParameter parameter = myParameters[paramIndex];
|
||||
String paramName = parameter.getName();
|
||||
if (paramName != null && paramName.length() >= MIN_NAME_LENGTH_THRESHOLD) {
|
||||
return TypeConversionUtil.isAssignable(parameter.getType(), argument.getType());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasLiteralExpression(@NotNull PsiExpression[] arguments) {
|
||||
for (PsiExpression argument : arguments) {
|
||||
if (isLiteralExpression(argument)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,7 @@ public class JavaDocInfoGenerator {
|
||||
LOG.debug(text);
|
||||
}
|
||||
|
||||
text = StringUtil.replaceIgnoreCase(text, "<p/>", "<p></p>");
|
||||
return StringUtil.replace(text, "/>", ">");
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ public class DeclarationParser {
|
||||
JavaTokenType.IDENTIFIER, JavaTokenType.COMMA, JavaTokenType.THROWS_KEYWORD);
|
||||
private static final TokenSet PARAM_LIST_STOPPERS = TokenSet.create(
|
||||
JavaTokenType.RPARENTH, JavaTokenType.LBRACE, JavaTokenType.ARROW);
|
||||
private static final TokenSet TYPE_START = TokenSet.orSet(
|
||||
ElementType.PRIMITIVE_TYPE_BIT_SET, TokenSet.create(JavaTokenType.IDENTIFIER, JavaTokenType.AT));
|
||||
|
||||
private static final String WHITESPACES = "\n\r \t";
|
||||
private static final String LINE_ENDS = "\n\r";
|
||||
@@ -278,56 +280,64 @@ public class DeclarationParser {
|
||||
return modList;
|
||||
}
|
||||
|
||||
PsiBuilder.Marker type;
|
||||
if (ElementType.PRIMITIVE_TYPE_BIT_SET.contains(builder.getTokenType())) {
|
||||
type = parseTypeNotNull(builder);
|
||||
}
|
||||
else if (builder.getTokenType() == JavaTokenType.IDENTIFIER /*|| builder.getTokenType() == JavaTokenType.AT*/) {
|
||||
PsiBuilder.Marker idPos = builder.mark();
|
||||
type = parseTypeNotNull(builder);
|
||||
if (builder.getTokenType() == JavaTokenType.LPARENTH) { // constructor
|
||||
if (context == Context.CODE_BLOCK) {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
idPos.rollbackTo();
|
||||
if (typeParams == null) {
|
||||
emptyElement(builder, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
}
|
||||
builder.advanceLexer();
|
||||
if (builder.getTokenType() != JavaTokenType.LPARENTH) {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
return parseMethodFromLeftParenth(builder, declaration, false, true);
|
||||
}
|
||||
idPos.drop();
|
||||
}
|
||||
else if (builder.getTokenType() == JavaTokenType.LBRACE) {
|
||||
if (builder.getTokenType() == JavaTokenType.LBRACE) {
|
||||
if (context == Context.CODE_BLOCK) {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier.or.type"), typeParams);
|
||||
declaration.drop();
|
||||
return modList;
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker codeBlock = myParser.getStatementParser().parseCodeBlock(builder);
|
||||
PsiBuilder.Marker codeBlock = myParser.getStatementParser().parseCodeBlock(builder);
|
||||
assert codeBlock != null : builder.getOriginalText();
|
||||
|
||||
if (typeParams != null) {
|
||||
final PsiBuilder.Marker error = typeParams.precede();
|
||||
PsiBuilder.Marker error = typeParams.precede();
|
||||
error.errorBefore(JavaErrorMessages.message("unexpected.token"), codeBlock);
|
||||
}
|
||||
|
||||
done(declaration, JavaElementType.CLASS_INITIALIZER);
|
||||
return declaration;
|
||||
}
|
||||
else {
|
||||
final PsiBuilder.Marker error;
|
||||
if (typeParams != null) {
|
||||
error = typeParams.precede();
|
||||
|
||||
PsiBuilder.Marker type = null;
|
||||
|
||||
if (TYPE_START.contains(builder.getTokenType())) {
|
||||
PsiBuilder.Marker pos = builder.mark();
|
||||
|
||||
type = myParser.getReferenceParser().parseType(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD);
|
||||
|
||||
if (type == null) {
|
||||
pos.rollbackTo();
|
||||
}
|
||||
else if (builder.getTokenType() == JavaTokenType.LPARENTH) { // constructor
|
||||
if (context == Context.CODE_BLOCK) {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
pos.rollbackTo();
|
||||
|
||||
if (typeParams == null) {
|
||||
emptyElement(builder, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
}
|
||||
parseAnnotations(builder);
|
||||
builder.advanceLexer();
|
||||
|
||||
if (builder.getTokenType() == JavaTokenType.LPARENTH) {
|
||||
return parseMethodFromLeftParenth(builder, declaration, false, true);
|
||||
}
|
||||
else {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = builder.mark();
|
||||
pos.drop();
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
PsiBuilder.Marker error = typeParams != null ? typeParams.precede() : builder.mark();
|
||||
error.error(JavaErrorMessages.message("expected.identifier.or.type"));
|
||||
declaration.drop();
|
||||
return modList;
|
||||
@@ -363,13 +373,6 @@ public class DeclarationParser {
|
||||
return parseFieldOrLocalVariable(builder, declaration, declarationStart, context);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiBuilder.Marker parseTypeNotNull(final PsiBuilder builder) {
|
||||
final PsiBuilder.Marker type = myParser.getReferenceParser().parseType(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD);
|
||||
assert type != null : builder.getOriginalText();
|
||||
return type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Pair<PsiBuilder.Marker, Boolean> parseModifierList(final PsiBuilder builder) {
|
||||
return parseModifierList(builder, ElementType.MODIFIER_BIT_SET);
|
||||
|
||||
+3
-3
@@ -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.
|
||||
@@ -24,7 +24,7 @@ import com.intellij.psi.impl.java.stubs.impl.PsiImportStatementStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiImportStatementImpl;
|
||||
import com.intellij.psi.impl.source.PsiImportStaticStatementImpl;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.SourceUtil;
|
||||
import com.intellij.psi.impl.source.tree.JavaSourceUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.ImportStaticStatementElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
@@ -68,7 +68,7 @@ public abstract class JavaImportStatementElementType extends JavaStubElementType
|
||||
for (LighterASTNode child : tree.getChildren(node)) {
|
||||
IElementType type = child.getTokenType();
|
||||
if (type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.IMPORT_STATIC_REFERENCE) {
|
||||
refText = SourceUtil.getReferenceText(tree, child);
|
||||
refText = JavaSourceUtil.getReferenceText(tree, child);
|
||||
}
|
||||
else if (type == JavaTokenType.ASTERISK) {
|
||||
isOnDemand = true;
|
||||
|
||||
@@ -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.
|
||||
@@ -44,7 +44,7 @@ public class JavaLightStubBuilder extends LightStubBuilder {
|
||||
if (pkg != null) {
|
||||
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
|
||||
if (ref != null) {
|
||||
refText = SourceUtil.getReferenceText(tree, ref);
|
||||
refText = JavaSourceUtil.getReferenceText(tree, ref);
|
||||
}
|
||||
}
|
||||
return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
|
||||
|
||||
+1
-1
@@ -751,7 +751,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
|
||||
private String getNormalizedText() {
|
||||
String whiteSpaceAndComments = myCachedNormalizedText;
|
||||
if (whiteSpaceAndComments == null) {
|
||||
myCachedNormalizedText = whiteSpaceAndComments = SourceUtil.getReferenceText(this);
|
||||
myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this);
|
||||
}
|
||||
return whiteSpaceAndComments;
|
||||
}
|
||||
|
||||
+9
-9
@@ -379,7 +379,7 @@ public class InferenceSession {
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (!PsiType.VOID.equals(returnType) && returnType != null) {
|
||||
PsiType targetType = getTargetType(context);
|
||||
if (targetType != null) {
|
||||
if (targetType != null && !PsiType.VOID.equals(targetType)) {
|
||||
registerReturnTypeConstraints(PsiUtil.isRawSubstitutor(method, mySiteSubstitutor) ? returnType : mySiteSubstitutor.substitute(returnType), targetType);
|
||||
}
|
||||
}
|
||||
@@ -1021,13 +1021,13 @@ public class InferenceSession {
|
||||
*/
|
||||
public static boolean isMoreSpecific(PsiMethod m1,
|
||||
PsiMethod m2,
|
||||
PsiSubstitutor siteSubstitutor2,
|
||||
PsiExpression[] args,
|
||||
PsiElement context,
|
||||
boolean varargs) {
|
||||
final PsiTypeParameter[] typeParameters = m2.getTypeParameters();
|
||||
|
||||
final InferenceSession session = new InferenceSession(typeParameters, siteSubstitutor2, m2.getManager(), context);
|
||||
final InferenceSession session = new InferenceSession(PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY, m2.getManager(), context);
|
||||
for (PsiTypeParameter param : PsiUtil.typeParametersIterable(m2)) {
|
||||
session.initBounds(param);
|
||||
}
|
||||
|
||||
final PsiParameter[] parameters1 = m1.getParameterList().getParameters();
|
||||
final PsiParameter[] parameters2 = m2.getParameterList().getParameters();
|
||||
@@ -1037,8 +1037,8 @@ public class InferenceSession {
|
||||
|
||||
final int paramsLength = !varargs ? parameters1.length : parameters1.length - 1;
|
||||
for (int i = 0; i < paramsLength; i++) {
|
||||
PsiType sType = getParameterType(parameters1, i, siteSubstitutor2, false);
|
||||
PsiType tType = getParameterType(parameters2, i, siteSubstitutor2, varargs);
|
||||
PsiType sType = getParameterType(parameters1, i, PsiSubstitutor.EMPTY, false);
|
||||
PsiType tType = getParameterType(parameters2, i, PsiSubstitutor.EMPTY, varargs);
|
||||
if (session.isProperType(sType) && session.isProperType(tType)) {
|
||||
if (!TypeConversionUtil.isAssignable(tType, sType)) {
|
||||
return false;
|
||||
@@ -1055,8 +1055,8 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (varargs) {
|
||||
PsiType sType = getParameterType(parameters1, paramsLength, siteSubstitutor2, true);
|
||||
PsiType tType = getParameterType(parameters2, paramsLength, siteSubstitutor2, true);
|
||||
PsiType sType = getParameterType(parameters1, paramsLength, PsiSubstitutor.EMPTY, true);
|
||||
PsiType tType = getParameterType(parameters2, paramsLength, PsiSubstitutor.EMPTY, true);
|
||||
session.addConstraint(new StrictSubtypingConstraint(tType, sType));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ public interface JavaElementType {
|
||||
IElementType PARAMETER_LIST = JavaStubElementTypes.PARAMETER_LIST;
|
||||
IElementType EXTENDS_BOUND_LIST = JavaStubElementTypes.EXTENDS_BOUND_LIST;
|
||||
IElementType THROWS_LIST = JavaStubElementTypes.THROWS_LIST;
|
||||
IElementType LITERAL_EXPRESSION = new JavaCompositeElementType("LITERAL_EXPRESSION", PsiLiteralExpressionImpl.class);
|
||||
|
||||
IElementType LITERAL_EXPRESSION = new JavaCompositeElementType("LITERAL_EXPRESSION", PsiLiteralExpressionImpl.class);
|
||||
IElementType IMPORT_STATIC_REFERENCE = new JavaCompositeElementType("IMPORT_STATIC_REFERENCE", PsiImportStaticReferenceElementImpl.class);
|
||||
IElementType TYPE = new JavaCompositeElementType("TYPE", PsiTypeElementImpl.class);
|
||||
IElementType DIAMOND_TYPE = new JavaCompositeElementType("DIAMOND_TYPE", PsiDiamondTypeElementImpl.class);
|
||||
|
||||
@@ -15,13 +15,28 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ASTFactory;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.impl.source.SourceJavaCodeReference;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaSourceUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.JavaSourceUtil");
|
||||
|
||||
private static final TokenSet REF_FILTER = TokenSet.orSet(
|
||||
ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET, TokenSet.create(JavaElementType.ANNOTATION));
|
||||
|
||||
private JavaSourceUtil() { }
|
||||
|
||||
public static void fullyQualifyReference(@NotNull CompositeElement reference, @NotNull PsiClass targetClass) {
|
||||
@@ -61,4 +76,70 @@ public class JavaSourceUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getReferenceText(@NotNull PsiJavaCodeReferenceElement ref) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
((TreeElement)ref.getNode()).acceptTree(new RecursiveTreeElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitLeaf(LeafElement leaf) {
|
||||
if (!REF_FILTER.contains(leaf.getElementType())) {
|
||||
String leafText = leaf.getText();
|
||||
if (buffer.length() > 0 && !leafText.isEmpty() && Character.isJavaIdentifierPart(leafText.charAt(0))) {
|
||||
char lastInBuffer = buffer.charAt(buffer.length() - 1);
|
||||
if (lastInBuffer == '?' || Character.isJavaIdentifierPart(lastInBuffer)) {
|
||||
buffer.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(leafText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitComposite(CompositeElement composite) {
|
||||
if (!REF_FILTER.contains(composite.getElementType())) {
|
||||
super.visitComposite(composite);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getReferenceText(@NotNull LighterAST tree, @NotNull LighterASTNode node) {
|
||||
return LightTreeUtil.toFilteredString(tree, node, REF_FILTER);
|
||||
}
|
||||
|
||||
public static TreeElement addParenthToReplacedChild(@NotNull IElementType parenthType,
|
||||
@NotNull TreeElement newChild,
|
||||
@NotNull PsiManager manager) {
|
||||
CompositeElement parenthExpr = ASTFactory.composite(parenthType);
|
||||
|
||||
TreeElement dummyExpr = (TreeElement)newChild.clone();
|
||||
final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(newChild);
|
||||
new DummyHolder(manager, parenthExpr, null, charTableByTree);
|
||||
parenthExpr.putUserData(CharTable.CHAR_TABLE_KEY, charTableByTree);
|
||||
parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.LPARENTH, "("));
|
||||
parenthExpr.rawAddChildren(dummyExpr);
|
||||
parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.RPARENTH, ")"));
|
||||
|
||||
try {
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
PsiElement formatted = codeStyleManager.reformat(SourceTreeToPsiMap.treeToPsiNotNull(parenthExpr));
|
||||
parenthExpr = (CompositeElement)SourceTreeToPsiMap.psiToTreeNotNull(formatted);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e); // should not happen
|
||||
}
|
||||
|
||||
newChild.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(newChild));
|
||||
dummyExpr.getTreeParent().replaceChild(dummyExpr, newChild);
|
||||
|
||||
// TODO remove explicit caches drop since this should be ok if we will use ChangeUtil for the modification
|
||||
TreeUtil.clearCaches(TreeUtil.getFileElement(parenthExpr));
|
||||
return parenthExpr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -15,94 +15,29 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ASTFactory;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/** @deprecated use {@link JavaSourceUtil} (to be removed in IDEA 15) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class SourceUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.SourceUtil");
|
||||
|
||||
private static final TokenSet REF_FILTER = TokenSet.orSet(
|
||||
ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET, TokenSet.create(JavaElementType.ANNOTATION));
|
||||
|
||||
private SourceUtil() { }
|
||||
|
||||
@NotNull
|
||||
public static String getReferenceText(@NotNull PsiJavaCodeReferenceElement ref) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
((TreeElement)ref.getNode()).acceptTree(new RecursiveTreeElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitLeaf(LeafElement leaf) {
|
||||
if (!REF_FILTER.contains(leaf.getElementType())) {
|
||||
String leafText = leaf.getText();
|
||||
if (buffer.length() > 0 && !leafText.isEmpty() && Character.isJavaIdentifierPart(leafText.charAt(0))) {
|
||||
char lastInBuffer = buffer.charAt(buffer.length() - 1);
|
||||
if (lastInBuffer == '?' || Character.isJavaIdentifierPart(lastInBuffer)) {
|
||||
buffer.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(leafText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitComposite(CompositeElement composite) {
|
||||
if (!REF_FILTER.contains(composite.getElementType())) {
|
||||
super.visitComposite(composite);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return buffer.toString();
|
||||
return JavaSourceUtil.getReferenceText(ref);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getReferenceText(@NotNull LighterAST tree, @NotNull LighterASTNode node) {
|
||||
return LightTreeUtil.toFilteredString(tree, node, REF_FILTER);
|
||||
return JavaSourceUtil.getReferenceText(tree, node);
|
||||
}
|
||||
|
||||
public static TreeElement addParenthToReplacedChild(@NotNull IElementType parenthType,
|
||||
@NotNull TreeElement newChild,
|
||||
@NotNull PsiManager manager) {
|
||||
CompositeElement parenthExpr = ASTFactory.composite(parenthType);
|
||||
|
||||
TreeElement dummyExpr = (TreeElement)newChild.clone();
|
||||
final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(newChild);
|
||||
new DummyHolder(manager, parenthExpr, null, charTableByTree);
|
||||
parenthExpr.putUserData(CharTable.CHAR_TABLE_KEY, charTableByTree);
|
||||
parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.LPARENTH, "("));
|
||||
parenthExpr.rawAddChildren(dummyExpr);
|
||||
parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.RPARENTH, ")"));
|
||||
|
||||
try {
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
PsiElement formatted = codeStyleManager.reformat(SourceTreeToPsiMap.treeToPsiNotNull(parenthExpr));
|
||||
parenthExpr = (CompositeElement)SourceTreeToPsiMap.psiToTreeNotNull(formatted);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e); // should not happen
|
||||
}
|
||||
|
||||
newChild.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(newChild));
|
||||
dummyExpr.getTreeParent().replaceChild(dummyExpr, newChild);
|
||||
|
||||
// TODO remove explicit caches drop since this should be ok if we will use ChangeUtil for the modification
|
||||
TreeUtil.clearCaches(TreeUtil.getFileElement(parenthExpr));
|
||||
return parenthExpr;
|
||||
public static TreeElement addParenthToReplacedChild(@NotNull IElementType parenthType, @NotNull TreeElement newChild, @NotNull PsiManager manager) {
|
||||
return JavaSourceUtil.addParenthToReplacedChild(parenthType, newChild, manager);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-11
@@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -24,13 +20,11 @@ import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ExpressionPsiElement extends CompositePsiElement {
|
||||
private final int myHC = CompositePsiElement.ourHC++;
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return myHC;
|
||||
}
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") private final int myHC = CompositePsiElement.ourHC++;
|
||||
|
||||
public ExpressionPsiElement(final IElementType type) {
|
||||
super(type);
|
||||
@@ -42,9 +36,14 @@ public class ExpressionPsiElement extends CompositePsiElement {
|
||||
ElementType.EXPRESSION_BIT_SET.contains(newElement.getElementType())) {
|
||||
boolean needParenth = ReplaceExpressionUtil.isNeedParenthesis(child, newElement);
|
||||
if (needParenth) {
|
||||
newElement = SourceUtil.addParenthToReplacedChild(JavaElementType.PARENTH_EXPRESSION, newElement, getManager());
|
||||
newElement = JavaSourceUtil.addParenthToReplacedChild(JavaElementType.PARENTH_EXPRESSION, newElement, getManager());
|
||||
}
|
||||
}
|
||||
super.replaceChildInternal(child, newElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return myHC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -41,14 +41,15 @@ public class MethodElement extends CompositeElement implements Constants {
|
||||
|
||||
@Override
|
||||
public int getTextOffset() {
|
||||
return findChildByRole(ChildRole.NAME).getStartOffset();
|
||||
ASTNode name = findChildByType(IDENTIFIER);
|
||||
return name != null ? name.getStartOffset() : this.getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
|
||||
if (first == last && first.getElementType() == JavaElementType.CODE_BLOCK){
|
||||
ASTNode semicolon = findChildByRole(ChildRole.CLOSING_SEMICOLON);
|
||||
if (semicolon != null){
|
||||
if (first == last && first.getElementType() == JavaElementType.CODE_BLOCK) {
|
||||
ASTNode semicolon = TreeUtil.findChildBackward(this, SEMICOLON);
|
||||
if (semicolon != null) {
|
||||
deleteChildInternal(semicolon);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +65,7 @@ public class MethodElement extends CompositeElement implements Constants {
|
||||
|
||||
@Override
|
||||
public void deleteChildInternal(@NotNull ASTNode child) {
|
||||
if (child.getElementType() == CODE_BLOCK){
|
||||
if (child.getElementType() == CODE_BLOCK) {
|
||||
final ASTNode prevWS = TreeUtil.prevLeaf(child);
|
||||
if (prevWS != null && prevWS.getElementType() == TokenType.WHITE_SPACE) {
|
||||
removeChild(prevWS);
|
||||
@@ -80,9 +81,9 @@ public class MethodElement extends CompositeElement implements Constants {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode findChildByRole(int role){
|
||||
public ASTNode findChildByRole(int role) {
|
||||
LOG.assertTrue(ChildRole.isUnique(role));
|
||||
switch(role){
|
||||
switch (role) {
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -161,5 +162,4 @@ public class MethodElement extends CompositeElement implements Constants {
|
||||
protected boolean isVisibilitySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -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.
|
||||
@@ -38,7 +38,7 @@ public class PsiPackageStatementImpl extends CompositePsiElement implements PsiP
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
PsiJavaCodeReferenceElement ref = getPackageReference();
|
||||
return ref == null ? null : SourceUtil.getReferenceText(ref);
|
||||
return ref == null ? null : JavaSourceUtil.getReferenceText(ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -761,7 +761,7 @@ public class PsiReferenceExpressionImpl extends PsiReferenceExpressionBase imple
|
||||
private String getCachedNormalizedText() {
|
||||
String whiteSpaceAndComments = myCachedNormalizedText;
|
||||
if (whiteSpaceAndComments == null) {
|
||||
myCachedNormalizedText = whiteSpaceAndComments = SourceUtil.getReferenceText(this);
|
||||
myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this);
|
||||
}
|
||||
return whiteSpaceAndComments;
|
||||
}
|
||||
|
||||
+6
-7
@@ -550,10 +550,10 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
|
||||
final PsiSubstitutor methodSubstitutor1 = calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite,
|
||||
languageLevel);
|
||||
boolean applicable12 = isApplicableTo(types2AtSite, method1, languageLevel, varargsPosition, methodSubstitutor1, method2, siteSubstitutor1);
|
||||
boolean applicable12 = isApplicableTo(types2AtSite, method1, languageLevel, varargsPosition, methodSubstitutor1, method2);
|
||||
|
||||
final PsiSubstitutor methodSubstitutor2 = calculateMethodSubstitutor(typeParameters2, method2, siteSubstitutor2, types2, types1AtSite, languageLevel);
|
||||
boolean applicable21 = isApplicableTo(types1AtSite, method2, languageLevel, varargsPosition, methodSubstitutor2, method1, siteSubstitutor2);
|
||||
boolean applicable21 = isApplicableTo(types1AtSite, method2, languageLevel, varargsPosition, methodSubstitutor2, method1);
|
||||
|
||||
if (!myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
final boolean typeArgsApplicable12 = GenericsUtil.isTypeArgumentsApplicable(typeParameters1, methodSubstitutor1, myArgumentsList, !applicable21);
|
||||
@@ -604,9 +604,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
|
||||
if (toCompareFunctional) {
|
||||
final boolean applicable12ignoreFunctionalType = isApplicableTo(types2AtSite, method1, languageLevel, varargsPosition,
|
||||
calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite, languageLevel), null, null);
|
||||
calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite, languageLevel), null);
|
||||
final boolean applicable21ignoreFunctionalType = isApplicableTo(types1AtSite, method2, languageLevel, varargsPosition,
|
||||
calculateMethodSubstitutor(typeParameters2, method2, siteSubstitutor2, types2, types1AtSite, languageLevel), null, null);
|
||||
calculateMethodSubstitutor(typeParameters2, method2, siteSubstitutor2, types2, types1AtSite, languageLevel), null);
|
||||
|
||||
if (applicable12ignoreFunctionalType || applicable21ignoreFunctionalType) {
|
||||
Specifics specifics = null;
|
||||
@@ -694,12 +694,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
@NotNull LanguageLevel languageLevel,
|
||||
boolean varargsPosition,
|
||||
@NotNull PsiSubstitutor methodSubstitutor1,
|
||||
PsiMethod method2,
|
||||
PsiSubstitutor siteSubstitutor1) {
|
||||
PsiMethod method2) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method2 != null && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) {
|
||||
final PsiElement parent = myArgumentsList.getParent();
|
||||
if (parent instanceof PsiCallExpression && ((PsiCallExpression)parent).getTypeArguments().length == 0) {
|
||||
return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
|
||||
return InferenceSession.isMoreSpecific(method2, method1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
|
||||
}
|
||||
}
|
||||
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method1, methodSubstitutor1, types2AtSite, languageLevel, false, varargsPosition);
|
||||
|
||||
+1
@@ -114,6 +114,7 @@ class Outer {
|
||||
void <error descr="Annotations are not allowed here">@TA</error> misplaced() { }
|
||||
|
||||
@TA Outer() { }
|
||||
<T> <error descr="Annotations are not allowed here">@TA</error> Outer(T t) { }
|
||||
|
||||
class MyClass<@TA @TPA T> { }
|
||||
interface MyInterface<@TA @TPA E> { }
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
class Test {
|
||||
public static <Tfoo, Vfoo> Future<Vfoo> foo(Future<Tfoo> future, Function<Tfoo, Vfoo> function) {
|
||||
return future.map(function);
|
||||
}
|
||||
|
||||
// These interfaces inspired by FoundationDB Java client class files
|
||||
interface PartialFunction <TP, VP> {
|
||||
VP apply(TP t) throws java.lang.Exception;
|
||||
}
|
||||
|
||||
interface Function <TF, VF> extends PartialFunction<TF, VF> {
|
||||
VF apply(TF t);
|
||||
}
|
||||
|
||||
interface PartialFuture <TPP> {
|
||||
<VPP> PartialFuture<VPP> map(PartialFunction<TPP, VPP> partialFunction);
|
||||
}
|
||||
|
||||
interface Future <TFF> extends PartialFuture<TFF> {
|
||||
<VFF> Future<VFF> map(Function<TFF, VFF> function);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Executor<E> {
|
||||
<K> void bar(Executor<K> e) {
|
||||
Runnable r = () -> foo(e);
|
||||
}
|
||||
|
||||
private <T> T foo(final Executor<T> e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import java.util.List;
|
||||
|
||||
// "Cast parameter to 'java.util.List'" "true"
|
||||
class Test {
|
||||
void m(Object o) {
|
||||
foo((List) o);
|
||||
}
|
||||
|
||||
private void foo(final java.util.List o) {}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Cast parameter to 'java.util.List'" "true"
|
||||
class Test {
|
||||
void m(Object o) {
|
||||
foo(<caret>o);
|
||||
}
|
||||
|
||||
private void foo(final java.util.List o) {}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with lambda" "false"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
void ab() {
|
||||
comparing(new Func<caret>tion<Integer, String>() {
|
||||
public String apply(Integer pObj) {
|
||||
return Integer.toString(pObj);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static <T> void comparing(Function<T, String> keyExtractor){}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create Method 'f'" "true"
|
||||
interface X {
|
||||
public static void m() {
|
||||
f();
|
||||
}
|
||||
|
||||
static void f() {
|
||||
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Create Method 'f'" "true"
|
||||
interface X {
|
||||
public static void m() {
|
||||
f<caret>();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
class Test {
|
||||
{
|
||||
BiConsumer<PrintStream, String> printer = PrintStream::println;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
class Test {
|
||||
{
|
||||
BiConsumer<PrintStream, String> printer = (printStream, x) -> printSt<caret>ream.println(x);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<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>public <a href="psi_element://java.lang.String"><code>String</code></a> <b>field = null</b></PRE>
|
||||
<pre>
|
||||
foo
|
||||
<p></p>
|
||||
bar
|
||||
</pre></body></html>
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
/**
|
||||
* <pre>
|
||||
* foo
|
||||
* <p/>
|
||||
* bar
|
||||
* </pre>
|
||||
*/
|
||||
public String field = null;
|
||||
}
|
||||
@@ -1,2 +1,8 @@
|
||||
@Ann(<error descr="Cannot find method 'value'">0</error>) class D {
|
||||
|
||||
<error>@EJB</error>
|
||||
Runnable myMissingEjbRef;
|
||||
|
||||
public <T> @SafeVarargs
|
||||
static void m();
|
||||
}
|
||||
@@ -69,5 +69,96 @@ PsiJavaFile:Errors.java
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier or type expected
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:error
|
||||
PsiIdentifier:error('error')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiModifierList:@EJB
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:EJB
|
||||
PsiIdentifier:EJB('EJB')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier or type expected
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiErrorElement:Type parameter expected
|
||||
<empty list>
|
||||
PsiErrorElement:'>' expected.
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:DIV('/')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:error
|
||||
PsiJavaCodeReferenceElement:error
|
||||
PsiIdentifier:error('error')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiField:myMissingEjbRef
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:Runnable
|
||||
PsiJavaCodeReferenceElement:Runnable
|
||||
PsiIdentifier:Runnable('Runnable')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:myMissingEjbRef('myMissingEjbRef')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiModifierList:public
|
||||
PsiKeyword:public('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Identifier or type expected
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiMethod:m
|
||||
PsiModifierList:@SafeVarargs
|
||||
static
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:SafeVarargs
|
||||
PsiIdentifier:SafeVarargs('SafeVarargs')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiKeyword:static('static')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:void
|
||||
PsiKeyword:void('void')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:m('m')
|
||||
PsiParameterList:()
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
+5
-4
@@ -47,9 +47,10 @@ class SpecSamples {
|
||||
try (@A Reader r = new @B FileReader("/dev/zero"); @A Writer w = new @B FileWriter("/dev/null")) { }
|
||||
}
|
||||
|
||||
//interface TestClass {
|
||||
// <T> @Nullable List<T> test();
|
||||
//}
|
||||
interface TestClass {
|
||||
<T> @Nullable List<T> test();
|
||||
<T> @Positive int test(T t);
|
||||
}
|
||||
|
||||
//
|
||||
// 2. An annotation on a wildcard type argument appears before the wildcard ...
|
||||
@@ -76,7 +77,7 @@ class SpecSamples {
|
||||
//
|
||||
|
||||
@Immutable SpecSamples() { }
|
||||
//<T> @Immutable SpecSamples(T t) { }
|
||||
<T> @Immutable SpecSamples(T t) { }
|
||||
|
||||
//
|
||||
// todo [r.sh] 5. It is permitted to explicitly declare the method receiver as the first formal parameter ...
|
||||
|
||||
+138
-6
@@ -1045,11 +1045,103 @@ PsiJavaFile:TypeAnnotations.java
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('//interface TestClass {')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('// <T> @Nullable List<T> test();')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('//}')
|
||||
PsiClass:TestClass
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:interface('interface')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:TestClass('TestClass')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiMethod:test
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:@Nullable List<T>
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:Nullable
|
||||
PsiIdentifier:Nullable('Nullable')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:List<T>
|
||||
PsiIdentifier:List('List')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:T
|
||||
PsiJavaCodeReferenceElement:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:test('test')
|
||||
PsiParameterList:()
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiMethod:test
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:@Positive int
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:Positive
|
||||
PsiIdentifier:Positive('Positive')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:int('int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:test('test')
|
||||
PsiParameterList:(T t)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:t
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:T
|
||||
PsiJavaCodeReferenceElement:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:t('t')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('//')
|
||||
PsiWhiteSpace('\n ')
|
||||
@@ -1492,7 +1584,47 @@ PsiJavaFile:TypeAnnotations.java
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('//<T> @Immutable SpecSamples(T t) { }')
|
||||
PsiMethod:SpecSamples
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:Immutable
|
||||
PsiIdentifier:Immutable('Immutable')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:SpecSamples('SpecSamples')
|
||||
PsiParameterList:(T t)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:t
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:T
|
||||
PsiJavaCodeReferenceElement:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:t('t')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiCodeBlock
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiComment(END_OF_LINE_COMMENT)('//')
|
||||
PsiWhiteSpace('\n ')
|
||||
|
||||
+4
@@ -111,6 +111,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA127584() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
+55
-205
@@ -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.
|
||||
@@ -31,214 +31,64 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{
|
||||
new UnusedSymbolLocalInspection(),
|
||||
new UnusedSymbolLocalInspection()
|
||||
};
|
||||
}
|
||||
|
||||
public void testIDEA93586() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
public void testIDEA93586() { doTest(); }
|
||||
public void testIDEA113573() { doTest(); }
|
||||
public void testIDEA112922() { doTest(); }
|
||||
public void testIDEA113504() { doTest(); }
|
||||
public void testAfterAbstractPipeline2() { doTest(); }
|
||||
public void testIDEA116252() { doTest(); }
|
||||
public void testIDEA106670() { doTest(); }
|
||||
public void testIDEA116548() { doTest(); }
|
||||
public void testOverloadResolutionSAM() { doTest(); }
|
||||
public void testIntersectionTypesDuringInference() { doTest(); }
|
||||
public void testIncludeConstraintsWhenParentMethodIsDuringCalculation() { doTest(); }
|
||||
public void testUseCalculatedSubstitutor() { doTest(); }
|
||||
public void testArgumentOfAnonymousClass() { doTest(); }
|
||||
public void testEllipsis() { doTest(); }
|
||||
public void testOuterMethodPropagation() { doTest(); }
|
||||
public void testRecursiveCalls() { doTest(); }
|
||||
public void testGroundTargetTypeForImplicitLambdas() { doTest(); }
|
||||
public void testAdditionalConstraintsReduceOrder() { doTest(); }
|
||||
public void testAdditionalConstraintSubstitution() { doTest(); }
|
||||
public void testFunctionalInterfacesCalculation() { doTest(); }
|
||||
public void testMissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering() { doTest(); }
|
||||
public void testIDEA120992() { doTest(); }
|
||||
public void testTargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType() { doTest(); }
|
||||
public void testIDEA119535() { doTest(); }
|
||||
public void testIDEA119003() { doTest(); }
|
||||
public void testIDEA117124() { doTest(); }
|
||||
public void testWildcardParameterization() { doTest(); }
|
||||
public void testDiamondInLambdaReturn() { doTest(); }
|
||||
public void testIDEA118965() { doTest(); }
|
||||
public void testIDEA121315() { doTest(); }
|
||||
public void testIDEA118965comment() { doTest(); }
|
||||
public void testIDEA122074() { doTest(); }
|
||||
public void testIDEA122084() { doTest(); }
|
||||
public void testAdditionalConstraintDependsOnNonMentionedVars() { doTest(); }
|
||||
public void testIDEA122616() { doTest(); }
|
||||
public void testIDEA122700() { doTest(); }
|
||||
public void testIDEA122406() { doTest(); }
|
||||
public void testNestedCallsInsideLambdaReturnExpression() { doTest(); }
|
||||
public void testIDEA123731() { doTest(); }
|
||||
public void testIDEA123869() { doTest(); }
|
||||
public void testIDEA123848() { doTest(); }
|
||||
public void testOnlyLambdaAtTypeParameterPlace() { doTest(); }
|
||||
public void testLiftedIntersectionType() { doTest(); }
|
||||
public void testInferenceFromReturnStatements() { doTest(); }
|
||||
public void testDownUpThroughLambdaReturnStatements() { doTest(); }
|
||||
public void testIDEA124547() { doTest(); }
|
||||
public void testIDEA118362() { doTest(); }
|
||||
public void testIDEA126056() { doTest(); }
|
||||
public void testIDEA125254() { doTest(); }
|
||||
public void testIDEA124961() { doTest(); }
|
||||
public void testIDEA126109() { doTest(); }
|
||||
public void testIDEA126809() { doTest(); }
|
||||
|
||||
public void testIDEA113573() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA112922() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA113504() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAfterAbstractPipeline2() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA116252() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA106670() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA116548() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOverloadResolutionSAM() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntersectionTypesDuringInference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncludeConstraintsWhenParentMethodIsDuringCalculation() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUseCalculatedSubstitutor() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArgumentOfAnonymousClass() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEllipsis() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOuterMethodPropagation() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRecursiveCalls() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testGroundTargetTypeForImplicitLambdas() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdditionalConstraintsReduceOrder() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdditionalConstraintSubstitution() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
public void testFunctionalInterfacesCalculation() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA120992() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA119535() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA119003() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA117124() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWildcardParameterization() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDiamondInLambdaReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA118965() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA121315() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA118965comment() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122074() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122084() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdditionalConstraintDependsOnNonMentionedVars() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122616() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122700() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122406() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNestedCallsInsideLambdaReturnExpression() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA123731() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA123869() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA123848() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOnlyLambdaAtTypeParameterPlace() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLiftedIntersectionType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferenceFromReturnStatements() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDownUpThroughLambdaReturnStatements() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA124547() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA118362() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA126056() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA125254() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA124961() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA126109() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA126809() throws Exception {
|
||||
public void testIDEA127596() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
+15
-1
@@ -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.codeInsight.daemon.quickFix;
|
||||
|
||||
public class RenameWrongReferenceTest extends LightQuickFixAvailabilityTestCase {
|
||||
@@ -9,4 +24,3 @@ public class RenameWrongReferenceTest extends LightQuickFixAvailabilityTestCase
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/renameWrongReference";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -608,7 +608,7 @@ class Test {
|
||||
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) {
|
||||
pubic void configure(boolean testNow, boolean shouldIgnoreRoots, int times, float pii, String title, char terminate, File file) {
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
@@ -672,7 +672,7 @@ public class VarArgTest {
|
||||
assert regions[1].placeholderText == "test: 13"
|
||||
}
|
||||
|
||||
public void "test inline if argument length is one (EA-57555)"() {
|
||||
public void "test do not inline if parameter length is one or two"() {
|
||||
def text = """
|
||||
public class CharSymbol {
|
||||
|
||||
@@ -681,7 +681,7 @@ public class CharSymbol {
|
||||
count(1, false);
|
||||
}
|
||||
|
||||
public void count(int test, boolean fast) {
|
||||
public void count(int t, boolean fa) {
|
||||
int temp = test;
|
||||
boolean isFast = fast;
|
||||
}
|
||||
@@ -689,13 +689,47 @@ public class CharSymbol {
|
||||
"""
|
||||
configure text
|
||||
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
|
||||
assert regions.size() == 4
|
||||
assert regions.size() == 2
|
||||
}
|
||||
|
||||
checkRangeOffsetByPositionInText(regions[1], text, "1")
|
||||
assert regions[1].placeholderText == "test: 1"
|
||||
public void "test do not inline paired ranged names"() {
|
||||
def text = """
|
||||
public class CharSymbol {
|
||||
|
||||
checkRangeOffsetByPositionInText(regions[2], text, "false")
|
||||
assert regions[2].placeholderText == "fast: false"
|
||||
public void main() {
|
||||
String s = "AAA";
|
||||
int last = 3;
|
||||
|
||||
substring1(1, last);
|
||||
substring2(1, last);
|
||||
substring3(1, last);
|
||||
substring4(1, last);
|
||||
}
|
||||
|
||||
public void substring1(int beginIndex, int endIndex) {
|
||||
int start = beginIndex;
|
||||
int end = endIndex;
|
||||
}
|
||||
|
||||
public void substring2(int startIndex, int endIndex) {
|
||||
int start = beginIndex;
|
||||
int end = endIndex;
|
||||
}
|
||||
|
||||
public void substring3(int from, int to) {
|
||||
int start = beginIndex;
|
||||
int end = endIndex;
|
||||
}
|
||||
|
||||
public void substring4(int first, int last) {
|
||||
int start = beginIndex;
|
||||
int end = endIndex;
|
||||
}
|
||||
}
|
||||
"""
|
||||
configure text
|
||||
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
|
||||
assert regions.size() == 5
|
||||
}
|
||||
|
||||
public void "test inline names if literal expression can be assigned to method parameter"() {
|
||||
@@ -764,7 +798,7 @@ public class Test {
|
||||
}
|
||||
|
||||
abstract class Checker {
|
||||
Checker(boolean applyToFirst, boolean applyToSecond) {}
|
||||
Checker(boolean isActive, boolean requestFocus) {}
|
||||
abstract void test();
|
||||
}
|
||||
}
|
||||
@@ -773,8 +807,8 @@ public class Test {
|
||||
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"
|
||||
assert regions[1].placeholderText == "isActive: true"
|
||||
assert regions[2].placeholderText == "requestFocus: false"
|
||||
|
||||
checkRangeOffsetByPositionInText(regions[1], text, "true")
|
||||
checkRangeOffsetByPositionInText(regions[2], text, "false")
|
||||
|
||||
@@ -88,6 +88,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
doTestField();
|
||||
}
|
||||
|
||||
public void testPInsidePre() throws Exception {
|
||||
doTestField();
|
||||
}
|
||||
|
||||
public void testEnumConstantOrdinal() throws Exception {
|
||||
PsiClass psiClass = getTestClass();
|
||||
PsiField field = psiClass.getFields() [0];
|
||||
|
||||
@@ -188,7 +188,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testDirInfos() throws IOException {
|
||||
checkNotInProject(myRootVFile);
|
||||
assertNotInProject(myRootVFile);
|
||||
|
||||
// beware: files in directory index
|
||||
checkInfo(myFileLibSrc, null, false, true, "", null, myModule);
|
||||
@@ -206,21 +206,21 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
checkInfo(myLibSrcDir, myModule, false, true, "", null, myModule2, myModule3);
|
||||
checkInfo(myLibClsDir, myModule, true, false, "", null, myModule2, myModule3);
|
||||
|
||||
assertEquals(myLibSrcDir, checkInProject(myLibSrcDir).getSourceRoot());
|
||||
assertEquals(myLibSrcDir, assertInProject(myLibSrcDir).getSourceRoot());
|
||||
|
||||
checkInfo(myModule2Dir, myModule2, false, false, null, null);
|
||||
checkInfo(mySrcDir2, myModule2, false, false, "", JavaSourceRootType.SOURCE, myModule2, myModule3);
|
||||
checkNotInProject(myCvsDir);
|
||||
checkExcluded(myExcludeDir, myModule2);
|
||||
checkExcluded(myExcludedLibClsDir, myModule);
|
||||
checkExcluded(myExcludedLibSrcDir, myModule);
|
||||
assertNotInProject(myCvsDir);
|
||||
assertExcluded(myExcludeDir, myModule2);
|
||||
assertExcluded(myExcludedLibClsDir, myModule);
|
||||
assertExcluded(myExcludedLibSrcDir, myModule);
|
||||
|
||||
assertEquals(myModule1Dir, checkInProject(myLibClsDir).getContentRoot());
|
||||
assertEquals(myModule1Dir, assertInProject(myLibClsDir).getContentRoot());
|
||||
|
||||
checkInfo(myModule3Dir, myModule3, false, false, null, null);
|
||||
|
||||
VirtualFile cvs = myPack1Dir.createChildDirectory(this, "CVS");
|
||||
checkNotInProject(cvs);
|
||||
assertNotInProject(cvs);
|
||||
assertNull(ProjectRootManager.getInstance(myProject).getFileIndex().getPackageNameByDirectory(cvs));
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile newDir = myModule1Dir.createChildDirectory(this, "newDir");
|
||||
|
||||
myIndex.checkConsistency();
|
||||
checkInProject(newDir);
|
||||
assertInProject(newDir);
|
||||
|
||||
final FileTypeManagerEx fileTypeManager = (FileTypeManagerEx)FileTypeManager.getInstance();
|
||||
final String list = fileTypeManager.getIgnoredFilesList();
|
||||
@@ -345,7 +345,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
});
|
||||
myIndex.checkConsistency();
|
||||
checkNotInProject(newDir);
|
||||
assertNotInProject(newDir);
|
||||
}
|
||||
finally {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@@ -354,7 +354,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
fileTypeManager.setIgnoredFilesList(list);
|
||||
}
|
||||
});
|
||||
checkInProject(newDir);
|
||||
assertInProject(newDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
|
||||
Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
|
||||
PsiTestUtil.addContentRoot(module, module4);
|
||||
checkNotInProject(ignored);
|
||||
assertNotInProject(ignored);
|
||||
checkInfo(module4, module, false, false, null, null);
|
||||
}
|
||||
}.execute().throwException();
|
||||
@@ -445,20 +445,20 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile output1 = myModule1Dir.createChildDirectory(this, "output1");
|
||||
VirtualFile output2 = myModule1Dir.createChildDirectory(this, "output2");
|
||||
|
||||
checkInProject(output1);
|
||||
checkInProject(output2);
|
||||
assertInProject(output1);
|
||||
assertInProject(output2);
|
||||
|
||||
getCompilerProjectExtension().setCompilerOutputUrl(output1.getUrl());
|
||||
fireRootsChanged();
|
||||
|
||||
checkExcluded(output1, myModule);
|
||||
checkInProject(output2);
|
||||
assertExcluded(output1, myModule);
|
||||
assertInProject(output2);
|
||||
|
||||
getCompilerProjectExtension().setCompilerOutputUrl(output2.getUrl());
|
||||
fireRootsChanged();
|
||||
|
||||
checkInProject(output1);
|
||||
checkExcluded(output2, myModule);
|
||||
assertInProject(output1);
|
||||
assertExcluded(output2, myModule);
|
||||
}
|
||||
|
||||
private void fireRootsChanged() {
|
||||
@@ -482,7 +482,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
public void testModuleSourceAsLibraryClasses() throws Exception {
|
||||
ModuleRootModificationUtil.addModuleLibrary(myModule, "someLib", Arrays.asList(mySrcDir1.getUrl()), Collections.<String>emptyList());
|
||||
checkInfo(mySrcDir1, myModule, true, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertInstanceOf(assertOneElement(checkInProject(mySrcDir1).getOrderEntries()), ModuleSourceOrderEntry.class);
|
||||
assertInstanceOf(assertOneElement(assertInProject(mySrcDir1).getOrderEntries()), ModuleSourceOrderEntry.class);
|
||||
}
|
||||
|
||||
public void testModulesWithSameSourceContentRoot() {
|
||||
@@ -512,7 +512,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
public void testSameSourceAndOutput() {
|
||||
PsiTestUtil.setCompilerOutputPath(myModule, mySrcDir1.getUrl(), false);
|
||||
checkExcluded(mySrcDir1, myModule);
|
||||
assertExcluded(mySrcDir1, myModule);
|
||||
}
|
||||
|
||||
public void testExcludedDirShouldBeExcludedRightAfterItsCreation() throws Exception {
|
||||
@@ -521,10 +521,10 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile module2Output = myModule1Dir.createChildDirectory(this, "module2Output");
|
||||
VirtualFile module2TestOutput = myModule2Dir.createChildDirectory(this, "module2TestOutput");
|
||||
|
||||
checkInProject(excluded);
|
||||
checkInProject(projectOutput);
|
||||
checkInProject(module2Output);
|
||||
checkInProject(module2TestOutput);
|
||||
assertInProject(excluded);
|
||||
assertInProject(projectOutput);
|
||||
assertInProject(module2Output);
|
||||
assertInProject(module2TestOutput);
|
||||
|
||||
getCompilerProjectExtension().setCompilerOutputUrl(projectOutput.getUrl());
|
||||
|
||||
@@ -533,15 +533,10 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
PsiTestUtil.setCompilerOutputPath(myModule2, module2TestOutput.getUrl(), true);
|
||||
PsiTestUtil.setExcludeCompileOutput(myModule2, true);
|
||||
|
||||
checkExcluded(excluded, myModule);
|
||||
checkExcluded(projectOutput, myModule);
|
||||
checkExcluded(module2Output, myModule);
|
||||
checkExcluded(module2TestOutput, myModule2);
|
||||
|
||||
assertFalse(myIndex.isProjectExcludeRoot(excluded));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(projectOutput));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2Output));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2TestOutput));
|
||||
assertExcluded(excluded, myModule);
|
||||
assertExcluded(projectOutput, myModule);
|
||||
assertExcluded(module2Output, myModule);
|
||||
assertExcluded(module2TestOutput, myModule2);
|
||||
|
||||
excluded.delete(this);
|
||||
projectOutput.delete(this);
|
||||
@@ -554,45 +549,25 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
public void fileCreated(@NotNull VirtualFileEvent e) {
|
||||
VirtualFile file = e.getFile();
|
||||
String fileName = e.getFileName();
|
||||
checkExcluded(file, fileName.contains("module2TestOutput") ? myModule2 : myModule);
|
||||
assertExcluded(file, fileName.contains("module2TestOutput") ? myModule2 : myModule);
|
||||
created.add(file);
|
||||
|
||||
if (fileName.equals("projectOutput")) {
|
||||
assertFalse(myIndex.isProjectExcludeRoot(file));
|
||||
}
|
||||
if (fileName.equals("module2Output")) {
|
||||
assertFalse(myIndex.isProjectExcludeRoot(file));
|
||||
}
|
||||
if (fileName.equals("module2TestOutput")) {
|
||||
assertFalse(myIndex.isProjectExcludeRoot(file));
|
||||
}
|
||||
}
|
||||
};
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
|
||||
|
||||
excluded = myModule1Dir.createChildDirectory(this, excluded.getName());
|
||||
assertFalse(myIndex.isProjectExcludeRoot(excluded));
|
||||
|
||||
projectOutput = myModule1Dir.createChildDirectory(this, projectOutput.getName());
|
||||
assertFalse(myIndex.isProjectExcludeRoot(projectOutput));
|
||||
|
||||
module2Output = myModule1Dir.createChildDirectory(this, module2Output.getName());
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2Output));
|
||||
|
||||
module2TestOutput = myModule2Dir.createChildDirectory(this, module2TestOutput.getName());
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2TestOutput));
|
||||
assertExcluded(excluded, myModule);
|
||||
|
||||
checkExcluded(excluded, myModule);
|
||||
checkExcluded(projectOutput, myModule);
|
||||
checkExcluded(module2Output, myModule);
|
||||
checkExcluded(module2TestOutput, myModule2);
|
||||
projectOutput = myModule1Dir.createChildDirectory(this, projectOutput.getName());
|
||||
assertExcluded(projectOutput, myModule);
|
||||
|
||||
module2Output = myModule1Dir.createChildDirectory(this, module2Output.getName());
|
||||
assertExcluded(module2Output, myModule);
|
||||
|
||||
module2TestOutput = myModule2Dir.createChildDirectory(this, module2TestOutput.getName());
|
||||
assertExcluded(module2TestOutput, myModule2);
|
||||
|
||||
assertEquals(created.toString(), 4, created.size());
|
||||
|
||||
assertFalse(myIndex.isProjectExcludeRoot(excluded));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(projectOutput));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2Output));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(module2TestOutput));
|
||||
}
|
||||
|
||||
public void testExcludesShouldBeRecognizedRightOnRefresh() throws Exception {
|
||||
@@ -616,9 +591,9 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
assertEquals("dir", e.getFileName());
|
||||
|
||||
VirtualFile file = e.getFile();
|
||||
checkInProject(file);
|
||||
checkExcluded(file.findFileByRelativePath("excluded"), myModule);
|
||||
checkExcluded(file.findFileByRelativePath("excluded/foo"), myModule);
|
||||
assertInProject(file);
|
||||
assertExcluded(file.findFileByRelativePath("excluded"), myModule);
|
||||
assertExcluded(file.findFileByRelativePath("excluded/foo"), myModule);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -647,8 +622,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
});
|
||||
|
||||
|
||||
checkExcluded(LocalFileSystem.getInstance().findFileByIoFile(f.getParentFile().getParentFile()), myModule);
|
||||
checkInProject(LocalFileSystem.getInstance().findFileByIoFile(f));
|
||||
assertExcluded(LocalFileSystem.getInstance().findFileByIoFile(f.getParentFile().getParentFile()), myModule);
|
||||
assertInProject(LocalFileSystem.getInstance().findFileByIoFile(f));
|
||||
}
|
||||
|
||||
public void testLibraryDirInContent() throws Exception {
|
||||
@@ -670,7 +645,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
checkInfo(myLibSrcDir, myModule, true, true, "", null, myModule, myModule3);
|
||||
|
||||
checkInfo(myResDir, myModule, true, false, "", JavaResourceRootType.RESOURCE, myModule);
|
||||
assertInstanceOf(assertOneElement(checkInProject(myResDir).getOrderEntries()), ModuleSourceOrderEntry.class);
|
||||
assertInstanceOf(assertOneElement(assertInProject(myResDir).getOrderEntries()), ModuleSourceOrderEntry.class);
|
||||
|
||||
checkInfo(myExcludedLibSrcDir, null, true, false, "lib.src.exc", null, myModule3, myModule);
|
||||
checkInfo(myExcludedLibClsDir, null, true, false, "lib.cls.exc", null, myModule3);
|
||||
@@ -690,9 +665,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
assertTrue(fileIndex.isIgnored(myOutputDir));
|
||||
assertTrue(fileIndex.isIgnored(myModule1OutputDir));
|
||||
assertFalse(fileIndex.isIgnored(myOutputDir.getParent()));
|
||||
assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
|
||||
checkExcluded(myOutputDir, null);
|
||||
assertFalse(myIndex.isProjectExcludeRoot(myModule1OutputDir));
|
||||
assertExcludedFromProject(myOutputDir);
|
||||
assertExcludedFromProject(myModule1OutputDir);
|
||||
String moduleOutputUrl = myModule1OutputDir.getUrl();
|
||||
|
||||
myOutputDir.delete(this);
|
||||
@@ -701,10 +675,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
myOutputDir = myRootVFile.createChildDirectory(this, "out");
|
||||
myModule1OutputDir = myOutputDir.createChildDirectory(this, "module1");
|
||||
|
||||
assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
|
||||
checkExcluded(myOutputDir, null);
|
||||
assertTrue(myIndex.isProjectExcludeRoot(myModule1OutputDir));
|
||||
checkExcluded(myModule1OutputDir, null);
|
||||
assertExcludedFromProject(myOutputDir);
|
||||
assertExcludedFromProject(myModule1OutputDir);
|
||||
assertTrue(fileIndex.isIgnored(myModule1OutputDir));
|
||||
|
||||
PsiTestUtil.setCompilerOutputPath(myModule, moduleOutputUrl, true);
|
||||
@@ -714,21 +686,20 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
PsiTestUtil.setCompilerOutputPath(myModule3, moduleOutputUrl, true);
|
||||
|
||||
// now no module inherits project output dir, but it still should be project-excluded
|
||||
assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
|
||||
checkExcluded(myOutputDir, null);
|
||||
assertExcludedFromProject(myOutputDir);
|
||||
|
||||
// project output inside module content shouldn't be projectExcludeRoot
|
||||
VirtualFile projectOutputUnderContent = myModule1Dir.createChildDirectory(this, "projectOutputUnderContent");
|
||||
getCompilerProjectExtension().setCompilerOutputUrl(projectOutputUnderContent.getUrl());
|
||||
fireRootsChanged();
|
||||
|
||||
assertFalse(myIndex.isProjectExcludeRoot(myOutputDir));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(projectOutputUnderContent));
|
||||
|
||||
assertNotExcluded(myOutputDir);
|
||||
assertExcluded(projectOutputUnderContent, myModule);
|
||||
|
||||
projectOutputUnderContent.delete(this);
|
||||
projectOutputUnderContent = myModule1Dir.createChildDirectory(this, "projectOutputUnderContent");
|
||||
assertFalse(myIndex.isProjectExcludeRoot(myOutputDir));
|
||||
assertFalse(myIndex.isProjectExcludeRoot(projectOutputUnderContent));
|
||||
assertNotExcluded(myOutputDir);
|
||||
assertExcluded(projectOutputUnderContent, myModule);
|
||||
}
|
||||
|
||||
public void testFileContentAndSourceRoots() throws IOException {
|
||||
@@ -738,7 +709,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
VirtualFile fileTestSourceRoot = myRootVFile.createChildData(this, "fileTestSourceRoot.txt");
|
||||
|
||||
checkNotInProject(fileRoot);
|
||||
assertNotInProject(fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
|
||||
|
||||
@@ -771,7 +742,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
// removing file content root
|
||||
PsiTestUtil.removeContentEntry(myModule, contentEntry);
|
||||
checkNotInProject(fileRoot);
|
||||
assertNotInProject(fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertFalse(fileIndex.isInSource(fileRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
|
||||
@@ -821,7 +792,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
PsiTestUtil.addExcludedRoot(myModule, fileExcludeRoot);
|
||||
assertFalse(fileIndex.isInContent(fileExcludeRoot));
|
||||
assertFalse(fileIndex.isInSource(fileExcludeRoot));
|
||||
checkExcluded(fileExcludeRoot, myModule);
|
||||
assertExcluded(fileExcludeRoot, myModule);
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileExcludeRoot));
|
||||
|
||||
// removing file exclude root
|
||||
@@ -842,7 +813,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
PsiTestUtil.addExcludedRoot(myModule, fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
checkExcluded(fileRoot, myModule);
|
||||
assertExcluded(fileRoot, myModule);
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot));
|
||||
|
||||
// removing file exclude root
|
||||
@@ -869,7 +840,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile temp = myRootVFile.createChildDirectory(this, "temp");
|
||||
|
||||
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
|
||||
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
|
||||
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
|
||||
@@ -879,7 +850,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
// delete and recreate
|
||||
fileSourceRoot.delete(this);
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
@@ -889,11 +860,11 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
// delete and move from another dir
|
||||
fileSourceRoot.delete(this);
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot.move(this, myRootVFile);
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
@@ -901,11 +872,11 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
// delete and copy from another dir
|
||||
fileSourceRoot.delete(this);
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot = fileSourceRoot.copy(this, myRootVFile, "fileSourceRoot.txt");
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
@@ -913,25 +884,25 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
// delete and rename from another file
|
||||
fileSourceRoot.delete(this);
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = myRootVFile.createChildData(this, "temp_file.txt");
|
||||
checkNotInProject(fileSourceRoot);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot.rename(this, "fileSourceRoot.txt");
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
}
|
||||
|
||||
private void checkInfo(VirtualFile dir,
|
||||
private void checkInfo(VirtualFile file,
|
||||
@Nullable Module module,
|
||||
boolean isInLibrary,
|
||||
boolean isInLibrarySource,
|
||||
@Nullable String packageName,
|
||||
@Nullable final JpsModuleSourceRootType<?> moduleSourceRootType,
|
||||
Module... modulesOfOrderEntries) {
|
||||
DirectoryInfo info = checkInProject(dir);
|
||||
DirectoryInfo info = assertInProject(file);
|
||||
assertEquals(module, info.getModule());
|
||||
if (moduleSourceRootType != null) {
|
||||
assertTrue("isInModuleSource", info.isInModuleSource());
|
||||
@@ -944,8 +915,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
assertEquals(isInLibrarySource, info.isInLibrarySource());
|
||||
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
if (dir.isDirectory()) {
|
||||
assertEquals(packageName, fileIndex.getPackageNameByDirectory(dir));
|
||||
if (file.isDirectory()) {
|
||||
assertEquals(packageName, fileIndex.getPackageNameByDirectory(file));
|
||||
}
|
||||
|
||||
assertEquals(Arrays.toString(info.getOrderEntries()), modulesOfOrderEntries.length, info.getOrderEntries().length);
|
||||
@@ -955,25 +926,33 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNotInProject(VirtualFile dir) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(dir);
|
||||
private void assertNotInProject(VirtualFile file) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(file);
|
||||
assertFalse(info.toString(), info.isInProject());
|
||||
assertFalse(info.toString(), info.isExcluded());
|
||||
}
|
||||
|
||||
private void checkExcluded(VirtualFile dir, Module module) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(dir);
|
||||
private void assertExcluded(VirtualFile file, Module module) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(file);
|
||||
assertTrue(info.toString(), info.isExcluded());
|
||||
assertEquals(module, info.getModule());
|
||||
}
|
||||
|
||||
private DirectoryInfo checkInProject(VirtualFile output2) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(output2);
|
||||
assertTrue(output2.toString(), info.isInProject());
|
||||
private DirectoryInfo assertInProject(VirtualFile file) {
|
||||
DirectoryInfo info = myIndex.getInfoForFile(file);
|
||||
assertTrue(file.toString(), info.isInProject());
|
||||
info.assertConsistency();
|
||||
return info;
|
||||
}
|
||||
|
||||
private void assertNotExcluded(VirtualFile file) {
|
||||
assertFalse(myIndex.getInfoForFile(file).isExcluded());
|
||||
}
|
||||
|
||||
private void assertExcludedFromProject(VirtualFile file) {
|
||||
assertExcluded(file, null);
|
||||
}
|
||||
|
||||
private void checkPackage(String packageName, boolean includeLibrarySources, VirtualFile... expectedDirs) {
|
||||
VirtualFile[] actualDirs = myIndex.getDirectoriesByPackageName(packageName, includeLibrarySources).toArray(VirtualFile.EMPTY_ARRAY);
|
||||
assertNotNull(actualDirs);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<orderEntry type="module" module-name="execution-openapi" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="remote-servers-impl" />
|
||||
<orderEntry type="module" module-name="java-impl" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<idea-plugin>
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint qualifiedName="com.intellij.remoteServer.moduleBuilderContribution"
|
||||
interface="com.intellij.remoteServer.impl.module.CloudModuleBuilderContribution"/>
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<applicationService serviceInterface="com.intellij.remoteServer.configuration.deployment.JavaDeploymentSourceUtil"
|
||||
serviceImplementation="com.intellij.remoteServer.impl.configuration.deployment.JavaDeploymentSourceUtilImpl"/>
|
||||
<remoteServer.deploymentSource.type implementation="com.intellij.remoteServer.impl.configuration.deployment.ArtifactDeploymentSourceType"/>
|
||||
<moduleBuilder builderClass="com.intellij.remoteServer.impl.module.CloudModuleBuilder"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.remoteServer.impl.module.CloudAccountSelectionPanel">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="e6946">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="5" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="ae2d8" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Account:"/>
|
||||
<visible value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a54bb" class="javax.swing.JButton" binding="myNewButton">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="New..."/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="54cd4" class="com.intellij.openapi.ui.ComboBox" binding="myAccountComboBox">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.actions.ShowSettingsUtilImpl;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.RemoteServersManager;
|
||||
import com.intellij.remoteServer.impl.configuration.RemoteServerConfigurable;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CloudAccountSelectionPanel {
|
||||
|
||||
private JButton myNewButton;
|
||||
private ComboBox myAccountComboBox;
|
||||
private JPanel myMainPanel;
|
||||
|
||||
private final List<ServerType<?>> myCloudTypes;
|
||||
|
||||
private Runnable myServerSelectionListener;
|
||||
|
||||
public CloudAccountSelectionPanel(List<ServerType<?>> cloudTypes) {
|
||||
myCloudTypes = cloudTypes;
|
||||
|
||||
for (ServerType<?> cloudType : cloudTypes) {
|
||||
for (RemoteServer<?> account : RemoteServersManager.getInstance().getServers(cloudType)) {
|
||||
myAccountComboBox.addItem(new AccountItem(account));
|
||||
}
|
||||
}
|
||||
|
||||
myNewButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onNewButton();
|
||||
}
|
||||
});
|
||||
|
||||
myAccountComboBox.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myServerSelectionListener != null) {
|
||||
myServerSelectionListener.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setAccountSelectionListener(Runnable listener) {
|
||||
myServerSelectionListener = listener;
|
||||
}
|
||||
|
||||
private void onNewButton() {
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
for (final ServerType<?> cloudType : myCloudTypes) {
|
||||
group.add(new AnAction(cloudType.getPresentableName(), cloudType.getPresentableName(), cloudType.getIcon()) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
createAccount(cloudType);
|
||||
}
|
||||
});
|
||||
}
|
||||
JBPopupFactory.getInstance().createActionGroupPopup("New Account", group, DataManager.getInstance().getDataContext(myMainPanel),
|
||||
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
|
||||
.showUnderneathOf(myNewButton);
|
||||
}
|
||||
|
||||
private void createAccount(ServerType<?> cloudType) {
|
||||
RemoteServer<?> newAccount = RemoteServersManager.getInstance().createServer(cloudType, generateServerName(cloudType));
|
||||
|
||||
final Ref<Consumer<String>> errorConsumerRef = new Ref<Consumer<String>>();
|
||||
|
||||
RemoteServerConfigurable configurable = new RemoteServerConfigurable(newAccount, null, true) {
|
||||
|
||||
@Override
|
||||
protected void setConnectionStatusText(boolean error, String text) {
|
||||
super.setConnectionStatusText(error, error ? "" : text);
|
||||
errorConsumerRef.get().consume(error ? text : null);
|
||||
}
|
||||
};
|
||||
|
||||
final SingleConfigurableEditor configurableEditor
|
||||
= new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) {
|
||||
|
||||
{
|
||||
errorConsumerRef.set(new Consumer<String>() {
|
||||
|
||||
@Override
|
||||
public void consume(String s) {
|
||||
setErrorText(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (!configurableEditor.showAndGet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
newAccount.setName(configurable.getDisplayName());
|
||||
|
||||
RemoteServersManager.getInstance().addServer(newAccount);
|
||||
AccountItem newAccountItem = new AccountItem(newAccount);
|
||||
myAccountComboBox.addItem(newAccountItem);
|
||||
myAccountComboBox.setSelectedItem(newAccountItem);
|
||||
}
|
||||
|
||||
public JComponent getMainPanel() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RemoteServer<?> getSelectedAccount() {
|
||||
AccountItem selectedItem = (AccountItem)myAccountComboBox.getSelectedItem();
|
||||
return selectedItem == null ? null : selectedItem.getAccount();
|
||||
}
|
||||
|
||||
private static String generateServerName(ServerType<?> cloudType) {
|
||||
return UniqueNameGenerator.generateUniqueName(cloudType.getPresentableName(), new Condition<String>() {
|
||||
|
||||
@Override
|
||||
public boolean value(String s) {
|
||||
for (RemoteServer<?> server : RemoteServersManager.getInstance().getServers()) {
|
||||
if (server.getName().equals(s)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void validate() throws ConfigurationException {
|
||||
if (getSelectedAccount() == null) {
|
||||
throw new ConfigurationException("Account required");
|
||||
}
|
||||
}
|
||||
|
||||
private static class AccountItem {
|
||||
|
||||
private final RemoteServer<?> myAccount;
|
||||
|
||||
public AccountItem(RemoteServer<?> account) {
|
||||
myAccount = account;
|
||||
}
|
||||
|
||||
public RemoteServer<?> getAccount() {
|
||||
return myAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myAccount.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.runtime.Deployment;
|
||||
import com.intellij.remoteServer.runtime.ServerConnection;
|
||||
import com.intellij.remoteServer.runtime.ServerConnector;
|
||||
import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
|
||||
import com.intellij.remoteServer.util.*;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
||||
public abstract class CloudApplicationConfigurable<
|
||||
SC extends CloudConfigurationBase,
|
||||
DC extends CloudDeploymentNameConfiguration,
|
||||
SR extends CloudMultiSourceServerRuntimeInstance<DC, ?, ?, ?>,
|
||||
AC extends CloudApplicationConfiguration> {
|
||||
|
||||
private final Project myProject;
|
||||
private final Disposable myParentDisposable;
|
||||
|
||||
private DelayedRunner myRunner;
|
||||
|
||||
private RemoteServer<?> myAccount;
|
||||
|
||||
public CloudApplicationConfigurable(@Nullable Project project, Disposable parentDisposable) {
|
||||
myProject = project;
|
||||
myParentDisposable = parentDisposable;
|
||||
}
|
||||
|
||||
public void setAccount(RemoteServer<?> account) {
|
||||
myAccount = account;
|
||||
clearCloudData();
|
||||
}
|
||||
|
||||
protected RemoteServer<SC> getAccount() {
|
||||
return (RemoteServer<SC>)myAccount;
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
JComponent result = getMainPanel();
|
||||
if (myRunner == null) {
|
||||
myRunner = new DelayedRunner(result) {
|
||||
|
||||
private RemoteServer<?> myPreviousAccount;
|
||||
|
||||
@Override
|
||||
protected boolean wasChanged() {
|
||||
boolean result = myPreviousAccount != myAccount;
|
||||
if (result) {
|
||||
myPreviousAccount = myAccount;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
loadCloudData();
|
||||
}
|
||||
};
|
||||
Disposer.register(myParentDisposable, myRunner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void clearCloudData() {
|
||||
getExistingComboBox().removeAllItems();
|
||||
}
|
||||
|
||||
protected void loadCloudData() {
|
||||
new ConnectionTask<Collection<Deployment>>("Loading existing applications list") {
|
||||
|
||||
@Override
|
||||
protected void run(final ServerConnection<DC> connection,
|
||||
final Semaphore semaphore,
|
||||
final AtomicReference<Collection<Deployment>> result) {
|
||||
connection.connectIfNeeded(new ServerConnector.ConnectionCallback<DC>() {
|
||||
|
||||
@Override
|
||||
public void connected(@NotNull ServerRuntimeInstance<DC> serverRuntimeInstance) {
|
||||
connection.computeDeployments(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
result.set(connection.getDeployments());
|
||||
semaphore.up();
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Disposer.isDisposed(myParentDisposable)) {
|
||||
setupExistingApplications(result.get());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
runtimeErrorOccurred(errorMessage);
|
||||
semaphore.up();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Deployment> run(SR serverRuntimeInstance) throws ServerRuntimeException {
|
||||
return null;
|
||||
}
|
||||
}.performAsync();
|
||||
}
|
||||
|
||||
private void setupExistingApplications(Collection<Deployment> deployments) {
|
||||
JComboBox existingComboBox = getExistingComboBox();
|
||||
existingComboBox.removeAllItems();
|
||||
for (Deployment deployment : deployments) {
|
||||
existingComboBox.addItem(deployment.getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
protected abstract JComboBox getExistingComboBox();
|
||||
|
||||
protected abstract JComponent getMainPanel();
|
||||
|
||||
public abstract AC createConfiguration();
|
||||
|
||||
public abstract void validate() throws ConfigurationException;
|
||||
|
||||
protected abstract class ConnectionTask<T> extends CloudConnectionTask<T, SC, DC, SR> {
|
||||
|
||||
public ConnectionTask(String title) {
|
||||
super(myProject, title, CloudApplicationConfigurable.this.getAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
|
||||
public abstract class CloudApplicationConfiguration {
|
||||
|
||||
private boolean myExisting;
|
||||
private final String myExistingAppName;
|
||||
|
||||
protected CloudApplicationConfiguration(boolean existing, String existingAppName) {
|
||||
myExisting = existing;
|
||||
myExistingAppName = existingAppName;
|
||||
}
|
||||
|
||||
public boolean isExisting() {
|
||||
return myExisting;
|
||||
}
|
||||
|
||||
public String getExistingAppName() {
|
||||
return myExistingAppName;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilderListener;
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.module.JavaModuleType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
public class CloudModuleBuilder extends JavaModuleBuilder {
|
||||
|
||||
private RemoteServer<?> myAccount;
|
||||
private CloudApplicationConfiguration myApplicationConfiguration;
|
||||
|
||||
public CloudModuleBuilder() {
|
||||
addListener(new ModuleBuilderListener() {
|
||||
|
||||
@Override
|
||||
public void moduleCreated(@NotNull Module module) {
|
||||
configureModule(module);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getBuilderId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBigIcon() {
|
||||
return AllIcons.General.Balloon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getNodeIcon() {
|
||||
return AllIcons.General.Balloon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Java module of PAAS cloud application";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "Clouds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupName() {
|
||||
return "Clouds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentGroup() {
|
||||
return JavaModuleType.JAVA_GROUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
|
||||
return ModuleWizardStep.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
|
||||
return new CloudModuleWizardStep(this, context.getProject(), parentDisposable);
|
||||
}
|
||||
|
||||
public void setAccount(RemoteServer<?> account) {
|
||||
myAccount = account;
|
||||
}
|
||||
|
||||
public RemoteServer<?> getAccount() {
|
||||
return myAccount;
|
||||
}
|
||||
|
||||
public void setApplicationConfiguration(CloudApplicationConfiguration applicationConfiguration) {
|
||||
myApplicationConfiguration = applicationConfiguration;
|
||||
}
|
||||
|
||||
private void configureModule(final Module module) {
|
||||
CloudModuleBuilderContribution.getInstanceByType(myAccount.getType()).configureModule(module, myAccount, myApplicationConfiguration);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
public abstract class CloudModuleBuilderContribution {
|
||||
|
||||
public static final ExtensionPointName<CloudModuleBuilderContribution> EP_NAME
|
||||
= ExtensionPointName.create("com.intellij.remoteServer.moduleBuilderContribution");
|
||||
|
||||
public abstract ServerType<?> getCloudType();
|
||||
|
||||
public abstract CloudApplicationConfigurable createApplicationConfigurable(@Nullable Project project, Disposable parentDisposable);
|
||||
|
||||
public abstract void configureModule(Module module,
|
||||
RemoteServer<?> account,
|
||||
CloudApplicationConfiguration configuration);
|
||||
|
||||
public static CloudModuleBuilderContribution getInstanceByType(ServerType<?> cloudType) {
|
||||
for (CloudModuleBuilderContribution contribution : EP_NAME.getExtensions()) {
|
||||
if (contribution.getCloudType() == cloudType) {
|
||||
return contribution;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;
|
||||
|
||||
import com.intellij.execution.RunManagerEx;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.openapi.module.ModulePointerManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.impl.configuration.deployment.DeployToServerConfigurationType;
|
||||
import com.intellij.remoteServer.impl.configuration.deployment.DeployToServerRunConfiguration;
|
||||
import com.intellij.remoteServer.impl.configuration.deployment.ModuleDeploymentSourceImpl;
|
||||
import com.intellij.remoteServer.util.*;
|
||||
import com.intellij.remoteServer.util.ssh.SshKeyChecker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
public abstract class CloudModuleBuilderContributionBase<
|
||||
SC extends CloudConfigurationBase,
|
||||
DC extends CloudDeploymentNameConfiguration,
|
||||
AC extends CloudApplicationConfiguration,
|
||||
SR extends CloudMultiSourceServerRuntimeInstance<DC, ?, ?, ?>>
|
||||
extends CloudModuleBuilderContribution {
|
||||
|
||||
@Override
|
||||
public void configureModule(Module module,
|
||||
RemoteServer<?> account,
|
||||
CloudApplicationConfiguration applicationConfiguration) {
|
||||
RemoteServer<SC> castedAccount = (RemoteServer<SC>)account;
|
||||
final AC castedApplicationConfiguration = (AC)applicationConfiguration;
|
||||
|
||||
DC deploymentConfiguration = createDeploymentConfiguration();
|
||||
|
||||
if (applicationConfiguration.isExisting()) {
|
||||
deploymentConfiguration.setDefaultDeploymentName(false);
|
||||
deploymentConfiguration.setDeploymentName(applicationConfiguration.getExistingAppName());
|
||||
}
|
||||
|
||||
final DeployToServerRunConfiguration<SC, DC> runConfiguration = createRunConfiguration(module, castedAccount, deploymentConfiguration);
|
||||
|
||||
final String cloudName = account.getType().getPresentableName();
|
||||
final Project project = module.getProject();
|
||||
new CloudConnectionTask<Object, SC, DC, SR>(project, CloudBundle.getText("cloud.support", cloudName), castedAccount) {
|
||||
|
||||
CloudNotifier myNotifier = new CloudNotifier(cloudName);
|
||||
|
||||
boolean myFirstAttempt = true;
|
||||
|
||||
@Override
|
||||
protected Object run(SR serverRuntime) throws ServerRuntimeException {
|
||||
doConfigureModule(castedApplicationConfiguration, runConfiguration, myFirstAttempt, serverRuntime);
|
||||
myNotifier.showMessage(CloudBundle.getText("cloud.support.added", cloudName), MessageType.INFO);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runtimeErrorOccurred(@NotNull String errorMessage) {
|
||||
myFirstAttempt = false;
|
||||
new SshKeyChecker().checkServerError(errorMessage, myNotifier, project, this);
|
||||
}
|
||||
}.performAsync();
|
||||
}
|
||||
|
||||
private DeployToServerRunConfiguration<SC, DC> createRunConfiguration(Module module,
|
||||
RemoteServer<SC> server,
|
||||
DC deploymentConfiguration) {
|
||||
Project project = module.getProject();
|
||||
|
||||
String serverName = server.getName();
|
||||
|
||||
String name = generateRunConfigurationName(serverName, module.getName());
|
||||
|
||||
final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
|
||||
final RunnerAndConfigurationSettings runSettings
|
||||
= runManager.createRunConfiguration(name, getRunConfigurationType().getConfigurationFactories()[0]);
|
||||
|
||||
final DeployToServerRunConfiguration<SC, DC> result = (DeployToServerRunConfiguration<SC, DC>)runSettings.getConfiguration();
|
||||
|
||||
result.setServerName(serverName);
|
||||
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(project).create(module);
|
||||
result.setDeploymentSource(new ModuleDeploymentSourceImpl(modulePointer));
|
||||
|
||||
result.setDeploymentConfiguration(deploymentConfiguration);
|
||||
|
||||
runManager.addConfiguration(runSettings, false);
|
||||
runManager.setSelectedConfiguration(runSettings);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String generateRunConfigurationName(String serverName, String moduleName) {
|
||||
return CloudBundle.getText("run.configuration.name", serverName, moduleName);
|
||||
}
|
||||
|
||||
private DeployToServerConfigurationType getRunConfigurationType() {
|
||||
String id = DeployToServerConfigurationType.getId(getCloudType());
|
||||
for (ConfigurationType configurationType : ConfigurationType.CONFIGURATION_TYPE_EP.getExtensions()) {
|
||||
if (configurationType instanceof DeployToServerConfigurationType) {
|
||||
DeployToServerConfigurationType deployConfigurationType = (DeployToServerConfigurationType)configurationType;
|
||||
if (deployConfigurationType.getId().equals(id)) {
|
||||
return deployConfigurationType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract ServerType<SC> getCloudType();
|
||||
|
||||
@Override
|
||||
public abstract CloudApplicationConfigurable<SC, DC, SR, AC> createApplicationConfigurable(@Nullable Project project,
|
||||
Disposable parentDisposable);
|
||||
|
||||
protected abstract DC createDeploymentConfiguration();
|
||||
|
||||
protected abstract void doConfigureModule(AC applicationConfiguration,
|
||||
DeployToServerRunConfiguration<SC, DC> runConfiguration,
|
||||
boolean firstAttempt,
|
||||
SR serverRuntime) throws ServerRuntimeException;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.remoteServer.impl.module.CloudModuleWizardStep">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="415" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b29a2" binding="myAccountPanelPlaceHolder" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="276c3">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="dd5e7" class="com.intellij.ui.TitledSeparator">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Account"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="61d9c" class="com.intellij.ui.TitledSeparator">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Application"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="582a2" binding="myApplicationPanelPlaceHolder" layout-manager="CardLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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.remoteServer.impl.module;/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class CloudModuleWizardStep extends ModuleWizardStep {
|
||||
|
||||
private JPanel myMainPanel;
|
||||
private JPanel myAccountPanelPlaceHolder;
|
||||
private JPanel myApplicationPanelPlaceHolder;
|
||||
|
||||
private final CloudModuleBuilder myModuleBuilder;
|
||||
private final Project myProject;
|
||||
private final Disposable myParentDisposable;
|
||||
|
||||
private CloudAccountSelectionPanel myAccountSelectionPanel;
|
||||
|
||||
private Map<ServerType<?>, CloudApplicationConfigurable> myCloudType2ApplicationConfigurable;
|
||||
|
||||
public CloudModuleWizardStep(CloudModuleBuilder moduleBuilder, Project project, Disposable parentDisposable) {
|
||||
myModuleBuilder = moduleBuilder;
|
||||
myProject = project;
|
||||
myParentDisposable = parentDisposable;
|
||||
|
||||
myCloudType2ApplicationConfigurable = new HashMap<ServerType<?>, CloudApplicationConfigurable>();
|
||||
|
||||
List<ServerType<?>> cloudTypes = new ArrayList<ServerType<?>>();
|
||||
for (CloudModuleBuilderContribution contribution : CloudModuleBuilderContribution.EP_NAME.getExtensions()) {
|
||||
cloudTypes.add(contribution.getCloudType());
|
||||
}
|
||||
|
||||
myAccountSelectionPanel = new CloudAccountSelectionPanel(cloudTypes);
|
||||
myAccountPanelPlaceHolder.add(myAccountSelectionPanel.getMainPanel());
|
||||
|
||||
myAccountSelectionPanel.setAccountSelectionListener(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
onAccountSelectionChanged();
|
||||
}
|
||||
});
|
||||
onAccountSelectionChanged();
|
||||
}
|
||||
|
||||
private RemoteServer<?> getSelectedAccount() {
|
||||
return myAccountSelectionPanel.getSelectedAccount();
|
||||
}
|
||||
|
||||
private void onAccountSelectionChanged() {
|
||||
CardLayout applicationPlaceHolderLayout = (CardLayout)myApplicationPanelPlaceHolder.getLayout();
|
||||
|
||||
RemoteServer<?> account = getSelectedAccount();
|
||||
boolean haveAccount = account != null;
|
||||
myApplicationPanelPlaceHolder.setVisible(haveAccount);
|
||||
if (!haveAccount) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServerType<?> cloudType = account.getType();
|
||||
String cardName = cloudType.getId();
|
||||
CloudApplicationConfigurable<?, ?, ?, ?> applicationConfigurable = getApplicationConfigurable();
|
||||
if (applicationConfigurable == null) {
|
||||
applicationConfigurable
|
||||
= CloudModuleBuilderContribution.getInstanceByType(cloudType).createApplicationConfigurable(myProject, myParentDisposable);
|
||||
myCloudType2ApplicationConfigurable.put(cloudType, applicationConfigurable);
|
||||
myApplicationPanelPlaceHolder.add(applicationConfigurable.getComponent(), cardName);
|
||||
}
|
||||
applicationPlaceHolderLayout.show(myApplicationPanelPlaceHolder, cardName);
|
||||
|
||||
applicationConfigurable.setAccount(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
private CloudApplicationConfigurable<?, ?, ?, ?> getApplicationConfigurable() {
|
||||
RemoteServer<?> account = getSelectedAccount();
|
||||
if (account == null) {
|
||||
return null;
|
||||
}
|
||||
return myCloudType2ApplicationConfigurable.get(account.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataModel() {
|
||||
myModuleBuilder.setAccount(myAccountSelectionPanel.getSelectedAccount());
|
||||
CloudApplicationConfigurable<?, ?, ?, ?> configurable = getApplicationConfigurable();
|
||||
myModuleBuilder.setApplicationConfiguration(configurable == null ? null : configurable.createConfiguration());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ConfigurationException {
|
||||
myAccountSelectionPanel.validate();
|
||||
CloudApplicationConfigurable<?, ?, ?, ?> configurable = getApplicationConfigurable();
|
||||
if (configurable != null) {
|
||||
configurable.validate();
|
||||
}
|
||||
return super.validate();
|
||||
}
|
||||
}
|
||||
+4
-18
@@ -411,7 +411,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
final ParameterInfo initInfo = builder.findParameterization(Replacer.stripTypedVariableDecoration(initText));
|
||||
|
||||
if (initInfo != null) {
|
||||
initInfo.setVariableInitialContext(true);
|
||||
initInfo.setVariableInitializerContext(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,20 +431,6 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethod(PsiMethod method) {
|
||||
super.visitMethod(method);
|
||||
|
||||
String name = method.getName();
|
||||
if (StructuralSearchUtil.isTypedVariable(name)) {
|
||||
name = Replacer.stripTypedVariableDecoration(name);
|
||||
|
||||
ParameterInfo methodInfo = builder.findParameterization(name);
|
||||
methodInfo.setScopeParameterization(true);
|
||||
//if (scopedParameterizations != null) scopedParameterizations.put(method.getTextRange(), methodInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitParameter(PsiParameter parameter) {
|
||||
super.visitParameter(parameter);
|
||||
@@ -462,8 +448,8 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
ParameterInfo typeInfo = builder.findParameterization(type);
|
||||
|
||||
if (nameInfo != null && typeInfo != null && !(parameter.getParent() instanceof PsiCatchSection)) {
|
||||
nameInfo.setParameterContext(false);
|
||||
typeInfo.setParameterContext(false);
|
||||
nameInfo.setArgumentContext(false);
|
||||
typeInfo.setArgumentContext(false);
|
||||
typeInfo.setMethodParameterContext(true);
|
||||
nameInfo.setMethodParameterContext(true);
|
||||
typeInfo.setElement(parameter.getTypeElement());
|
||||
@@ -524,7 +510,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
buf.append('\n');
|
||||
}
|
||||
}
|
||||
else if (info.isParameterContext()) {
|
||||
else if (info.isArgumentContext()) {
|
||||
buf.append(',');
|
||||
}
|
||||
else if (parent instanceof PsiClass) {
|
||||
|
||||
+9
-13
@@ -321,18 +321,14 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
@Override
|
||||
public void visitNameValuePair(PsiNameValuePair pair) {
|
||||
final PsiIdentifier nameIdentifier = pair.getNameIdentifier();
|
||||
if (nameIdentifier == null) {
|
||||
myMatchingVisitor.setResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiNameValuePair elementNameValuePair = (PsiNameValuePair)myMatchingVisitor.getElement();
|
||||
PsiIdentifier matchedNameValuePair = elementNameValuePair.getNameIdentifier();
|
||||
final PsiIdentifier otherIdentifier = elementNameValuePair.getNameIdentifier();
|
||||
|
||||
PsiAnnotationMemberValue annotationInitializer = pair.getValue();
|
||||
final PsiAnnotationMemberValue annotationInitializer = pair.getValue();
|
||||
if (annotationInitializer != null) {
|
||||
boolean isTypedInitializer = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(annotationInitializer) &&
|
||||
annotationInitializer instanceof PsiReferenceExpression;
|
||||
final boolean isTypedInitializer = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(annotationInitializer) &&
|
||||
annotationInitializer instanceof PsiReferenceExpression;
|
||||
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(annotationInitializer, elementNameValuePair.getValue()) ||
|
||||
(isTypedInitializer &&
|
||||
@@ -344,13 +340,13 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(nameIdentifier);
|
||||
|
||||
if (handler instanceof SubstitutionHandler) {
|
||||
myMatchingVisitor
|
||||
.setResult(((SubstitutionHandler)handler).handle(matchedNameValuePair,
|
||||
myMatchingVisitor.getMatchContext()));
|
||||
myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(otherIdentifier, myMatchingVisitor.getMatchContext()));
|
||||
}
|
||||
else if (nameIdentifier != null) {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(nameIdentifier, otherIdentifier));
|
||||
}
|
||||
else {
|
||||
myMatchingVisitor
|
||||
.setResult(myMatchingVisitor.match(nameIdentifier, matchedNameValuePair));
|
||||
myMatchingVisitor.setResult(otherIdentifier == null || otherIdentifier.getText().equals("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ public class HighlightDisplayLevel {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ImageHolder {
|
||||
private static final Image ourErrorMaskImage = ImageLoader.loadFromResource("/general/errorMask.png");
|
||||
public static class ImageHolder {
|
||||
public static final Image ourErrorMaskImage = ImageLoader.loadFromResource("/general/errorMask.png");
|
||||
}
|
||||
|
||||
private static final int EMPTY_ICON_DIM = 12;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public abstract class ProgressIndicatorProvider {
|
||||
@Nullable
|
||||
public static volatile ProgressIndicatorProvider ourInstance;
|
||||
public static ProgressIndicatorProvider ourInstance;
|
||||
|
||||
@Nullable
|
||||
public static ProgressIndicatorProvider getInstance() {
|
||||
@@ -36,27 +36,22 @@ public abstract class ProgressIndicatorProvider {
|
||||
|
||||
@Nullable
|
||||
public static ProgressIndicator getGlobalProgressIndicator() {
|
||||
ProgressIndicatorProvider provider = ourInstance;
|
||||
return provider != null ? provider.getProgressIndicator() : null;
|
||||
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
|
||||
}
|
||||
|
||||
public abstract NonCancelableSection startNonCancelableSection();
|
||||
|
||||
@NotNull
|
||||
public static NonCancelableSection startNonCancelableSectionIfSupported() {
|
||||
ProgressIndicatorProvider provider = ourInstance;
|
||||
return provider != null ? provider.startNonCancelableSection() : NonCancelableSection.EMPTY;
|
||||
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY;
|
||||
}
|
||||
|
||||
public static volatile boolean ourNeedToCheckCancel = false;
|
||||
public static void checkCanceled() throws ProcessCanceledException {
|
||||
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
|
||||
if (ourNeedToCheckCancel) {
|
||||
ProgressIndicatorProvider provider = ourInstance;
|
||||
if (provider != null) {
|
||||
provider.doCheckCanceled();
|
||||
ourNeedToCheckCancel = false;
|
||||
}
|
||||
if (ourNeedToCheckCancel && ourInstance != null) {
|
||||
ourInstance.doCheckCanceled();
|
||||
ourNeedToCheckCancel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,13 @@ public abstract class ProgressManager {
|
||||
};
|
||||
}
|
||||
|
||||
private static volatile ProgressManager ourInstance;
|
||||
private static ProgressManager ourInstance;
|
||||
|
||||
public static ProgressManager getInstance() {
|
||||
ProgressManager progressManager = ourInstance;
|
||||
if (progressManager == null) {
|
||||
ourInstance = progressManager = ServiceManager.getService(ProgressManager.class);
|
||||
if (ourInstance == null) {
|
||||
ourInstance = ServiceManager.getService(ProgressManager.class);
|
||||
}
|
||||
return progressManager;
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
public abstract boolean hasProgressIndicator();
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.keymap.MacKeymapUtil;
|
||||
import com.intellij.openapi.keymap.impl.ModifierKeyDoubleClickHandler;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -151,106 +152,25 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
private Component myContextComponent;
|
||||
private CalcThread myCalcThread;
|
||||
private static AtomicBoolean ourShiftIsPressed = new AtomicBoolean(false);
|
||||
private final static Couple<AtomicBoolean> ourPressed = Couple.of(new AtomicBoolean(false), new AtomicBoolean(false));
|
||||
private final static Couple<AtomicBoolean> ourReleased = Couple.of(new AtomicBoolean(false), new AtomicBoolean(false));
|
||||
private static AtomicBoolean ourOtherKeyWasPressed = new AtomicBoolean(false);
|
||||
private static AtomicLong ourLastTimePressed = new AtomicLong(0);
|
||||
private static AtomicBoolean showAll = new AtomicBoolean(false);
|
||||
private volatile ActionCallback myCurrentWorker = ActionCallback.DONE;
|
||||
private int myHistoryIndex = 0;
|
||||
boolean mySkipFocusGain = false;
|
||||
|
||||
static {
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_SEARCH_EVERYWHERE, KeyEvent.VK_SHIFT, -1);
|
||||
|
||||
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
|
||||
@Override
|
||||
public boolean dispatch(AWTEvent event) {
|
||||
if (event instanceof KeyEvent) {
|
||||
final KeyEvent keyEvent = (KeyEvent)event;
|
||||
final int keyCode = keyEvent.getKeyCode();
|
||||
|
||||
final int keyCode = ((KeyEvent)event).getKeyCode();
|
||||
if (keyCode == KeyEvent.VK_SHIFT) {
|
||||
ourShiftIsPressed.set(event.getID() == KeyEvent.KEY_PRESSED);
|
||||
|
||||
if (keyEvent.isControlDown() || keyEvent.isAltDown() || keyEvent.isMetaDown()) {
|
||||
resetState();
|
||||
return false;
|
||||
}
|
||||
if (ourOtherKeyWasPressed.get() && System.currentTimeMillis() - ourLastTimePressed.get() < 500) {
|
||||
resetState();
|
||||
return false;
|
||||
}
|
||||
ourOtherKeyWasPressed.set(false);
|
||||
if (ourPressed.first.get() && System.currentTimeMillis() - ourLastTimePressed.get() > 500) {
|
||||
resetState();
|
||||
}
|
||||
handleShift((KeyEvent)event);
|
||||
return false;
|
||||
} else {
|
||||
ourLastTimePressed.set(System.currentTimeMillis());
|
||||
ourOtherKeyWasPressed.set(true);
|
||||
if (keyCode == KeyEvent.VK_ESCAPE || keyCode == KeyEvent.VK_TAB) {
|
||||
ourLastTimePressed.set(0);
|
||||
}
|
||||
}
|
||||
resetState();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void resetState() {
|
||||
ourPressed.first.set(false);
|
||||
ourPressed.second.set(false);
|
||||
ourReleased.first.set(false);
|
||||
ourReleased.second.set(false);
|
||||
}
|
||||
|
||||
private void handleShift(KeyEvent event) {
|
||||
if (ourPressed.first.get() && System.currentTimeMillis() - ourLastTimePressed.get() > 300) {
|
||||
resetState();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getID() == KeyEvent.KEY_PRESSED) {
|
||||
if (!ourPressed.first.get()) {
|
||||
resetState();
|
||||
ourPressed.first.set(true);
|
||||
ourLastTimePressed.set(System.currentTimeMillis());
|
||||
return;
|
||||
} else {
|
||||
if (ourPressed.first.get() && ourReleased.first.get()) {
|
||||
ourPressed.second.set(true);
|
||||
ourLastTimePressed.set(System.currentTimeMillis());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (event.getID() == KeyEvent.KEY_RELEASED) {
|
||||
if (ourPressed.first.get() && !ourReleased.first.get()) {
|
||||
ourReleased.first.set(true);
|
||||
ourLastTimePressed.set(System.currentTimeMillis());
|
||||
return;
|
||||
} else if (ourPressed.first.get() && ourReleased.first.get() && ourPressed.second.get()) {
|
||||
resetState();
|
||||
run(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
resetState();
|
||||
}
|
||||
|
||||
private void run(KeyEvent event) {
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
final AnAction action = actionManager.getAction(IdeActions.ACTION_SEARCH_EVERYWHERE);
|
||||
if (KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE).length > 0) {
|
||||
return;
|
||||
}
|
||||
final AnActionEvent anActionEvent = new AnActionEvent(event,
|
||||
DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner()),
|
||||
ActionPlaces.MAIN_MENU,
|
||||
action.getTemplatePresentation(),
|
||||
actionManager,
|
||||
0);
|
||||
action.actionPerformed(anActionEvent);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@@ -1796,8 +1716,9 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
GotoActionModel model = new GotoActionModel(project, myFocusComponent, myEditor, myFile) {
|
||||
@Override
|
||||
protected MatchMode actionMatches(String pattern, @NotNull AnAction anAction) {
|
||||
return NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE)
|
||||
.matches(anAction.getTemplatePresentation().getText()) ? MatchMode.NAME : MatchMode.NONE;
|
||||
String text = anAction.getTemplatePresentation().getText();
|
||||
return text != null && NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE)
|
||||
.matches(text) ? MatchMode.NAME : MatchMode.NONE;
|
||||
}
|
||||
};
|
||||
return new GotoActionItemProvider(model);
|
||||
|
||||
@@ -459,7 +459,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
}
|
||||
final String groupName = myActionsMap.get(anAction);
|
||||
if (groupName == null) {
|
||||
return matcher.matches(text, compiledPattern) ? MatchMode.NON_MENU : MatchMode.NONE;
|
||||
return text != null && matcher.matches(text, compiledPattern) ? MatchMode.NON_MENU : MatchMode.NONE;
|
||||
}
|
||||
return text != null && matcher.matches(groupName + " " + text, compiledPattern) ? MatchMode.GROUP : MatchMode.NONE;
|
||||
}
|
||||
|
||||
@@ -173,14 +173,6 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectExcludeRoot(@NotNull VirtualFile dir) {
|
||||
checkAvailability();
|
||||
if (!(dir instanceof NewVirtualFile)) return false;
|
||||
|
||||
return getRootIndex().isProjectExcludeRoot(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageName(@NotNull VirtualFile dir) {
|
||||
checkAvailability();
|
||||
|
||||
+11
-1
@@ -541,7 +541,17 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
myTreeExpander = new DefaultTreeExpander(myTreeTable.getTree());
|
||||
myTreeExpander = new DefaultTreeExpander(myTreeTable.getTree()) {
|
||||
@Override
|
||||
public boolean canExpand() {
|
||||
return myTreeTable.isShowing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollapse() {
|
||||
return myTreeTable.isShowing();
|
||||
}
|
||||
};
|
||||
myProfileFilter = new MyFilterComponent();
|
||||
|
||||
return scrollPane;
|
||||
|
||||
+7
-2
@@ -149,8 +149,10 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink();
|
||||
for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) {
|
||||
final String toolId = selectedInspectionsNode.toString();
|
||||
sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()),
|
||||
mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
|
||||
if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) {
|
||||
sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()),
|
||||
mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
|
||||
}
|
||||
}
|
||||
return sink.constructIcon();
|
||||
} else if (column == IS_ENABLED_COLUMN) {
|
||||
@@ -207,6 +209,9 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
private boolean myIsFirst = true;
|
||||
|
||||
public Icon constructIcon() {
|
||||
if (myScopeToAverageSeverityMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
//TODO order scopes
|
||||
return !allScopesHasMixedSeverity()
|
||||
? new MultiScopeSeverityIcon(myScopeToAverageSeverityMap)
|
||||
|
||||
+2
-2
@@ -46,7 +46,6 @@ public class MultiScopeSeverityIcon implements Icon {
|
||||
@Override
|
||||
public void paintIcon(final Component c, final Graphics g, final int i, final int j) {
|
||||
final int iconWidth = getIconWidth();
|
||||
final int iconHeightCoordinate = j + getIconHeight();
|
||||
|
||||
final int partWidth = iconWidth / myScopeToAverageSeverityMap.size();
|
||||
|
||||
@@ -57,9 +56,10 @@ public class MultiScopeSeverityIcon implements Icon {
|
||||
g.setColor(icon instanceof HighlightDisplayLevel.SingleColorIconWithMask ?
|
||||
((HighlightDisplayLevel.SingleColorIconWithMask)icon).getColor() : MIXED_SEVERITY_COLOR);
|
||||
final int x = i + partWidth * idx;
|
||||
g.fillRect(x, j, partWidth, iconHeightCoordinate);
|
||||
g.fillRect(x, j, partWidth, getIconHeight());
|
||||
idx++;
|
||||
}
|
||||
g.drawImage(HighlightDisplayLevel.ImageHolder.ourErrorMaskImage, i, j, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -360,14 +360,16 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
data = deserializeSavedPersistentData(bytes);
|
||||
havePersistentData = true;
|
||||
if (DebugAssertions.EXTRA_SANITY_CHECKS) {
|
||||
boolean sameValueForSavedIndexedResultAndCurrentOne = myIndexer.map(content).equals(data);
|
||||
Map<Key, Value> contentData = myIndexer.map(content);
|
||||
boolean sameValueForSavedIndexedResultAndCurrentOne = contentData.equals(data);
|
||||
if (!sameValueForSavedIndexedResultAndCurrentOne) {
|
||||
DebugAssertions.error(
|
||||
"Unexpected difference in indexing of %s by index %s, file type %s, charset %s\nprevious indexed info %s",
|
||||
"Unexpected difference in indexing of %s by index %s, file type %s, charset %s\ndiff %s\nprevious indexed info %s",
|
||||
fileContent.getFile(),
|
||||
myIndexId,
|
||||
fileContent.getFileType(),
|
||||
((FileContentImpl)fileContent).getCharset(),
|
||||
buildDiff(data, contentData),
|
||||
myIndexingTrace.get(hashId)
|
||||
);
|
||||
}
|
||||
@@ -395,7 +397,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
FileContent fileContent = (FileContent)content;
|
||||
try {
|
||||
myIndexingTrace.put(hashId, ((FileContentImpl)fileContent).getCharset() + "," + fileContent.getFileType()+"," + fileContent.getFile().getPath() + "," +
|
||||
ExceptionUtil.getThrowableText(new Throwable()));
|
||||
ExceptionUtil.getThrowableText(new Throwable()));
|
||||
} catch (IOException ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
@@ -507,6 +509,41 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
};
|
||||
}
|
||||
|
||||
private StringBuilder buildDiff(Map<Key, Value> data, Map<Key, Value> contentData) {
|
||||
StringBuilder moreInfo = new StringBuilder();
|
||||
if (contentData.size() != data.size()) {
|
||||
moreInfo.append("Indexer has different number of elements, previously ").append(data.size()).append(" after ")
|
||||
.append(contentData.size()).append("\n");
|
||||
} else {
|
||||
moreInfo.append("total ").append(contentData.size()).append(" entries\n");
|
||||
}
|
||||
|
||||
for(Map.Entry<Key, Value> keyValueEntry:contentData.entrySet()) {
|
||||
if (!data.containsKey(keyValueEntry.getKey())) {
|
||||
moreInfo.append("Previous data doesn't contain:").append(keyValueEntry.getKey()).append( " with value ").append(keyValueEntry.getValue()).append("\n");
|
||||
}
|
||||
else {
|
||||
Value value = data.get(keyValueEntry.getKey());
|
||||
if (!Comparing.equal(keyValueEntry.getValue(), value)) {
|
||||
moreInfo.append("Previous data has different value for key:").append(keyValueEntry.getKey()).append( ", new value ").append(keyValueEntry.getValue()).append( ", oldValue:").append(value).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Map.Entry<Key, Value> keyValueEntry:data.entrySet()) {
|
||||
if (!contentData.containsKey(keyValueEntry.getKey())) {
|
||||
moreInfo.append("New data doesn't contain:").append(keyValueEntry.getKey()).append( " with value ").append(keyValueEntry.getValue()).append("\n");
|
||||
}
|
||||
else {
|
||||
Value value = contentData.get(keyValueEntry.getKey());
|
||||
if (!Comparing.equal(keyValueEntry.getValue(), value)) {
|
||||
moreInfo.append("New data has different value for key:").append(keyValueEntry.getKey()).append( " new value ").append(value).append( ", oldValue:").append(keyValueEntry.getValue()).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return moreInfo;
|
||||
}
|
||||
|
||||
private Map<Key, Value> deserializeSavedPersistentData(ByteSequence bytes) throws IOException {
|
||||
DataInputStream stream = new DataInputStream(new UnsyncByteArrayInputStream(bytes.getBytes(), bytes.getOffset(), bytes.getLength()));
|
||||
int pairs = DataInputOutputUtil.readINT(stream);
|
||||
|
||||
@@ -50,6 +50,8 @@ public interface IdeActions {
|
||||
@NonNls String ACTION_EDITOR_COMPLETE_STATEMENT = "EditorCompleteStatement";
|
||||
@NonNls String ACTION_EDITOR_USE_SOFT_WRAPS = "EditorToggleUseSoftWraps";
|
||||
@NonNls String ACTION_EDITOR_ADD_OR_REMOVE_CARET= "EditorAddOrRemoveCaret";
|
||||
@NonNls String ACTION_EDITOR_CLONE_CARET_BELOW= "EditorCloneCaretBelow";
|
||||
@NonNls String ACTION_EDITOR_CLONE_CARET_ABOVE= "EditorCloneCaretAbove";
|
||||
|
||||
@NonNls String ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE = "NextTemplateVariable";
|
||||
@NonNls String ACTION_EDITOR_PREVIOUS_TEMPLATE_VARIABLE = "PreviousTemplateVariable";
|
||||
|
||||
@@ -36,41 +36,49 @@ public interface SearchableConfigurable extends Configurable {
|
||||
boolean hasOwnContent();
|
||||
boolean isVisible();
|
||||
|
||||
|
||||
abstract class Abstract implements Parent {
|
||||
private Configurable[] myKids;
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOwnContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myKids = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable enableSearch(final String option) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Configurable[] getConfigurables() {
|
||||
if (myKids != null) return myKids;
|
||||
myKids = buildConfigurables();
|
||||
|
||||
@@ -87,7 +87,7 @@ public class FixedSizeButton extends JButton {
|
||||
public Dimension getPreferredSize() {
|
||||
if (myComponent != null) {
|
||||
int size = myComponent.getPreferredSize().height;
|
||||
if (myComponent instanceof ComboBox && (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
|
||||
if (myComponent instanceof JComboBox && (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
|
||||
size -= 2; // decrement to match JTextField's preferred height
|
||||
}
|
||||
return new Dimension(size, size);
|
||||
@@ -120,9 +120,7 @@ public class FixedSizeButton extends JButton {
|
||||
public void setBounds(Rectangle r) {
|
||||
if (r.width != r.height) {
|
||||
int size = Math.min(r.width, r.height);
|
||||
r = new Rectangle(r);
|
||||
r.width = size;
|
||||
r.height = size;
|
||||
r = new Rectangle(r.x, r.y, size, size);
|
||||
}
|
||||
super.setBounds(r);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user