mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Guava">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-r08.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-r09.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/guava-src-r08.zip!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/guava-src-r09.zip!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -150,7 +150,7 @@ libraryLicense(name: "Apache Lucene", libraryName: "lucene-core-2.4.1.jar", vers
|
||||
libraryLicense(name: "Automaton", libraryName: "automaton.jar", version: "1.11", license: "BSD", url: "http://www.brics.dk/automaton/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php")
|
||||
libraryLicense(name: "DTDParser", version: "1.13", license: "LGPL", url: "http://sourceforge.net/projects/dtdparser/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1")
|
||||
libraryLicense(name: "Ganymed", version: "bundled with SVNKit", libraryName: "svnkit.jar", license: "BSD", url: "http://www.ganymed.ethz.ch/ssh2/", licenseUrl: "http://www.ganymed.ethz.ch/ssh2/LICENSE.txt")
|
||||
libraryLicense(name: "Guava", version: "R6", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html")
|
||||
libraryLicense(name: "Guava", version: "R8", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html")
|
||||
libraryLicense(name: "Gradle API", libraryName: "gradle-open-api-0.8.jar", version: "0.8", license: "Apache 2.0", url: "http://www.gradle.org/")
|
||||
libraryLicense(name: "Groovy", version: "1.7.3", license: "Apache 2.0", url: "http://groovy.codehaus.org/")
|
||||
libraryLicense(name: "Gson", libraryName: "gson-1.3.jar", license: "Apache 2.0", url: "http://code.google.com/p/google-gson/")
|
||||
@@ -192,7 +192,7 @@ libraryLicense(name: "XML Commons (xml-apis.jar, resolver.jar)", version: "", li
|
||||
libraryLicense(name: "XMLBeans", libraryName: "XmlBeans", version: "2.3.0", license: "Apache 2.0", url: "http://xmlbeans.apache.org/", licenseUrl: "http://svn.jetbrains.org/idea/Trunk/bundled/WebServices/resources/lib/xmlbeans-2.3.0/xmlbeans.LICENSE")
|
||||
libraryLicense(name: "XML-RPC", libraryName: "XmlRPC", version: "2.0", license: "Apache 2.0", url: "http://ws.apache.org/xmlrpc/xmlrpc2/", licenseUrl: "http://ws.apache.org/xmlrpc/xmlrpc2/license.html")
|
||||
libraryLicense(name: "XStream", version: "1.2.1", license: "BSD", url: "http://xstream.codehaus.org/", licenseUrl: "http://xstream.codehaus.org/license.html")
|
||||
libraryLicense(name: "YourKit Java Profiler", libraryName: "yjp-controller-api-redist.jar", version: "7.0.2", license: "link (commercial license)", url: "http://yourkit.com/", licenseUrl: "http://www.yourkit.com/purchase/license.html")
|
||||
libraryLicense(name: "YourKit Java Profiler", libraryName: "yjp-controller-api-redist.jar", version: "8.0.x", license: "link (commercial license)", url: "http://yourkit.com/", licenseUrl: "http://www.yourkit.com/purchase/license.html")
|
||||
jetbrainsLibrary("JPS")
|
||||
jetbrainsLibrary("Maven Embedder")
|
||||
jetbrainsLibrary("tcServiceMessages")
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class ImplicitVariableElementInfoFactory implements SmartPointerElementIn
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
if (other instanceof ImplicitVariableInfo) {
|
||||
return myVar == ((ImplicitVariableInfo)other).myVar;
|
||||
}
|
||||
|
||||
+103
-25
@@ -19,7 +19,13 @@ import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.intention.impl.TypeExpression;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -28,6 +34,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -42,11 +49,11 @@ import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import com.intellij.ui.TitlePanel;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -83,7 +90,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
|
||||
private JCheckBox myMoveToAnotherClassCb;
|
||||
|
||||
private JavaVisibilityPanel myVisibilityPanel;
|
||||
private JComboBox myVisibilityCombo;
|
||||
|
||||
private JPanel myWholePanel;
|
||||
|
||||
@@ -122,31 +129,36 @@ public class InplaceIntroduceConstantPopup {
|
||||
myLocalName = localVariable != null ? localVariable.getName() : null;
|
||||
|
||||
myWholePanel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0 , 0, 0), 0, 0);
|
||||
GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0 , 0, 0), 0, 0);
|
||||
|
||||
final TitlePanel titlePanel = new TitlePanel();
|
||||
titlePanel.setBorder(null);
|
||||
titlePanel.setText(IntroduceConstantHandler.REFACTORING_NAME);
|
||||
|
||||
gc.gridwidth = 2;
|
||||
myWholePanel.add(titlePanel, gc);
|
||||
|
||||
gc.insets = new Insets(5, 5, 5, 5);
|
||||
gc.gridwidth = 1;
|
||||
gc.gridy = 1;
|
||||
myWholePanel.add(createLeftPanel(), gc);
|
||||
|
||||
myVisibilityPanel = new JavaVisibilityPanel(false, false);
|
||||
myVisibilityPanel.setVisibility(JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY);
|
||||
myWholePanel.add(myVisibilityPanel, gc);
|
||||
gc.gridx = 1;
|
||||
gc.insets.left = 6;
|
||||
myWholePanel.add(createRightPanel(), gc);
|
||||
|
||||
}
|
||||
|
||||
private JPanel createRightPanel() {
|
||||
final JPanel right = new JPanel(new GridBagLayout());
|
||||
final GridBagConstraints rgc = new GridBagConstraints(0, GridBagConstraints.RELATIVE,1,1,0,0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(1,0,0,0), 0, 0);
|
||||
myReplaceAllCb = new JCheckBox("Replace all occurrences");
|
||||
myReplaceAllCb.setMnemonic('a');
|
||||
myReplaceAllCb.setFocusable(false);
|
||||
myWholePanel.add(myReplaceAllCb, gc);
|
||||
myReplaceAllCb.setVisible(myOccurrences.length > 1);
|
||||
|
||||
right.add(myReplaceAllCb, rgc);
|
||||
|
||||
myCbDeleteVariable = new StateRestoringCheckBox("Delete variable declaration");
|
||||
myCbDeleteVariable.setMnemonic('d');
|
||||
myCbDeleteVariable.setFocusable(false);
|
||||
myWholePanel.add(myCbDeleteVariable, gc);
|
||||
if (myLocalVariable != null) {
|
||||
if (myReplaceAllCb != null) {
|
||||
myReplaceAllCb.setEnabled(false);
|
||||
@@ -157,15 +169,15 @@ public class InplaceIntroduceConstantPopup {
|
||||
} else {
|
||||
myCbDeleteVariable.setVisible(false);
|
||||
}
|
||||
right.add(myCbDeleteVariable, rgc);
|
||||
|
||||
myAnnotateNonNls = new JCheckBox("Annotate field as @NonNls");
|
||||
myAnnotateNonNls.setMnemonic('f');
|
||||
myAnnotateNonNls.setFocusable(false);
|
||||
myWholePanel.add(myAnnotateNonNls, gc);
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
if ((myTypeSelectorManager.isSuggestedType("java.lang.String") || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false)))&&
|
||||
LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().hasEnumKeywordAndAutoboxing() &&
|
||||
JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) {
|
||||
if ((myTypeSelectorManager.isSuggestedType("java.lang.String") || (myLocalVariable != null && AnnotationUtil
|
||||
.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false)))&&
|
||||
LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel().hasEnumKeywordAndAutoboxing() &&
|
||||
JavaPsiFacade.getInstance(myProject).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) {
|
||||
final PropertiesComponent component = PropertiesComponent.getInstance(myProject);
|
||||
myAnnotateNonNls.setSelected(component.isTrueValue(IntroduceConstantDialog.NONNLS_SELECTED_PROPERTY));
|
||||
myAnnotateNonNls.addItemListener(new ItemListener() {
|
||||
@@ -176,13 +188,69 @@ public class InplaceIntroduceConstantPopup {
|
||||
} else {
|
||||
myAnnotateNonNls.setVisible(false);
|
||||
}
|
||||
right.add(myAnnotateNonNls, rgc);
|
||||
return right;
|
||||
}
|
||||
|
||||
private JPanel createLeftPanel() {
|
||||
final JPanel left = new JPanel(new GridBagLayout());
|
||||
final GridBagConstraints lgc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5,5,0,0), 0, 0);
|
||||
|
||||
final JLabel label = new JLabel("Visibility:");
|
||||
label.setDisplayedMnemonic('V');
|
||||
left.add(label, lgc);
|
||||
myVisibilityCombo = new JComboBox(new String[]{PsiModifier.PUBLIC, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PRIVATE});
|
||||
myVisibilityCombo.setRenderer(new ListCellRendererWrapper<String>(myVisibilityCombo.getRenderer()){
|
||||
@Override
|
||||
public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
|
||||
setText(PsiBundle.visibilityPresentation(value));
|
||||
}
|
||||
});
|
||||
label.setLabelFor(myVisibilityCombo);
|
||||
myVisibilityCombo.setSelectedItem(JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY);
|
||||
myVisibilityCombo.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
ToolWindowManager.getInstance(myProject).activateEditorComponent();
|
||||
}
|
||||
}
|
||||
});
|
||||
final AnAction arrow = new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
if (e.getInputEvent() instanceof KeyEvent) {
|
||||
final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
|
||||
final int delta = code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0;
|
||||
if (delta == 0) return;
|
||||
final int size = myVisibilityCombo.getModel().getSize();
|
||||
int next = myVisibilityCombo.getSelectedIndex() + delta;
|
||||
if (next < 0 || next >= size) {
|
||||
if (!UISettings.getInstance().CYCLE_SCROLLING) {
|
||||
return;
|
||||
}
|
||||
next = (next + size) % size;
|
||||
}
|
||||
myVisibilityCombo.setSelectedIndex(next);
|
||||
}
|
||||
}
|
||||
};
|
||||
arrow.registerCustomShortcutSet(new CustomShortcutSet(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), null),
|
||||
new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), null)), myVisibilityCombo);
|
||||
lgc.gridx = 1;
|
||||
lgc.insets.top = 2;
|
||||
lgc.insets.left = 0;
|
||||
left.add(myVisibilityCombo, lgc);
|
||||
|
||||
myMoveToAnotherClassCb = new JCheckBox("Move to another class");
|
||||
myMoveToAnotherClassCb.setMnemonic('m');
|
||||
myMoveToAnotherClassCb.setFocusable(false);
|
||||
myWholePanel.add(myMoveToAnotherClassCb, gc);
|
||||
|
||||
|
||||
lgc.gridx = 0;
|
||||
lgc.gridy = 1;
|
||||
lgc.gridwidth = 2;
|
||||
lgc.insets.top = 0;
|
||||
left.add(myMoveToAnotherClassCb, lgc);
|
||||
return left;
|
||||
}
|
||||
|
||||
public void performInplaceIntroduce() {
|
||||
@@ -220,7 +288,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
PsiField field = elementFactory.createFieldFromText(psiType.getCanonicalText() + " " + (myConstantName != null ? myConstantName : names[0]) + " = " + myExprText + ";", myParentClass);
|
||||
PsiUtil.setModifierProperty(field, PsiModifier.FINAL, true);
|
||||
PsiUtil.setModifierProperty(field, PsiModifier.STATIC, true);
|
||||
final String visibility = myVisibilityPanel.getVisibility();
|
||||
final String visibility = getSelectedVisibility();
|
||||
if (visibility != null) {
|
||||
PsiUtil.setModifierProperty(field, visibility, true);
|
||||
}
|
||||
@@ -230,6 +298,10 @@ public class InplaceIntroduceConstantPopup {
|
||||
});
|
||||
}
|
||||
|
||||
private String getSelectedVisibility() {
|
||||
return (String)myVisibilityCombo.getSelectedItem();
|
||||
}
|
||||
|
||||
public List<RangeMarker> getOccurrenceMarkers() {
|
||||
if (myOccurrenceMarkers == null) {
|
||||
myOccurrenceMarkers = new ArrayList<RangeMarker>();
|
||||
@@ -301,7 +373,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
@Override
|
||||
protected void saveSettings(PsiVariable psiVariable) {
|
||||
TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), myDefaultParameterTypePointer.getType());
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = myVisibilityPanel.getVisibility();
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = getSelectedVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -321,7 +393,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
isReplaceAllOccurrences(), true,
|
||||
true,
|
||||
BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION,
|
||||
myVisibilityPanel.getVisibility(), myLocalVariable,
|
||||
getSelectedVisibility(), myLocalVariable,
|
||||
myFieldTypePointer.getType(),
|
||||
isDeleteVariable(),
|
||||
myParentClass, isAnnotateNonNls(), false);
|
||||
@@ -358,10 +430,16 @@ public class InplaceIntroduceConstantPopup {
|
||||
protected JComponent getComponent() {
|
||||
if (!myInitListeners) {
|
||||
myInitListeners = true;
|
||||
myVisibilityPanel.addListener(new VisibilityListener(myProject, myEditor){
|
||||
final VisibilityListener visibilityListener = new VisibilityListener(myProject, myEditor) {
|
||||
@Override
|
||||
protected String getVisibility() {
|
||||
return myVisibilityPanel.getVisibility();
|
||||
return getSelectedVisibility();
|
||||
}
|
||||
};
|
||||
myVisibilityCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
visibilityListener.stateChanged(null);
|
||||
}
|
||||
});
|
||||
myReplaceAllCb.addItemListener(new ItemListener() {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,7 @@ commons-logging-1.1.1.jar
|
||||
commons-net-2.0-patched.jar
|
||||
dtdparser113.jar
|
||||
groovy-all-1.7.3.jar
|
||||
guava-r08.jar
|
||||
guava-r09.jar
|
||||
jaxen-1.1.3.jar
|
||||
jcip-annotations.jar
|
||||
jdom.jar
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+22
-28
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.editors.JBComboBoxTableCellEditorComponent;
|
||||
import com.intellij.ui.treeStructure.treetable.ListTreeTableModel;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTable;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer;
|
||||
@@ -602,34 +603,32 @@ public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyle
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
private class MyValueEditor extends AbstractTableCellEditor {
|
||||
private final JComboBox myComboBox = new JComboBox();
|
||||
private final JCheckBox myCheckBox = new JCheckBox();
|
||||
private final JCheckBox myBooleanEditor = new JCheckBox();
|
||||
private JBComboBoxTableCellEditorComponent myOptionsEditor = new JBComboBoxTableCellEditorComponent();
|
||||
private Component myCurrentEditor = null;
|
||||
private MyTreeNode myCurrentNode = null;
|
||||
|
||||
public MyValueEditor() {
|
||||
ActionListener synchronizer = new ActionListener() {
|
||||
myBooleanEditor.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myCurrentNode != null) {
|
||||
myCurrentNode.setValue(getCellEditorValue());
|
||||
}
|
||||
}
|
||||
};
|
||||
myComboBox.addActionListener(synchronizer);
|
||||
myCheckBox.addActionListener(synchronizer);
|
||||
|
||||
myComboBox.putClientProperty("JComponent.sizeVariant", "small");
|
||||
myComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
|
||||
myCheckBox.putClientProperty("JComponent.sizeVariant", "small");
|
||||
});
|
||||
myBooleanEditor.putClientProperty("JComponent.sizeVariant", "small");
|
||||
}
|
||||
|
||||
public Object getCellEditorValue() {
|
||||
if (myCurrentEditor == myComboBox) {
|
||||
return myComboBox.getSelectedItem();
|
||||
if (myCurrentEditor == myOptionsEditor) {
|
||||
return myOptionsEditor.getEditorValue();
|
||||
}
|
||||
else if (myCurrentEditor == myCheckBox) {
|
||||
return myCheckBox.isSelected() ? Boolean.TRUE : Boolean.FALSE;
|
||||
else if (myCurrentEditor == myBooleanEditor) {
|
||||
return myBooleanEditor.isSelected() ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -642,27 +641,22 @@ public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyle
|
||||
myCurrentNode = null;
|
||||
if (defaultNode instanceof MyTreeNode) {
|
||||
MyTreeNode node = (MyTreeNode)defaultNode;
|
||||
myCurrentNode = node;
|
||||
if (node.getKey() instanceof BooleanOption) {
|
||||
myCurrentEditor = myCheckBox;
|
||||
myCheckBox.setSelected(node.getValue() == Boolean.TRUE);
|
||||
myCheckBox.setEnabled(node.isEnabled());
|
||||
myCurrentEditor = myBooleanEditor;
|
||||
myBooleanEditor.setSelected(node.getValue() == Boolean.TRUE);
|
||||
myBooleanEditor.setEnabled(node.isEnabled());
|
||||
}
|
||||
else {
|
||||
myCurrentEditor = myComboBox;
|
||||
myComboBox.removeAllItems();
|
||||
SelectionOption key = (SelectionOption)node.getKey();
|
||||
String[] values = key.options;
|
||||
for (String value1 : values) {
|
||||
myComboBox.addItem(value1);
|
||||
}
|
||||
myComboBox.setSelectedItem(node.getValue());
|
||||
myComboBox.setEnabled(node.isEnabled());
|
||||
myCurrentEditor = myOptionsEditor;
|
||||
myOptionsEditor.setCell(table, row, column);
|
||||
myOptionsEditor.setText(String.valueOf(node.getValue()));
|
||||
myOptionsEditor.setOptions(((SelectionOption)node.getKey()).options);
|
||||
myOptionsEditor.setDefaultValue(node.getValue());
|
||||
}
|
||||
myCurrentNode = node;
|
||||
}
|
||||
|
||||
myCurrentEditor.setBackground(table.getBackground());
|
||||
|
||||
return myCurrentEditor;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -51,7 +51,7 @@ import java.util.List;
|
||||
* This class provides basic functionality for running consoles.
|
||||
* It launches external process and handles line input with history
|
||||
*/
|
||||
public abstract class AbstractConsoleRunnerWithHistory {
|
||||
public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsoleViewImpl> {
|
||||
private final Project myProject;
|
||||
private final String myConsoleTitle;
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract class AbstractConsoleRunnerWithHistory {
|
||||
private final CommandLineArgumentsProvider myProvider;
|
||||
private final String myWorkingDir;
|
||||
|
||||
private LanguageConsoleViewImpl myConsoleView;
|
||||
private T myConsoleView;
|
||||
|
||||
private ConsoleExecuteActionHandler myConsoleExecuteActionHandler;
|
||||
|
||||
@@ -194,7 +194,7 @@ public abstract class AbstractConsoleRunnerWithHistory {
|
||||
myConsoleView.getConsole().setEditable(false);
|
||||
}
|
||||
|
||||
protected abstract LanguageConsoleViewImpl createConsoleView();
|
||||
protected abstract T createConsoleView();
|
||||
|
||||
@Nullable
|
||||
protected abstract Process createProcess(CommandLineArgumentsProvider provider) throws ExecutionException;
|
||||
@@ -288,7 +288,7 @@ public abstract class AbstractConsoleRunnerWithHistory {
|
||||
}
|
||||
}
|
||||
|
||||
public LanguageConsoleViewImpl getConsoleView() {
|
||||
public T getConsoleView() {
|
||||
return myConsoleView;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -27,6 +27,7 @@ public abstract class EditorHeaderToggleAction extends CheckboxAction {
|
||||
public JComponent createCustomComponent(Presentation presentation) {
|
||||
final JComponent customComponent = super.createCustomComponent(presentation);
|
||||
getCheckBox().setFocusable(false);
|
||||
getCheckBox().setOpaque(false);
|
||||
return customComponent;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.intellij.find.editorHeaderActions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -61,4 +66,20 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ensureOkToWrite(Editor e) {
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(e.getProject()).getPsiFile(e.getDocument());
|
||||
boolean okWritable;
|
||||
if (psiFile != null) {
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
okWritable = ReadonlyStatusHandler.ensureFilesWritable(e.getProject(), virtualFile);
|
||||
} else {
|
||||
okWritable = psiFile.isWritable();
|
||||
}
|
||||
} else {
|
||||
okWritable = e.getDocument().isWritable();
|
||||
}
|
||||
return okWritable;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,6 +3,7 @@ package com.intellij.find.impl.livePreview;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.FindModel;
|
||||
import com.intellij.find.FindUtil;
|
||||
import com.intellij.find.editorHeaderActions.Utils;
|
||||
import com.intellij.find.impl.FindResultImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -194,7 +195,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange performReplace(final LiveOccurrence occurrence, final String replacement, final Editor editor) {
|
||||
if (myReplaceDenied) return null;
|
||||
if (myReplaceDenied || !Utils.ensureOkToWrite(editor)) return null;
|
||||
TextRange range = occurrence.getPrimaryRange();
|
||||
FindModel findModel = mySearchResults.getFindModel();
|
||||
TextRange result = null;
|
||||
@@ -216,6 +217,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil
|
||||
|
||||
@Override
|
||||
public void performReplaceAll(Editor e) {
|
||||
if (!Utils.ensureOkToWrite(e)) return;
|
||||
if (mySearchResults.getFindModel() != null) {
|
||||
FindUtil.replace(e.getProject(), e,
|
||||
mySearchResults.getFindModel().isGlobal() ? 0 : mySearchResults.getEditor().getSelectionModel().getSelectionStart(),
|
||||
|
||||
@@ -37,10 +37,8 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class FormatterImpl extends FormatterEx
|
||||
@@ -52,15 +50,9 @@ public class FormatterImpl extends FormatterEx
|
||||
FormattingModelFactory
|
||||
{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.formatting.FormatterImpl");
|
||||
|
||||
private enum Source {
|
||||
EXECUTE_SEQUENTIAL_TASK, GET_WHITESPACE_BEFORE, ADJUST_LINE_INDENT, ADJUST_LINE_INDENTS_FOR_RANGE, FORMAT_AROUND_RANGE,
|
||||
ADJUST_TEXT_RANGE, ADJUST_TEXT_RANGE_WITH_ADDITIONAL_SETTINGS, RUN_WITH_FORMATTING_DISABLED
|
||||
}
|
||||
|
||||
private FormattingProgressIndicatorImpl myProgressIndicator;
|
||||
|
||||
private final Deque<Source> myDisabledFormattingRequests = new LinkedBlockingDeque<Source>();
|
||||
private final AtomicInteger myIsDisabledCount = new AtomicInteger();
|
||||
private final IndentImpl NONE_INDENT = new IndentImpl(Indent.Type.NONE, false, false);
|
||||
private final IndentImpl myAbsoluteNoneIndent = new IndentImpl(Indent.Type.NONE, true, false);
|
||||
@@ -218,7 +210,7 @@ public class FormatterImpl extends FormatterEx
|
||||
* @param task task to execute
|
||||
*/
|
||||
private void execute(@NotNull SequentialTask task) {
|
||||
disableFormatting(Source.EXECUTE_SEQUENTIAL_TASK);
|
||||
disableFormatting();
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (myProgressIndicator == null || !application.isDispatchThread() || application.isUnitTestMode()) {
|
||||
try {
|
||||
@@ -228,7 +220,7 @@ public class FormatterImpl extends FormatterEx
|
||||
}
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.EXECUTE_SEQUENTIAL_TASK);
|
||||
enableFormatting();
|
||||
myProgressIndicator = null;
|
||||
}
|
||||
}
|
||||
@@ -242,7 +234,7 @@ public class FormatterImpl extends FormatterEx
|
||||
public void run() {
|
||||
// Reset current progress indicator.
|
||||
myProgressIndicator = null;
|
||||
enableFormatting(Source.EXECUTE_SEQUENTIAL_TASK);
|
||||
enableFormatting();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -257,7 +249,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final CodeStyleSettings.IndentOptions indentOptions,
|
||||
final TextRange affectedRange, final boolean mayChangeLineFeeds)
|
||||
{
|
||||
disableFormatting(Source.GET_WHITESPACE_BEFORE);
|
||||
disableFormatting();
|
||||
try {
|
||||
final FormatProcessor processor = buildProcessorAndWrapBlocks(
|
||||
model, block, settings, indentOptions, new FormatTextRanges(affectedRange, true)
|
||||
@@ -275,7 +267,7 @@ public class FormatterImpl extends FormatterEx
|
||||
return new IndentInfo(whiteSpace.getLineFeeds(), whiteSpace.getIndentOffset(), whiteSpace.getSpaces());
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.GET_WHITESPACE_BEFORE);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +275,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final CodeStyleSettings settings,
|
||||
final CodeStyleSettings.IndentOptions indentOptions,
|
||||
final TextRange rangeToAdjust) {
|
||||
disableFormatting(Source.ADJUST_LINE_INDENTS_FOR_RANGE);
|
||||
disableFormatting();
|
||||
try {
|
||||
final FormattingDocumentModel documentModel = model.getDocumentModel();
|
||||
final Block block = model.getRootBlock();
|
||||
@@ -303,7 +295,7 @@ public class FormatterImpl extends FormatterEx
|
||||
processor.performModifications(model);
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.ADJUST_LINE_INDENTS_FOR_RANGE);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +303,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final CodeStyleSettings settings,
|
||||
final TextRange textRange,
|
||||
final FileType fileType) {
|
||||
disableFormatting(Source.FORMAT_AROUND_RANGE);
|
||||
disableFormatting();
|
||||
try {
|
||||
final FormattingDocumentModel documentModel = model.getDocumentModel();
|
||||
final Block block = model.getRootBlock();
|
||||
@@ -340,7 +332,7 @@ public class FormatterImpl extends FormatterEx
|
||||
processor.performModifications(model);
|
||||
}
|
||||
finally{
|
||||
enableFormatting(Source.FORMAT_AROUND_RANGE);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +341,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final CodeStyleSettings.IndentOptions indentOptions,
|
||||
final int offset,
|
||||
final TextRange affectedRange) throws IncorrectOperationException {
|
||||
disableFormatting(Source.ADJUST_LINE_INDENT);
|
||||
disableFormatting();
|
||||
if (model instanceof PsiBasedFormattingModel) {
|
||||
((PsiBasedFormattingModel)model).canModifyAllWhiteSpaces();
|
||||
}
|
||||
@@ -370,7 +362,7 @@ public class FormatterImpl extends FormatterEx
|
||||
return adjustLineIndent(offset, documentModel, processor, indentOptions, model, whiteSpace);
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.ADJUST_LINE_INDENT);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +534,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final boolean changeWSBeforeFirstElement,
|
||||
final boolean changeLineFeedsBeforeFirstElement,
|
||||
@Nullable final IndentInfoStorage indentInfoStorage) {
|
||||
disableFormatting(Source.ADJUST_TEXT_RANGE_WITH_ADDITIONAL_SETTINGS);
|
||||
disableFormatting();
|
||||
try {
|
||||
final FormatProcessor processor = buildProcessorAndWrapBlocks(
|
||||
model.getDocumentModel(), model.getRootBlock(), settings, indentOptions, new FormatTextRanges(affectedRange, true)
|
||||
@@ -603,7 +595,7 @@ public class FormatterImpl extends FormatterEx
|
||||
processor.format(model);
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.ADJUST_TEXT_RANGE_WITH_ADDITIONAL_SETTINGS);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +603,7 @@ public class FormatterImpl extends FormatterEx
|
||||
final CodeStyleSettings settings,
|
||||
final CodeStyleSettings.IndentOptions indentOptions,
|
||||
final TextRange affectedRange) {
|
||||
disableFormatting(Source.ADJUST_TEXT_RANGE);
|
||||
disableFormatting();
|
||||
try {
|
||||
final FormatProcessor processor = buildProcessorAndWrapBlocks(
|
||||
model.getDocumentModel(), model.getRootBlock(), settings, indentOptions, new FormatTextRanges(affectedRange, true)
|
||||
@@ -633,7 +625,7 @@ public class FormatterImpl extends FormatterEx
|
||||
processor.format(model);
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.ADJUST_TEXT_RANGE);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,34 +735,24 @@ public class FormatterImpl extends FormatterEx
|
||||
return myIsDisabledCount.get() > 0;
|
||||
}
|
||||
|
||||
private void disableFormatting(@NotNull Source requestSource) {
|
||||
private void disableFormatting() {
|
||||
myIsDisabledCount.incrementAndGet();
|
||||
myDisabledFormattingRequests.add(requestSource);
|
||||
}
|
||||
|
||||
private void enableFormatting(@NotNull Source requestSource) {
|
||||
boolean checkSource = true;
|
||||
private void enableFormatting() {
|
||||
int old = myIsDisabledCount.getAndDecrement();
|
||||
if (old <= 0) {
|
||||
checkSource = false;
|
||||
LOG.error(
|
||||
"enableFormatting()/disableFormatting() not paired. DisabledLevel = " + old + ", request source: " + myDisabledFormattingRequests
|
||||
);
|
||||
}
|
||||
Source source = myDisabledFormattingRequests.pollLast();
|
||||
if (checkSource && requestSource != source) {
|
||||
LOG.error("enableFormatting()/disableFormatting() from different sources detected! 'Disable source': " + source
|
||||
+ ", 'enable source': " + requestSource);
|
||||
LOG.error("enableFormatting()/disableFormatting() not paired. DisabledLevel = " + old);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T runWithFormattingDisabled(@NotNull Computable<T> runnable) {
|
||||
disableFormatting(Source.RUN_WITH_FORMATTING_DISABLED);
|
||||
disableFormatting();
|
||||
try {
|
||||
return runnable.compute();
|
||||
}
|
||||
finally {
|
||||
enableFormatting(Source.RUN_WITH_FORMATTING_DISABLED);
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class FileElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
if (other instanceof FileElementInfo) {
|
||||
return myVirtualFile == ((FileElementInfo)other).myVirtualFile;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class HardElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
return Comparing.equal(myElement, other.restoreElement());
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -77,4 +77,13 @@ class InjectedSelfElementInfo extends SelfElementInfo {
|
||||
|
||||
return result.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
if (getClass() != other.getClass()) return false;
|
||||
if (!super.pointsToTheSameElementAs(other)) return false;
|
||||
SmartPointerElementInfo myElementInfo = ((SmartPsiElementPointerImpl)myPsiFileRangeInHostElement).getElementInfo();
|
||||
SmartPointerElementInfo oElementInfo = ((SmartPsiElementPointerImpl)((InjectedSelfElementInfo)other).myPsiFileRangeInHostElement).getElementInfo();
|
||||
return myElementInfo.pointsToTheSameElementAs(oElementInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
if (other instanceof SelfElementInfo) {
|
||||
return myVirtualFile == ((SelfElementInfo)other).myVirtualFile
|
||||
&& myType == ((SelfElementInfo)other).myType
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ interface SmartPointerElementInfo {
|
||||
|
||||
void dispose();
|
||||
int elementHashCode(); // must be immutable
|
||||
boolean pointsToTheSameElementAs(SmartPointerElementInfo other);
|
||||
boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other);
|
||||
|
||||
VirtualFile getVirtualFile();
|
||||
|
||||
|
||||
+5
-8
@@ -85,7 +85,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
if (element != null && !element.isValid()) {
|
||||
element = null;
|
||||
}
|
||||
if (element == null && myElementInfo != null) {
|
||||
if (element == null) {
|
||||
element = (E)myElementInfo.restoreElement();
|
||||
if (element != null && (!element.getClass().equals(myElementClass) || !element.isValid())) {
|
||||
element = null;
|
||||
@@ -168,17 +168,13 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
}
|
||||
|
||||
public void documentAndPsiInSync() {
|
||||
if (myElementInfo != null) {
|
||||
myElementInfo.documentAndPsiInSync();
|
||||
}
|
||||
myElementInfo.documentAndPsiInSync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myElementInfo != null) {
|
||||
myElementInfo.dispose();
|
||||
myElement = null;
|
||||
}
|
||||
myElementInfo.dispose();
|
||||
myElement = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,6 +186,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
myElementInfo.fastenBelt(offset);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
SmartPointerElementInfo getElementInfo() {
|
||||
return myElementInfo;
|
||||
}
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc
|
||||
|
||||
public boolean execute(PsiFileSystemItem element) {
|
||||
result.add(new PsiElementResolveResult(getOriginalFile(element)));
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public abstract class FileDocumentManager {
|
||||
return ApplicationManager.getApplication().getComponent(FileDocumentManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract Document getDocument(@NotNull VirtualFile file);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -53,7 +53,7 @@ public class JBList extends JList implements ComponentWithEmptyText, ComponentWi
|
||||
init();
|
||||
}
|
||||
|
||||
private static DefaultListModel createDefaultListModel(Object[] items) {
|
||||
public static DefaultListModel createDefaultListModel(Object... items) {
|
||||
final DefaultListModel model = new DefaultListModel();
|
||||
for (Object item : items) {
|
||||
model.add(model.getSize(), item);
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.ui.components.editors;
|
||||
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.Icons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Solves rendering problems in JTable components when JComboBox objects are used as cell
|
||||
* editors components. Known issues of using JComboBox component are the following:
|
||||
* 1. Ugly view if row height is small enough
|
||||
* 2. Truncated strings in the combobox popup if column width is less than text value width
|
||||
*
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class JBComboBoxTableCellEditorComponent extends JBLabel {
|
||||
private JTable myTable;
|
||||
private int myRow = 0;
|
||||
private int myColumn = 0;
|
||||
private final JBList myList = new JBList();
|
||||
private Object[] myOptions = {};
|
||||
private Object myValue;
|
||||
|
||||
private ListCellRenderer myRenderer = new DefaultListCellRenderer() {
|
||||
private Icon myCheckIcon = Icons.CHECK_ICON;
|
||||
private Icon myEmptyIcon = EmptyIcon.create(Icons.CHECK_ICON.getIconWidth());
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
final JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (value == myValue) {
|
||||
label.setIcon(myCheckIcon);
|
||||
} else {
|
||||
label.setIcon(myEmptyIcon);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
public JBComboBoxTableCellEditorComponent() {
|
||||
}
|
||||
|
||||
public JBComboBoxTableCellEditorComponent(JTable table) {
|
||||
myTable = table;
|
||||
}
|
||||
|
||||
public void setTable(JTable table) {
|
||||
myTable = table;
|
||||
}
|
||||
|
||||
public void setCell(JTable table, int row, int column) {
|
||||
setTable(table);
|
||||
setRow(row);
|
||||
setColumn(column);
|
||||
}
|
||||
|
||||
public void setRow(int row) {
|
||||
myRow = row;
|
||||
}
|
||||
|
||||
public void setColumn(int column) {
|
||||
myColumn = column;
|
||||
}
|
||||
|
||||
public void setOptions(Object... options) {
|
||||
myOptions = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
initAndShowPopup();
|
||||
}
|
||||
|
||||
private void initAndShowPopup() {
|
||||
myList.removeAll();
|
||||
final Rectangle rect = myTable.getCellRect(myRow, myColumn, true);
|
||||
final Point point = new Point(rect.x, rect.y);
|
||||
myList.setModel(JBList.createDefaultListModel(myOptions));
|
||||
if (myRenderer != null) {
|
||||
myList.setCellRenderer(myRenderer);
|
||||
}
|
||||
JBPopupFactory.getInstance()
|
||||
.createListPopupBuilder(myList)
|
||||
.setItemChoosenCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myValue = myList.getSelectedValue();
|
||||
}
|
||||
}).createPopup()
|
||||
.show(new RelativePoint(myTable, point));
|
||||
}
|
||||
|
||||
public Object getEditorValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void setRenderer(ListCellRenderer renderer) {
|
||||
myRenderer = renderer;
|
||||
}
|
||||
|
||||
public void setDefaultValue(Object value) {
|
||||
myValue = value;
|
||||
}
|
||||
}
|
||||
+1
@@ -107,6 +107,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Appl
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Document getDocument(@NotNull final VirtualFile file) {
|
||||
DocumentEx document = (DocumentEx)getCachedDocument(file);
|
||||
if (document == null) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
@@ -89,7 +90,10 @@ public abstract class AbstractShowDiffAction extends AbstractVcsAction{
|
||||
final Project project = vcsContext.getProject();
|
||||
final VirtualFile selectedFile = vcsContext.getSelectedFiles()[0];
|
||||
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
|
||||
fileDocumentManager.saveDocument(fileDocumentManager.getDocument(selectedFile));
|
||||
final Document document = fileDocumentManager.getDocument(selectedFile);
|
||||
if (document != null) {
|
||||
fileDocumentManager.saveDocument(document);
|
||||
}
|
||||
|
||||
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
|
||||
final AbstractVcs vcs = vcsManager.getVcsFor(selectedFile);
|
||||
|
||||
@@ -36,11 +36,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
|
||||
public class PatchFileType implements FileType {
|
||||
public static final String NAME = "PATCH";
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getName() {
|
||||
return "PATCH";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+43
-20
@@ -24,7 +24,9 @@ import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
@@ -60,28 +62,49 @@ public class ImportIntoShelfAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void consume(final VirtualFile[] virtualFiles) {
|
||||
if (virtualFiles.length == 0) return;
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<VcsException> exceptions = new ArrayList<VcsException>();
|
||||
final List<ShelvedChangeList> lists =
|
||||
ShelveChangesManager.getInstance(project).importChangeLists(Arrays.asList(virtualFiles), new Consumer<VcsException>() {
|
||||
@Override
|
||||
public void consume(VcsException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
});
|
||||
if (! lists.isEmpty()) {
|
||||
ShelvedChangesViewManager.getInstance(project).activateView(lists.get(lists.size() - 1));
|
||||
//gatherPatchFiles
|
||||
final ProgressManager pm = ProgressManager.getInstance();
|
||||
final ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(project);
|
||||
final List<VirtualFile> asList = Arrays.asList(virtualFiles);
|
||||
|
||||
final List<VirtualFile> patchTypeFiles = new ArrayList<VirtualFile>();
|
||||
final boolean filesFound = pm.runProcessWithProgressSynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
patchTypeFiles.addAll(shelveChangesManager.gatherPatchFiles(asList));
|
||||
}
|
||||
if (! exceptions.isEmpty()) {
|
||||
AbstractVcsHelper.getInstance(project).showErrors(exceptions, "Import patches into shelf");
|
||||
}, "Looking for patch files...", true, project);
|
||||
if (! filesFound || patchTypeFiles.isEmpty()) return;
|
||||
if (! patchTypeFiles.equals(asList)) {
|
||||
final int toImport = Messages.showYesNoDialog(project, "Found " +
|
||||
(patchTypeFiles.size() == 1
|
||||
? "one patch file (" + patchTypeFiles.get(0).getPath() + ")."
|
||||
: (patchTypeFiles.size() + " patch files.")) +
|
||||
"\nContinue with import?", "Import patches", Messages.getQuestionIcon());
|
||||
if (DialogWrapper.CANCEL_EXIT_CODE == toImport) return;
|
||||
}
|
||||
pm.runProcessWithProgressSynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<VcsException> exceptions = new ArrayList<VcsException>();
|
||||
final List<ShelvedChangeList> lists =
|
||||
shelveChangesManager.importChangeLists(patchTypeFiles, new Consumer<VcsException>() {
|
||||
@Override
|
||||
public void consume(VcsException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
});
|
||||
if (!lists.isEmpty()) {
|
||||
ShelvedChangesViewManager.getInstance(project).activateView(lists.get(lists.size() - 1));
|
||||
}
|
||||
if (!exceptions.isEmpty()) {
|
||||
AbstractVcsHelper.getInstance(project).showErrors(exceptions, "Import patches into shelf");
|
||||
}
|
||||
if (lists.isEmpty() && exceptions.isEmpty()) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(project, "No patches found", MessageType.WARNING);
|
||||
}
|
||||
}
|
||||
if (lists.isEmpty() && exceptions.isEmpty()) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(project, "No patches found", MessageType.WARNING);
|
||||
}
|
||||
}
|
||||
}, "Import patches into shelf", true, project);
|
||||
}, "Import patches into shelf", true, project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+22
-7
@@ -39,8 +39,10 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.patch.PatchFileType;
|
||||
import com.intellij.openapi.vcs.changes.patch.PatchNameChecker;
|
||||
import com.intellij.openapi.vcs.changes.ui.RollbackWorker;
|
||||
import com.intellij.openapi.vcs.impl.VcsFileTypeFactory;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -213,17 +215,30 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl
|
||||
}
|
||||
}
|
||||
|
||||
public List<VirtualFile> gatherPatchFiles(final Collection<VirtualFile> files) {
|
||||
final List<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
|
||||
final LinkedList<VirtualFile> filesQueue = new LinkedList<VirtualFile>(files);
|
||||
while (! filesQueue.isEmpty()) {
|
||||
ProgressManager.checkCanceled();
|
||||
final VirtualFile file = filesQueue.removeFirst();
|
||||
if (file.isDirectory()) {
|
||||
filesQueue.addAll(Arrays.asList(file.getChildren()));
|
||||
continue;
|
||||
}
|
||||
if (PatchFileType.NAME.equals(file.getFileType().getName())) {
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ShelvedChangeList> importChangeLists(final Collection<VirtualFile> files, final Consumer<VcsException> exceptionConsumer) {
|
||||
final List<ShelvedChangeList> result = new ArrayList<ShelvedChangeList>(files.size());
|
||||
try {
|
||||
final LinkedList<VirtualFile> filesQueue = new LinkedList<VirtualFile>(files);
|
||||
while (! filesQueue.isEmpty()) {
|
||||
for (VirtualFile file : files) {
|
||||
ProgressManager.checkCanceled();
|
||||
final VirtualFile file = filesQueue.removeFirst();
|
||||
if (file.isDirectory()) {
|
||||
filesQueue.addAll(Arrays.asList(file.getChildren()));
|
||||
continue;
|
||||
}
|
||||
|
||||
final String description = file.getNameWithoutExtension().replace('_', ' ');
|
||||
final File patchPath = getPatchPath(description);
|
||||
|
||||
+8
-12
@@ -65,7 +65,6 @@ import java.util.*;
|
||||
import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
import static com.intellij.patterns.PsiJavaPatterns.elementType;
|
||||
import static com.intellij.util.containers.CollectionFactory.hashMap;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils.*;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
@@ -332,17 +331,14 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
final int invocationCount = parameters.getInvocationCount();
|
||||
final boolean secondCompletionInvoked = invocationCount > 1;
|
||||
final boolean firstCompletionInvoked = invocationCount < 2;
|
||||
|
||||
final String prefix = result.getPrefixMatcher().getPrefix();
|
||||
final boolean skipAccessors = !secondCompletionInvoked && !prefix.startsWith(GET_PREFIX) &&
|
||||
!prefix.startsWith(SET_PREFIX) &&
|
||||
!prefix.startsWith(IS_PREFIX);
|
||||
final boolean skipAccessors = firstCompletionInvoked && !prefix.startsWith("g") && !prefix.startsWith("s") && !prefix.startsWith("i");
|
||||
result.restartCompletionOnPrefixChange("g");
|
||||
result.restartCompletionOnPrefixChange("i");
|
||||
result.restartCompletionOnPrefixChange("s");
|
||||
|
||||
|
||||
result.restartCompletionOnPrefixChange(GET_PREFIX);
|
||||
result.restartCompletionOnPrefixChange(SET_PREFIX);
|
||||
result.restartCompletionOnPrefixChange(IS_PREFIX);
|
||||
final Map<PsiModifierListOwner, LookupElement> staticMembers = hashMap();
|
||||
final PsiElement qualifier = reference.getQualifier();
|
||||
final PsiType qualifierType = qualifier instanceof GrExpression ? ((GrExpression)qualifier).getType() : null;
|
||||
@@ -372,7 +368,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
|
||||
final boolean autopopup = parameters.getInvocationCount() == 0;
|
||||
//skip default groovy methods
|
||||
if (!secondCompletionInvoked &&
|
||||
if (firstCompletionInvoked &&
|
||||
object instanceof GrGdkMethod &&
|
||||
GroovyCompletionUtil.skipDefGroovyMethod((GrGdkMethod)object, substitutor, qualifierType)) {
|
||||
if (!autopopup) {
|
||||
@@ -382,7 +378,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
//skip operator methods
|
||||
if (!secondCompletionInvoked &&
|
||||
if (firstCompletionInvoked &&
|
||||
object instanceof PsiMethod &&
|
||||
GroovyCompletionUtil.OPERATOR_METHOD_NAMES.contains(((PsiMethod)object).getName())) {
|
||||
if (!checkForIterator((PsiMethod)object)) {
|
||||
@@ -402,7 +398,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
//skip inaccessible elements
|
||||
if (!secondCompletionInvoked && resolveResult != null && !resolveResult.isAccessible()) {
|
||||
if (firstCompletionInvoked && resolveResult != null && !resolveResult.isAccessible()) {
|
||||
if (!autopopup) {
|
||||
showInfo();
|
||||
}
|
||||
|
||||
+3
-7
@@ -67,11 +67,7 @@ public class SwitchStatement implements GroovyElementTypes {
|
||||
ParserUtils.getToken(builder, mLCURLY);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
while (true) {
|
||||
if (ParserUtils.getToken(builder, mRCURLY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!ParserUtils.getToken(builder, mRCURLY)) {
|
||||
if (builder.getTokenType() != kCASE && builder.getTokenType() != kDEFAULT) {
|
||||
builder.error("case, default or } expected");
|
||||
ParserUtils.skipCountingBraces(builder, TokenSet.create(kCASE, kDEFAULT, mRCURLY));
|
||||
@@ -104,8 +100,8 @@ public class SwitchStatement implements GroovyElementTypes {
|
||||
|
||||
PsiBuilder.Marker label = builder.mark();
|
||||
builder.advanceLexer();
|
||||
if (kCASE.equals(elem)) {
|
||||
AssignmentExpression.parse(builder, parser, true);
|
||||
if (kCASE.equals(elem) && !AssignmentExpression.parse(builder, parser)) {
|
||||
builder.error(GroovyBundle.message("expression.expected"));
|
||||
}
|
||||
ParserUtils.getToken(builder, mCOLON, GroovyBundle.message("colon.expected"));
|
||||
label.done(CASE_LABEL);
|
||||
|
||||
+7
-2
@@ -16,14 +16,19 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public interface GrSwitchStatement extends GroovyPsiElement, GrStatement {
|
||||
GrCondition getCondition();
|
||||
@Nullable
|
||||
GrExpression getCondition();
|
||||
|
||||
@NotNull
|
||||
GrCaseSection[] getCaseSections();
|
||||
}
|
||||
|
||||
+4
@@ -16,10 +16,14 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public interface GrCaseLabel extends GroovyPsiElement {
|
||||
@Nullable
|
||||
GrExpression getValue();
|
||||
}
|
||||
|
||||
+4
-3
@@ -19,9 +19,9 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrSwitchStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
|
||||
/**
|
||||
@@ -41,10 +41,11 @@ public class GrSwitchStatementImpl extends GroovyPsiElementImpl implements GrSwi
|
||||
return "Switch statement";
|
||||
}
|
||||
|
||||
public GrCondition getCondition() {
|
||||
return findChildByClass(GrCondition.class);
|
||||
public GrExpression getCondition() {
|
||||
return findChildByClass(GrExpression.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GrCaseSection[] getCaseSections() {
|
||||
return findChildrenByClass(GrCaseSection.class);
|
||||
}
|
||||
|
||||
+6
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseLabel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
|
||||
/**
|
||||
@@ -38,4 +39,9 @@ public class GrCaseLabelImpl extends GroovyPsiElementImpl implements GrCaseLabel
|
||||
public String toString() {
|
||||
return "Case label";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrExpression getValue() {
|
||||
return findChildByClass(GrExpression.class);
|
||||
}
|
||||
}
|
||||
+65
-53
@@ -17,7 +17,10 @@ package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
@@ -32,7 +35,9 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrAssertState
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrFlowInterruptingStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrTraditionalForClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
@@ -219,6 +224,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
final GrForClause clause = forStatement.getClause();
|
||||
ExpressionContext forContext = context.extend();
|
||||
if (clause instanceof GrForInClause) {
|
||||
final GrExpression expression = ((GrForInClause)clause).getIteratedExpression();
|
||||
final GrVariable declaredVariable = clause.getDeclaredVariable();
|
||||
@@ -228,7 +234,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
writeVariableWithoutColon(builder, declaredVariable);
|
||||
builder.append(" : ");
|
||||
if (expression != null) {
|
||||
final ExpressionContext context = this.context.copy();
|
||||
final ExpressionContext context = forContext.copy();
|
||||
expression.accept(new ExpressionGenerator(builder, context));
|
||||
}
|
||||
builder.append(")");
|
||||
@@ -244,7 +250,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
writeVariableWithoutColon(partBuilder, (GrParameter)initialization);
|
||||
final GrExpression initializer = ((GrParameter)initialization).getDefaultInitializer();
|
||||
if (initializer != null) {
|
||||
final ExpressionContext partContext = context.copy();
|
||||
final ExpressionContext partContext = forContext.copy();
|
||||
initializer.accept(new ExpressionGenerator(partBuilder, partContext));
|
||||
for (String statement : partContext.myStatements) {
|
||||
builder.append(statement).append(", ");
|
||||
@@ -255,30 +261,28 @@ public class CodeBlockGenerator extends Generator {
|
||||
else {
|
||||
if (initialization != null) {
|
||||
StringBuilder partBuilder = new StringBuilder();
|
||||
final ExpressionContext partContext = this.context.copy();
|
||||
final ExpressionContext partContext = forContext.copy();
|
||||
genForPart(builder, initialization, new CodeBlockGenerator(partBuilder, partContext));
|
||||
}
|
||||
}
|
||||
|
||||
builder.append(";");
|
||||
if (condition != null) {
|
||||
genForPart(builder, condition);
|
||||
genForPart(builder, condition, forContext.copy());
|
||||
}
|
||||
|
||||
builder.append(";");
|
||||
if (update != null) {
|
||||
genForPart(builder, update);
|
||||
genForPart(builder, update, forContext.copy());
|
||||
}
|
||||
builder.append(")");
|
||||
}
|
||||
|
||||
forStatement.getBody().accept(new CodeBlockGenerator(builder, context));
|
||||
forStatement.getBody().accept(new CodeBlockGenerator(builder, forContext));
|
||||
}
|
||||
|
||||
private void genForPart(StringBuilder builder, GrExpression part) {
|
||||
StringBuilder partBuilder = new StringBuilder();
|
||||
final ExpressionContext partContext = this.context.copy();
|
||||
genForPart(builder, part, new ExpressionGenerator(partBuilder, partContext));
|
||||
private static void genForPart(StringBuilder builder, GrExpression part, final ExpressionContext context) {
|
||||
genForPart(builder, part, new ExpressionGenerator(new StringBuilder(), context));
|
||||
}
|
||||
|
||||
private static void genForPart(StringBuilder builder, GroovyPsiElement part, final Generator visitor) {
|
||||
@@ -299,57 +303,63 @@ public class CodeBlockGenerator extends Generator {
|
||||
|
||||
@Override
|
||||
public void visitWhileStatement(GrWhileStatement whileStatement) {
|
||||
//todo
|
||||
final GrCondition condition = whileStatement.getCondition();
|
||||
final GrStatement body = whileStatement.getBody();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("while (");
|
||||
final ExpressionContext copy = context.copy();
|
||||
if (condition != null) {
|
||||
condition.accept(new ExpressionGenerator(builder, copy));
|
||||
}
|
||||
builder.append(" )");
|
||||
if (body != null) {
|
||||
body.accept(new CodeBlockGenerator(builder, copy.extend()));
|
||||
}
|
||||
writeStatement(builder, whileStatement, copy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitchStatement(GrSwitchStatement switchStatement) {
|
||||
super.visitSwitchStatement(switchStatement); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCaseSection(GrCaseSection caseSection) {
|
||||
super.visitCaseSection(caseSection); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCaseLabel(GrCaseLabel caseLabel) {
|
||||
super.visitCaseLabel(caseLabel); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitForInClause(GrForInClause forInClause) {
|
||||
super.visitForInClause(forInClause); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitForClause(GrForClause forClause) {
|
||||
super.visitForClause(forClause); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTraditionalForClause(GrTraditionalForClause forClause) {
|
||||
super.visitTraditionalForClause(forClause); //To change body of overridden methods use File | Settings | File Templates.
|
||||
//todo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTryStatement(GrTryCatchStatement tryCatchStatement) {
|
||||
super.visitTryStatement(tryCatchStatement); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBlockStatement(GrBlockStatement blockStatement) {
|
||||
super.visitBlockStatement(blockStatement); //To change body of overridden methods use File | Settings | File Templates.
|
||||
final GrOpenBlock tryBlock = tryCatchStatement.getTryBlock();
|
||||
final GrCatchClause[] catchClauses = tryCatchStatement.getCatchClauses();
|
||||
final GrFinallyClause finallyClause = tryCatchStatement.getFinallyClause();
|
||||
builder.append("try");
|
||||
tryBlock.accept(this);
|
||||
for (GrCatchClause catchClause : catchClauses) {
|
||||
catchClause.accept(this);
|
||||
}
|
||||
if (finallyClause != null) {
|
||||
finallyClause.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCatchClause(GrCatchClause catchClause) {
|
||||
super.visitCatchClause(catchClause); //To change body of overridden methods use File | Settings | File Templates.
|
||||
final GrParameter parameter = catchClause.getParameter();
|
||||
builder.append("catch (");
|
||||
writeVariableWithoutColon(builder, parameter);
|
||||
builder.append(") ");
|
||||
final GrOpenBlock body = catchClause.getBody();
|
||||
if (body != null) {
|
||||
body.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFinallyClause(GrFinallyClause catchClause) {
|
||||
super.visitFinallyClause(catchClause); //To change body of overridden methods use File | Settings | File Templates.
|
||||
public void visitFinallyClause(GrFinallyClause finallyClause) {
|
||||
builder.append("finally ");
|
||||
finallyClause.getBody().accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBlockStatement(GrBlockStatement blockStatement) {
|
||||
//todo
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -369,13 +379,14 @@ public class CodeBlockGenerator extends Generator {
|
||||
|
||||
@Override
|
||||
public void visitVariableDeclaration(GrVariableDeclaration variableDeclaration) {
|
||||
final GrModifierList modifierList = variableDeclaration.getModifierList(); //todo
|
||||
final GrModifierList modifierList = variableDeclaration.getModifierList();
|
||||
final GrVariable[] variables = variableDeclaration.getVariables();
|
||||
|
||||
StringBuilder builder=new StringBuilder();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
ExpressionContext expressionContext = context.copy();
|
||||
final ExpressionGenerator expressionGenerator = new ExpressionGenerator(builder, expressionContext);
|
||||
|
||||
|
||||
if (variableDeclaration.isTuple()) {
|
||||
final GrTupleDeclaration tuple = variableDeclaration.getTupleDeclaration();
|
||||
final GrExpression tupleInitializer = tuple.getInitializerGroovy();
|
||||
@@ -384,6 +395,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
for (int i = 0; i < variables.length; i++) {
|
||||
final GrVariable v = variables[i];
|
||||
final PsiType type = v.getDeclaredType();
|
||||
GenerationUtil.writeModifiers(builder, modifierList);
|
||||
GenerationUtil.writeType(builder, type);
|
||||
builder.append(" ").append(v.getName());
|
||||
if (i < initializers.length) {
|
||||
@@ -396,12 +408,13 @@ public class CodeBlockGenerator extends Generator {
|
||||
else {
|
||||
final PsiType iteratorType =
|
||||
JavaPsiFacade.getElementFactory(context.project).createTypeFromText(CommonClassNames.JAVA_UTIL_ITERATOR, variableDeclaration);
|
||||
final String iteratorName = GenerationUtil.suggestVarName(iteratorType,variableDeclaration, expressionContext);
|
||||
final String iteratorName = GenerationUtil.suggestVarName(iteratorType, variableDeclaration, expressionContext);
|
||||
builder.append("final ").append(CommonClassNames.JAVA_UTIL_ITERATOR).append(" ").append(iteratorName).append(" = ");
|
||||
|
||||
GenerationUtil.invokeMethodByName(tupleInitializer, "iterator", GrExpression.EMPTY_ARRAY, GrNamedArgument.EMPTY_ARRAY,
|
||||
GrClosableBlock.EMPTY_ARRAY, expressionGenerator, variableDeclaration);
|
||||
for (final GrVariable v : variables) {
|
||||
GenerationUtil.writeModifiers(builder, modifierList);
|
||||
final PsiType type = v.getDeclaredType();
|
||||
GenerationUtil.writeType(builder, type);
|
||||
builder.append(" ").append(v.getName());
|
||||
@@ -410,13 +423,12 @@ public class CodeBlockGenerator extends Generator {
|
||||
}
|
||||
}
|
||||
else {
|
||||
GenerationUtil.writeModifiers(builder, modifierList);
|
||||
final GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
|
||||
PsiType type = typeElement == null
|
||||
? PsiType.getJavaLangObject(variableDeclaration.getManager(), variableDeclaration.getResolveScope())
|
||||
: typeElement.getType();
|
||||
GenerationUtil.writeType(builder, type);
|
||||
|
||||
|
||||
}
|
||||
writeStatement(builder, variableDeclaration, expressionContext);
|
||||
}
|
||||
|
||||
+6
@@ -39,4 +39,10 @@ class ExpressionContext {
|
||||
ExpressionContext copy() {
|
||||
return new ExpressionContext(project, myUsedVarNames);
|
||||
}
|
||||
|
||||
ExpressionContext extend() {
|
||||
final HashSet<String> usedVarNames = new HashSet<String>();
|
||||
usedVarNames.addAll(myUsedVarNames);
|
||||
return new ExpressionContext(project, usedVarNames);
|
||||
}
|
||||
}
|
||||
+4
@@ -129,6 +129,10 @@ public class GenerationUtil {
|
||||
argumentListGenerator.generate(null, exprs, namedArgs, closureArgs, psiContext);
|
||||
}
|
||||
|
||||
public static boolean writeModifiers(StringBuilder text, PsiModifierList modifierList) {
|
||||
return writeModifiers(text, modifierList, JAVA_MODIFIERS);
|
||||
}
|
||||
|
||||
public static boolean writeModifiers(StringBuilder text, PsiModifierList modifierList, String[] modifiers) {
|
||||
boolean wasAddedModifiers = false;
|
||||
for (String modifierType : modifiers) {
|
||||
|
||||
+28
@@ -657,4 +657,32 @@ return foo()"""
|
||||
checkCompletion "asse<caret>x", ' ', 'assert <caret>x'
|
||||
}
|
||||
|
||||
public void testDontShowAccessors() {
|
||||
assertNull doContainsTest("getFoo", """
|
||||
class MyClass {
|
||||
def foo
|
||||
}
|
||||
|
||||
def a = new MyClass()
|
||||
a.<caret>""")
|
||||
}
|
||||
|
||||
private doContainsTest(String itemToCheck, String text) {
|
||||
myFixture.configureByText "a.groovy", text
|
||||
|
||||
final LookupElement[] completion = myFixture.completeBasic()
|
||||
return completion.find {println it.lookupString;itemToCheck == it.lookupString}
|
||||
}
|
||||
|
||||
|
||||
public void testShowAccessor() {
|
||||
assertNotNull doContainsTest("getFoo", """
|
||||
class MyClass {
|
||||
def foo
|
||||
}
|
||||
|
||||
def a = new MyClass()
|
||||
a.g<caret>
|
||||
""")
|
||||
}
|
||||
}
|
||||
+1
@@ -112,6 +112,7 @@ public class StatementsParsingTest extends GroovyParsingTestCase {
|
||||
public void testSwitch$swit5() throws Throwable { doTest(); }
|
||||
public void testSwitch$swit6() throws Throwable { doTest(); }
|
||||
public void testSwitch$swit7() throws Throwable { doTest(); }
|
||||
public void testSwitch$swit8() throws Throwable { doTest(); }
|
||||
public void testSyn$syn1() throws Throwable { doTest(); }
|
||||
public void testTop_methods$method1() throws Throwable { doTest(); }
|
||||
public void testTop_methods$method2() throws Throwable { doTest(); }
|
||||
|
||||
+1
-1
@@ -649,7 +649,7 @@ set<caret>Foo(2)
|
||||
assertTrue GroovyRefactoringUtil.isLocalVariable(resolved)
|
||||
}
|
||||
|
||||
public void testResolveForVarOutsideOfFor() {
|
||||
public void _testResolveForVarOutsideOfFor() {
|
||||
final PsiElement resolved = resolve("A.groovy")
|
||||
assertInstanceOf resolved, GrParameter
|
||||
}
|
||||
|
||||
@@ -18,16 +18,15 @@ Groovy script
|
||||
Case label
|
||||
PsiElement(case)('case')
|
||||
PsiWhiteSpace(' ')
|
||||
Call expression
|
||||
Literal
|
||||
PsiElement(Integer)('1')
|
||||
PsiWhiteSpace(' ')
|
||||
Command arguments
|
||||
Reference expression
|
||||
PsiElement(identifier)('expr1')
|
||||
Literal
|
||||
PsiElement(Integer)('1')
|
||||
PsiErrorElement:':' expected
|
||||
<empty list>
|
||||
PsiElement(new line)('\n')
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
PsiElement(identifier)('expr1')
|
||||
PsiElement(new line)('\n')
|
||||
Case section
|
||||
Case label
|
||||
PsiElement(default)('default')
|
||||
PsiElement(:)(':')
|
||||
@@ -40,4 +39,4 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(string)(''abc'')
|
||||
PsiElement(new line)('\n')
|
||||
PsiElement(})('}')
|
||||
PsiElement(})('}')
|
||||
@@ -0,0 +1,33 @@
|
||||
switch (a) {
|
||||
case:
|
||||
print a;
|
||||
}
|
||||
-----
|
||||
Groovy script
|
||||
Switch statement
|
||||
PsiElement(switch)('switch')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(()('(')
|
||||
Reference expression
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement({)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
Case section
|
||||
Case label
|
||||
PsiElement(case)('case')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiElement(:)(':')
|
||||
PsiElement(new line)('\n ')
|
||||
Call expression
|
||||
Reference expression
|
||||
PsiElement(identifier)('print')
|
||||
PsiWhiteSpace(' ')
|
||||
Command arguments
|
||||
Reference expression
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement(;)(';')
|
||||
PsiElement(new line)('\n')
|
||||
PsiElement(})('}')
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def a = 5;
|
||||
while (a < 20) a--
|
||||
@@ -0,0 +1,2 @@
|
||||
int a = 5;
|
||||
while (a < 20) a--;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def a = 5;
|
||||
while (![1, 2, 3, 4].find {a > it}) a--
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
int i = 5;
|
||||
java.util.List<Integer> list = new java.util.ArrayList<Integer>(4);
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
list.add(3);
|
||||
list.add(4);
|
||||
while (!org.codehaus.groovy.runtime.DefaultGroovyMethods.find(list, new groovy.lang.Closure(this, this) {
|
||||
boolean doCall(java.lang.Integer it) {
|
||||
return a.equals(it);
|
||||
}
|
||||
})) a--;
|
||||
@@ -134,6 +134,9 @@ public final class HgCommandExecutor {
|
||||
} catch (IOException e) {
|
||||
showError(e);
|
||||
LOG.info("IOException during preparing command", e);
|
||||
promptServer.stop();
|
||||
warningServer.stop();
|
||||
passServer.stop();
|
||||
return null;
|
||||
}
|
||||
cmdLine.addAll(myOptions);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea.execution;
|
||||
|
||||
import com.intellij.execution.process.CapturingProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
@@ -56,48 +58,19 @@ public final class ShellCommand {
|
||||
processBuilder = processBuilder.directory(new File(dir));
|
||||
}
|
||||
Process process = processBuilder.start();
|
||||
Thread outReaderThread = startReader(
|
||||
new InputStreamReader(process.getInputStream(), charset), out
|
||||
);
|
||||
Thread errReaderThread = startReader(
|
||||
new InputStreamReader(process.getErrorStream()), err
|
||||
);
|
||||
process.waitFor();
|
||||
int exitValue = process.exitValue();
|
||||
outReaderThread.join();
|
||||
errReaderThread.join();
|
||||
|
||||
CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
|
||||
final ProcessOutput processOutput = processHandler.runProcess();
|
||||
|
||||
int exitValue = processOutput.getExitCode();
|
||||
out.write(processOutput.getStdout());
|
||||
err.write(processOutput.getStderr());
|
||||
return new HgCommandResult(out, err, exitValue );
|
||||
} catch (IOException e) {
|
||||
throw new ShellCommandException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Thread startReader(final InputStreamReader in, final Writer writer) {
|
||||
Thread readingThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
char[] buffer = new char[BUFFER_SIZE];
|
||||
int count;
|
||||
try {
|
||||
while ((count = in.read(buffer)) > 0) {
|
||||
writer.write(buffer, 0, count);
|
||||
}
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
LOG.info(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
readingThread.start();
|
||||
return readingThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes charactes in the command which will be executed via 'bash -c' - these are standard chars like \n, and some bash specials.
|
||||
* @param source Original string.
|
||||
|
||||
@@ -12,64 +12,67 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea.execution;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* Common server class that contains the boiler-plate code to set up a server socket.
|
||||
* The actual logic is delegated to the Protocol instance.
|
||||
*/
|
||||
public class SocketServer {
|
||||
protected Thread serverThread;
|
||||
protected ServerSocket serverSocket;
|
||||
private final Protocol protocol;
|
||||
protected ServerSocket myServerSocket;
|
||||
private final Protocol myProtocol;
|
||||
private Future<?> myExecutingFuture;
|
||||
|
||||
public SocketServer(Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
myProtocol = protocol;
|
||||
}
|
||||
|
||||
public int start() throws IOException {
|
||||
serverSocket = new ServerSocket(0);
|
||||
int port = serverSocket.getLocalPort();
|
||||
myServerSocket = new ServerSocket(0);
|
||||
int port = myServerSocket.getLocalPort();
|
||||
|
||||
serverThread = new Thread("hg4idea prompt server") {
|
||||
myExecutingFuture = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean _continue = true;
|
||||
while (_continue) {
|
||||
Socket socket = serverSocket.accept();
|
||||
Socket socket = myServerSocket.accept();
|
||||
try {
|
||||
_continue = protocol.handleConnection(socket);
|
||||
_continue = myProtocol.handleConnection(socket);
|
||||
}
|
||||
finally {
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
}
|
||||
catch (SocketException e) {
|
||||
//socket was closed, that's OK
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e); //TODO implement catch clause
|
||||
}
|
||||
}
|
||||
};
|
||||
serverThread.start();
|
||||
});
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
serverThread.interrupt();
|
||||
myExecutingFuture.cancel(true);
|
||||
try {
|
||||
serverSocket.close();
|
||||
myServerSocket.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e); //TODO implement catch clause
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static abstract class Protocol {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class HgHistoryProvider implements VcsHistoryProvider {
|
||||
}
|
||||
final List<VcsFileRevision> revisions = new ArrayList<VcsFileRevision>();
|
||||
revisions.addAll(getHistory(filePath, vcsRoot, myProject, DEFAULT_LIMIT));
|
||||
return createAppendableSession(vcsRoot, revisions);
|
||||
return createAppendableSession(vcsRoot, revisions, null);
|
||||
}
|
||||
|
||||
public void reportAppendableHistory(FilePath filePath, final VcsAppendableHistorySessionPartner partner) throws VcsException {
|
||||
@@ -75,7 +75,7 @@ public class HgHistoryProvider implements VcsHistoryProvider {
|
||||
final List<HgFileRevision> history = getHistory(filePath, vcsRoot, myProject, DEFAULT_LIMIT);
|
||||
if (history.size() == 0) return;
|
||||
|
||||
final VcsAbstractHistorySession emptySession = createAppendableSession(vcsRoot, Collections.<VcsFileRevision>emptyList());
|
||||
final VcsAbstractHistorySession emptySession = createAppendableSession(vcsRoot, Collections.<VcsFileRevision>emptyList(), null);
|
||||
partner.reportCreatedEmptySession(emptySession);
|
||||
|
||||
for (HgFileRevision hgFileRevision : history) {
|
||||
@@ -84,8 +84,8 @@ public class HgHistoryProvider implements VcsHistoryProvider {
|
||||
partner.finished();
|
||||
}
|
||||
|
||||
private VcsAbstractHistorySession createAppendableSession(final VirtualFile vcsRoot, List<VcsFileRevision> revisions) {
|
||||
return new VcsAbstractHistorySession(revisions) {
|
||||
private VcsAbstractHistorySession createAppendableSession(final VirtualFile vcsRoot, List<VcsFileRevision> revisions, @Nullable VcsRevisionNumber number) {
|
||||
return new VcsAbstractHistorySession(revisions, number) {
|
||||
@Nullable
|
||||
protected VcsRevisionNumber calcCurrentRevisionNumber() {
|
||||
return new HgWorkingCopyRevisionsCommand(myProject).firstParent(vcsRoot);
|
||||
@@ -97,7 +97,7 @@ public class HgHistoryProvider implements VcsHistoryProvider {
|
||||
|
||||
@Override
|
||||
public VcsHistorySession copy() {
|
||||
return createAppendableSession(vcsRoot, getRevisionList());
|
||||
return createAppendableSession(vcsRoot, getRevisionList(), getCurrentRevisionNumber());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+9
-4
@@ -96,7 +96,8 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
|
||||
private JComboBox myForkCb;
|
||||
@NonNls private static final String NONE = "none";
|
||||
@NonNls private static final String METHOD = "method";
|
||||
private static final String[] FORK_MODE_ALL = {NONE, METHOD, "class"};
|
||||
@NonNls private static final String KLASS = "class";
|
||||
private static final String[] FORK_MODE_ALL = {NONE, METHOD, KLASS};
|
||||
private static final String[] FORK_MODE = {NONE, METHOD};
|
||||
|
||||
public JUnitConfigurable(final Project project) {
|
||||
@@ -203,6 +204,10 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
|
||||
}
|
||||
|
||||
private void changePanel () {
|
||||
String selectedItem = (String)myForkCb.getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
selectedItem = NONE;
|
||||
}
|
||||
if (myAllInPackageButton.isSelected()) {
|
||||
myPackagePanel.setVisible(true);
|
||||
myPattern.setVisible(false);
|
||||
@@ -210,7 +215,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
|
||||
myMethod.setVisible(false);
|
||||
myForkCb.setEnabled(true);
|
||||
myForkCb.setModel(new DefaultComboBoxModel(FORK_MODE_ALL));
|
||||
myForkCb.setSelectedItem(NONE);
|
||||
myForkCb.setSelectedItem(selectedItem);
|
||||
}
|
||||
else if (myClassButton.isSelected()){
|
||||
myPackagePanel.setVisible(false);
|
||||
@@ -219,7 +224,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
|
||||
myMethod.setVisible(false);
|
||||
myForkCb.setEnabled(true);
|
||||
myForkCb.setModel(new DefaultComboBoxModel(FORK_MODE));
|
||||
myForkCb.setSelectedItem(NONE);
|
||||
myForkCb.setSelectedItem(selectedItem != KLASS ? selectedItem : METHOD);
|
||||
}
|
||||
else if (myTestMethodButton.isSelected()){
|
||||
myPackagePanel.setVisible(false);
|
||||
@@ -235,7 +240,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
|
||||
myMethod.setVisible(false);
|
||||
myForkCb.setEnabled(true);
|
||||
myForkCb.setModel(new DefaultComboBoxModel(FORK_MODE_ALL));
|
||||
myForkCb.setSelectedItem(NONE);
|
||||
myForkCb.setSelectedItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -19,14 +19,17 @@ package com.intellij.util.xml.converters.values;
|
||||
import com.intellij.util.xml.ConvertContext;
|
||||
import com.intellij.util.xml.Converter;
|
||||
import com.intellij.util.xml.DomBundle;
|
||||
import com.intellij.util.xml.ResolvingConverter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class NumberValueConverter extends Converter<String> {
|
||||
public class NumberValueConverter extends ResolvingConverter<String> {
|
||||
|
||||
private final Class myNumberClass;
|
||||
private final boolean myAllowEmpty;
|
||||
@@ -57,6 +60,12 @@ public class NumberValueConverter extends Converter<String> {
|
||||
DomBundle.message("value.converter.format.exception", s, myNumberClass.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends String> getVariants(ConvertContext context) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Number parseNumber(@NotNull String text, @NotNull Class targetClass) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user