From 7dcdc818143efb1598546eea758d1a7552a203e8 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 11:17:40 +0200 Subject: [PATCH 001/210] cleanup --- .../siyeh/ig/imports/JavaLangImportInspection.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/JavaLangImportInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/JavaLangImportInspection.java index b53121de0143..bc7887fcfef1 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/JavaLangImportInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/JavaLangImportInspection.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. @@ -27,22 +27,26 @@ import org.jetbrains.annotations.NotNull; public class JavaLangImportInspection extends BaseInspection { + @Override @NotNull public String getDisplayName(){ return InspectionGadgetsBundle.message( "java.lang.import.display.name"); } + @Override @NotNull public String buildErrorString(Object... infos){ return InspectionGadgetsBundle.message( "java.lang.import.problem.descriptor"); } + @Override public InspectionGadgetsFix buildFix(Object... infos) { return new DeleteImportFix(); } + @Override public BaseInspectionVisitor buildVisitor(){ return new JavaLangImportVisitor(); } @@ -68,12 +72,12 @@ public class JavaLangImportInspection extends BaseInspection { final PsiImportStatement[] importStatements = importList.getImportStatements(); for(PsiImportStatement importStatement : importStatements) { - checkImportStatment(importStatement, file); + checkImportStatement(importStatement, file); } } - private void checkImportStatment(PsiImportStatement importStatement, - PsiJavaFile file){ + private void checkImportStatement(PsiImportStatement importStatement, + PsiJavaFile file){ final PsiJavaCodeReferenceElement reference = importStatement.getImportReference(); if (reference == null) { From ee386701bb930321b1660f7a331d20f9f425fdd1 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 13:21:47 +0400 Subject: [PATCH 002/210] Maven: test --- .../maven/compiler/ResourceCopyingTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java index 3680c939732b..7b5618f7413c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java @@ -15,6 +15,8 @@ */ package org.jetbrains.idea.maven.compiler; +import com.intellij.compiler.CompilerConfiguration; +import com.intellij.compiler.CompilerConfigurationImpl; import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; @@ -223,6 +225,38 @@ public class ResourceCopyingTest extends MavenImportingTestCase { assertNotCopied("target/classes/file.properties"); } + public void testDoNotCopyExcludedStandardResources() throws Exception { + if (ignore()) return; + + CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject); + configuration.addResourceFilePattern("*.zzz"); + + createProjectSubFile("res/file.xxx"); + createProjectSubFile("res/file.zzz"); + + importProject("test" + + "project" + + "1" + + + "" + + " " + + " " + + " res" + + " " + + " **/*.xxx" + + " " + + " " + + " **/*.zzz" + + " " + + " " + + " " + + ""); + + compileModules("project"); + assertCopied("target/classes/file.xxx"); + assertNotCopied("target/classes/file.zzz"); + } + public void testDeletingManuallyCopyedFiles() throws Exception { if (ignore()) return; From c6ad653f65eb8eb00e0ce349f704f67db6538422 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 13:35:41 +0400 Subject: [PATCH 003/210] Maven: erroneous NotNull annotation removed --- .../java/org/jetbrains/idea/maven/importing/FacetImporter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java index 85ec1de7c1f7..c7f0db91e427 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java @@ -105,7 +105,6 @@ public abstract class FacetImporter T findFacet(FacetModel model, FacetType type, String defaultFacetName) { T result = model.findFacet(type.getId(), defaultFacetName); if (result == null) result = model.getFacetByType(type.getId()); From f59e1d94db498cc03a338e69a9b6b87c105fb0de Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 11:38:40 +0200 Subject: [PATCH 004/210] IDEA-53471 (New inspection: split "static import" inspection by field & method) --- .../siyeh/InspectionGadgetsBundle.properties | 4 +- .../ig/imports/StaticImportInspection.java | 82 +++++++++++++++---- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index e7601c3445e7..df1b738df96e 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1727,7 +1727,7 @@ int.literal.may.be.long.literal.display.name=int literal cast to long could be l int.literal.may.be.long.literal.problem.descriptor=#ref could be replaced with ''{0}'' int.literal.may.be.long.literal.quickfix=Replace with ''{0}'' constant.assert.condition.display.name='assert' statement condition is constant -constant.assert.condition.problem.descriptor=assert condition #ref is constant +constant.assert.condition.problem.descriptor=Assert condition #ref is constant assert.with.side.effects.display.name='assert' statement with side effects assert.with.side.effects.problem.descriptor=#ref has side effects #loc method.count.ignore.getters.setters.option=&Ignore simple getter and setter methods @@ -1761,3 +1761,5 @@ 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 diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java index a23a93e90a00..2cd3216a05bf 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java @@ -26,8 +26,10 @@ import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; import com.siyeh.ig.psiutils.StringUtils; +import com.siyeh.ig.ui.MultipleCheckboxOptionsPanel; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -35,33 +37,51 @@ import java.util.Map; public class StaticImportInspection extends BaseInspection { + @SuppressWarnings({"PublicField"}) + public boolean ignoreSingleFieldImports = false; + @SuppressWarnings({"PublicField"}) + public boolean ignoreSingeMethodImports = false; + @Override @NotNull - public String getDisplayName(){ + public String getDisplayName() { return InspectionGadgetsBundle.message("static.import.display.name"); } @Override @NotNull - public String buildErrorString(Object... infos){ + public String buildErrorString(Object... infos) { return InspectionGadgetsBundle.message( "static.import.problem.descriptor"); } @Override - public BaseInspectionVisitor buildVisitor(){ + public JComponent createOptionsPanel() { + final MultipleCheckboxOptionsPanel panel = + new MultipleCheckboxOptionsPanel(this); + panel.addCheckbox(InspectionGadgetsBundle.message( + "ignore.single.field.static.imports"), + "ignoreSingleFieldImports"); + panel.addCheckbox(InspectionGadgetsBundle.message( + "ignore.single.method.static.imports"), + "ignoreSingeMethodImports"); + return panel; + } + + @Override + public BaseInspectionVisitor buildVisitor() { return new StaticImportVisitor(); } @Override - protected InspectionGadgetsFix buildFix(Object... infos){ + protected InspectionGadgetsFix buildFix(Object... infos) { return new StaticImportFix(); } private static class StaticImportFix extends InspectionGadgetsFix{ @NotNull - public String getName(){ + public String getName() { return InspectionGadgetsBundle.message( "static.import.replace.quickfix"); } @@ -234,7 +254,7 @@ public class StaticImportInspection extends BaseInspection { return false; } final PsiElement target = reference.resolve(); - if(!(target instanceof PsiClass)) { + if (!(target instanceof PsiClass)) { return false; } final PsiClass aClass = (PsiClass) target; @@ -249,33 +269,59 @@ public class StaticImportInspection extends BaseInspection { } } - private static class StaticImportVisitor extends BaseInspectionVisitor{ + private class StaticImportVisitor extends BaseInspectionVisitor{ - @Override public void visitClass(@NotNull PsiClass aClass){ + @Override public void visitClass(@NotNull PsiClass aClass) { // no call to super, so it doesn't drill down - if(!(aClass.getParent() instanceof PsiJavaFile)){ + if (!(aClass.getParent() instanceof PsiJavaFile)) { + return; + } + if (JspPsiUtil.isInJspFile(aClass.getContainingFile())) { return; } - if (JspPsiUtil.isInJspFile(aClass.getContainingFile())) { - return; - } final PsiJavaFile file = (PsiJavaFile) aClass.getParent(); - if(file == null){ + if (file == null) { return; } - if(!file.getClasses()[0].equals(aClass)){ + if (!file.getClasses()[0].equals(aClass)) { return; } final PsiImportList importList = file.getImportList(); - if(importList == null){ + if (importList == null) { return; } final PsiImportStaticStatement[] importStatements = importList.getImportStaticStatements(); - for(final PsiImportStaticStatement importStatement : - importStatements){ - registerError(importStatement); + for (PsiImportStaticStatement importStatement : importStatements) { + if (shouldReportImportStatement(importStatement)) { + registerError(importStatement); + } } } + + private boolean shouldReportImportStatement( + PsiImportStatementBase importStatement) { + if (importStatement.isOnDemand()) { + return true; + } + final PsiReference importReference = + importStatement.getImportReference(); + if (importReference == null) { + return false; + } + if (ignoreSingleFieldImports || ignoreSingeMethodImports) { + final PsiElement target = importReference.resolve(); + if (target != null && target instanceof PsiField) { + if (ignoreSingleFieldImports) { + return false; + } + } else { + if (ignoreSingeMethodImports) { + return false; + } + } + } + return true; + } } } From aaed92b37f90a7e3071a815a6ba5ac2006ce420c Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 5 Apr 2010 13:57:09 +0400 Subject: [PATCH 005/210] make EmptyValidityState common and move to openapi --- .../openapi/compiler/EmptyValidityState.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 java/compiler/openapi/src/com/intellij/openapi/compiler/EmptyValidityState.java diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/EmptyValidityState.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/EmptyValidityState.java new file mode 100644 index 000000000000..fdcf40543232 --- /dev/null +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/EmptyValidityState.java @@ -0,0 +1,42 @@ +/* + * 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.openapi.compiler; + +import java.io.DataOutput; +import java.io.IOException; + +/** + * Empty validity state for force recompilation + * + * @author Konstantin Bulenkov + */ +public final class EmptyValidityState implements ValidityState { + /** + * In most cases this method returns false to force recompile + * + * @param otherState the state to compare with. + * @return true if and only if otherState == this + */ + public boolean equalsTo(ValidityState otherState) { + return otherState == this; + } + + /** + * Do nothing here + */ + public void save(DataOutput dataOutput) throws IOException { + } +} From 4574d87dff3246941d9527a930a86e01a84eb591 Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Tue, 30 Mar 2010 16:38:13 +0400 Subject: [PATCH 006/210] common controls extracted to the platform + messages moved to the right bundle --- .../intellij/util/ui/LocalPathCellEditor.java | 69 ++++ .../util/ui/ValidatingTableEditor.form | 83 +++++ .../util/ui/ValidatingTableEditor.java | 337 ++++++++++++++++++ 3 files changed, 489 insertions(+) create mode 100644 platform/platform-impl/src/com/intellij/util/ui/LocalPathCellEditor.java create mode 100644 platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form create mode 100644 platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java 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..3c0af0f68318 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form @@ -0,0 +1,83 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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..0ffa6dce00e0 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -0,0 +1,337 @@ +/* + * 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 abstract Pair validate(List current, List warnings); + + 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; + } + } + +} From 52fa6e41288f11a84ee9518b5d3629ffab446689 Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Wed, 31 Mar 2010 16:58:00 +0400 Subject: [PATCH 007/210] nested forms from another module are not supported --- .../src/com/intellij/util/ui/ValidatingTableEditor.form | 9 ++------- .../src/com/intellij/util/ui/ValidatingTableEditor.java | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form index 3c0af0f68318..811d6ca765be 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form @@ -1,6 +1,6 @@
- + @@ -45,7 +45,7 @@ - + @@ -73,11 +73,6 @@ - - - - - diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java index 0ffa6dce00e0..0d1242e064ab 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -334,4 +334,9 @@ public abstract class ValidatingTableEditor { } } + public Component getContentPane() { + return myContentPane; + } + + } From 9eca46e0208cbfe54dcfac23d1065e146ab64f12 Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Wed, 31 Mar 2010 20:45:11 +0400 Subject: [PATCH 008/210] WD PHP: resources paths management --- .../util/ui/ValidatingTableEditor.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java index 0d1242e064ab..5f8e3b7f475b 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -95,7 +95,23 @@ public abstract class ValidatingTableEditor { protected abstract Item cloneOf(Item item); @Nullable - protected abstract Pair validate(List current, List warnings); + 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(); From 5949a15e9f4eb4aa67128df91c553fc1b67eed1c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 5 Apr 2010 14:20:36 +0400 Subject: [PATCH 009/210] cleanup --- .../command/impl/UndoRedoStacksHolder.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java index 5f5e169a6271..d74b150d1720 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java @@ -40,16 +40,7 @@ class UndoRedoStacksHolder { myUndo = isUndo; } - public LinkedList getStack(Document d) { - return getStack(createReferenceOrGetOriginal(d)); - } - - private static DocumentReference createReferenceOrGetOriginal(Document d) { - Document original = UndoManagerImpl.getOriginal(d); - return DocumentReferenceManager.getInstance().create(original); - } - - public LinkedList getStack(@NotNull DocumentReference r) { + private LinkedList getStack(@NotNull DocumentReference r) { return r.getFile() != null ? doGetStackForFile(r) : doGetStackForDocument(r); } @@ -161,15 +152,15 @@ class UndoRedoStacksHolder { public void clearStacks(boolean clearGlobal, Set affectedDocuments) { if (clearGlobal) myGlobalStack.clear(); - for (DocumentReference each : affectedDocuments) { - List stack = getStack(each); + for (DocumentReference ref : affectedDocuments) { + List stack = getStack(ref); stack.clear(); - if (each.getFile() != null) { - myDocumentStacks.remove(each); + if (ref.getFile() != null) { + myDocumentStacks.remove(ref); } else { - Document d = each.getDocument(); + Document d = ref.getDocument(); d.putUserData(STACK_IN_DOCUMENT_KEY, null); myDocumentsWithStacks.remove(d); } From 26370bdffb31ff41b0e02f7739c94b6a6724563b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 5 Apr 2010 14:56:07 +0400 Subject: [PATCH 010/210] documents leak fixed --- .../vfs/encoding/EncodingManagerImpl.java | 41 +++++++++++++++---- .../testFramework/LightPlatformTestCase.java | 6 +++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java index 16ec5be2d307..e58ed35a9032 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java @@ -23,6 +23,7 @@ package com.intellij.openapi.vfs.encoding; import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; @@ -71,23 +72,47 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt private final Queue myChangedDocuments = new ConcurrentLinkedQueue(); private final Runnable myEncodingUpdateRunnable = new Runnable() { public void run() { - Document document = myChangedDocuments.poll(); - if (document == null) return; - VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); - if (virtualFile == null) return; - Project project = guessProject(virtualFile); - if (project != null && project.isDisposed()) return; - Charset charset = LoadTextUtil.charsetFromContentOrNull(project, virtualFile, document.getText()); - document.putUserData(CACHED_CHARSET_FROM_CONTENT, charset); + for (int i=0; i<50;i++) { + if (!pollAndHandleDocument()) return; + } + // requeue myself to handle the tail of the queue in next request + addCacheEncodingAlarm(); } }; + private boolean pollAndHandleDocument() { + final Document document = myChangedDocuments.poll(); + if (document == null) return false; + ApplicationManager.getApplication().runReadAction(new Runnable(){ + public void run() { + VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); + if (virtualFile == null) return; + Project project = guessProject(virtualFile); + if (project != null && project.isDisposed()) return; + Charset charset = LoadTextUtil.charsetFromContentOrNull(project, virtualFile, document.getText()); + document.putUserData(CACHED_CHARSET_FROM_CONTENT, charset); + } + }); + return true; + } + public void dispose() { updateEncodingFromContent.cancelAllRequests(); + drainDocumentQueue(); + } + + public void drainDocumentQueue() { + while (pollAndHandleDocument()) { + // loop until empty + } } public void updateEncodingFromContent(Document document) { myChangedDocuments.offer(document); + addCacheEncodingAlarm(); + } + + private void addCacheEncodingAlarm() { updateEncodingFromContent.cancelAllRequests(); updateEncodingFromContent.addRequest(myEncodingUpdateRunnable, 400); } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index bb51060993f7..0e1863ddff05 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -61,6 +61,8 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.encoding.EncodingManager; +import com.intellij.openapi.vfs.encoding.EncodingManagerImpl; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS; import com.intellij.profile.codeInspection.InspectionProfileManager; @@ -411,10 +413,14 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da e.printStackTrace(); } } + EncodingManager encodingManager = EncodingManager.getInstance(); + if (encodingManager instanceof EncodingManagerImpl) ((EncodingManagerImpl)encodingManager).drainDocumentQueue(); + FileDocumentManager manager = FileDocumentManager.getInstance(); if (manager instanceof FileDocumentManagerImpl) { ((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments(); } + ApplicationManager.getApplication().runWriteAction(EmptyRunnable.getInstance()); // Flash posponed formatting if any. manager.saveAllDocuments(); } From cc28af14aea709fe6ba6c89d0f9afc657f7d6f96 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 1 Apr 2010 15:59:23 +0400 Subject: [PATCH 011/210] IDEA-47033: Support updating a deployed WebSphere application --- .../impl/compiler/IncrementalArtifactsCompiler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java index bed30dbcba13..9a322302d56c 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java @@ -70,6 +70,7 @@ import java.util.*; */ public class IncrementalArtifactsCompiler implements PackagingCompiler { private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.compiler.IncrementalArtifactsCompiler"); + private static final Key> WRITTEN_PATHS_KEY = Key.create("artifacts_written_paths"); private static final Key> FILES_TO_DELETE_KEY = Key.create("artifacts_files_to_delete"); private static final Key> AFFECTED_ARTIFACTS = Key.create("affected_artifacts"); private static final Key BUILDER_CONTEXT_KEY = Key.create("artifacts_builder_context"); @@ -212,6 +213,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { }.execute(); removeInvalidItems(processedItems); updateOutputCache(context.getProject(), processedItems); + context.putUserData(WRITTEN_PATHS_KEY, writtenPaths); return processedItems.toArray(new ProcessingItem[processedItems.size()]); } @@ -325,6 +327,11 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { return compileContext.getUserData(AFFECTED_ARTIFACTS); } + @Nullable + public static Set getWrittenPaths(@NotNull CompileContext context) { + return context.getUserData(WRITTEN_PATHS_KEY); + } + @NotNull public String getDescription() { return "Artifacts Packaging Compiler"; From 6b86f5c132b965b0f0828c65ee1160b1079ae123 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 2 Apr 2010 09:27:46 +0400 Subject: [PATCH 012/210] IDEA-53280: Could not remove modules from project --- .../projectRoot/daemon/ModuleProjectStructureElement.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java index 7bf2e1e263dd..e2b35d0477be 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java @@ -8,6 +8,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.ui.configuration.ModuleEditor; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -32,6 +33,10 @@ public class ModuleProjectStructureElement extends ProjectStructureElement { public void check(ProjectStructureProblemsHolder problemsHolder) { final ModifiableModuleModel moduleModel = myContext.getModulesConfigurator().getModuleModel(); final Module[] all = moduleModel.getModules(); + if (!ArrayUtil.contains(myModule, all)) { + return;//module has been deleted + } + for (Module each : all) { if (each != myModule && myContext.getRealName(each).equals(myContext.getRealName(myModule))) { problemsHolder.registerError(ProjectBundle.message("project.roots.module.duplicate.name.message")); From 90936ed38f868a8006894dbf7d79ce27c15b1b8a Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 5 Apr 2010 16:23:28 +0400 Subject: [PATCH 013/210] an intention to download @Grab-defined Groovy dependencies, as a separate plugin --- plugins/groovy/grape/grape-rt.iml | 13 ++ plugins/groovy/grape/grape.iml | 18 ++ .../GrabDependencies/description.html | 1 + .../plugins/groovy/grape/GrapeRunner.java | 40 ++++ plugins/groovy/grape/src/META-INF/plugin.xml | 18 ++ .../groovy/grape/GrabDependencies.java | 218 ++++++++++++++++++ .../runner/DefaultGroovyScriptRunner.java | 31 +-- .../runner/GroovyScriptRunConfiguration.java | 30 +-- 8 files changed, 343 insertions(+), 26 deletions(-) create mode 100644 plugins/groovy/grape/grape-rt.iml create mode 100644 plugins/groovy/grape/grape.iml create mode 100644 plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html create mode 100644 plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java create mode 100644 plugins/groovy/grape/src/META-INF/plugin.xml create mode 100644 plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java diff --git a/plugins/groovy/grape/grape-rt.iml b/plugins/groovy/grape/grape-rt.iml new file mode 100644 index 000000000000..a24fe4731851 --- /dev/null +++ b/plugins/groovy/grape/grape-rt.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/plugins/groovy/grape/grape.iml b/plugins/groovy/grape/grape.iml new file mode 100644 index 000000000000..73ea14e036bf --- /dev/null +++ b/plugins/groovy/grape/grape.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html b/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html new file mode 100644 index 000000000000..b7b71fca3d68 --- /dev/null +++ b/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html @@ -0,0 +1 @@ +Add the dependency defined by @Grab annotation to the project \ No newline at end of file diff --git a/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java b/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java new file mode 100644 index 000000000000..39cc770d181e --- /dev/null +++ b/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java @@ -0,0 +1,40 @@ +package org.jetbrains.plugins.groovy.grape; + +import groovy.lang.GroovyShell; +import org.codehaus.groovy.control.CompilationFailedException; + +import java.io.File; +import java.net.URL; + +/** + * @author peter + */ +public class GrapeRunner { + public static final String URL_PREFIX = "URL:"; + + private GrapeRunner() { + } + + public static void main(String[] args) { + final File file = new File(args[0]); + if (!file.exists()) { + return; + } + + final GroovyShell shell = new GroovyShell(); + try { + shell.parse(file); + } + catch (CompilationFailedException ignored) { + //should fail, we're not compiling, we're just resolving Grab dependencies + } + catch (Throwable e) { + e.printStackTrace(); + } + + for (URL url : shell.getClassLoader().getURLs()) { + System.out.println(URL_PREFIX + url); + } + } + +} diff --git a/plugins/groovy/grape/src/META-INF/plugin.xml b/plugins/groovy/grape/src/META-INF/plugin.xml new file mode 100644 index 000000000000..b8fa5622ebc4 --- /dev/null +++ b/plugins/groovy/grape/src/META-INF/plugin.xml @@ -0,0 +1,18 @@ + + org.intellij.groovy.grape + Groovy Grape support + Managing Grape-defined dependencies + 0.1 + + JetBrains Inc. + org.intellij.groovy + + + + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle + intention.category.groovy + org.jetbrains.plugins.groovy.grape.GrabDependencies + + + + diff --git a/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java b/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java new file mode 100644 index 000000000000..c41775277184 --- /dev/null +++ b/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java @@ -0,0 +1,218 @@ +package org.jetbrains.plugins.groovy.grape; + +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.execution.CantRunException; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.GeneralCommandLine; +import com.intellij.execution.configurations.JavaParameters; +import com.intellij.execution.process.DefaultJavaProcessHandler; +import com.intellij.execution.process.ProcessOutputTypes; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationDisplayType; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.JavaSdkType; +import com.intellij.openapi.projectRoots.JdkUtil; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkType; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.IncorrectOperationException; +import com.intellij.util.PathUtil; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation; +import org.jetbrains.plugins.groovy.runner.DefaultGroovyScriptRunner; +import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * @author peter + */ +public class GrabDependencies implements IntentionAction { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.grape.GrabDependencies"); + + @NotNull + public String getText() { + return "Grab the artifacts"; + } + + @NotNull + public String getFamilyName() { + return "Grab"; + } + + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + final GrAnnotation anno = PsiTreeUtil.findElementOfClassAtOffset(file, editor.getCaretModel().getOffset(), GrAnnotation.class, false); + if (anno == null) { + return false; + } + + final String qname = anno.getQualifiedName(); + if (qname == null || !(qname.startsWith("groovy.lang.Grab") || "groovy.lang.Grapes".equals(qname))) { + return false; + } + + final Module module = ModuleUtil.findModuleForPsiElement(file); + if (module == null) { + return false; + } + + return file.getOriginalFile().getVirtualFile() != null; + } + + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final Module module = ModuleUtil.findModuleForPsiElement(file); + assert module != null; + + final VirtualFile vfile = file.getOriginalFile().getVirtualFile(); + assert vfile != null; + + final JavaParameters javaParameters = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module); + try { + //debug + //javaParameters.getVMParametersList().add("-Xdebug"); javaParameters.getVMParametersList().add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239"); + + final boolean tests = ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(vfile); + DefaultGroovyScriptRunner.configureGenericGroovyRunner(javaParameters, module, tests, "org.jetbrains.plugins.groovy.grape.GrapeRunner"); + + javaParameters.getProgramParametersList().add("--classpath"); + javaParameters.getProgramParametersList().add(PathUtil.getJarPathForClass(GrapeRunner.class)); + + javaParameters.getProgramParametersList().add(FileUtil.toSystemDependentName(vfile.getPath())); + + } + catch (CantRunException e) { + Messages.showErrorDialog(e.getMessage(), "Can't run Groovyc"); + return; + } + + final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); + assert sdk != null; + SdkType sdkType = sdk.getSdkType(); + assert sdkType instanceof JavaSdkType; + final String exePath = ((JavaSdkType)sdkType).getVMExecutablePath(sdk); + + try { + final GrapeProcessHandler handler = new GrapeProcessHandler(JdkUtil.setupJVMCommandLine(exePath, javaParameters, true), module); + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing @Grab annotations") { + @Override + public void run(@NotNull ProgressIndicator indicator) { + handler.startNotify(); + handler.waitFor(); + } + }); + + } + catch (ExecutionException e) { + LOG.error(e); + } + + } + + public boolean startInWriteAction() { + return false; + } + + private static class GrapeProcessHandler extends DefaultJavaProcessHandler { + private final StringBuilder myStdOut = new StringBuilder(); + private final StringBuilder myStdErr = new StringBuilder(); + private final Module myModule; + + public GrapeProcessHandler(GeneralCommandLine commandLine, Module module) throws ExecutionException { + super(commandLine); + myModule = module; + } + + @Override + public void notifyTextAvailable(String text, Key outputType) { + text = StringUtil.convertLineSeparators(text); + if (LOG.isDebugEnabled()) { + LOG.debug(outputType + text); + } + if (outputType == ProcessOutputTypes.STDOUT) { + myStdOut.append(text); + } + else if (outputType == ProcessOutputTypes.STDERR) { + myStdErr.append(text); + } + } + + private void addGrapeDependencies(List jars) { + final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel(); + final LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel(); + for (VirtualFile jar : jars) { + final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(jar); + if (jarRoot != null) { + final Library.ModifiableModel libModel = tableModel.createLibrary("Grab:" + jar.getName()).getModifiableModel(); + libModel.addRoot(jarRoot, OrderRootType.CLASSES); + libModel.commit(); + } + } + tableModel.commit(); + model.commit(); + } + + @Override + protected void notifyProcessTerminated(int exitCode) { + super.notifyProcessTerminated(exitCode); + final List jars = new ArrayList(); + for (String line : myStdOut.toString().split("\n")) { + if (line.startsWith(GrapeRunner.URL_PREFIX)) { + try { + final URL url = new URL(line.substring(GrapeRunner.URL_PREFIX.length())); + final File libFile = new File(url.toURI()); + if (libFile.exists() && libFile.getName().endsWith(".jar")) { + final VirtualFile vfile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libFile); + ContainerUtil.addIfNotNull(vfile, jars); + } + } + catch (MalformedURLException e) { + LOG.error(e); + } + catch (URISyntaxException e) { + LOG.error(e); + } + } + } + new WriteAction() { + protected void run(Result result) throws Throwable { + final String title = jars.size() + " dependencies added"; + final String descr = myStdOut.toString().replaceAll("\n", "
") + "

" + myStdErr.toString().replaceAll("\n", "
"); + Notifications.Bus.notify(new Notification("Grape", title, descr, NotificationType.INFORMATION), NotificationDisplayType.BALLOON, myModule.getProject()); + if (!jars.isEmpty()) { + addGrapeDependencies(jars); + } + } + }.execute(); + } + } +} \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java index 94232dd3a7ee..774cd6f1c03c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java @@ -66,6 +66,23 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { @Override public void configureCommandLine(JavaParameters params, @Nullable Module module, boolean tests, VirtualFile script, GroovyScriptRunConfiguration configuration) throws CantRunException { + configureGenericGroovyRunner(params, module, tests, "groovy.ui.GroovyMain"); + + addClasspathFromRootModel(module, tests, params); + + params.getVMParametersList().addParametersString(configuration.vmParams); + + params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.scriptPath)); + params.getProgramParametersList().addParametersString(configuration.scriptParams); + + addScriptEncodingSettings(params, script, module); + + if (configuration.isDebugEnabled) { + params.getProgramParametersList().add("--debug"); + } + } + + public static void configureGenericGroovyRunner(JavaParameters params, Module module, boolean tests, String mainClass) throws CantRunException { assert module != null; final VirtualFile groovyJar = findGroovyJar(module); if (groovyJar != null) { @@ -80,25 +97,13 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { final String confPath = getConfPath(groovyHome); params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); - params.getVMParametersList().addParametersString(configuration.vmParams); params.setMainClass("org.codehaus.groovy.tools.GroovyStarter"); params.getProgramParametersList().add("--conf"); params.getProgramParametersList().add(confPath); - addClasspathFromRootModel(module, tests, params); - params.getProgramParametersList().add("--main"); - params.getProgramParametersList().add("groovy.ui.GroovyMain"); - - params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.scriptPath)); - params.getProgramParametersList().addParametersString(configuration.scriptParams); - - addScriptEncodingSettings(params, script, module); - - if (configuration.isDebugEnabled) { - params.getProgramParametersList().add("--debug"); - } + params.getProgramParametersList().add(mainClass); } private static void addScriptEncodingSettings(final JavaParameters params, final VirtualFile scriptFile, Module module) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java index 5034cb7eefe0..ad0b1e7df128 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java @@ -172,20 +172,8 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration Date: Mon, 5 Apr 2010 16:37:04 +0400 Subject: [PATCH 014/210] since the next maia eap --- plugins/groovy/grape/src/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/groovy/grape/src/META-INF/plugin.xml b/plugins/groovy/grape/src/META-INF/plugin.xml index b8fa5622ebc4..8b9df9c1612a 100644 --- a/plugins/groovy/grape/src/META-INF/plugin.xml +++ b/plugins/groovy/grape/src/META-INF/plugin.xml @@ -3,7 +3,7 @@ Groovy Grape support Managing Grape-defined dependencies 0.1 - + JetBrains Inc. org.intellij.groovy From 4b1849ba213852cd6e83ebefb25f48f1c84d3d5a Mon Sep 17 00:00:00 2001 From: Constantine Plotnikov Date: Mon, 5 Apr 2010 17:05:38 +0400 Subject: [PATCH 015/210] git4idea: Changed text for merge and rebase strategies in update option panel --- .../git4idea/src/git4idea/i18n/GitBundle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index e6dcbda90f8b..e5b1c6cd35ca 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -437,11 +437,11 @@ update.options.save.shelve.tooltip=Use IDEA Shelve (the files will be restored w update.options.save.stash=Using S&tash update.options.save.stash.tooltip=Use 'git stash' to save changes (the files will be restored when update finishes) update.options.type.default=Branch &Default -update.options.type.default.tooltip=Use branch default update type for all updated vcs roots -update.options.type.merge=Force &Merge -update.options.type.merge.tooltip=Force merge update strategy -update.options.type.rebase=Force &Rebase -update.options.type.rebase.tooltip=Force rebase update strategy +update.options.type.default.tooltip=Use branch default update strategy for all updated git vcs roots +update.options.type.merge=&Merge +update.options.type.merge.tooltip=Use merge update strategy for all git vcs roots +update.options.type.rebase=&Rebase +update.options.type.rebase.tooltip=Use rebase update strategy for all git vcs roots update.options.type=Update Type update.rebase.no.change.cancel=Cancel Update update.rebase.no.change.retry=Retry Continue From 75dcad0b68de2b8c79318569853973bd534e5ebf Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 15:17:06 +0200 Subject: [PATCH 016/210] rename static import properties --- .../src/com/siyeh/InspectionGadgetsBundle.properties | 4 ++-- .../src/com/siyeh/ig/imports/StaticImportInspection.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index df1b738df96e..defcc79c8a61 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1761,5 +1761,5 @@ 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 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; } From 440183c8e4a75beafdab1a7ec75563cf82c47ec2 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Mon, 5 Apr 2010 17:25:45 +0400 Subject: [PATCH 017/210] Generalizing --- .../codeInsight/dataflow/DFAEngine.java | 20 +++++++-------- .../codeInsight/dataflow/DfaInstance.java | 4 +-- .../codeInsight/dataflow/Semilattice.java | 6 ++--- .../dataflow/{ => map}/DFAMap.java | 3 ++- .../dataflow/map/DFAMapEngine.java | 25 +++++++++++++++++++ .../dataflow/map/DfaMapInstance.java | 21 ++++++++++++++++ .../dataflow/map/MapSemilattice.java | 22 ++++++++++++++++ 7 files changed, 84 insertions(+), 17 deletions(-) rename platform/lang-impl/src/com/intellij/codeInsight/dataflow/{ => map}/DFAMap.java (97%) create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java index 65908b8d7466..6967dbfefaca 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java @@ -39,18 +39,18 @@ public class DFAEngine { } - public List> performDFA() { - final ArrayList> info = new ArrayList>(myFlow.length); + public List performDFA() { + final ArrayList info = new ArrayList(myFlow.length); return performDFA(info); } - public List> performDFA(final List> info) { + public List performDFA(final List info) { if (LOG.isDebugEnabled()){ LOG.debug("Perfoming DFA\n" + "Instance: " + myDfa + " Semilattice: " + mySemilattice); } // initializing dfa - final DFAMap initial = myDfa.initial(); + final E initial = myDfa.initial(); for (int i = 0; i < myFlow.length; i++) { info.add(i, initial); } @@ -104,12 +104,12 @@ public class DFAEngine { } final int currentNumber = currentInstruction.num(); - final DFAMap oldE = info.get(currentNumber); - final DFAMap joinedE = join(currentInstruction, info); - final DFAMap newE = myDfa.fun(joinedE, currentInstruction); + final E oldE = info.get(currentNumber); + final E joinedE = join(currentInstruction, info); + final E newE = myDfa.fun(joinedE, currentInstruction); if (!mySemilattice.eq(newE, oldE)) { if (LOG.isDebugEnabled()){ - LOG.debug("Number: " + currentNumber + " old: " + oldE.keySet() + " new: " + newE.keySet()); + LOG.debug("Number: " + currentNumber + " old: " + oldE.toString() + " new: " + newE.toString()); } info.set(currentNumber, newE); for (Instruction next : getNext(currentInstruction)) { @@ -148,9 +148,9 @@ public class DFAEngine { return allPred * 2; } - private DFAMap join(final Instruction instruction, final List> info) { + private E join(final Instruction instruction, final List info) { final Iterable prev = myDfa.isForward() ? instruction.allPred() : instruction.allSucc(); - final ArrayList> prevInfos = new ArrayList>(); + final ArrayList prevInfos = new ArrayList(); for (Instruction i : prev) { prevInfos.add(info.get(i.num())); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java index ce618834fe4b..894e54d0af5b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java @@ -21,10 +21,10 @@ public interface DfaInstance { // Please ensure that E has correctly implemented equals method // Invariant: fun must create new instance of DFAMap if modifies it - DFAMap fun(DFAMap e, Instruction instruction); + E fun(E e, Instruction instruction); @NotNull - DFAMap initial(); + E initial(); boolean isForward(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java index 199ea50bd62d..0b1e89a7eaeb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java @@ -17,9 +17,7 @@ package com.intellij.codeInsight.dataflow; import java.util.ArrayList; public interface Semilattice { - // Invariant: join can return unmodified ins(0) or empty DFAMap - // DfaInstance must create new one before modifying - DFAMap join(ArrayList> ins); + E join(ArrayList ins); - boolean eq(DFAMap e1, DFAMap e2); + boolean eq(E e1, E e2); } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java rename to platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java index 148a5942c3ec..9f7e1078ded4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java @@ -1,5 +1,6 @@ -package com.intellij.codeInsight.dataflow; +package com.intellij.codeInsight.dataflow.map; +import com.intellij.codeInsight.dataflow.SetUtil; import org.jetbrains.annotations.Nullable; import java.util.*; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java new file mode 100644 index 000000000000..d10c588a9bf2 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java @@ -0,0 +1,25 @@ +/* + * 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.codeInsight.dataflow.map; + +import com.intellij.codeInsight.controlflow.Instruction; +import com.intellij.codeInsight.dataflow.DFAEngine; + +public class DFAMapEngine extends DFAEngine>{ + public DFAMapEngine(final Instruction[] flow, final DfaMapInstance dfa, final MapSemilattice dfaMapSemilattice) { + super(flow, dfa, dfaMapSemilattice); + } +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java new file mode 100644 index 000000000000..e6bc73381c10 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java @@ -0,0 +1,21 @@ +/* + * 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.codeInsight.dataflow.map; + +import com.intellij.codeInsight.dataflow.DfaInstance; + +public interface DfaMapInstance extends DfaInstance> { +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java new file mode 100644 index 000000000000..fb3547b7d698 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2007 JetBrains s.r.o. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.dataflow.map; + +import com.intellij.codeInsight.dataflow.Semilattice; + +public interface MapSemilattice extends Semilattice>{ + // Invariant: join can return unmodified ins(0) or empty DFAMap + // DfaInstance must create new one before modifying +} \ No newline at end of file From 992ef7c2165cf2743e08d0c5a728beebd89b97ce Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 15:26:53 +0200 Subject: [PATCH 018/210] IDEA-53385 ("Non-boolean method name must not start with question" doesn't know Boolean) and added option to ignore Boolean methods again --- .../siyeh/InspectionGadgetsBundle.properties | 1 + ...NameMayNotStartWithQuestionInspection.java | 98 +++++++++++++------ ...onBooleanNameMustNotStartWithQuestion.form | 48 --------- 3 files changed, 67 insertions(+), 80 deletions(-) delete mode 100644 plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index defcc79c8a61..0a2176e0369c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1763,3 +1763,4 @@ 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.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 diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java index bba21404f217..042aaa2a5894 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 = true; + 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 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From c86899e9da2d16bd1061980cd1a1425f4ca14898 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 5 Apr 2010 17:50:53 +0400 Subject: [PATCH 019/210] IDEA-53369 Groovy Editor -> Map Keys In Parenthetical Expressions All Considered Identical --- .../groovy/annotator/GroovyAnnotator.java | 49 +++++++------------ .../groovy/lang/GroovyHighlightingTest.java | 2 + .../highlighting/DuplicateMapKeys.groovy | 2 + 3 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy 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/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 From 09eeb6ca0b0ff9de545587e60824c2829acbe64a Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 14:49:38 +0400 Subject: [PATCH 020/210] Maven: more assertions in test --- .../idea/maven/compiler/ResourceFilteringTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java index b74f4ad4e4ca..1ee0218e2355 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java @@ -15,11 +15,14 @@ */ package org.jetbrains.idea.maven.compiler; +import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerManagerImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; import com.intellij.compiler.impl.ModuleCompileScope; import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor; import com.intellij.openapi.compiler.*; +import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.io.FileUtil; @@ -824,6 +827,9 @@ public class ResourceFilteringTest extends MavenImportingTestCase { } public void testDoNotFilterButCopyBigFiles() throws Exception { + assertFalse(CompilerConfiguration.getInstance(myProject).isResourceFile("file.xyz")); + assertEquals(FileTypeManager.getInstance().getFileTypeByFileName("file.xyz"), StdFileTypes.UNKNOWN); + createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]); importProject("test" + From 26b1ba726f7abdf3414a9c3e143423fd4d2d9792 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 17:11:34 +0400 Subject: [PATCH 021/210] Maven: disabling some buttons for non-maven projects (IDEA-46413) --- .../project/actions/DownloadActionGroup.java | 30 +++++++++++++++++++ .../actions/MavenProjectsManagerAction.java | 5 ++++ .../maven/project/actions/ReimportAction.java | 6 ++++ .../src/main/resources/META-INF/plugin.xml | 3 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java 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..f4f43364f1ad --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java @@ -0,0 +1,30 @@ +/* + * 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); + if (MavenActionUtil.getProject(e.getDataContext()) == null) return; + 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/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 @@ - + From a349dc35cdc196b8215ccd3a098643fb171051f2 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 17:20:47 +0400 Subject: [PATCH 022/210] Maven: do not set 'exported' flag on Maven deps (IDEA-53170) --- .../maven/importing/MavenModuleImporter.java | 5 +- .../importing/MavenRootModelAdapter.java | 5 +- .../project/actions/DownloadActionGroup.java | 2 +- .../idea/maven/MavenImportingTestCase.java | 2 +- .../importing/DependenciesImportingTest.java | 80 +------------------ 5 files changed, 9 insertions(+), 85 deletions(-) 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 index f4f43364f1ad..22080c8fe162 100644 --- 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 @@ -24,7 +24,7 @@ public class DownloadActionGroup extends DefaultActionGroup { @Override public void update(AnActionEvent e) { super.update(e); - if (MavenActionUtil.getProject(e.getDataContext()) == null) return; + if (MavenActionUtil.getProject(e.getDataContext()) == null) return; // todo: remove this when kirill fixes the problem e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject()); } } 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() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java index b4c00b7f36ed..0fa9553d59e7 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java @@ -21,7 +21,6 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.maven.MavenImportingTestCase; @@ -527,30 +526,7 @@ public class DependenciesImportingTest extends MavenImportingTestCase { assertModuleModuleDepScope("m1", "m4", DependencyScope.TEST); } - public void testOptionalLibraryDependencyIsNotExportable() throws Exception { - importProject("test" + - "project" + - "1" + - - "" + - " " + - " group" + - " lib1" + - " 1" + - " " + - " " + - " group" + - " lib2" + - " 1" + - " true" + - " " + - ""); - - assertModules("project"); - assertExportedModuleDeps("project", "Maven: group:lib1:1"); - } - - public void testOptionalModuleDependencyIsNotExportable() throws Exception { + public void testDependenciesAreNotExported() throws Exception { createProjectPom("test" + "project" + "pom" + @@ -572,10 +548,9 @@ public class DependenciesImportingTest extends MavenImportingTestCase { " 1" + " " + " " + - " test" + - " m3" + + " lib" + + " lib" + " 1" + - " true" + " " + ""); @@ -583,55 +558,8 @@ public class DependenciesImportingTest extends MavenImportingTestCase { "m2" + "1"); - createModulePom("m3", "test" + - "m3" + - "1"); - importProject(); - - assertExportedModuleDeps("m1", "m2"); - } - - public void testOnlyCompileAndRuntimeDependenciesAreExported() throws Exception { - importProject("test" + - "project" + - "1" + - - "" + - " " + - " test" + - " compile" + - " compile" + - " 1" + - " " + - " " + - " test" + - " runtime" + - " runtime" + - " 1" + - " " + - " " + - " test" + - " test" + - " test" + - " 1" + - " " + - " " + - " test" + - " provided" + - " provided" + - " 1" + - " " + - " " + - " test" + - " system" + - " system" + - " ${java.home}/lib/tools.jar" + - " 1" + - " " + - ""); - - assertExportedModuleDeps("project", "Maven: test:compile:1", "Maven: test:runtime:1"); + assertExportedDeps("m1"); } public void testTransitiveDependencies() throws Exception { From bdf09134485818ea9a26eaa810844262505f126a Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 18:18:59 +0400 Subject: [PATCH 023/210] Actions: null project in DataContext when creating toolbars (on behalf of Kirillka) --- .../actionSystem/impl/ActionToolbarImpl.java | 51 ++++++++++--------- .../project/actions/DownloadActionGroup.java | 1 - .../maven/utils/actions/MavenActionGroup.java | 4 +- .../maven/utils/actions/MavenActionUtil.java | 3 +- .../utils/actions/MavenToggleAction.java | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) 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/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 index 22080c8fe162..d23364e0df28 100644 --- 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 @@ -24,7 +24,6 @@ public class DownloadActionGroup extends DefaultActionGroup { @Override public void update(AnActionEvent e) { super.update(e); - if (MavenActionUtil.getProject(e.getDataContext()) == null) return; // todo: remove this when kirill fixes the problem e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject()); } } 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) { From b14939b868fca335ac33b9443272b832d08cc8c9 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 17:05:28 +0200 Subject: [PATCH 024/210] IDEA-20936 (BooleanMethodDoesNotStartWithQuestionWord: add option for suppressing in @Interface) --- .../siyeh/InspectionGadgetsBundle.properties | 3 +- ...ooleanMethodNameMustStartWithQuestion.form | 49 -------- ...odNameMustStartWithQuestionInspection.java | 119 +++++++++++++----- ...NameMayNotStartWithQuestionInspection.java | 2 +- 4 files changed, 89 insertions(+), 84 deletions(-) delete mode 100644 plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 0a2176e0369c..75ac24687559 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1763,4 +1763,5 @@ 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.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.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/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 042aaa2a5894..99f368ab9a90 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java @@ -48,7 +48,7 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection "startsWith,endsWith"; @SuppressWarnings({"PublicField"}) - public boolean ignoreBooleanMethods = true; + public boolean ignoreBooleanMethods = false; List questionList = new ArrayList(32); From f2a87f17bd706c1b814e6a8c830eeee1b32fab45 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 17:40:07 +0200 Subject: [PATCH 025/210] cleanup --- .../FieldRepeatedlyAccessedInspection.java | 21 ++++++++++++------- .../VariableAccessVisitor.java | 12 +++++------ 2 files changed, 20 insertions(+), 13 deletions(-) rename plugins/InspectionGadgets/src/com/siyeh/ig/{performance => j2me}/VariableAccessVisitor.java (87%) 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); From f3d953abbbad1df97bea2c23c641fc32fee08dad Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 5 Apr 2010 19:39:57 +0400 Subject: [PATCH 026/210] do not attempt to calculate icon for uninitialized projects --- .../com/intellij/execution/actions/RunConfigurationAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From b33a336ce68a55d8d71c000663c0d8ab58c454d2 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 17:55:47 +0200 Subject: [PATCH 027/210] restrict access and some cleanup --- .../ArrayContentsAccessedVisitor.java | 36 ++++++++++++------- .../ArrayContentsAssignedVisitor.java | 16 ++++++--- .../psiutils/VariableAssignedFromVisitor.java | 4 +-- .../ig/psiutils/VariableAssignedVisitor.java | 4 +-- ...riablePassedAsArgumentExcludedVisitor.java | 4 +-- .../VariablePassedAsArgumentVisitor.java | 5 ++- .../ig/psiutils/VariableReturnedVisitor.java | 4 +-- ...VariableUsedInArrayInitializerVisitor.java | 13 +++---- .../VariableUsedInInnerClassVisitor.java | 14 ++++---- .../ig/psiutils/VariableUsedVisitor.java | 4 +-- .../ig/psiutils/VariableValueUsedVisitor.java | 4 +-- 11 files changed, 61 insertions(+), 47 deletions(-) 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; From 69596fe84222fd2bf725e0f41f76b8a0d9dc5400 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 5 Apr 2010 20:05:51 +0400 Subject: [PATCH 028/210] read-action --- .../junit/src/com/intellij/execution/ConfigurationUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; From a6c33dd0f65cf4b50eb66eb15ab50f4f02fe8760 Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Mon, 5 Apr 2010 20:36:19 +0400 Subject: [PATCH 029/210] intelliLang dependency optimization --- .idea/inspectionProfiles/idea_default.xml | 19 +-- .../idea_default_no_spellchecker.xml | 19 +-- .idea/modules.xml | 7 +- build/scripts/layouts.gant | 12 +- .../lang/java/JavaLiteralEscaper.java | 8 ++ .../lang/LanguageLiteralEscapers.java | 8 ++ .../src/com/intellij/lang/LiteralEscaper.java | 2 + .../src/META-INF/XmlPlugin.xml | 1 + plugins/IntelliLang/IntelliLang-java.iml | 26 ++++ plugins/IntelliLang/IntelliLang-javaee.iml | 20 +++ plugins/IntelliLang/IntelliLang-xml.iml | 27 ++++ plugins/IntelliLang/IntelliLangJava.iml | 8 -- .../InjectionNotApplicable.html | 0 .../LanguageMismatch.html | 0 .../PatternNotApplicable.html | 0 ...PatternOverriddenByNonAnnotatedMethod.html | 0 .../PatternValidation.html | 0 .../UnknownLanguage.html | 0 .../intelliLang/AdvancedSettingsUI.form | 0 .../intelliLang/AdvancedSettingsUI.java | 0 .../config/MethodParameterInjection.java | 60 +++++++- .../config/ui/MethodParameterPanel.form | 0 .../config/ui/MethodParameterPanel.java | 0 .../MethodParameterInjectionConfigurable.java | 2 +- .../inject/java/ConcatenationInjector.java | 0 .../java/JavaLanguageInjectionSupport.java | 17 +-- .../inject/java/LanguageReference.java | 0 .../java/LanguageReferenceProvider.java | 0 .../inject/java/RegExpEnumReference.java | 0 .../validation/InjectionNotApplicable.java | 2 +- .../java/validation/InspectionProvider.java | 0 .../java/validation/LanguageMismatch.java | 0 .../java/validation/UnknownLanguageID.java | 0 .../pattern/InspectionProvider.java | 0 .../PatternAnnotationNotApplicable.java | 0 ...PatternOverriddenByNonAnnotatedMethod.java | 0 .../intelliLang/pattern/PatternValidator.java | 0 .../AnnotationBasedInstrumentingCompiler.java | 0 .../compiler/InstrumentationException.java | 0 .../pattern/compiler/InstrumentationItem.java | 0 .../pattern/compiler/Instrumenter.java | 0 .../compiler/impl/InstrumentationAdapter.java | 0 .../impl/PatternValidationCompiler.java | 0 .../impl/PatternValidationInstrumenter.java | 0 .../plugins/intelliLang/util/AnnotateFix.java | 0 .../intelliLang/util/AnnotationUtilEx.java | 0 .../util/ContextComputationProcessor.java | 0 .../util/InitializerRequirement.java | 0 .../plugins/intelliLang/util/PsiUtilEx.java | 0 .../intelliLang/util/RemoveAnnotationFix.java | 0 .../util/StringLiteralReference.java | 2 +- ...SubstitutedExpressionEvaluationHelper.java | 0 .../resources/javaInjections.xml | 0 .../inject/config/JspSupportProxyImpl.java | 31 +++++ .../META-INF/intellilang-javaee-support.xml | 2 +- .../META-INF/intellilang-xpath-support.xml | 2 +- plugins/IntelliLang/src/META-INF/plugin.xml | 3 +- .../plugins/intelliLang/Configuration.java | 41 ++++-- .../PatternBasedInjectionHelper.java | 84 ------------ .../intelliLang/inject/InjectorUtils.java | 24 +--- .../inject/config/JspSupportProxy.java | 11 +- .../inject/config/XPathSupportProxy.java | 129 ------------------ .../inject/config/ui/AdvancedPanel.form | 21 +-- .../inject/config/ui/AdvancedPanel.java | 36 +---- .../inject/config/AbstractTagInjection.java | 0 .../inject/config/XPathSupportProxy.java | 59 ++++++++ .../inject/config/XPathSupportProxyImpl.java | 95 +++++++++++++ .../inject/config/XmlAttributeInjection.java | 16 ++- .../inject/config/XmlTagInjection.java | 14 +- .../inject/config/ui/AdvancedXmlPanel.form | 65 +++++++++ .../inject/config/ui/AdvancedXmlPanel.java | 98 +++++++++++++ .../inject/config/ui/TagPanel.form | 0 .../inject/config/ui/TagPanel.java | 0 .../inject/config/ui/XmlAttributePanel.form | 2 +- .../inject/config/ui/XmlAttributePanel.java | 4 +- .../inject/config/ui/XmlTagPanel.form | 2 +- .../inject/config/ui/XmlTagPanel.java | 4 +- .../XmlAttributeInjectionConfigurable.java | 2 +- .../XmlTagInjectionConfigurable.java | 2 +- .../xml/XmlLanguageInjectionSupport.java | 0 .../inject/xml/XmlLanguageInjector.java | 0 .../resources/xmlInjections.xml | 0 plugins/groovy/jetgroovy.iml | 1 + .../META-INF/intellilang-groovy-support.xml | 2 +- plugins/groovy/src/META-INF/plugin.xml | 1 + .../GroovyLanguageInjectionSupport.java | 0 .../src/resources/groovyInjections.xml | 0 .../intellij/lang/xml/XmlLiteralEscaper.java | 37 +++++ 88 files changed, 665 insertions(+), 363 deletions(-) create mode 100644 plugins/IntelliLang/IntelliLang-java.iml create mode 100644 plugins/IntelliLang/IntelliLang-javaee.iml create mode 100644 plugins/IntelliLang/IntelliLang-xml.iml rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/InjectionNotApplicable.html (100%) rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/LanguageMismatch.html (100%) rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/PatternNotApplicable.html (100%) rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/PatternOverriddenByNonAnnotatedMethod.html (100%) rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/PatternValidation.html (100%) rename plugins/IntelliLang/{src => java-support}/inspectionDescriptions/UnknownLanguage.html (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/AdvancedSettingsUI.form (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java (83%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.form (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/config/ui/configurables/MethodParameterInjectionConfigurable.java (99%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java (96%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/LanguageReferenceProvider.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/validation/InjectionNotApplicable.java (99%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/validation/InspectionProvider.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/validation/LanguageMismatch.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/inject/java/validation/UnknownLanguageID.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/InspectionProvider.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/PatternAnnotationNotApplicable.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/PatternOverriddenByNonAnnotatedMethod.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/PatternValidator.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationException.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/InstrumentationItem.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/Instrumenter.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/impl/InstrumentationAdapter.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationCompiler.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/pattern/compiler/impl/PatternValidationInstrumenter.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/AnnotateFix.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/ContextComputationProcessor.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/InitializerRequirement.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/PsiUtilEx.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/RemoveAnnotationFix.java (100%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/StringLiteralReference.java (99%) rename plugins/IntelliLang/{src => java-support}/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java (100%) rename plugins/IntelliLang/{src => java-support}/resources/javaInjections.xml (100%) create mode 100644 plugins/IntelliLang/javaee-support/org/intellij/plugins/intelliLang/inject/config/JspSupportProxyImpl.java delete mode 100644 plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/AbstractTagInjection.java (100%) create mode 100644 plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxy.java create mode 100644 plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/XPathSupportProxyImpl.java rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/XmlAttributeInjection.java (83%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/XmlTagInjection.java (69%) create mode 100644 plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.form create mode 100644 plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.form (100%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java (100%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.form (97%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java (95%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.form (95%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/XmlTagPanel.java (93%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlAttributeInjectionConfigurable.java (99%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/config/ui/configurables/XmlTagInjectionConfigurable.java (99%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/xml/XmlLanguageInjectionSupport.java (100%) rename plugins/IntelliLang/{src => xml-support}/org/intellij/plugins/intelliLang/inject/xml/XmlLanguageInjector.java (100%) rename plugins/IntelliLang/{src => xml-support}/resources/xmlInjections.xml (100%) rename plugins/{IntelliLang => groovy}/src/META-INF/intellilang-groovy-support.xml (95%) rename plugins/{IntelliLang => groovy}/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java (100%) rename plugins/{IntelliLang => groovy}/src/resources/groovyInjections.xml (100%) create mode 100644 xml/impl/src/com/intellij/lang/xml/XmlLiteralEscaper.java 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 @@