diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml
index 60950c712066..46a1e1effbc3 100644
--- a/.idea/inspectionProfiles/idea_default.xml
+++ b/.idea/inspectionProfiles/idea_default.xml
@@ -65,13 +65,17 @@
-
+
+
+
-
+
+
+
@@ -109,6 +113,7 @@
+
@@ -138,6 +143,7 @@
+
@@ -167,6 +173,7 @@
+
+
@@ -263,12 +271,7 @@
-
-
-
-
-
-
+
diff --git a/.idea/inspectionProfiles/idea_default_no_spellchecker.xml b/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
index d815dc710bdf..659d9c39b097 100644
--- a/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
+++ b/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
@@ -65,13 +65,17 @@
-
+
+
+
-
+
+
+
@@ -109,6 +113,7 @@
+
@@ -138,6 +143,7 @@
+
@@ -167,6 +173,7 @@
+
+
@@ -263,12 +271,7 @@
-
-
-
-
-
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 68c989a28ef6..e9537356e97a 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,7 +3,10 @@
-
+
+
+
+
@@ -70,11 +73,11 @@
-
+
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index de219770142e..403876d24d65 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -156,7 +156,17 @@ def layoutFull(String home, String targetDirectory) {
layoutPlugin("ant", "ant", "antIntegration")
layoutPlugin("InspectionGadgets", "InspectionGadgetsPlugin")
- layoutPlugin("IntelliLang", "IntelliLangJava")
+ dir("IntelliLang") {
+ dir("lib") {
+ jar("IntelliLang.jar") {
+ module("IntelliLangJava")
+ module("IntelliLang-java")
+ module("IntelliLang-xml")
+ module("IntelliLang-javaee")
+ }
+ }
+ }
+
layoutPlugin("IntentionPowerPack", "IntentionPowerPackPlugin")
layoutPlugin("ToString", "generate-tostring", "toString")
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index 3eec278f347e..f9d22e8931f6 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -1591,7 +1591,6 @@ public class CompileDriver {
}
private static boolean syncOutputDir(final CompileContextEx context, final Collection> toDelete) throws CacheCorruptedException {
- final int total = toDelete.size();
final DependencyCache dependencyCache = context.getDependencyCache();
final boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode();
@@ -1601,11 +1600,9 @@ public class CompileDriver {
public void run() throws CacheCorruptedException {
final long start = System.currentTimeMillis();
try {
- int current = 0;
for (final Trinity trinity : toDelete) {
final File outputPath = trinity.getFirst();
context.getProgressIndicator().checkCanceled();
- context.getProgressIndicator().setFraction((double)++current / total);
context.getProgressIndicator().setText2(outputPath.getPath());
filesToRefresh.add(outputPath);
if (isTestMode) {
diff --git a/java/java-impl/src/com/intellij/lang/java/JavaLiteralEscaper.java b/java/java-impl/src/com/intellij/lang/java/JavaLiteralEscaper.java
index 8134060faac1..2ada4772a8e0 100644
--- a/java/java-impl/src/com/intellij/lang/java/JavaLiteralEscaper.java
+++ b/java/java-impl/src/com/intellij/lang/java/JavaLiteralEscaper.java
@@ -31,4 +31,12 @@ public class JavaLiteralEscaper implements LiteralEscaper {
}
return originalText;
}
+
+ public String escapeText(String originalText) {
+ return StringUtil.escapeStringCharacters(originalText);
+ }
+
+ public String unescapeText(String originalText) {
+ return StringUtil.unescapeStringCharacters(originalText);
+ }
}
diff --git a/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java b/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java
index e2600572e693..44b290ce142a 100644
--- a/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java
+++ b/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.NonNls;
* A testcase that provides IDEA application and project. Note both are reused for each test run in the session so
* be careful to return all the modification made to application and project components (such as settings) after
* test is finished so other test aren't affected. The project is initialized with single module that have single
- * content&source entry. For your convinience the project may be equipped with some mock JDK so your tests may
+ * content&source entry. For your convenience the project may be equipped with some mock JDK so your tests may
* refer to external classes. In order to enable this feature you have to have a folder named "mockJDK" under
* idea installation home that is used for test running. Place src.zip under that folder. We'd suggest this is real mock
* so it contains classes that is really needed in order to speed up tests startup.
diff --git a/platform/lang-api/src/com/intellij/lang/LanguageLiteralEscapers.java b/platform/lang-api/src/com/intellij/lang/LanguageLiteralEscapers.java
index e6b4b937582f..7941a013ae75 100644
--- a/platform/lang-api/src/com/intellij/lang/LanguageLiteralEscapers.java
+++ b/platform/lang-api/src/com/intellij/lang/LanguageLiteralEscapers.java
@@ -29,6 +29,14 @@ public class LanguageLiteralEscapers extends LanguageExtension {
public String getEscapedText(final PsiElement context, final String originalText) {
return originalText;
}
+
+ public String escapeText(String originalText) {
+ return originalText;
+ }
+
+ public String unescapeText(String originalText) {
+ return originalText;
+ }
});
}
}
diff --git a/platform/lang-api/src/com/intellij/lang/LiteralEscaper.java b/platform/lang-api/src/com/intellij/lang/LiteralEscaper.java
index 466c7cd84f78..2108f2cd136a 100644
--- a/platform/lang-api/src/com/intellij/lang/LiteralEscaper.java
+++ b/platform/lang-api/src/com/intellij/lang/LiteralEscaper.java
@@ -23,4 +23,6 @@ import com.intellij.psi.PsiElement;
*/
public interface LiteralEscaper {
String getEscapedText(PsiElement context, String originalText);
+ String escapeText(String originalText);
+ String unescapeText(String originalText);
}
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java
index ea5f0fe01112..58af540743d9 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java
@@ -63,7 +63,7 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
}
try {
- if (project == null || project.isDisposed()) {
+ if (project == null || project.isDisposed() || !project.isInitialized()) {
//if (ProjectManager.getInstance().getOpenProjects().length > 0) {
// // do nothing if frame is not active
// return;
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
index 4fa570d010d9..e6a1008a7943 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
@@ -36,6 +36,7 @@ import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.ui.UIUtil;
@@ -717,37 +718,41 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
public void updateActionsImmediately() {
ApplicationManager.getApplication().assertIsDispatchThread();
- myNewVisibleActions.clear();
- final DataContext dataContext = getDataContext();
+ IdeFocusManager.getInstance(null).doWhenFocusSettlesDown(new Runnable() {
+ public void run() {
+ myNewVisibleActions.clear();
+ final DataContext dataContext = getDataContext();
- Utils.expandActionGroup(myActionGroup, myNewVisibleActions, myPresentationFactory, dataContext, myPlace, myActionManager);
+ Utils.expandActionGroup(myActionGroup, myNewVisibleActions, myPresentationFactory, dataContext, myPlace, myActionManager);
- if (!myNewVisibleActions.equals(myVisibleActions)) {
- // should rebuild UI
+ if (!myNewVisibleActions.equals(myVisibleActions)) {
+ // should rebuild UI
- final boolean changeBarVisibility = myNewVisibleActions.isEmpty() || myVisibleActions.isEmpty();
+ final boolean changeBarVisibility = myNewVisibleActions.isEmpty() || myVisibleActions.isEmpty();
- final ArrayList temp = myVisibleActions;
- myVisibleActions = myNewVisibleActions;
- myNewVisibleActions = temp;
+ final ArrayList temp = myVisibleActions;
+ myVisibleActions = myNewVisibleActions;
+ myNewVisibleActions = temp;
- removeAll();
- mySecondaryActions.removeAll();
- mySecondaryActionsButton = null;
- fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL);
+ removeAll();
+ mySecondaryActions.removeAll();
+ mySecondaryActionsButton = null;
+ fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL);
- if (changeBarVisibility) {
- revalidate();
- }
- else {
- final Container parent = getParent();
- if (parent != null) {
- parent.invalidate();
- parent.validate();
+ if (changeBarVisibility) {
+ revalidate();
+ }
+ else {
+ final Container parent = getParent();
+ if (parent != null) {
+ parent.invalidate();
+ parent.validate();
+ }
+ }
+ repaint();
}
}
- repaint();
- }
+ });
}
public void setTargetComponent(final JComponent component) {
diff --git a/platform/platform-impl/src/com/intellij/util/ui/LocalPathCellEditor.java b/platform/platform-impl/src/com/intellij/util/ui/LocalPathCellEditor.java
new file mode 100644
index 000000000000..f46845347a69
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/util/ui/LocalPathCellEditor.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2010 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.util.ui;
+
+import com.intellij.openapi.fileChooser.FileChooser;
+import com.intellij.openapi.fileChooser.FileChooserDescriptor;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.ui.AbstractTableCellEditor;
+import com.intellij.util.ui.CellEditorComponentWithBrowseButton;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class LocalPathCellEditor extends AbstractTableCellEditor {
+ private final String myTitle;
+
+ private CellEditorComponentWithBrowseButton myComponent;
+
+ public LocalPathCellEditor(String title) {
+ myTitle = title;
+ }
+
+ public Object getCellEditorValue() {
+ return myComponent.getChildComponent().getText();
+ }
+
+ public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
+ ActionListener listener = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ FileChooserDescriptor d = new FileChooserDescriptor(false, true, false, true, false, false);
+ if (myTitle != null) {
+ d.setTitle(myTitle);
+ }
+ d.setShowFileSystemRoots(true);
+
+ VirtualFile initialFile = LocalFileSystem.getInstance().findFileByPath((String)getCellEditorValue());
+ VirtualFile[] files = FileChooser.chooseFiles(table, d, initialFile);
+ if (files.length == 1 && files[0] != null) {
+ String path = files[0].getPresentableUrl();
+ if (SystemInfo.isWindows && path.length() == 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') {
+ path += "\\"; // make path absolute
+ }
+ myComponent.getChildComponent().setText(path);
+ }
+ }
+ };
+ myComponent = new CellEditorComponentWithBrowseButton(new TextFieldWithBrowseButton(listener), this);
+ myComponent.getChildComponent().setText((String)value);
+ return myComponent;
+ }
+}
diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form
new file mode 100644
index 000000000000..811d6ca765be
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form
@@ -0,0 +1,78 @@
+
+
diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java
new file mode 100644
index 000000000000..5f8e3b7f475b
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2000-2010 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.util.ui;
+
+import com.intellij.openapi.util.NullableComputable;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.ui.HoverHyperlinkLabel;
+import com.intellij.ui.table.TableView;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class ValidatingTableEditor- {
+
+ private static final Icon WARNING_ICON = UIUtil.getBalloonWarningIcon();
+ private static final Icon EMPTY_ICON = new EmptyIcon(WARNING_ICON);
+ private static final String REMOVE_KEY = "REMOVE_SELECTED";
+
+ public interface RowHeightProvider {
+ int getRowHeight();
+ }
+
+ public interface Fix extends Runnable {
+ String getTitle();
+ }
+
+ private class ColumnInfoWrapper extends ColumnInfo
- {
+ private final ColumnInfo
- myDelegate;
+
+ public ColumnInfoWrapper(ColumnInfo
- delegate) {
+ super(delegate.getName());
+ myDelegate = delegate;
+ }
+
+ @Override
+ public String valueOf(Item item) {
+ return myDelegate.valueOf(item);
+ }
+
+ @Override
+ public boolean isCellEditable(Item item) {
+ return myDelegate.isCellEditable(item);
+ }
+
+ @Override
+ public void setValue(Item item, String value) {
+ myDelegate.setValue(item, value);
+ updateMessage(-1, null);
+ }
+
+ @Override
+ public TableCellEditor getEditor(Item item) {
+ return myDelegate.getEditor(item);
+ }
+ }
+
+ private JPanel myContentPane;
+ private TableView
- myTable;
+ private JButton myAddButton;
+ private JButton myRemoveButton;
+ private JLabel myMessageLabel;
+ private HoverHyperlinkLabel myFixLink;
+ private final List myWarnings = new ArrayList();
+ private Fix myFixRunnable;
+
+ protected abstract Item cloneOf(Item item);
+
+ @Nullable
+ protected Pair validate(List
- current, List warnings) {
+ String error = null;
+ for (int i = 0; i < current.size(); i++) {
+ Item item = current.get(i);
+ String s = validate(item);
+ warnings.set(i, s);
+ if (error == null) {
+ error = s;
+ }
+ }
+ return error != null ? Pair.create(error, (Fix)null) : null;
+ }
+
+ @Nullable
+ protected String validate(Item item) {
+ return null;
+ }
+
+ protected abstract Item createItem();
+
+ private class IconColumn extends ColumnInfo
- implements RowHeightProvider {
+ public IconColumn() {
+ super(" ");
+ }
+
+ public String valueOf(Item item) {
+ return null;
+ }
+
+ @Override
+ public int getWidth(JTable table) {
+ return WARNING_ICON.getIconWidth() + 2;
+ }
+
+ public int getRowHeight() {
+ return WARNING_ICON.getIconHeight();
+ }
+
+ @Override
+ public TableCellRenderer getRenderer(final Item item) {
+ return new WarningIconCellRenderer(new NullableComputable() {
+ public String compute() {
+ return myWarnings.get(doGetItems().indexOf(item));
+ }
+ });
+ }
+ }
+
+
+ private void createUIComponents() {
+ myTable = new ChangesTrackingTableView
- () {
+ protected void onTextChanged(int row, int column, String value) {
+ final Item original = getItems().get(row);
+ Item override = cloneOf(original);
+ final ColumnInfo
- columnInfo = getTableModel().getColumnInfos()[column];
+ columnInfo.setValue(override, value);
+ updateMessage(row, override);
+ }
+
+ @Override
+ protected void onEditingStopped() {
+ updateMessage(-1, null);
+ }
+ };
+
+ myFixLink = new HoverHyperlinkLabel(null);
+ }
+
+ protected ValidatingTableEditor() {
+ myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ updateButtons();
+ }
+ });
+
+ myTable.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), REMOVE_KEY);
+ myTable.getActionMap().put(REMOVE_KEY, new AbstractAction() {
+ public void actionPerformed(final ActionEvent e) {
+ removeSelected();
+ }
+ });
+
+ myFixLink.addHyperlinkListener(new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && myFixRunnable != null) {
+ myFixRunnable.run();
+ }
+ }
+ });
+
+ myAddButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ addItem();
+ }
+ });
+
+ myRemoveButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ removeSelected();
+ }
+ });
+ }
+
+ private void removeSelected() {
+ myTable.stopEditing();
+ List
- items = new ArrayList
- (doGetItems());
+ final int[] rows = myTable.getSelectedRows();
+ for (int i = rows.length - 1; i >= 0; i--) {
+ items.remove(rows[i]);
+ }
+
+ setItems(items);
+ updateMessage(-1, null);
+
+ if (!items.isEmpty()) {
+ int index = Math.min(rows[0], items.size() - 1);
+ myTable.getSelectionModel().addSelectionInterval(index, index);
+ }
+ }
+
+ protected void addItem() {
+ List
- items = new ArrayList
- (doGetItems());
+ items.add(createItem());
+
+ setItems(items);
+
+ final int row = items.size() - 1;
+ myTable.getSelectionModel().setSelectionInterval(row, row);
+ myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));
+ if (getTableModel().getColumnInfos()[1].isCellEditable(items.get(row))) {
+ myTable.editCellAt(row, 1);
+ IdeFocusManager.findInstanceByComponent(myContentPane).requestFocus(myTable.getEditorComponent(), true);
+ }
+ updateMessage(-1, null);
+ }
+
+ private ListTableModel
- getTableModel() {
+ return (ListTableModel
- )myTable.getModel();
+ }
+
+ public void setModel(ColumnInfo
- [] valueColumns, List
- items) {
+ ColumnInfo[] columns = new ColumnInfo[valueColumns.length + 1];
+ IconColumn iconColumn = new IconColumn();
+ int maxHeight = iconColumn.getRowHeight();
+
+ columns[0] = iconColumn;
+ for (int i = 0; i < valueColumns.length; i++) {
+ columns[i + 1] = new ColumnInfoWrapper(valueColumns[i]);
+ if (valueColumns[i] instanceof RowHeightProvider) {
+ maxHeight = Math.max(maxHeight, ((RowHeightProvider)valueColumns[i]).getRowHeight());
+ }
+ }
+
+ myTable.stopEditing();
+ myTable.setModel(new ListTableModel
- (columns));
+ if (maxHeight > 0) {
+ myTable.setRowHeight(maxHeight);
+ }
+
+ setItems(items);
+ updateMessage(-1, null);
+ }
+
+ public List
- getItems() {
+ return Collections.unmodifiableList(doGetItems());
+ }
+
+ private List
- doGetItems() {
+ List
- items = new ArrayList
- (getTableModel().getItems());
+ if (myTable.isEditing()) {
+ Component c = myTable.getEditorComponent();
+ final JTextField textField;
+ if (c instanceof CellEditorComponentWithBrowseButton) {
+ textField = (JTextField)((CellEditorComponentWithBrowseButton)c).getChildComponent();
+ }
+ else {
+ textField = (JTextField)c;
+ }
+ String value = textField.getText();
+ ColumnInfo column = ((ListTableModel)myTable.getModel()).getColumnInfos()[myTable.getEditingColumn()];
+ ((ColumnInfoWrapper)column).myDelegate.setValue(items.get(myTable.getEditingRow()), value);
+ }
+ return items;
+ }
+
+ private void setItems(List
- items) {
+ if (items.isEmpty()) {
+ getTableModel().setItems(Collections.
- emptyList());
+ myWarnings.clear();
+ }
+ else {
+ getTableModel().setItems(new ArrayList
- (items));
+ for (Item item : items) {
+ myWarnings.add(null);
+ }
+ }
+ updateButtons();
+ }
+
+ public void setTableHeader(JTableHeader header) {
+ myTable.setTableHeader(header);
+ }
+
+ private void updateButtons() {
+ myRemoveButton.setEnabled(myTable.getSelectedRow() != -1);
+ }
+
+ public void updateMessage(int index, @Nullable Item override) {
+ List
- current = new ArrayList
- (doGetItems());
+ if (override != null) {
+ current.set(index, override);
+ }
+
+ Pair messageAndFix = validate(current, myWarnings);
+ if (messageAndFix != null) {
+ myMessageLabel.setText(messageAndFix.first);
+ myMessageLabel.setIcon(WARNING_ICON);
+ myMessageLabel.setVisible(true);
+ myFixRunnable = messageAndFix.second;
+ myFixLink.setVisible(myFixRunnable != null);
+ myFixLink.setText(myFixRunnable != null ? myFixRunnable.getTitle() : null);
+ }
+ else {
+ myMessageLabel.setText(" ");
+ myMessageLabel.setIcon(EMPTY_ICON);
+ myFixLink.setVisible(false);
+ myFixRunnable = null;
+ }
+ myTable.repaint();
+ }
+
+ public JComponent getPreferredFocusedComponent() {
+ return myTable;
+ }
+
+
+ private static class WarningIconCellRenderer extends DefaultTableCellRenderer {
+ private final NullableComputable myWarningProvider;
+
+ public WarningIconCellRenderer(NullableComputable warningProvider) {
+ myWarningProvider = warningProvider;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ String message = myWarningProvider.compute();
+ label.setIcon(message != null ? WARNING_ICON : null);
+ label.setToolTipText(message);
+ label.setHorizontalAlignment(CENTER);
+ label.setVerticalAlignment(CENTER);
+ return label;
+ }
+ }
+
+ public Component getContentPane() {
+ return myContentPane;
+ }
+
+
+}
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index c0cf915bbdad..0ce71a2dac71 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -289,7 +289,13 @@ title.unable.to.save.data=Unable to Save Data
link.click.here.to.license.server.info=More info
link.purchase.commercial.license=To purchase a commercial license, please visit
license.panel.current.license.description=The license will expire on {0,date,MMMM dd, yyyy}
-license.panel.buildit.evaluation.expires.in=Remains {0} day(s)
+license.panel.current.permanent.ticket.description=Permanent ticket obtained
+license.panel.current.floating.ticket.description=Floating ticket obtained
+license.panel.buildit.evaluation.expires.in.one=1 day left
+license.panel.buildit.evaluation.expires.in.many={0} days left
+license.panel.ping.license.server.error.message=No response from autodetected license server
+license.panel.ping.license.server.error.title=No response from server
+license.panel.default.server.discover=Discover
editbox.license.user.name=User name:
editbox.license.license.key=License key:
radio.license.server.address=Enter license &server address
@@ -1051,3 +1057,4 @@ FileChooser.listViewActionLabelText=List
FileChooser.detailsViewActionLabelText=Details
FileChooser.refreshActionLabelText=Refresh
browsers.settings=Web Browsers
+
diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml
index 19e768f3bdfd..3d7f6bf339da 100644
--- a/platform/platform-resources/src/META-INF/XmlPlugin.xml
+++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml
@@ -44,6 +44,7 @@
+
diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
index df1b738df96e..75ac24687559 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -1761,5 +1761,7 @@ remove.try.finally.block.quickfix=Remove try-finally block
remove.finally.block.quickfix=Remove finally block
remove.leading.zero.to.make.decimal.quickfix=Remove leading zero to make decimal
convert.octal.literal.to.decimal.literal.quickfix=Convert octal literal to decimal literal
-ignore.single.field.static.imports=Ignore single &field static imports
-ignore.single.method.static.imports=Ignore single &method static imports
+ignore.single.field.static.imports.option=Ignore single &field static imports
+ignore.single.method.static.imports.option=Ignore single &method static imports
+ignore.methods.with.boolean.return.type.option=Ignore methods with &Boolean return type
+ignore.boolean.methods.in.an.interface.option=Ignore boolean methods in an @&interface
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java
index 2cd3216a05bf..2278b4316a7e 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java
@@ -60,10 +60,10 @@ public class StaticImportInspection extends BaseInspection {
final MultipleCheckboxOptionsPanel panel =
new MultipleCheckboxOptionsPanel(this);
panel.addCheckbox(InspectionGadgetsBundle.message(
- "ignore.single.field.static.imports"),
+ "ignore.single.field.static.imports.option"),
"ignoreSingleFieldImports");
panel.addCheckbox(InspectionGadgetsBundle.message(
- "ignore.single.method.static.imports"),
+ "ignore.single.method.static.imports.option"),
"ignoreSingeMethodImports");
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/FieldRepeatedlyAccessedInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/FieldRepeatedlyAccessedInspection.java
index 571365d425d3..fc1b75e9a383 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/FieldRepeatedlyAccessedInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/FieldRepeatedlyAccessedInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,34 +15,36 @@
*/
package com.siyeh.ig.j2me;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.psi.*;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.performance.VariableAccessVisitor;
import com.siyeh.ig.psiutils.ExpressionUtils;
-import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
+import javax.swing.JComponent;
import java.util.Set;
public class FieldRepeatedlyAccessedInspection extends BaseInspection {
-
+
/** @noinspection PublicField*/
public boolean m_ignoreFinalFields = false;
+ @Override
@NotNull
public String getID(){
return "FieldRepeatedlyAccessedInMethod";
}
+ @Override
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message(
"field.repeatedly.accessed.in.method.display.name");
}
+ @Override
@NotNull
public String buildErrorString(Object... arg) {
final String fieldName = ((PsiNamedElement) arg[0]).getName();
@@ -51,12 +53,14 @@ public class FieldRepeatedlyAccessedInspection extends BaseInspection {
fieldName);
}
+ @Override
public JComponent createOptionsPanel() {
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message(
"field.repeatedly.accessed.in.method.ignore.option"),
this, "m_ignoreFinalFields");
}
+ @Override
public BaseInspectionVisitor buildVisitor() {
return new FieldRepeatedlyAccessedVisitor();
}
@@ -72,8 +76,11 @@ public class FieldRepeatedlyAccessedInspection extends BaseInspection {
method.accept(visitor);
final Set fields = visitor.getOveraccessedFields();
for(PsiField field : fields){
- if(ExpressionUtils.isConstant(field) || m_ignoreFinalFields &&
- field.hasModifierProperty(PsiModifier.FINAL)){
+ if(ExpressionUtils.isConstant(field)){
+ continue;
+ }
+ if(m_ignoreFinalFields &&
+ field.hasModifierProperty(PsiModifier.FINAL)){
continue;
}
registerError(nameIdentifier, field);
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/VariableAccessVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/VariableAccessVisitor.java
similarity index 87%
rename from plugins/InspectionGadgets/src/com/siyeh/ig/performance/VariableAccessVisitor.java
rename to plugins/InspectionGadgets/src/com/siyeh/ig/j2me/VariableAccessVisitor.java
index 79646864e4de..cde48d586c32 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/VariableAccessVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/VariableAccessVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.siyeh.ig.performance;
+package com.siyeh.ig.j2me;
import com.intellij.psi.*;
import com.siyeh.ig.psiutils.ControlFlowUtils;
@@ -21,17 +21,17 @@ import org.jetbrains.annotations.NotNull;
import java.util.*;
-public class VariableAccessVisitor extends JavaRecursiveElementVisitor {
+class VariableAccessVisitor extends JavaRecursiveElementVisitor {
private final Map m_accessCounts =
new HashMap(2);
private final Set m_overAccessedFields =
new HashSet(2);
- @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression ref) {
+ @Override public void visitReferenceExpression(
+ @NotNull PsiReferenceExpression ref) {
super.visitReferenceExpression(ref);
final PsiExpression qualifier = ref.getQualifierExpression();
-
if (qualifier != null && !(qualifier instanceof PsiThisExpression)) {
return;
}
@@ -51,7 +51,7 @@ public class VariableAccessVisitor extends JavaRecursiveElementVisitor {
final Integer count = accessCounts.get(field);
if (count == null) {
accessCounts.put(field, 1);
- } else if (count == 1) {
+ } else if (count.intValue() == 1) {
accessCounts.put(field, 2);
} else {
overAccessedFields.add(field);
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form
deleted file mode 100644
index a17199c50fa3..000000000000
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
index 96e9adcc2326..e3d223cee746 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.siyeh.ig.naming;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.siyeh.InspectionGadgetsBundle;
@@ -25,21 +26,29 @@ import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.fixes.RenameFix;
import com.siyeh.ig.psiutils.LibraryUtil;
-import com.siyeh.ig.ui.AddAction;
-import com.siyeh.ig.ui.IGTable;
-import com.siyeh.ig.ui.ListWrappingTableModel;
-import com.siyeh.ig.ui.RemoveAction;
+import com.siyeh.ig.ui.*;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
public class BooleanMethodNameMustStartWithQuestionInspection
extends BaseInspection{
+ @SuppressWarnings({"PublicField"})
+ public boolean ignoreBooleanMethods = false;
+
+ @SuppressWarnings({"PublicField"})
+ public boolean ignoreInAnnotationInterface = true;
+
/** @noinspection PublicField*/
@NonNls public String questionString =
"is,can,has,should,could,will,shall,check,contains,equals,add," +
@@ -51,41 +60,97 @@ public class BooleanMethodNameMustStartWithQuestionInspection
parseString(questionString, questionList);
}
+ @Override
@NotNull
public String getDisplayName(){
return InspectionGadgetsBundle.message(
"boolean.method.name.must.start.with.question.display.name");
}
+ @Override
@NotNull
public String buildErrorString(Object... infos){
return InspectionGadgetsBundle.message(
"boolean.method.name.must.start.with.question.problem.descriptor");
}
+ @Override
public void readSettings(Element element) throws InvalidDataException{
super.readSettings(element);
parseString(questionString, questionList);
}
+ @Override
public void writeSettings(Element element) throws WriteExternalException{
questionString = formatString(questionList);
super.writeSettings(element);
}
+ @Override
public JComponent createOptionsPanel(){
- final Form form = new Form();
- return form.getContentPanel();
+ final JPanel panel = new JPanel(new GridBagLayout());
+ final IGTable table =
+ new IGTable(new ListWrappingTableModel(questionList,
+ InspectionGadgetsBundle.message(
+ "boolean.method.name.must.start.with.question.table.column.name")));
+ final JScrollPane scrollPane = new JScrollPane(table);
+
+ final GridBagConstraints constraints = new GridBagConstraints();
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.gridheight = 3;
+ constraints.weightx = 1.0;
+ constraints.weighty = 1.0;
+ constraints.fill = GridBagConstraints.BOTH;
+ panel.add(scrollPane, constraints);
+
+ final JButton addButton = new JButton(new AddAction(table));
+ constraints.gridx = 1;
+ constraints.gridheight = 1;
+ constraints.weightx = 0.0;
+ constraints.weighty = 0.0;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ panel.add(addButton, constraints);
+
+ final JButton removeButton = new JButton(new RemoveAction(table));
+ constraints.gridy = 1;
+ panel.add(removeButton, constraints);
+
+ final BlankFiller filler = new BlankFiller();
+ constraints.gridy = 2;
+ constraints.weighty = 1.0;
+ panel.add(filler, constraints);
+
+ final CheckBox checkBox1 =
+ new CheckBox(InspectionGadgetsBundle.message(
+ "ignore.methods.with.boolean.return.type.option"),
+ this, "ignoreBooleanMethods");
+ constraints.gridy = 3;
+ constraints.gridx = 0;
+ constraints.gridwidth = 2;
+ constraints.weighty = 0.0;
+ panel.add(checkBox1, constraints);
+
+ final CheckBox checkBox2 =
+ new CheckBox(InspectionGadgetsBundle.message(
+ "ignore.boolean.methods.in.an.interface.option"),
+ this, "ignoreInAnnotationInterface");
+ constraints.gridy = 4;
+ panel.add(checkBox2, constraints);
+ return panel;
}
+ @Override
protected InspectionGadgetsFix buildFix(Object... infos){
return new RenameFix();
}
+ @Override
protected boolean buildQuickFixesOnlyForOnTheFlyErrors(){
return true;
}
+ @Override
public BaseInspectionVisitor buildVisitor(){
return new BooleanMethodNameMustStartWithQuestionVisitor();
}
@@ -95,8 +160,20 @@ public class BooleanMethodNameMustStartWithQuestionInspection
@Override public void visitMethod(@NotNull PsiMethod method){
final PsiType returnType = method.getReturnType();
- if(returnType == null || !returnType.equals(PsiType.BOOLEAN)){
+ if(returnType == null){
return;
+ } else if(!returnType.equals(PsiType.BOOLEAN)){
+ if (ignoreBooleanMethods ||
+ !returnType.equalsToText("java.lang.Boolean")) {
+ return;
+ }
+ }
+ if (ignoreInAnnotationInterface) {
+ final PsiClass containingClass = method.getContainingClass();
+ if (containingClass != null &&
+ containingClass.isAnnotationType()) {
+ return;
+ }
}
final String name = method.getName();
for(String question : questionList){
@@ -110,28 +187,4 @@ public class BooleanMethodNameMustStartWithQuestionInspection
registerMethodError(method);
}
}
-
- private class Form{
-
- JPanel contentPanel;
- JButton addButton;
- JButton removeButton;
- IGTable table;
-
- Form(){
- super();
- addButton.setAction(new AddAction(table));
- removeButton.setAction(new RemoveAction(table));
- }
-
- private void createUIComponents(){
- table = new IGTable(new ListWrappingTableModel(questionList,
- InspectionGadgetsBundle.message(
- "boolean.method.name.must.start.with.question.table.column.name")));
- }
-
- public JComponent getContentPanel(){
- return contentPanel;
- }
- }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
index bba21404f217..99f368ab9a90 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,15 +25,17 @@ import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.fixes.RenameFix;
import com.siyeh.ig.psiutils.LibraryUtil;
-import com.siyeh.ig.ui.AddAction;
-import com.siyeh.ig.ui.IGTable;
-import com.siyeh.ig.ui.ListWrappingTableModel;
-import com.siyeh.ig.ui.RemoveAction;
+import com.siyeh.ig.ui.*;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
@@ -45,47 +47,99 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection
"is,can,has,should,could,will,shall,check,contains,equals," +
"startsWith,endsWith";
+ @SuppressWarnings({"PublicField"})
+ public boolean ignoreBooleanMethods = false;
+
List questionList = new ArrayList(32);
public NonBooleanMethodNameMayNotStartWithQuestionInspection(){
parseString(questionString, questionList);
}
+ @Override
@NotNull
public String getDisplayName(){
return InspectionGadgetsBundle.message(
"non.boolean.method.name.must.not.start.with.question.display.name");
}
+ @Override
@NotNull
public String buildErrorString(Object... infos){
return InspectionGadgetsBundle.message(
"non.boolean.method.name.must.not.start.with.question.problem.descriptor");
}
+ @Override
public void readSettings(Element element) throws InvalidDataException{
super.readSettings(element);
parseString(questionString, questionList);
}
+ @Override
public void writeSettings(Element element) throws WriteExternalException{
questionString = formatString(questionList);
super.writeSettings(element);
}
+ @Override
public JComponent createOptionsPanel(){
- final Form form = new Form();
- return form.getContentPanel();
+ final JPanel panel = new JPanel(new GridBagLayout());
+ final IGTable table =
+ new IGTable(new ListWrappingTableModel(questionList,
+ InspectionGadgetsBundle.message(
+ "boolean.method.name.must.start.with.question.table.column.name")));
+ final JScrollPane scrollPane = new JScrollPane(table);
+
+ final GridBagConstraints constraints = new GridBagConstraints();
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.gridheight = 3;
+ constraints.weightx = 1.0;
+ constraints.weighty = 1.0;
+ constraints.fill = GridBagConstraints.BOTH;
+ panel.add(scrollPane, constraints);
+
+ final JButton addButton = new JButton(new AddAction(table));
+ constraints.gridx = 1;
+ constraints.gridheight = 1;
+ constraints.weightx = 0.0;
+ constraints.weighty = 0.0;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ panel.add(addButton, constraints);
+
+ final JButton removeButton = new JButton(new RemoveAction(table));
+ constraints.gridy = 1;
+ panel.add(removeButton, constraints);
+
+ final BlankFiller filler = new BlankFiller();
+ constraints.gridy = 2;
+ constraints.weighty = 1.0;
+ panel.add(filler, constraints);
+
+ final CheckBox checkBox =
+ new CheckBox(InspectionGadgetsBundle.message(
+ "ignore.methods.with.boolean.return.type.option"),
+ this, "ignoreBooleanMethods");
+ constraints.gridy = 3;
+ constraints.gridx = 0;
+ constraints.gridwidth = 2;
+ constraints.weighty = 0.0;
+ panel.add(checkBox, constraints);
+ return panel;
}
+ @Override
protected InspectionGadgetsFix buildFix(Object... infos){
return new RenameFix();
}
+ @Override
protected boolean buildQuickFixesOnlyForOnTheFlyErrors(){
return true;
}
+ @Override
public BaseInspectionVisitor buildVisitor(){
return new NonBooleanMethodNameMayNotStartWithQuestionVisitor();
}
@@ -99,6 +153,10 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection
if(returnType == null || returnType.equals(PsiType.BOOLEAN)){
return;
}
+ if(ignoreBooleanMethods && returnType.equalsToText(
+ "java.lang.Boolean")){
+ return;
+ }
final String name = method.getName();
boolean startsWithQuestionWord = false;
for(String question : questionList){
@@ -121,28 +179,4 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection
registerMethodError(method);
}
}
-
- private class Form{
-
- JPanel contentPanel;
- JButton addButton;
- JButton removeButton;
- IGTable table;
-
- Form(){
- super();
- addButton.setAction(new AddAction(table));
- removeButton.setAction(new RemoveAction(table));
- }
-
- private void createUIComponents(){
- table = new IGTable(new ListWrappingTableModel(questionList,
- InspectionGadgetsBundle.message(
- "boolean.method.name.must.start.with.question.table.column.name")));
- }
-
- public JComponent getContentPanel(){
- return contentPanel;
- }
- }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form
deleted file mode 100644
index 19792463c197..000000000000
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAccessedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAccessedVisitor.java
index 2d34dabec1d6..a73eb445aaf0 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAccessedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAccessedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,8 @@ package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class ArrayContentsAccessedVisitor extends JavaRecursiveElementVisitor{
+class ArrayContentsAccessedVisitor extends JavaRecursiveElementVisitor{
+
private boolean accessed = false;
private final PsiVariable variable;
@@ -27,7 +28,8 @@ public class ArrayContentsAccessedVisitor extends JavaRecursiveElementVisitor{
this.variable = variable;
}
- @Override public void visitForeachStatement(@NotNull PsiForeachStatement statement){
+ @Override public void visitForeachStatement(
+ @NotNull PsiForeachStatement statement){
if(accessed){
return;
}
@@ -36,7 +38,9 @@ public class ArrayContentsAccessedVisitor extends JavaRecursiveElementVisitor{
if(!(qualifier instanceof PsiReferenceExpression)){
return;
}
- final PsiElement referent = ((PsiReference) qualifier).resolve();
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression)qualifier;
+ final PsiElement referent = referenceExpression.resolve();
if(referent == null){
return;
}
@@ -46,21 +50,29 @@ public class ArrayContentsAccessedVisitor extends JavaRecursiveElementVisitor{
accessed = true;
}
- @Override public void visitArrayAccessExpression(PsiArrayAccessExpression arg){
+ @Override public void visitArrayAccessExpression(
+ PsiArrayAccessExpression arrayAccessExpression){
if(accessed){
return;
}
- super.visitArrayAccessExpression(arg);
- if(arg.getParent() instanceof PsiAssignmentExpression &&
- ((PsiAssignmentExpression) arg.getParent()).getLExpression()
- .equals(arg)){
- return;
+ super.visitArrayAccessExpression(arrayAccessExpression);
+ final PsiElement parent = arrayAccessExpression.getParent();
+ if(parent instanceof PsiAssignmentExpression) {
+ final PsiAssignmentExpression assignmentExpression =
+ (PsiAssignmentExpression)parent;
+ final PsiExpression lhs = assignmentExpression.getLExpression();
+ if(lhs.equals(arrayAccessExpression)){
+ return;
+ }
}
- final PsiExpression arrayExpression = arg.getArrayExpression();
+ final PsiExpression arrayExpression =
+ arrayAccessExpression.getArrayExpression();
if(!(arrayExpression instanceof PsiReferenceExpression)){
return;
}
- final PsiElement referent = ((PsiReference) arrayExpression).resolve();
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression)arrayExpression;
+ final PsiElement referent = referenceExpression.resolve();
if(referent == null){
return;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAssignedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAssignedVisitor.java
index defa78bd8498..bfb6388299ac 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAssignedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ArrayContentsAssignedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class ArrayContentsAssignedVisitor extends JavaRecursiveElementVisitor {
+class ArrayContentsAssignedVisitor extends JavaRecursiveElementVisitor {
private boolean assigned = false;
private final PsiVariable variable;
@@ -40,7 +40,9 @@ public class ArrayContentsAssignedVisitor extends JavaRecursiveElementVisitor {
if(!(arrayExpression instanceof PsiReferenceExpression)){
return;
}
- final PsiElement referent = ((PsiReference) arrayExpression).resolve();
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression)arrayExpression;
+ final PsiElement referent = referenceExpression.resolve();
if(referent == null){
return;
}
@@ -66,7 +68,9 @@ public class ArrayContentsAssignedVisitor extends JavaRecursiveElementVisitor {
if(!(arrayExpression instanceof PsiReferenceExpression)){
return;
}
- final PsiElement referent = ((PsiReference) arrayExpression).resolve();
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression)arrayExpression;
+ final PsiElement referent = referenceExpression.resolve();
if(referent == null){
return;
}
@@ -91,7 +95,9 @@ public class ArrayContentsAssignedVisitor extends JavaRecursiveElementVisitor {
if(!(arrayExpression instanceof PsiReferenceExpression)){
return;
}
- final PsiElement referent = ((PsiReference) arrayExpression).resolve();
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression)arrayExpression;
+ final PsiElement referent = referenceExpression.resolve();
if(referent == null){
return;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedFromVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedFromVisitor.java
index 8e59b777bdd8..b4e4c655f685 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedFromVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedFromVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class VariableAssignedFromVisitor extends JavaRecursiveElementVisitor{
+class VariableAssignedFromVisitor extends JavaRecursiveElementVisitor{
private boolean assignedFrom = false;
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java
index 6eecc8eb71c0..d9786e40c37b 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.TypeConversionUtil;
import org.jetbrains.annotations.NotNull;
-public class VariableAssignedVisitor extends JavaRecursiveElementVisitor{
+class VariableAssignedVisitor extends JavaRecursiveElementVisitor{
@NotNull private final PsiVariable variable;
private final boolean recurseIntoClasses;
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentExcludedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentExcludedVisitor.java
index 7d4c1db42255..c8e0a86417f5 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentExcludedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentExcludedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Set;
-public class VariablePassedAsArgumentExcludedVisitor
+class VariablePassedAsArgumentExcludedVisitor
extends JavaRecursiveElementVisitor{
@NotNull
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentVisitor.java
index 833ed7d9aa8b..e944972fb4c4 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariablePassedAsArgumentVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,7 @@ package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class VariablePassedAsArgumentVisitor
- extends JavaRecursiveElementVisitor{
+class VariablePassedAsArgumentVisitor extends JavaRecursiveElementVisitor{
@NotNull
private final PsiVariable variable;
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableReturnedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableReturnedVisitor.java
index 2458ebb8b8d3..0780c9d3327c 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableReturnedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableReturnedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiReturnStatement;
import com.intellij.psi.PsiVariable;
import org.jetbrains.annotations.NotNull;
-public class VariableReturnedVisitor extends JavaRecursiveElementVisitor {
+class VariableReturnedVisitor extends JavaRecursiveElementVisitor {
private boolean returned = false;
@NotNull private final PsiVariable variable;
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInArrayInitializerVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInArrayInitializerVisitor.java
index 3ada0b0aa68f..784cb7b49f1c 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInArrayInitializerVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInArrayInitializerVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,7 @@ package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class VariableUsedInArrayInitializerVisitor
- extends JavaRecursiveElementVisitor{
+class VariableUsedInArrayInitializerVisitor extends JavaRecursiveElementVisitor{
@NotNull
private final PsiVariable variable;
@@ -42,11 +41,9 @@ public class VariableUsedInArrayInitializerVisitor
return;
}
super.visitArrayInitializerExpression(expression);
-
- final PsiExpression[] args = expression.getInitializers();
- for(final PsiExpression arg : args){
-
- if(VariableAccessUtils.mayEvaluateToVariable(arg, variable)){
+ final PsiExpression[] initializers = expression.getInitializers();
+ for(final PsiExpression initializer : initializers){
+ if(VariableAccessUtils.mayEvaluateToVariable(initializer, variable)){
passed = true;
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInInnerClassVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInInnerClassVisitor.java
index 0df56dd4f62b..1f015a95bda4 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInInnerClassVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedInInnerClassVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class VariableUsedInInnerClassVisitor extends JavaRecursiveElementVisitor{
+class VariableUsedInInnerClassVisitor extends JavaRecursiveElementVisitor{
@NotNull private final PsiVariable variable;
private boolean usedInInnerClass = false;
@@ -45,17 +45,17 @@ public class VariableUsedInInnerClassVisitor extends JavaRecursiveElementVisitor
inInnerClass = wasInInnerClass;
}
- @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression ref){
+ @Override public void visitReferenceExpression(
+ @NotNull PsiReferenceExpression referenceExpression){
if(usedInInnerClass){
return;
}
- super.visitReferenceExpression(ref);
-
+ super.visitReferenceExpression(referenceExpression);
if(!inInnerClass){
return;
}
- final PsiElement element = ref.resolve();
- if(variable.equals(element)){
+ final PsiElement target = referenceExpression.resolve();
+ if(variable.equals(target)){
usedInInnerClass = true;
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedVisitor.java
index 6549c56d65f4..30b543be3fc1 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableUsedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiReferenceExpression;
import com.intellij.psi.PsiVariable;
import org.jetbrains.annotations.NotNull;
-public class VariableUsedVisitor extends JavaRecursiveElementVisitor {
+class VariableUsedVisitor extends JavaRecursiveElementVisitor {
private boolean used = false;
@NotNull private final PsiVariable variable;
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableValueUsedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableValueUsedVisitor.java
index 0abb4fde0724..e3eaa104943b 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableValueUsedVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableValueUsedVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Dave Griffith, Bas Leijdekkers
+ * Copyright 2008-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
-public class VariableValueUsedVisitor extends JavaRecursiveElementVisitor {
+class VariableValueUsedVisitor extends JavaRecursiveElementVisitor {
@NotNull
private final PsiVariable variable;
diff --git a/plugins/IntelliLang/IntelliLang-java.iml b/plugins/IntelliLang/IntelliLang-java.iml
new file mode 100644
index 000000000000..a9a38446a280
--- /dev/null
+++ b/plugins/IntelliLang/IntelliLang-java.iml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/IntelliLang/IntelliLang-javaee.iml b/plugins/IntelliLang/IntelliLang-javaee.iml
new file mode 100644
index 000000000000..bfbccd5a1eac
--- /dev/null
+++ b/plugins/IntelliLang/IntelliLang-javaee.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/IntelliLang/IntelliLang-xml.iml b/plugins/IntelliLang/IntelliLang-xml.iml
new file mode 100644
index 000000000000..d57e3f2a4b2d
--- /dev/null
+++ b/plugins/IntelliLang/IntelliLang-xml.iml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/IntelliLang/IntelliLangJava.iml b/plugins/IntelliLang/IntelliLangJava.iml
index e6aaec1b47c5..c286c6a5c90f 100644
--- a/plugins/IntelliLang/IntelliLangJava.iml
+++ b/plugins/IntelliLang/IntelliLangJava.iml
@@ -7,18 +7,10 @@
-
-
-
-
-
-
-
-
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/InjectionNotApplicable.html b/plugins/IntelliLang/java-support/inspectionDescriptions/InjectionNotApplicable.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/InjectionNotApplicable.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/InjectionNotApplicable.html
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/LanguageMismatch.html b/plugins/IntelliLang/java-support/inspectionDescriptions/LanguageMismatch.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/LanguageMismatch.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/LanguageMismatch.html
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/PatternNotApplicable.html b/plugins/IntelliLang/java-support/inspectionDescriptions/PatternNotApplicable.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/PatternNotApplicable.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/PatternNotApplicable.html
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/PatternOverriddenByNonAnnotatedMethod.html b/plugins/IntelliLang/java-support/inspectionDescriptions/PatternOverriddenByNonAnnotatedMethod.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/PatternOverriddenByNonAnnotatedMethod.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/PatternOverriddenByNonAnnotatedMethod.html
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/PatternValidation.html b/plugins/IntelliLang/java-support/inspectionDescriptions/PatternValidation.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/PatternValidation.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/PatternValidation.html
diff --git a/plugins/IntelliLang/src/inspectionDescriptions/UnknownLanguage.html b/plugins/IntelliLang/java-support/inspectionDescriptions/UnknownLanguage.html
similarity index 100%
rename from plugins/IntelliLang/src/inspectionDescriptions/UnknownLanguage.html
rename to plugins/IntelliLang/java-support/inspectionDescriptions/UnknownLanguage.html
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/AdvancedSettingsUI.form b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.form
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/AdvancedSettingsUI.form
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.form
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java
similarity index 83%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java
index bb60a711e4db..7be07abb49a8 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java
@@ -117,7 +117,7 @@ public class MethodParameterInjection extends BaseInjection {
@Override
protected List generatePlaces() {
- return PatternBasedInjectionHelper.getPatternString(this);
+ return getPatternString(this);
}
@SuppressWarnings({"RedundantIfStatement"})
@@ -230,6 +230,45 @@ public class MethodParameterInjection extends BaseInjection {
return null;
}
+ public static String getParameterTypesString(final String signature) {
+ @NonNls final StringBuilder sb = new StringBuilder();
+ final StringTokenizer st = new StringTokenizer(signature, "(,)");
+ //noinspection ForLoopThatDoesntUseLoopVariable
+ for (int i = 0; st.hasMoreTokens(); i++) {
+ final String token = st.nextToken().trim();
+ if (i > 1) sb.append(", ");
+ final int idx;
+ if (i == 0) {
+ // nothing
+ }
+ else {
+ sb.append('\"');
+ if ((idx = token.indexOf(' ')) > -1) {
+ sb.append(token.substring(0, idx));
+ }
+ else {
+ sb.append(token);
+ }
+ sb.append('\"');
+ }
+ }
+ return sb.toString();
+ }
+
+ public static String getPatternStringForJavaPlace(final String methodName, final String parametersStrings, final int parameterIndex, final String className) {
+ final StringBuilder sb = new StringBuilder();
+ if (parameterIndex >= 0) {
+ sb.append("psiParameter().ofMethod(").append(parameterIndex).append(", ");
+ }
+ sb.append("psiMethod().withName(\"").append(methodName)
+ .append("\").withParameters(").append(parametersStrings)
+ .append(").definedInClass(\"").append(className).append("\")");
+ if (parameterIndex >= 0) {
+ sb.append(")");
+ }
+ return sb.toString();
+ }
+
public static class MethodInfo {
@NotNull
final String methodSignature;
@@ -343,5 +382,24 @@ public class MethodParameterInjection extends BaseInjection {
}
}
+ public static List getPatternString(final MethodParameterInjection injection) {
+ final ArrayList list = new ArrayList();
+ final String className = injection.getClassName();
+ for (MethodParameterInjection.MethodInfo info : injection.getMethodInfos()) {
+ final boolean[] paramFlags = info.getParamFlags();
+ final int paramFlagsLength = paramFlags.length;
+ final String methodName = info.getMethodName();
+ final String typesString = getParameterTypesString(info.getMethodSignature());
+ if (info.isReturnFlag()) {
+ list.add(getPatternStringForJavaPlace(methodName, typesString, -1, className));
+ }
+ for (int i = 0; i < paramFlagsLength; i++) {
+ if (paramFlags[i]) {
+ list.add(getPatternStringForJavaPlace(methodName, typesString, i, className));
+ }
+ }
+ }
+ return list;
+ }
}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.form b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.form
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.form
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.form
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java
similarity index 99%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java
index b2490b47b64e..229126aba4ab 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java
@@ -38,4 +38,4 @@ public class MethodParameterInjectionConfigurable extends InjectionConfigurable<
public Icon getIcon() {
return Icons.METHOD_ICON;
}
-}
\ No newline at end of file
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
similarity index 96%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
index 2c42f8e638a6..1000db367163 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
@@ -45,7 +45,6 @@ import com.intellij.ui.SimpleColoredText;
import com.intellij.ui.SimpleTextAttributes;
import org.intellij.plugins.intelliLang.AdvancedSettingsUI;
import org.intellij.plugins.intelliLang.Configuration;
-import org.intellij.plugins.intelliLang.PatternBasedInjectionHelper;
import org.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport;
import org.intellij.plugins.intelliLang.inject.EditInjectionSettingsAction;
import org.intellij.plugins.intelliLang.inject.InjectLanguageAction;
@@ -66,6 +65,8 @@ import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import static org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection.*;
+
/**
* @author Gregory.Shrago
*/
@@ -245,7 +246,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
final MethodParameterInjection injection = new MethodParameterInjection();
injection.setInjectedLanguageId(languageId);
injection.setClassName(className);
- final MethodParameterInjection.MethodInfo info = MethodParameterInjection.createMethodInfo(psiMethod);
+ final MethodParameterInjection.MethodInfo info = createMethodInfo(psiMethod);
if (parameterIndex < 0) {
info.setReturnFlag(true);
}
@@ -389,8 +390,8 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
final PsiModifierList modifiers = method.getModifierList();
if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) || modifiers.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) continue;
boolean add = false;
- final MethodParameterInjection.MethodInfo methodInfo = MethodParameterInjection.createMethodInfo(method);
- if (MethodParameterInjection.isInjectable(method.getReturnType(), method.getProject())) {
+ final MethodParameterInjection.MethodInfo methodInfo = createMethodInfo(method);
+ if (isInjectable(method.getReturnType(), method.getProject())) {
final int parameterIndex = -1;
final InjectionPlace place = injection.findPlaceByText(getPatternStringForJavaPlace(method, parameterIndex));
methodInfo.setReturnFlag(place != null && place.isEnabled() || includeAllPlaces);
@@ -399,7 +400,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
final PsiParameter[] parameters = method.getParameterList().getParameters();
for (int i = 0; i < parameters.length; i++) {
final PsiParameter p = parameters[i];
- if (MethodParameterInjection.isInjectable(p.getType(), p.getProject())) {
+ if (isInjectable(p.getType(), p.getProject())) {
final InjectionPlace place = injection.findPlaceByText(getPatternStringForJavaPlace(method, i));
methodInfo.getParamFlags()[i] = place != null && place.isEnabled() || includeAllPlaces;
add = true;
@@ -426,8 +427,8 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
public static String getPatternStringForJavaPlace(final PsiMethod method, final int parameterIndex) {
final PsiClass psiClass = method.getContainingClass();
final String className = psiClass == null ? "" : StringUtil.notNullize(psiClass.getQualifiedName());
- final String signature = MethodParameterInjection.createMethodInfo(method).getMethodSignature();
- return PatternBasedInjectionHelper.getPatternStringForJavaPlace(method.getName(), PatternBasedInjectionHelper.getParameterTypesString(signature), parameterIndex, className);
+ final String signature = createMethodInfo(method).getMethodSignature();
+ return MethodParameterInjection.getPatternStringForJavaPlace(method.getName(), getParameterTypesString(signature), parameterIndex, className);
}
@Override
@@ -476,4 +477,4 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
super.setupPresentation(injection, presentation, isSelected);
}
}
-}
\ No newline at end of file
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/LanguageReferenceProvider.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReferenceProvider.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/LanguageReferenceProvider.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReferenceProvider.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java
similarity index 99%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java
index 32a840c119d5..bc9d66c82fcd 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java
@@ -97,4 +97,4 @@ public class InjectionNotApplicable extends LocalInspectionTool {
public String getShortName() {
return "InjectionNotApplicable";
}
-}
\ No newline at end of file
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/InspectionProvider.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/InspectionProvider.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/InspectionProvider.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/InspectionProvider.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/LanguageMismatch.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/LanguageMismatch.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/LanguageMismatch.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/LanguageMismatch.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/UnknownLanguageID.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/UnknownLanguageID.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/validation/UnknownLanguageID.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/validation/UnknownLanguageID.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/InspectionProvider.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/InspectionProvider.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/InspectionProvider.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/InspectionProvider.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternAnnotationNotApplicable.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternAnnotationNotApplicable.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternAnnotationNotApplicable.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternAnnotationNotApplicable.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternOverriddenByNonAnnotatedMethod.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternOverriddenByNonAnnotatedMethod.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternOverriddenByNonAnnotatedMethod.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternOverriddenByNonAnnotatedMethod.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternValidator.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternValidator.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternValidator.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternValidator.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationException.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationException.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationException.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationException.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationItem.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationItem.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationItem.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationItem.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/Instrumenter.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/Instrumenter.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/Instrumenter.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/Instrumenter.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/InstrumentationAdapter.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/InstrumentationAdapter.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/InstrumentationAdapter.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/InstrumentationAdapter.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationCompiler.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationCompiler.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationCompiler.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationCompiler.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationInstrumenter.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationInstrumenter.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationInstrumenter.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationInstrumenter.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/AnnotateFix.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotateFix.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/AnnotateFix.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotateFix.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/ContextComputationProcessor.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/ContextComputationProcessor.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/ContextComputationProcessor.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/ContextComputationProcessor.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/InitializerRequirement.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/InitializerRequirement.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/InitializerRequirement.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/InitializerRequirement.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/PsiUtilEx.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/PsiUtilEx.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/PsiUtilEx.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/PsiUtilEx.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/RemoveAnnotationFix.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/RemoveAnnotationFix.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/RemoveAnnotationFix.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/RemoveAnnotationFix.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/StringLiteralReference.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/StringLiteralReference.java
similarity index 99%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/StringLiteralReference.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/StringLiteralReference.java
index 1e2c8596a856..8bf9b38560f9 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/StringLiteralReference.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/StringLiteralReference.java
@@ -63,4 +63,4 @@ public abstract class StringLiteralReference implements PsiReference {
return (String)myValue.getValue();
}
-}
\ No newline at end of file
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java
rename to plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java
diff --git a/plugins/IntelliLang/src/resources/javaInjections.xml b/plugins/IntelliLang/java-support/resources/javaInjections.xml
similarity index 100%
rename from plugins/IntelliLang/src/resources/javaInjections.xml
rename to plugins/IntelliLang/java-support/resources/javaInjections.xml
diff --git a/plugins/IntelliLang/javaee-support/org/intellij/plugins/intelliLang/inject/config/JspSupportProxyImpl.java b/plugins/IntelliLang/javaee-support/org/intellij/plugins/intelliLang/inject/config/JspSupportProxyImpl.java
new file mode 100644
index 000000000000..8bca634e7851
--- /dev/null
+++ b/plugins/IntelliLang/javaee-support/org/intellij/plugins/intelliLang/inject/config/JspSupportProxyImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2010 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 org.intellij.plugins.intelliLang.inject.config;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.psi.impl.source.jsp.JspManager;
+import org.jetbrains.annotations.NotNull;
+
+/**
+* @author Gregory.Shrago
+*/
+public class JspSupportProxyImpl extends JspSupportProxy {
+ @NotNull
+ @Override
+ public String[] getPossibleTldUris(Module module) {
+ return JspManager.getInstance(module.getProject()).getPossibleTldUris(module);
+ }
+}
diff --git a/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml b/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml
index 611d06a73218..19d55a8d9aac 100644
--- a/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml
+++ b/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml
@@ -4,6 +4,6 @@
+ serviceImplementation="org.intellij.plugins.intelliLang.inject.config.JspSupportProxyImpl"/>
\ No newline at end of file
diff --git a/plugins/IntelliLang/src/META-INF/intellilang-xpath-support.xml b/plugins/IntelliLang/src/META-INF/intellilang-xpath-support.xml
index 98415dea0f7d..16caabfc5ecc 100644
--- a/plugins/IntelliLang/src/META-INF/intellilang-xpath-support.xml
+++ b/plugins/IntelliLang/src/META-INF/intellilang-xpath-support.xml
@@ -4,7 +4,7 @@
+ serviceImplementation="org.intellij.plugins.intelliLang.inject.config.XPathSupportProxyImpl"/>
\ No newline at end of file
diff --git a/plugins/IntelliLang/src/META-INF/plugin.xml b/plugins/IntelliLang/src/META-INF/plugin.xml
index 08fc53463f67..91b24787d24f 100644
--- a/plugins/IntelliLang/src/META-INF/plugin.xml
+++ b/plugins/IntelliLang/src/META-INF/plugin.xml
@@ -6,10 +6,9 @@
8.0
XPathView
- com.intellij.modules.java
- com.intellij.javaee
- com.intellij.modules.xml
- org.intellij.groovy
+
+
+
Sascha Weinreuter
@@ -45,4 +44,4 @@
-
\ No newline at end of file
+
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/Configuration.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/Configuration.java
index 4ee6369b793d..2610c4e47330 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/Configuration.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/Configuration.java
@@ -122,21 +122,7 @@ public final class Configuration implements PersistentStateComponent {
for (LanguageInjectionSupport support : Extensions.getExtensions(LanguageInjectionSupport.EP_NAME)) {
supports.put(support.getId(), support);
}
- myInjections.get(LanguageInjectionSupport.XML_SUPPORT_ID).addAll(readExternal(element.getChild(TAG_INJECTION_NAME), new Factory() {
- public XmlTagInjection create() {
- return new XmlTagInjection();
- }
- }));
- myInjections.get(LanguageInjectionSupport.XML_SUPPORT_ID).addAll(readExternal(element.getChild(ATTRIBUTE_INJECTION_NAME), new Factory() {
- public XmlAttributeInjection create() {
- return new XmlAttributeInjection();
- }
- }));
- myInjections.get(LanguageInjectionSupport.JAVA_SUPPORT_ID).addAll(readExternal(element.getChild(PARAMETER_INJECTION_NAME), new Factory() {
- public MethodParameterInjection create() {
- return new MethodParameterInjection();
- }
- }));
+ loadStateOld(element, supports.get(LanguageInjectionSupport.XML_SUPPORT_ID), supports.get(LanguageInjectionSupport.JAVA_SUPPORT_ID));
for (Element child : (List)element.getChildren("injection")){
final String key = child.getAttributeValue("injector-id");
final LanguageInjectionSupport support = supports.get(key);
@@ -163,6 +149,31 @@ public final class Configuration implements PersistentStateComponent {
}
}
+ private void loadStateOld(Element element, final LanguageInjectionSupport xmlSupport, final LanguageInjectionSupport javaSupport) {
+ if (xmlSupport != null) {
+ final Element xmlTagMarker = new Element("XmlTagInjection");
+ myInjections.get(LanguageInjectionSupport.XML_SUPPORT_ID).addAll(readExternal(element.getChild(TAG_INJECTION_NAME), new Factory() {
+ public BaseInjection create() {
+ return xmlSupport.createInjection(xmlTagMarker);
+ }
+ }));
+ final Element xmlAttributeMarker = new Element("XmlAttributeInjection");
+ myInjections.get(LanguageInjectionSupport.XML_SUPPORT_ID).addAll(readExternal(element.getChild(ATTRIBUTE_INJECTION_NAME), new Factory() {
+ public BaseInjection create() {
+ return xmlSupport.createInjection(xmlAttributeMarker);
+ }
+ }));
+ }
+ if (javaSupport != null) {
+ final Element javaMethodMarker = new Element("MethodParameterInjection");
+ myInjections.get(LanguageInjectionSupport.JAVA_SUPPORT_ID).addAll(readExternal(element.getChild(PARAMETER_INJECTION_NAME), new Factory() {
+ public BaseInjection create() {
+ return javaSupport.createInjection(javaMethodMarker);
+ }
+ }));
+ }
+ }
+
private static boolean readBoolean(Element element, String key, boolean defValue) {
final String value = JDOMExternalizerUtil.readField(element, key);
if (value == null) return defValue;
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/PatternBasedInjectionHelper.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/PatternBasedInjectionHelper.java
index 71e6bd075247..0b3801acdcd8 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/PatternBasedInjectionHelper.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/PatternBasedInjectionHelper.java
@@ -18,7 +18,6 @@ package org.intellij.plugins.intelliLang;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.text.StringUtil;
import com.intellij.patterns.ElementPattern;
import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
@@ -27,9 +26,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import gnu.trove.THashSet;
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
-import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection;
-import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection;
-import org.intellij.plugins.intelliLang.inject.config.XmlAttributeInjection;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -71,86 +67,6 @@ public class PatternBasedInjectionHelper {
// return StandardPatterns.or(list.toArray(new ElementPattern[list.size()]));
//}
- public static List getPatternString(final MethodParameterInjection injection) {
- final ArrayList list = new ArrayList();
- final String className = injection.getClassName();
- for (MethodParameterInjection.MethodInfo info : injection.getMethodInfos()) {
- final boolean[] paramFlags = info.getParamFlags();
- final int paramFlagsLength = paramFlags.length;
- final String methodName = info.getMethodName();
- final String typesString = getParameterTypesString(info.getMethodSignature());
- if (info.isReturnFlag()) {
- list.add(getPatternStringForJavaPlace(methodName, typesString, -1, className));
- }
- for (int i = 0; i < paramFlagsLength; i++) {
- if (paramFlags[i]) {
- list.add(getPatternStringForJavaPlace(methodName, typesString, i, className));
- }
- }
- }
- return list;
- }
-
- public static String getParameterTypesString(final String signature) {
- @NonNls final StringBuilder sb = new StringBuilder();
- final StringTokenizer st = new StringTokenizer(signature, "(,)");
- //noinspection ForLoopThatDoesntUseLoopVariable
- for (int i = 0; st.hasMoreTokens(); i++) {
- final String token = st.nextToken().trim();
- if (i > 1) sb.append(", ");
- final int idx;
- if (i == 0) {
- // nothing
- }
- else {
- sb.append('\"');
- if ((idx = token.indexOf(' ')) > -1) {
- sb.append(token.substring(0, idx));
- }
- else {
- sb.append(token);
- }
- sb.append('\"');
- }
- }
- return sb.toString();
- }
-
- public static String getPatternStringForJavaPlace(final String methodName, final String parametersStrings, final int parameterIndex, final String className) {
- final StringBuilder sb = new StringBuilder();
- if (parameterIndex >= 0) {
- sb.append("psiParameter().ofMethod(").append(parameterIndex).append(", ");
- }
- sb.append("psiMethod().withName(\"").append(methodName)
- .append("\").withParameters(").append(parametersStrings)
- .append(").definedInClass(\"").append(className).append("\")");
- if (parameterIndex >= 0) {
- sb.append(")");
- }
- return sb.toString();
- }
-
- public static String getPatternString(final XmlAttributeInjection injection) {
- final String name = injection.getAttributeName();
- final String namespace = injection.getAttributeNamespace();
- final StringBuilder result = new StringBuilder("xmlAttribute()");
- if (StringUtil.isNotEmpty(name)) result.append(".withLocalName(string().matches(\"").append(name).append("\"))");
- if (StringUtil.isNotEmpty(namespace)) result.append(".withNamespace(string().matches(\"").append(namespace).append("\"))");
- if (StringUtil.isNotEmpty(injection.getTagName()) || StringUtil.isNotEmpty(injection.getTagNamespace())) {
- result.append(".inside(").append(getPatternString((AbstractTagInjection)injection)).append(")");
- }
- return result.toString();
- }
-
- public static String getPatternString(final AbstractTagInjection injection) {
- final String name = injection.getTagName();
- final String namespace = injection.getTagNamespace();
- final StringBuilder result = new StringBuilder("xmlTag()");
- if (StringUtil.isNotEmpty(name)) result.append(".withLocalName(string().matches(\"").append(name).append("\"))");
- if (StringUtil.isNotEmpty(namespace)) result.append(".withNamespace(string().matches(\"").append(namespace).append("\"))");
- return result.toString();
- }
-
@Nullable
public static ElementPattern createElementPattern(final String text, final String displayName, final String supportId) {
return createElementPatternNoGroovy(text, displayName, supportId);
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
index 7069c6c48dd2..e39c71a7fc42 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
@@ -17,20 +17,17 @@
package org.intellij.plugins.intelliLang.inject;
import com.intellij.lang.Language;
+import com.intellij.lang.LanguageLiteralEscapers;
+import com.intellij.lang.LiteralEscaper;
import com.intellij.lang.injection.MultiHostRegistrar;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiLanguageInjectionHost;
-import com.intellij.psi.PsiLiteralExpression;
-import com.intellij.psi.xml.XmlElement;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -56,17 +53,6 @@ public class InjectorUtils {
registrar.addPlace(prefix, suffix, host, textRange);
}
- public static String getUnescapedText(final PsiElement host, final String text) {
- if (host instanceof PsiLiteralExpression) {
- return StringUtil.unescapeStringCharacters(text);
- }
- else if (host instanceof XmlElement) {
- return XmlUtil.unescape(text);
- }
- else {
- return text;
- }
- }// Avoid sticking text and prefix/suffix together in a way that it would form a single token.
// See http://www.jetbrains.net/jira/browse/IDEADEV-8302#action_111865
// This code assumes that for the injected language a single space character is a token separator
// that doesn't (significantly) change the semantics if added to the prefix/suffix
@@ -117,6 +103,7 @@ public class InjectorUtils {
if (language == null/* && (pair.second.getLength() > 0*/) {
return;
}
+ final LiteralEscaper literalEscaper = LanguageLiteralEscapers.INSTANCE.forLanguage(containingFile.getLanguage());
boolean injectionStarted = false;
for (Trinity trinity : list) {
final PsiLanguageInjectionHost host = trinity.first;
@@ -134,7 +121,10 @@ public class InjectorUtils {
// useful cases may break. This system is far from perfect still...
final StringBuilder prefix = new StringBuilder(injectedLanguage.getPrefix());
final StringBuilder suffix = new StringBuilder(injectedLanguage.getSuffix());
- adjustPrefixAndSuffix(getUnescapedText(host, textRange.substring(host.getText())), prefix, suffix);
+ final String text = textRange.substring(host.getText());
+ final String result = literalEscaper != null ? literalEscaper.unescapeText(text) : text;
+
+ adjustPrefixAndSuffix(result, prefix, suffix);
addPlaceSafe(registrar, prefix.toString(), suffix.toString(), host, textRange);
}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java
index 6c503dad460a..9a6507d9a650 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.intellij.plugins.intelliLang.inject.config;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.module.Module;
-import com.intellij.psi.impl.source.jsp.JspManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,12 +43,4 @@ public abstract class JspSupportProxy {
isInitialized = true;
}
}
-
- public static class Impl extends JspSupportProxy {
- @NotNull
- @Override
- public String[] getPossibleTldUris(Module module) {
- return JspManager.getInstance(module.getProject()).getPossibleTldUris(module);
- }
- }
}
\ No newline at end of file
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java
deleted file mode 100644
index 44756b5455d9..000000000000
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.intellij.plugins.intelliLang.inject.config;
-
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.impl.source.xml.XmlTokenImpl;
-import com.intellij.psi.xml.XmlElement;
-import com.intellij.psi.xml.XmlElementType;
-import org.intellij.lang.xpath.context.ContextProvider;
-import org.intellij.lang.xpath.context.ContextType;
-import org.intellij.lang.xpath.context.NamespaceContext;
-import org.intellij.lang.xpath.context.VariableContext;
-import org.intellij.lang.xpath.psi.XPathExpression;
-import org.intellij.lang.xpath.psi.XPathType;
-import org.intellij.plugins.xpathView.support.XPathSupport;
-import org.intellij.plugins.xpathView.util.Namespace;
-import org.jaxen.JaxenException;
-import org.jaxen.XPath;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.xml.namespace.QName;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * Proxy class that allows to avoid a hard compile time dependency on the XPathView plugin.
- */
-public abstract class XPathSupportProxy {
- private static final Logger LOG = Logger.getInstance("org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy");
-
- public static final Object UNSUPPORTED = "UNSUPPORTED";
- public static final Object INVALID = "INVALID";
-
- @NotNull
- public abstract XPath createXPath(String expression) throws JaxenException;
-
- public abstract void attachContext(@NotNull PsiFile file);
-
- private static XPathSupportProxy ourInstance;
- private static boolean isInitialized;
-
- @Nullable
- public static synchronized XPathSupportProxy getInstance() {
- if (isInitialized) {
- return ourInstance;
- }
- try {
- return ourInstance = ServiceManager.getService(XPathSupportProxy.class);
- } finally {
- if (ourInstance == null) {
- LOG.info("XPath Support is not available");
- }
- isInitialized = true;
- }
- }
-
- public static class Impl extends XPathSupportProxy {
- private static class Provider extends ContextProvider {
- private final XmlTokenImpl myDummyContext = new XmlTokenImpl(XmlElementType.XML_CONTENT_EMPTY, "") {
- @Override
- public boolean isValid() {
- return true;
- }
- };
-
- @NotNull
- public ContextType getContextType() {
- return XPathSupport.TYPE;
- }
-
- @NotNull
- @Override
- public XPathType getExpectedType(XPathExpression expr) {
- return XPathType.BOOLEAN;
- }
-
- public XmlElement getContextElement() {
- // needed because the static method ContextProvider.isValid() checks this to determine if the provider
- // is still valid - refactor this into an instance method ContextProvider.isValid()?
- return myDummyContext;
- }
-
- public NamespaceContext getNamespaceContext() {
- return null;
- }
-
- public VariableContext getVariableContext() {
- return null;
- }
-
- public Set getAttributes(boolean forValidation) {
- return null;
- }
-
- public Set getElements(boolean forValidation) {
- return null;
- }
- }
-
- private final ContextProvider myProvider = new Provider();
- private final XPathSupport mySupport = XPathSupport.getInstance();
-
- @NotNull
- public XPath createXPath(String expression) throws JaxenException {
- return mySupport.createXPath(null, expression, Collections.emptyList());
- }
-
- public void attachContext(@NotNull PsiFile file) {
- myProvider.attachTo(file);
- }
- }
-}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.form b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.form
index 5e247344962d..1fefd7a3b6d1 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.form
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.form
@@ -8,10 +8,10 @@
-
+
-
+
@@ -33,23 +33,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java
index a5931af8d00a..934cdb0be3d8 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java
@@ -20,9 +20,6 @@ import com.intellij.psi.PsiFile;
import com.intellij.ui.EditorTextField;
import com.intellij.util.Consumer;
import org.intellij.lang.regexp.RegExpLanguage;
-import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
-import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection;
-import org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy;
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
import org.intellij.plugins.intelliLang.util.LanguageTextField;
@@ -33,34 +30,21 @@ public class AdvancedPanel extends AbstractInjectionPanel {
private JPanel myRoot;
private EditorTextField myValuePattern;
- private EditorTextField myXPathCondition;
- private JLabel myXPathConditionLabel;
private JCheckBox mySingleFileCheckBox;
public AdvancedPanel(Project project, BaseInjection injection) {
super(injection, project);
$$$setupUI$$$(); // see IDEA-9987
- if (!(injection instanceof AbstractTagInjection)) {
- myXPathCondition.setVisible(false);
- myXPathConditionLabel.setVisible(false);
- }
-
}
protected void apply(BaseInjection other) {
other.setValuePattern(myValuePattern.getText());
other.setSingleFile(mySingleFileCheckBox.isSelected());
- if (myOrigInjection instanceof AbstractTagInjection) {
- ((AbstractTagInjection)other).setXPathCondition(myXPathCondition.getText());
- }
}
protected void resetImpl() {
myValuePattern.setText(myOrigInjection.getValuePattern());
mySingleFileCheckBox.setSelected(myOrigInjection.isSingleFile());
- if (myOrigInjection instanceof AbstractTagInjection) {
- myXPathCondition.setText(((AbstractTagInjection)myOrigInjection).getXPathCondition());
- }
}
public JPanel getComponent() {
@@ -73,26 +57,8 @@ public class AdvancedPanel extends AbstractInjectionPanel {
psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE);
}
});
-
- if (myOrigInjection instanceof AbstractTagInjection) {
-// don't even bother to look up the language when xpath-evaluation isn't possible
- final XPathSupportProxy proxy = XPathSupportProxy.getInstance();
- myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject,
- ((AbstractTagInjection)myOrigInjection).getXPathCondition(), new Consumer() {
- public void consume(PsiFile psiFile) {
- // important to get proper validation & completion for Jaxen's built-in and PSI functions
- // like lower-case(), file-type(), file-ext(), file-name(), etc.
- if (proxy != null) {
- proxy.attachContext(psiFile);
- }
- }
- });
- }
- else {
- myXPathCondition = new EditorTextField();
- }
}
private void $$$setupUI$$$() {
}
-}
\ No newline at end of file
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/AbstractTagInjection.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/AbstractTagInjection.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/AbstractTagInjection.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/AbstractTagInjection.java
diff --git a/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java
new file mode 100644
index 000000000000..107335864e19
--- /dev/null
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2010 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 org.intellij.plugins.intelliLang.inject.config;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.PsiFile;
+import org.jaxen.JaxenException;
+import org.jaxen.XPath;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Proxy class that allows to avoid a hard compile time dependency on the XPathView plugin.
+ */
+public abstract class XPathSupportProxy {
+ private static final Logger LOG = Logger.getInstance("org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy");
+
+ public static final Object UNSUPPORTED = "UNSUPPORTED";
+ public static final Object INVALID = "INVALID";
+
+ @NotNull
+ public abstract XPath createXPath(String expression) throws JaxenException;
+
+ public abstract void attachContext(@NotNull PsiFile file);
+
+ private static XPathSupportProxy ourInstance;
+ private static boolean isInitialized;
+
+ @Nullable
+ public static synchronized XPathSupportProxy getInstance() {
+ if (isInitialized) {
+ return ourInstance;
+ }
+ try {
+ return ourInstance = ServiceManager.getService(XPathSupportProxy.class);
+ } finally {
+ if (ourInstance == null) {
+ LOG.info("XPath Support is not available");
+ }
+ isInitialized = true;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxyImpl.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxyImpl.java
new file mode 100644
index 000000000000..e581327a321f
--- /dev/null
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxyImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2000-2010 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 org.intellij.plugins.intelliLang.inject.config;
+
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.impl.source.xml.XmlTokenImpl;
+import com.intellij.psi.xml.XmlElement;
+import com.intellij.psi.xml.XmlElementType;
+import org.intellij.lang.xpath.context.ContextProvider;
+import org.intellij.lang.xpath.context.ContextType;
+import org.intellij.lang.xpath.context.NamespaceContext;
+import org.intellij.lang.xpath.context.VariableContext;
+import org.intellij.lang.xpath.psi.XPathExpression;
+import org.intellij.lang.xpath.psi.XPathType;
+import org.intellij.plugins.xpathView.support.XPathSupport;
+import org.intellij.plugins.xpathView.util.Namespace;
+import org.jaxen.JaxenException;
+import org.jaxen.XPath;
+import org.jetbrains.annotations.NotNull;
+
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+* @author Gregory.Shrago
+*/
+public class XPathSupportProxyImpl extends XPathSupportProxy {
+ private static class Provider extends ContextProvider {
+ private final XmlTokenImpl myDummyContext = new XmlTokenImpl(XmlElementType.XML_CONTENT_EMPTY, "") {
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+ };
+
+ @NotNull
+ public ContextType getContextType() {
+ return XPathSupport.TYPE;
+ }
+
+ @NotNull
+ @Override
+ public XPathType getExpectedType(XPathExpression expr) {
+ return XPathType.BOOLEAN;
+ }
+
+ public XmlElement getContextElement() {
+ // needed because the static method ContextProvider.isValid() checks this to determine if the provider
+ // is still valid - refactor this into an instance method ContextProvider.isValid()?
+ return myDummyContext;
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return null;
+ }
+
+ public VariableContext getVariableContext() {
+ return null;
+ }
+
+ public Set getAttributes(boolean forValidation) {
+ return null;
+ }
+
+ public Set getElements(boolean forValidation) {
+ return null;
+ }
+ }
+
+ private final ContextProvider myProvider = new Provider();
+ private final XPathSupport mySupport = XPathSupport.getInstance();
+
+ @NotNull
+ public XPath createXPath(String expression) throws JaxenException {
+ return mySupport.createXPath(null, expression, Collections.emptyList());
+ }
+
+ public void attachContext(@NotNull PsiFile file) {
+ myProvider.attachTo(file);
+ }
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java
similarity index 83%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java
index 972fb1bfaede..fa715cc33206 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java
@@ -16,6 +16,7 @@
package org.intellij.plugins.intelliLang.inject.config;
import com.intellij.openapi.util.JDOMExternalizer;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
@@ -75,7 +76,7 @@ public class XmlAttributeInjection extends AbstractTagInjection {
@Override
protected List generatePlaces() {
- return Collections.singletonList(PatternBasedInjectionHelper.getPatternString(this));
+ return Collections.singletonList(getPatternString(this));
}
private boolean matches(@NotNull XmlAttribute attr) {
@@ -135,4 +136,17 @@ public class XmlAttributeInjection extends AbstractTagInjection {
result = 31 * result + myAttributeNamespace.hashCode();
return result;
}
+
+ public static String getPatternString(final XmlAttributeInjection injection) {
+ final String name = injection.getAttributeName();
+ final String namespace = injection.getAttributeNamespace();
+ final StringBuilder result = new StringBuilder("xmlAttribute()");
+ if (StringUtil.isNotEmpty(name)) result.append(".withLocalName(string().matches(\"").append(name).append("\"))");
+ if (StringUtil.isNotEmpty(namespace)) result.append(".withNamespace(string().matches(\"").append(namespace).append("\"))");
+ if (StringUtil.isNotEmpty(injection.getTagName()) || StringUtil.isNotEmpty(injection.getTagNamespace())) {
+ result.append(".inside(").append(XmlTagInjection.getPatternString(injection)).append(")");
+ }
+ return result.toString();
+ }
+
}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java
similarity index 69%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java
index b28b4acce4cb..6ccaee639ece 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java
@@ -15,6 +15,7 @@
*/
package org.intellij.plugins.intelliLang.inject.config;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.xml.XmlTag;
import org.intellij.plugins.intelliLang.PatternBasedInjectionHelper;
import org.jetbrains.annotations.NotNull;
@@ -50,6 +51,17 @@ public class XmlTagInjection extends AbstractTagInjection {
@Override
protected List generatePlaces() {
- return Collections.singletonList(PatternBasedInjectionHelper.getPatternString(this));
+ return Collections.singletonList(getPatternString(this));
}
+
+ public static String getPatternString(final AbstractTagInjection injection) {
+ final String name = injection.getTagName();
+ final String namespace = injection.getTagNamespace();
+ final StringBuilder result = new StringBuilder("xmlTag()");
+ if (StringUtil.isNotEmpty(name)) result.append(".withLocalName(string().matches(\"").append(name).append("\"))");
+ if (StringUtil.isNotEmpty(namespace)) result.append(".withNamespace(string().matches(\"").append(namespace).append("\"))");
+ return result.toString();
+ }
+
+
}
diff --git a/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.form b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.form
new file mode 100644
index 000000000000..fac897331d1e
--- /dev/null
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.form
@@ -0,0 +1,65 @@
+
+
diff --git a/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java
new file mode 100644
index 000000000000..ef664eeefd23
--- /dev/null
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2006 Sascha Weinreuter
+ *
+ * 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 org.intellij.plugins.intelliLang.inject.config.ui;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiFile;
+import com.intellij.ui.EditorTextField;
+import com.intellij.util.Consumer;
+import org.intellij.lang.regexp.RegExpLanguage;
+import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
+import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection;
+import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
+import org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy;
+import org.intellij.plugins.intelliLang.util.LanguageTextField;
+
+import javax.swing.*;
+
+public class AdvancedXmlPanel extends AbstractInjectionPanel {
+
+ private JPanel myRoot;
+
+ private EditorTextField myValuePattern;
+ private EditorTextField myXPathCondition;
+ private JLabel myXPathConditionLabel;
+ private JCheckBox mySingleFileCheckBox;
+
+ public AdvancedXmlPanel(Project project, BaseInjection injection) {
+ super(injection, project);
+ $$$setupUI$$$(); // see IDEA-9987
+ if (!(injection instanceof AbstractTagInjection)) {
+ myXPathCondition.setVisible(false);
+ myXPathConditionLabel.setVisible(false);
+ }
+
+ }
+
+ protected void apply(BaseInjection other) {
+ other.setValuePattern(myValuePattern.getText());
+ other.setSingleFile(mySingleFileCheckBox.isSelected());
+ if (myOrigInjection instanceof AbstractTagInjection) {
+ ((AbstractTagInjection)other).setXPathCondition(myXPathCondition.getText());
+ }
+ }
+
+ protected void resetImpl() {
+ myValuePattern.setText(myOrigInjection.getValuePattern());
+ mySingleFileCheckBox.setSelected(myOrigInjection.isSingleFile());
+ if (myOrigInjection instanceof AbstractTagInjection) {
+ myXPathCondition.setText(((AbstractTagInjection)myOrigInjection).getXPathCondition());
+ }
+ }
+
+ public JPanel getComponent() {
+ return myRoot;
+ }
+
+ private void createUIComponents() {
+ myValuePattern = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getValuePattern(), new Consumer() {
+ public void consume(PsiFile psiFile) {
+ psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE);
+ }
+ });
+
+ if (myOrigInjection instanceof AbstractTagInjection) {
+// don't even bother to look up the language when xpath-evaluation isn't possible
+ final XPathSupportProxy proxy = XPathSupportProxy.getInstance();
+ myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject,
+ ((AbstractTagInjection)myOrigInjection).getXPathCondition(), new Consumer() {
+ public void consume(PsiFile psiFile) {
+ // important to get proper validation & completion for Jaxen's built-in and PSI functions
+ // like lower-case(), file-type(), file-ext(), file-name(), etc.
+ if (proxy != null) {
+ proxy.attachContext(psiFile);
+ }
+ }
+ });
+ }
+ else {
+ myXPathCondition = new EditorTextField();
+ }
+ }
+
+ private void $$$setupUI$$$() {
+ }
+}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.form b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.form
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.form
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.form
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form
similarity index 97%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form
index 8c43e593a2ae..ce2490d0a4a5 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form
@@ -69,7 +69,7 @@
-
+
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java
similarity index 95%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java
index 481b8e846988..ffb890b805ea 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java
@@ -31,7 +31,7 @@ public class XmlAttributePanel extends AbstractInjectionPanel
-
+
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java
similarity index 93%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java
index 2c92a3bb1218..ffc92143ba0c 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java
@@ -25,7 +25,7 @@ public class XmlTagPanel extends AbstractInjectionPanel {
// read by reflection
LanguagePanel myLanguagePanel;
TagPanel myPanel;
- AdvancedPanel myAdvancedPanel;
+ AdvancedXmlPanel myAdvancedPanel;
private JPanel myRoot;
@@ -51,7 +51,7 @@ public class XmlTagPanel extends AbstractInjectionPanel {
private void createUIComponents() {
myLanguagePanel = new LanguagePanel(myProject, myOrigInjection);
myPanel = new TagPanel(myProject, myOrigInjection);
- myAdvancedPanel = new AdvancedPanel(myProject, myOrigInjection);
+ myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection);
}
private void $$$setupUI$$$() {
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java
similarity index 99%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java
rename to plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java
index e063875b9239..f4f5e94914de 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java
+++ b/plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java
@@ -38,4 +38,4 @@ public class XmlAttributeInjectionConfigurable extends InjectionConfigurable variables,
+ @Nullable PsiElement context) {
+ if (context == null) {
+ return false;
+ }
+ final VariableAssignedVisitor visitor =
+ new VariableAssignedVisitor(variables, true);
+ context.accept(visitor);
+ return visitor.isAssigned();
+ }
+
+ public static Set collectUsedVariables(
+ PsiElement context) {
+ if (context == null) {
+ return Collections.EMPTY_SET;
+ }
+ final VariableCollectingVisitor visitor =
+ new VariableCollectingVisitor();
+ context.accept(visitor);
+ return visitor.getUsedVariables();
+ }
+
+ private static class VariableCollectingVisitor
+ extends JavaRecursiveElementVisitor {
+
+ private final Set usedVariables = new HashSet();
+
+ @Override
+ public void visitReferenceExpression(
+ PsiReferenceExpression expression) {
+ super.visitReferenceExpression(expression);
+ final PsiElement target = expression.resolve();
+ if (!(target instanceof PsiVariable)) {
+ return;
+ }
+ final PsiVariable variable = (PsiVariable)target;
+ usedVariables.add(variable);
+ }
+
+ public Set getUsedVariables() {
+ return usedVariables;
+ }
+ }
}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/psiutils/VariableAssignedVisitor.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/psiutils/VariableAssignedVisitor.java
new file mode 100644
index 000000000000..5956e36e2bdf
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/psiutils/VariableAssignedVisitor.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
+ *
+ * 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.siyeh.ipp.psiutils;
+
+import com.intellij.psi.*;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+class VariableAssignedVisitor extends JavaRecursiveElementVisitor{
+
+ @NotNull private final Collection variables;
+ private final boolean recurseIntoClasses;
+ private boolean assigned = false;
+
+ public VariableAssignedVisitor(@NotNull Collection variables,
+ boolean recurseIntoClasses){
+ this.variables = variables;
+ this.recurseIntoClasses = recurseIntoClasses;
+ }
+
+ @Override public void visitElement(@NotNull PsiElement element){
+ if(assigned){
+ return;
+ }
+ super.visitElement(element);
+ }
+
+ @Override public void visitAssignmentExpression(
+ @NotNull PsiAssignmentExpression assignment){
+ if(assigned){
+ return;
+ }
+ super.visitAssignmentExpression(assignment);
+ final PsiExpression lhs = assignment.getLExpression();
+ for (PsiVariable variable : variables) {
+ if(mayEvaluateToVariable(lhs, variable)){
+ assigned = true;
+ }
+ }
+ }
+
+ @Override
+ public void visitClass(PsiClass aClass) {
+ if(!recurseIntoClasses){
+ return;
+ }
+ if(assigned){
+ return;
+ }
+ super.visitClass(aClass);
+ }
+
+ @Override public void visitPrefixExpression(
+ @NotNull PsiPrefixExpression prefixExpression){
+ if(assigned){
+ return;
+ }
+ super.visitPrefixExpression(prefixExpression);
+ final PsiJavaToken operationSign = prefixExpression.getOperationSign();
+ final IElementType tokenType = operationSign.getTokenType();
+ if(!tokenType.equals(JavaTokenType.PLUSPLUS) &&
+ !tokenType.equals(JavaTokenType.MINUSMINUS)){
+ return;
+ }
+ final PsiExpression operand = prefixExpression.getOperand();
+ for (PsiVariable variable : variables) {
+ if(mayEvaluateToVariable(operand, variable)){
+ assigned = true;
+ }
+ }
+ }
+
+ @Override public void visitPostfixExpression(
+ @NotNull PsiPostfixExpression postfixExpression){
+ if(assigned){
+ return;
+ }
+ super.visitPostfixExpression(postfixExpression);
+ final PsiJavaToken operationSign = postfixExpression.getOperationSign();
+ final IElementType tokenType = operationSign.getTokenType();
+ if(!tokenType.equals(JavaTokenType.PLUSPLUS) &&
+ !tokenType.equals(JavaTokenType.MINUSMINUS)){
+ return;
+ }
+ final PsiExpression operand = postfixExpression.getOperand();
+ for (PsiVariable variable : variables) {
+ if(mayEvaluateToVariable(operand, variable)){
+ assigned = true;
+ }
+ }
+ }
+
+ public static boolean mayEvaluateToVariable(
+ @Nullable PsiExpression expression,
+ @NotNull PsiVariable variable) {
+ if (expression == null){
+ return false;
+ }
+ if(expression instanceof PsiBinaryExpression) {
+ final PsiBinaryExpression binaryExpression =
+ (PsiBinaryExpression)expression;
+ final PsiExpression lOperand = binaryExpression.getLOperand();
+ final PsiExpression rOperand = binaryExpression.getROperand();
+ return mayEvaluateToVariable(lOperand, variable) ||
+ mayEvaluateToVariable(rOperand, variable);
+ }
+ if(expression instanceof PsiParenthesizedExpression){
+ final PsiParenthesizedExpression parenthesizedExpression =
+ (PsiParenthesizedExpression)expression;
+ final PsiExpression containedExpression =
+ parenthesizedExpression.getExpression();
+ return mayEvaluateToVariable(containedExpression, variable);
+ }
+ if(expression instanceof PsiTypeCastExpression){
+ final PsiTypeCastExpression typeCastExpression =
+ (PsiTypeCastExpression)expression;
+ final PsiExpression containedExpression =
+ typeCastExpression.getOperand();
+ return mayEvaluateToVariable(containedExpression, variable);
+ }
+ if(expression instanceof PsiConditionalExpression){
+ final PsiConditionalExpression conditional =
+ (PsiConditionalExpression) expression;
+ final PsiExpression thenExpression = conditional.getThenExpression();
+ final PsiExpression elseExpression = conditional.getElseExpression();
+ return mayEvaluateToVariable(thenExpression, variable) ||
+ mayEvaluateToVariable(elseExpression, variable);
+ }
+ if(expression instanceof PsiArrayAccessExpression){
+ final PsiElement parent = expression.getParent();
+ if (parent instanceof PsiArrayAccessExpression){
+ return false;
+ }
+ final PsiType type = variable.getType();
+ if (!(type instanceof PsiArrayType)) {
+ return false;
+ }
+ final PsiArrayType arrayType = (PsiArrayType)type;
+ final int dimensions = arrayType.getArrayDimensions();
+ if (dimensions <= 1) {
+ return false;
+ }
+ PsiArrayAccessExpression arrayAccessExpression =
+ (PsiArrayAccessExpression)expression;
+ PsiExpression arrayExpression =
+ arrayAccessExpression.getArrayExpression();
+ int count = 1;
+ while (arrayExpression instanceof PsiArrayAccessExpression) {
+ arrayAccessExpression =
+ (PsiArrayAccessExpression)arrayExpression;
+ arrayExpression = arrayAccessExpression.getArrayExpression();
+ count++;
+ }
+ return count != dimensions &&
+ mayEvaluateToVariable(arrayExpression, variable);
+ }
+ return evaluatesToVariable(expression, variable);
+ }
+
+ public static boolean evaluatesToVariable(
+ @Nullable PsiExpression expression,
+ @NotNull PsiVariable variable) {
+ final PsiExpression strippedExpression =
+ ParenthesesUtils.stripParentheses(expression);
+ if(strippedExpression == null){
+ return false;
+ }
+ if (!(expression instanceof PsiReferenceExpression)) {
+ return false;
+ }
+ final PsiReferenceExpression referenceExpression =
+ (PsiReferenceExpression) expression;
+ final PsiElement referent = referenceExpression.resolve();
+ return variable.equals(referent);
+ }
+
+ public boolean isAssigned(){
+ return assigned;
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsIntention.java
index a08745671c6d..1d97c213a0d0 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,11 +25,13 @@ import org.jetbrains.annotations.NonNls;
public class MergeParallelIfsIntention extends Intention {
+ @Override
@NotNull
public PsiElementPredicate getElementPredicate() {
return new MergeParallelIfsPredicate();
}
+ @Override
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiJavaToken token = (PsiJavaToken)element;
@@ -57,23 +59,23 @@ public class MergeParallelIfsIntention extends Intention {
final PsiStatement firstThenBranch = firstStatement.getThenBranch();
final PsiStatement secondThenBranch = secondStatement.getThenBranch();
@NonNls String statement = "if(" + conditionText + ')' +
- printStatementsInSequence(firstThenBranch,
- secondThenBranch);
+ printStatementsInSequence(firstThenBranch,
+ secondThenBranch);
final PsiStatement firstElseBranch = firstStatement.getElseBranch();
final PsiStatement secondElseBranch = secondStatement.getElseBranch();
if (firstElseBranch != null || secondElseBranch != null) {
if (firstElseBranch instanceof PsiIfStatement
- && secondElseBranch instanceof PsiIfStatement
- && MergeParallelIfsPredicate.ifStatementsCanBeMerged(
+ && secondElseBranch instanceof PsiIfStatement
+ && MergeParallelIfsPredicate.ifStatementsCanBeMerged(
(PsiIfStatement)firstElseBranch,
(PsiIfStatement)secondElseBranch)) {
statement += "else " +
- mergeIfStatements((PsiIfStatement)firstElseBranch,
- (PsiIfStatement)secondElseBranch);
+ mergeIfStatements((PsiIfStatement)firstElseBranch,
+ (PsiIfStatement)secondElseBranch);
} else {
statement += "else" +
- printStatementsInSequence(firstElseBranch,
- secondElseBranch);
+ printStatementsInSequence(firstElseBranch,
+ secondElseBranch);
}
}
return statement;
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsPredicate.java
index fc69581a1ba9..04fe5fd6cb62 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsPredicate.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/MergeParallelIfsPredicate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@ import com.siyeh.ipp.base.PsiElementPredicate;
import com.siyeh.ipp.psiutils.ControlFlowUtils;
import com.siyeh.ipp.psiutils.EquivalenceChecker;
import com.siyeh.ipp.psiutils.ErrorUtil;
+import com.siyeh.ipp.psiutils.VariableAccessUtils;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -32,7 +34,6 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
return false;
}
final PsiJavaToken token = (PsiJavaToken) element;
-
final PsiElement parent = token.getParent();
if(!(parent instanceof PsiIfStatement)){
return false;
@@ -51,7 +52,19 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
if(ErrorUtil.containsError(nextIfStatement)){
return false;
}
- return ifStatementsCanBeMerged(ifStatement, nextIfStatement);
+ if(!ifStatementsCanBeMerged(ifStatement, nextIfStatement)){
+ return false;
+ }
+ final PsiExpression condition = ifStatement.getCondition();
+ final Set variables =
+ VariableAccessUtils.collectUsedVariables(condition);
+ final PsiStatement thenBranch = ifStatement.getThenBranch();
+ if(VariableAccessUtils.isAnyVariableAssigned(variables, thenBranch)){
+ return false;
+ }
+ final PsiStatement elseBranch = ifStatement.getElseBranch();
+ return !VariableAccessUtils.isAnyVariableAssigned(variables,
+ elseBranch);
}
public static boolean ifStatementsCanBeMerged(PsiIfStatement statement1,
@@ -63,8 +76,8 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
}
final PsiExpression firstCondition = statement1.getCondition();
final PsiExpression secondCondition = statement2.getCondition();
- if(! EquivalenceChecker.expressionsAreEquivalent(firstCondition,
- secondCondition)){
+ if(!EquivalenceChecker.expressionsAreEquivalent(firstCondition,
+ secondCondition)){
return false;
}
final PsiStatement nextThenBranch = statement2.getThenBranch();
@@ -73,11 +86,11 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
}
final PsiStatement nextElseBranch = statement2.getElseBranch();
return elseBranch == null || nextElseBranch == null ||
- canBeMerged(elseBranch, nextElseBranch);
+ canBeMerged(elseBranch, nextElseBranch);
}
private static boolean canBeMerged(PsiStatement statement1,
- PsiStatement statement2){
+ PsiStatement statement2){
if(!ControlFlowUtils.statementMayCompleteNormally(statement1)){
return false;
}
@@ -89,13 +102,13 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
final Set statement2Declarations =
calculateTopLevelDeclarations(statement2);
return !containsConflictingDeclarations(statement2Declarations,
- statement1);
+ statement1);
}
private static boolean containsConflictingDeclarations(
- Set declarations, PsiStatement statement) {
+ Set declarations, PsiElement context) {
final DeclarationVisitor visitor = new DeclarationVisitor(declarations);
- statement.accept(visitor);
+ context.accept(visitor);
return visitor.hasConflict();
}
@@ -119,18 +132,19 @@ class MergeParallelIfsPredicate implements PsiElementPredicate{
}
private static void addDeclarations(PsiDeclarationStatement statement,
- Set declaredVars){
+ Collection declaredVariables){
final PsiElement[] elements = statement.getDeclaredElements();
for(final PsiElement element : elements){
if(element instanceof PsiVariable){
final PsiVariable variable = (PsiVariable) element;
final String name = variable.getName();
- declaredVars.add(name);
+ declaredVariables.add(name);
}
}
}
- private static class DeclarationVisitor extends JavaRecursiveElementWalkingVisitor{
+ private static class DeclarationVisitor
+ extends JavaRecursiveElementWalkingVisitor{
private final Set declarations;
private boolean hasConflict = false;
diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml
index 3a78d9adb66a..947e43d2bf53 100644
--- a/plugins/groovy/jetgroovy.iml
+++ b/plugins/groovy/jetgroovy.iml
@@ -32,6 +32,7 @@
+
diff --git a/plugins/IntelliLang/src/META-INF/intellilang-groovy-support.xml b/plugins/groovy/src/META-INF/intellilang-groovy-support.xml
similarity index 95%
rename from plugins/IntelliLang/src/META-INF/intellilang-groovy-support.xml
rename to plugins/groovy/src/META-INF/intellilang-groovy-support.xml
index 241b30708fd5..365491c9511e 100644
--- a/plugins/IntelliLang/src/META-INF/intellilang-groovy-support.xml
+++ b/plugins/groovy/src/META-INF/intellilang-groovy-support.xml
@@ -7,4 +7,4 @@
config="/resources/groovyInjections.xml"/>
-
\ No newline at end of file
+
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index 5d0536d3d6b8..4896b89518a7 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -24,6 +24,7 @@
com.intellij.properties
com.intellij.copyright
+ org.intellij.intelliLang
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
similarity index 100%
rename from plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
rename to plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
index d114ec046a7d..601ba52d8a88 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
@@ -33,6 +33,7 @@ import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.MultiMap;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
@@ -365,31 +366,28 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
@Override
public void visitListOrMap(GrListOrMap listOrMap) {
- final Map> map = DuplicatesUtil.factorDuplicates(listOrMap.getNamedArguments(), new TObjectHashingStrategy() {
- public int computeHashCode(GrNamedArgument arg) {
- final GrArgumentLabel label = arg.getLabel();
- if (label == null) return 0;
+ MultiMap map = new MultiMap();
+
+ for (GrNamedArgument element : listOrMap.getNamedArguments()) {
+ final GrArgumentLabel label = element.getLabel();
+ if (label != null) {
final String name = label.getName();
- if (name == null) return 0;
- return name.hashCode();
- }
-
- public boolean equals(GrNamedArgument arg1, GrNamedArgument arg2) {
- final GrArgumentLabel label1 = arg1.getLabel();
- final GrArgumentLabel label2 = arg2.getLabel();
- if (label1 == null || label2 == null) {
- return label1 == null && label2 == null;
+ if (name != null) {
+ map.putValue(name, element);
}
- final String name1 = label1.getName();
- final String name2 = label2.getName();
- if (name1 == null || name2 == null) {
- return name1 == null && name2 == null;
- }
- return name1.equals(name2);
}
- });
+ }
- processDuplicates(map, myHolder);
+ for (String key : map.keySet()) {
+ final Collection arguments = map.get(key);
+ if (arguments.size() > 1) {
+ final List args = new ArrayList(arguments);
+ for (int i = 1; i < args.size(); i++) {
+ GrNamedArgument namedArgument = args.get(i);
+ myHolder.createWarningAnnotation(namedArgument.getLabel(), GroovyBundle.message("duplicate.element.in.the.map"));
+ }
+ }
+ }
}
@Override
@@ -734,15 +732,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
}
}
- protected static void processDuplicates(Map> map, AnnotationHolder holder) {
- for (List args : map.values()) {
- for (int i = 1; i < args.size(); i++) {
- GrNamedArgument namedArgument = args.get(i);
- holder.createWarningAnnotation(namedArgument, GroovyBundle.message("duplicate.element.in.the.map"));
- }
- }
- }
-
private static void registerAbstractMethodFix(Annotation annotation, GrMethod method, boolean makeClassAbstract) {
if (method.getBlock() == null) {
annotation.registerFix(new AddMethodBodyFix(method));
diff --git a/plugins/IntelliLang/src/resources/groovyInjections.xml b/plugins/groovy/src/resources/groovyInjections.xml
similarity index 100%
rename from plugins/IntelliLang/src/resources/groovyInjections.xml
rename to plugins/groovy/src/resources/groovyInjections.xml
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
index 3cf292ba7117..7083e7fef480 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
@@ -224,6 +224,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
public void testSuperConstructorInvocation() throws Exception {doTest();}
+ public void testDuplicateMapKeys() throws Exception {doTest();}
+
public void testIndexPropertyAccess() throws Exception {
doTest();
}
diff --git a/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy b/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy
new file mode 100644
index 000000000000..ea162db4a8fa
--- /dev/null
+++ b/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy
@@ -0,0 +1,2 @@
+x = [ (person.firstNameKey):person.firstName, (person.lastNameKey):person.lastName ]
+x = [2:1, 2:2]
\ No newline at end of file
diff --git a/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java b/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java
index c9a23a0af167..e29ba3ee7336 100644
--- a/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java
+++ b/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java
@@ -57,7 +57,11 @@ public class ConfigurationUtil {
}
);
for (final PsiMethod method : suiteMethods) {
- final PsiClass containingClass = method.getContainingClass();
+ final PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable() {
+ public PsiClass compute() {
+ return method.getContainingClass();
+ }
+ });
if (containingClass == null) continue;
if (containingClass instanceof PsiAnonymousClass) continue;
if (containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
index 61cbe9521080..0161d147559a 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
@@ -107,14 +107,13 @@ public class MavenModuleImporter {
private void configDependencies() {
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
- boolean isExportable = artifact.isExportable();
DependencyScope scope = selectScope(artifact.getScope());
MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
if (depProject != null) {
- myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), isExportable, scope);
+ myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), scope);
}
else if (myMavenProject.isSupportedDependency(artifact)) {
- myRootModelAdapter.addLibraryDependency(artifact, isExportable, scope, myModifiableModelsProvider, myMavenProject);
+ myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
}
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
index 8cb89ef664cb..5ebda0447bf8 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
@@ -194,7 +194,7 @@ public class MavenRootModelAdapter {
return new Path(path);
}
- public void addModuleDependency(String moduleName, boolean isExportable, DependencyScope scope) {
+ public void addModuleDependency(String moduleName, DependencyScope scope) {
Module m = findModuleByName(moduleName);
ModuleOrderEntry e;
@@ -205,7 +205,6 @@ public class MavenRootModelAdapter {
e = myRootModel.addInvalidModuleEntry(moduleName);
}
- e.setExported(isExportable);
e.setScope(scope);
}
@@ -215,7 +214,6 @@ public class MavenRootModelAdapter {
}
public void addLibraryDependency(MavenArtifact artifact,
- boolean isExportable,
DependencyScope scope,
MavenModifiableModelsProvider provider,
MavenProject project) {
@@ -234,7 +232,6 @@ public class MavenRootModelAdapter {
}
LibraryOrderEntry e = myRootModel.addLibraryEntry(library);
- e.setExported(isExportable);
e.setScope(scope);
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java
new file mode 100644
index 000000000000..d23364e0df28
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2010 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 org.jetbrains.idea.maven.project.actions;
+
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import org.jetbrains.idea.maven.utils.actions.MavenActionUtil;
+
+public class DownloadActionGroup extends DefaultActionGroup {
+ @Override
+ public void update(AnActionEvent e) {
+ super.update(e);
+ e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject());
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java
index 24288ad3ccfb..5626ef504af3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java
@@ -26,5 +26,10 @@ public abstract class MavenProjectsManagerAction extends MavenAction {
perform(MavenActionUtil.getProjectsManager(e.getDataContext()));
}
+ @Override
+ protected boolean isAvailable(AnActionEvent e) {
+ return super.isAvailable(e) && MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject();
+ }
+
protected abstract void perform(MavenProjectsManager manager);
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java
index d7c80f0b6a5e..b40c7f0a4ff3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java
@@ -15,9 +15,15 @@
*/
package org.jetbrains.idea.maven.project.actions;
+import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
public class ReimportAction extends MavenProjectsManagerAction {
+ @Override
+ protected boolean isAvailable(AnActionEvent e) {
+ return true;
+ }
+
@Override
protected void perform(MavenProjectsManager manager) {
manager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
index 861217b18b3e..999f62d4012d 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
@@ -29,8 +29,6 @@ public class MavenActionGroup extends DefaultActionGroup {
}
protected boolean isAvailable(AnActionEvent e) {
- final DataContext context = e.getDataContext();
- if (MavenActionUtil.getProject(context) == null) return false;
- return !MavenActionUtil.getMavenProjects(context).isEmpty();
+ return !MavenActionUtil.getMavenProjects(e.getDataContext()).isEmpty();
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
index c8554cfcd71c..26114abaefb3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
@@ -33,7 +34,7 @@ public class MavenActionUtil {
private MavenActionUtil() {
}
- @Nullable
+ @NotNull
public static Project getProject(DataContext context) {
return PlatformDataKeys.PROJECT.getData(context);
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java
index 46bc9e2bcf10..09ad1d396c53 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java
@@ -27,7 +27,7 @@ public abstract class MavenToggleAction extends ToggleAction implements DumbAwar
}
protected boolean isAvailable(AnActionEvent e) {
- return MavenActionUtil.getProject(e.getDataContext()) != null;
+ return true;
}
public final boolean isSelected(AnActionEvent e) {
diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml
index e63770130d0d..34bedb046eae 100644
--- a/plugins/maven/src/main/resources/META-INF/plugin.xml
+++ b/plugins/maven/src/main/resources/META-INF/plugin.xml
@@ -293,7 +293,8 @@
-
+
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
index 2d7316c664b4..e1570464176c 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
@@ -199,7 +199,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
assertModuleDeps(moduleName, LibraryOrderEntry.class, expectedDeps);
}
- protected void assertExportedModuleDeps(String moduleName, String... expectedDeps) {
+ protected void assertExportedDeps(String moduleName, String... expectedDeps) {
final List actual = new ArrayList();
getRootManager(moduleName).processOrder(new RootPolicy