diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 071981fb72b5..f524e85552cb 100644 --- a/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -18,10 +18,7 @@ package com.intellij.psi.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.util.Iconable; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.UserDataHolderEx; +import com.intellij.openapi.util.*; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.filters.OrFilter; @@ -972,6 +969,12 @@ public class PsiClassImplUtil { else { PsiClass class1 = ((PsiClassType)type1).resolve(); PsiClass class2 = ((PsiClassType)type2).resolve(); + + if (class1 instanceof PsiTypeParameter && class2 instanceof PsiTypeParameter) { + return Comparing.equal(class1.getName(), class2.getName()) && + ((PsiTypeParameter)class1).getIndex() == ((PsiTypeParameter)class2).getIndex(); + } + if (!manager.areElementsEquivalent(class1, class2)) return false; } } diff --git a/java/openapi/src/com/intellij/codeInsight/TestFramework.java b/java/openapi/src/com/intellij/codeInsight/TestFramework.java index 195e188b64ce..037425648b9e 100644 --- a/java/openapi/src/com/intellij/codeInsight/TestFramework.java +++ b/java/openapi/src/com/intellij/codeInsight/TestFramework.java @@ -27,4 +27,6 @@ import com.intellij.util.IncorrectOperationException; public interface TestFramework { boolean isTestKlass(PsiClass psiClass); PsiMethod findSetUpMethod(PsiClass psiClass) throws IncorrectOperationException; + + boolean isTestMethodOrConfig(PsiMethod psiMethod); } \ No newline at end of file diff --git a/java/openapi/src/com/intellij/codeInsight/TestUtil.java b/java/openapi/src/com/intellij/codeInsight/TestUtil.java index 45e980e1aa32..b22d4f2f211f 100644 --- a/java/openapi/src/com/intellij/codeInsight/TestUtil.java +++ b/java/openapi/src/com/intellij/codeInsight/TestUtil.java @@ -60,4 +60,13 @@ public class TestUtil { } return null; } + + public static boolean isTestMethodOrConfig(PsiMethod psiMethod) { + for (TestFramework framework : Extensions.getExtensions(TEST_FRAMEWORK)) { + if (framework.isTestMethodOrConfig(psiMethod)) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/LineMarkerInfo.java b/platform/lang-api/src/com/intellij/codeInsight/daemon/LineMarkerInfo.java index 3ae3a2e1a867..f86bf6db7855 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/LineMarkerInfo.java +++ b/platform/lang-api/src/com/intellij/codeInsight/daemon/LineMarkerInfo.java @@ -47,7 +47,6 @@ public class LineMarkerInfo { @Nullable private final Function myTooltipProvider; private final GutterIconRenderer.Alignment myIconAlignment; @Nullable private final GutterIconNavigationHandler myNavigationHandler; - public TextAttributesKey textAttributesKey; public LineMarkerInfo(T element, diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java index b70d8223c90d..4b57eeab75a0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java @@ -143,7 +143,6 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl return injectedMarker.getLineMarkerTooltip(); } }, injectedMarker.getNavigationHandler(), GutterIconRenderer.Alignment.RIGHT); - converted.textAttributesKey = injectedMarker.textAttributesKey; result.add(converted); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index 7bd8431b23e6..e86552ba77e6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -399,8 +399,7 @@ public class UpdateHighlightersUtil { } RangeHighlighter marker = toReuse.reuseHighlighterAt(info.startOffset, info.endOffset); if (marker == null) { - TextAttributes attributes = info.textAttributesKey == null ? null : colorsScheme.getAttributes(info.textAttributesKey); - marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attributes, HighlighterTargetArea.EXACT_RANGE); + marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.EXACT_RANGE); } LineMarkerInfo.LineMarkerGutterIconRenderer renderer = (LineMarkerInfo.LineMarkerGutterIconRenderer)info.createGutterRenderer(); LineMarkerInfo.LineMarkerGutterIconRenderer oldRenderer = marker.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer)marker.getGutterIconRenderer() : null; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SimpleTokenSetQuoteHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SimpleTokenSetQuoteHandler.java index 65f46bd4b6f8..bea5c066932d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SimpleTokenSetQuoteHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SimpleTokenSetQuoteHandler.java @@ -65,10 +65,7 @@ public class SimpleTokenSetQuoteHandler implements QuoteHandler { IElementType tokenType = iterator.getTokenType(); if (myLiteralTokenSet.contains(tokenType)) { - if (iterator.getStart() >= iterator.getEnd() - 1 || - chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') { - return true; - } + if (isNonClosedLiteral(iterator, chars)) return true; } iterator.advance(); } @@ -80,6 +77,14 @@ public class SimpleTokenSetQuoteHandler implements QuoteHandler { return false; } + protected boolean isNonClosedLiteral(HighlighterIterator iterator, CharSequence chars) { + if (iterator.getStart() >= iterator.getEnd() - 1 || + chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') { + return true; + } + return false; + } + public boolean isInsideLiteral(HighlighterIterator iterator) { return myLiteralTokenSet.contains(iterator.getTokenType()); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 26296a354797..ee4204cead67 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -850,7 +850,7 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ } private class MyHighlighter extends DocumentAdapter implements EditorHighlighter { - private boolean myHasEditor; + private HighlighterClient myEditor; public HighlighterIterator createIterator(final int startOffset) { final int startIndex = findTokenInfoIndexByOffset(startOffset); @@ -889,6 +889,10 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ return myIndex < 0 || myIndex >= myTokens.size(); } + public Document getDocument() { + return myEditor.getDocument(); + } + private TokenInfo getTokenInfo() { return myTokens.get(myIndex); } @@ -899,8 +903,8 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ } public void setEditor(final HighlighterClient editor) { - LOG.assertTrue(!myHasEditor, "Highlighters cannot be reused with different editors"); - myHasEditor = true; + LOG.assertTrue(myEditor == null, "Highlighters cannot be reused with different editors"); + myEditor = editor; } public void setColorScheme(EditorColorsScheme scheme) { diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java b/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java index 820bffd471f9..f9a333971f38 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java @@ -498,5 +498,9 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter { public boolean atEnd() { return myBaseIterator.atEnd(); } + + public Document getDocument() { + return myBaseIterator.getDocument(); + } } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java index de118d9d2108..7efcab47e49e 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java @@ -22,16 +22,14 @@ import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.*; +import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.Messages; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.refactoring.RefactoringBundle; -import com.intellij.ui.DocumentAdapter; -import com.intellij.ui.EditorComboWithBrowseButton; -import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.RecentsManager; +import com.intellij.ui.*; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; @@ -147,13 +145,12 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ if (myShowDirectoryField) { panel.add(new JLabel(RefactoringBundle.message("copy.files.to.directory.label")), new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0)); - final ComponentWithBrowseButton.BrowseFolderActionListener browseActionListener = - new ComponentWithBrowseButton.BrowseFolderActionListener(RefactoringBundle.message("select.target.directory"), - RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), - null, myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(), - TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT); - myTargetDirectoryField = new EditorComboWithBrowseButton(browseActionListener, "", myProject, + myTargetDirectoryField = new EditorComboWithBrowseButton(null, "", myProject, RECENT_KEYS); + myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), + RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), + myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(), + EditorComboBox.COMPONENT_ACCESSOR); myTargetDirectoryField.setTextFieldPreferredWidth(60); panel.add(myTargetDirectoryField, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,4,8),0,0)); diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java index 3fe59552f956..4906d0a85439 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java @@ -24,9 +24,7 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.TextComponentAccessor; import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; @@ -34,6 +32,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.CommonRefactoringUtil; +import com.intellij.ui.EditorComboBox; import com.intellij.ui.EditorComboWithBrowseButton; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.RecentsManager; @@ -90,12 +89,12 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ panel.add(new JLabel(RefactoringBundle.message("move.files.to.directory.label")), new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0)); - final ComponentWithBrowseButton.BrowseFolderActionListener browseActionListener = - new ComponentWithBrowseButton.BrowseFolderActionListener(RefactoringBundle.message("select.target.directory"), - RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), null, - myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(), - TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT); - myTargetDirectoryField = new EditorComboWithBrowseButton(browseActionListener, "", myProject, RECENT_KEYS); + myTargetDirectoryField = new EditorComboWithBrowseButton(null, "", myProject, RECENT_KEYS); + myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), + RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), + myProject, + FileChooserDescriptorFactory.createSingleFolderDescriptor(), + EditorComboBox.COMPONENT_ACCESSOR); myTargetDirectoryField.setTextFieldPreferredWidth(60); panel.add(myTargetDirectoryField, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,4,8),0,0)); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java index 4fbaeb082d1d..336a86977b4c 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.highlighter; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.tree.IElementType; @@ -28,4 +29,5 @@ public interface HighlighterIterator { void advance(); void retreat(); boolean atEnd(); + Document getDocument(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java index a839190de2b3..51b392145ee6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.ex.util; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.HighlighterColors; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.event.DocumentEvent; @@ -31,7 +32,7 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc private TextAttributes myAttributes; private int myTextLength = 0; - private boolean myHasEditor = false; + private HighlighterClient myEditor; public EmptyEditorHighlighter(TextAttributes attributes) { myAttributes = attributes; @@ -46,8 +47,8 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc } public void setEditor(HighlighterClient editor) { - LOG.assertTrue(!myHasEditor, "Highlighters cannot be reused with different editors"); - myHasEditor = true; + LOG.assertTrue(myEditor == null, "Highlighters cannot be reused with different editors"); + myEditor = editor; } public void setColorScheme(EditorColorsScheme scheme) { @@ -92,6 +93,10 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc return index != 0; } + public Document getDocument() { + return myEditor.getDocument(); + } + public IElementType getTokenType(){ return IElementType.find(IElementType.FIRST_TOKEN_INDEX); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java index 481ea5c6c92c..2efae3125f19 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java @@ -383,5 +383,9 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc public boolean atEnd() { return mySegmentIndex >= mySegments.getSegmentCount() || mySegmentIndex < 0; } + + public Document getDocument() { + return myEditor.getDocument(); + } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LimitedRangeHighlighterIterator.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LimitedRangeHighlighterIterator.java index 0a07d7131605..f46c83597fe7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LimitedRangeHighlighterIterator.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/LimitedRangeHighlighterIterator.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.editor.ex.util; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.tree.IElementType; @@ -61,4 +62,8 @@ public class LimitedRangeHighlighterIterator implements HighlighterIterator { public boolean atEnd() { return myOriginal.atEnd() || myOriginal.getStart() >= myEndOffset || myOriginal.getEnd() <= myStartOffset; } + + public Document getDocument() { + return myOriginal.getDocument(); + } } diff --git a/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java b/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java index 93c933a961d9..1d701013e79c 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java @@ -28,6 +28,7 @@ import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.TextComponentAccessor; import javax.swing.*; import java.awt.*; @@ -38,6 +39,15 @@ import java.util.ArrayList; * @author max */ public class EditorComboBox extends JComboBox implements DocumentListener { + public static TextComponentAccessor COMPONENT_ACCESSOR = new TextComponentAccessor() { + public String getText(EditorComboBox component) { + return component.getText(); + } + + public void setText(EditorComboBox component, String text) { + component.setText(text); + } + }; private static final Logger LOG = Logger.getInstance("#com.intellij.ui.EditorTextField"); private Document myDocument; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java index 36353171f08e..7c815c363b37 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java @@ -64,18 +64,20 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.actions.AnnotateToggleAction"); protected static final Key> KEY_IN_EDITOR = Key.create("Annotations"); private final static Color[] BG_COLORS = { - new Color(255, 238, 187), - new Color(218, 227, 227), - new Color(255, 217, 179), - new Color(230, 255, 222), - new Color(212, 207, 207), - new Color(255, 231, 255), - new Color(255, 111, 111), - new Color(128, 254, 254), - new Color(126, 148, 182), - new Color(207, 162, 251), - new Color(172, 156, 233), - new Color(51, 204, 0)}; + new Color(222, 241, 229), + new Color(234, 255, 226), + new Color(208, 229, 229), + new Color(255, 226, 199), + new Color(227, 226, 223), + new Color(255, 213, 203), + new Color(220, 204, 236), + new Color(255, 191, 195), + new Color(243, 223, 243), + new Color(217, 228, 249), + new Color(255, 251, 207), + new Color(217, 222, 229), + new Color(255, 204, 238), + new Color(236, 236, 236)}; public void update(AnActionEvent e) { e.getPresentation().setEnabled(isEnabled(VcsContextFactory.SERVICE.getInstance().createContextOn(e))); @@ -212,7 +214,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware { final HighlightAnnotationsActions highlighting = new HighlightAnnotationsActions(project, file, fileAnnotation, editorGutterComponentEx); final List gutters = new ArrayList(); final AnnotationSourceSwitcher switcher = fileAnnotation.getAnnotationSourceSwitcher(); - final MyAnnotationPresentation presentation = new MyAnnotationPresentation(highlighting, switcher, editorGutterComponentEx); + final MyAnnotationPresentation presentation = new MyAnnotationPresentation(highlighting, switcher, editorGutterComponentEx, gutters); if (switcher != null) { @@ -370,19 +372,23 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware { private final HighlightAnnotationsActions myHighlighting; @Nullable private final AnnotationSourceSwitcher mySwitcher; + private final List myGutters; private final List myActions; private MySwitchAnnotationSourceAction mySwitchAction; public MyAnnotationPresentation(@NotNull final HighlightAnnotationsActions highlighting, @Nullable final AnnotationSourceSwitcher switcher, - final EditorGutterComponentEx gutter) { + final EditorGutterComponentEx gutter, + List gutters) { myHighlighting = highlighting; mySwitcher = switcher; + myGutters = gutters; myActions = new ArrayList(myHighlighting.getList()); if (mySwitcher != null) { mySwitchAction = new MySwitchAnnotationSourceAction(mySwitcher, gutter); myActions.add(mySwitchAction); } + myActions.add(new ShowHideColorsAction(myGutters, gutter)); } public EditorFontType getFontType(final int line) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java index f0fa642f11cc..2ac37f45dd8c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java @@ -43,6 +43,7 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { private final AnnotationListener myListener; private final boolean myIsGutterAction; private Map myColorScheme; + private boolean myShowBg = true; AnnotationFieldGutter(FileAnnotation annotation, Editor editor, LineAnnotationAspect aspect, final TextAnnotationPresentation presentation) { myAnnotation = annotation; @@ -109,8 +110,9 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { @Nullable public Color getBgColor(int line, Editor editor) { + if (myColorScheme == null || !myShowBg) return null; final String s = getLineText(line, editor); - if (myColorScheme == null || s == null) return null; + if (s == null) return null; final Color bg = myColorScheme.get(s); return bg == null ? findBgColor(s) : bg; } @@ -129,5 +131,9 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { public void setAspectValueToBgColorMap(Map colorScheme) { myColorScheme = colorScheme; - } + } + + public void setShowBg(boolean show) { + myShowBg = show; + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowHideColorsAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowHideColorsAction.java new file mode 100644 index 000000000000..053d306f5b99 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowHideColorsAction.java @@ -0,0 +1,51 @@ +/* + * 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.vcs.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.editor.ex.EditorGutterComponentEx; +import com.intellij.openapi.util.registry.Registry; + +import java.util.List; + +/** + * @author Konstantin Bulenkov + */ +public class ShowHideColorsAction extends AnAction { + private boolean showColors = Registry.is("vcs.show.colored.annotations"); + private final List myGutters; + private final EditorGutterComponentEx myGutter; + + public ShowHideColorsAction(List gutters, EditorGutterComponentEx gutter) { + myGutters = gutters; + myGutter = gutter; + } + + @Override + public void actionPerformed(AnActionEvent e) { + showColors = !showColors; + for (AnnotationFieldGutter gutter : myGutters) { + gutter.setShowBg(showColors); + } + myGutter.revalidateMarkup(); + } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setText(showColors ? "Hide Colors" : "Show Colors"); + } +} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsDiffProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsDiffProvider.java index 2745699777ef..0217f3c3adf8 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsDiffProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsDiffProvider.java @@ -116,21 +116,8 @@ public class CvsDiffProvider implements DiffProvider{ final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name); if (entry == null) return new ItemLatestState(new CvsRevisionNumber("HEAD"), true, true); - String headRevision = null; - if (entry.getStickyDate() != null) { - headRevision = new StickyHeadGetter.MyStickyDateGetter(entry.getStickyDateString(), entry.getStickyDate(), entry.getRevision()).getHead(parent, name); - } else if (entry.getStickyRevision() != null) { - headRevision = entry.getStickyRevision(); - } else if (entry.getStickyTag() != null) { - headRevision = new StickyHeadGetter.MyStickyBranchHeadGetter(entry.getRevision()).getHead(parent, name); - } else { - headRevision = new StickyHeadGetter.MyStickyBranchHeadGetter(entry.getRevision()).getHead(parent, name); - } - if (headRevision != null) { - return new ItemLatestState(new CvsRevisionNumber(headRevision), (! entry.isRemoved()), false); - } - - return new ItemLatestState(new CvsRevisionNumber("HEAD"), (! entry.isRemoved()), true); + return new ItemLatestState(new CvsRevisionNumber( + new StickyHeadGetter.MyStickyBranchHeadGetter(entry.getRevision()).getHead(parent, name)), (! entry.isRemoved()), false); } @Nullable diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/BrowseCvsRepositoryAction.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/BrowseCvsRepositoryAction.java index eec61112bc1e..a1149dd412e3 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/BrowseCvsRepositoryAction.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/BrowseCvsRepositoryAction.java @@ -32,6 +32,7 @@ import com.intellij.cvsSupport2.ui.CvsTabbedWindow; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.actions.VcsContext; @@ -42,7 +43,7 @@ import java.util.Collections; /** * author: lesya */ -public class BrowseCvsRepositoryAction extends AbstractAction{ +public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAware { private static final String TITLE = CvsBundle.message("operation.name.browse.repository"); private CvsRootConfiguration mySelectedConfiguration; 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 a13d292d1c5f..2858bd3dcdf1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -191,7 +191,11 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { registerCreateClassByTypeFix(referenceExpression, annotation); registerAddImportFixes(referenceExpression, annotation); } - } else { + else { + registerStaticImportFix(referenceExpression, annotation); + } + } + else { if (qualifier.getType() == null) { return; } @@ -201,6 +205,16 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } + private static void registerStaticImportFix(GrReferenceExpression referenceExpression, Annotation annotation) { + final String referenceName = referenceExpression.getReferenceName(); + //noinspection ConstantConditions + if (StringUtil.isEmpty(referenceName)) { + return; + } + + annotation.registerFix(new GroovyStaticImportMethodFix((GrCall)referenceExpression.getParent())); + } + @Override public void visitTypeDefinition(GrTypeDefinition typeDefinition) { checkTypeDefinition(myHolder, typeDefinition); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/gutter/OverrideGutter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/gutter/OverrideGutter.java deleted file mode 100644 index 413abd559664..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/gutter/OverrideGutter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.groovy.annotator.gutter; - -import com.intellij.codeInsight.navigation.NavigationUtil; -import com.intellij.ide.util.PsiElementListCellRenderer; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.editor.markup.GutterIconRenderer; -import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.Iconable; -import com.intellij.pom.Navigatable; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiMethod; -import com.intellij.ui.awt.RelativePoint; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.GroovyBundle; -import org.jetbrains.plugins.groovy.structure.GroovyElementPresentation; - -import javax.swing.*; -import java.awt.event.MouseEvent; - -/** - * User: Dmitry.Krasilschikov - * Date: 05.09.2007 - */ -public class OverrideGutter extends GutterIconRenderer { - private final AnAction myClickAction; - - private final GrMethodsListCellRenderer GROOVY_METHOD_LIST_CELL_RENDERER = new GrMethodsListCellRenderer(); - private final boolean myIsImplements; - - private final String myTooltipText; - - @Nullable - public String getTooltipText() { - return myTooltipText; - } - - public static final int OVERRIDING_ICON_TYPE = 1; - - public OverrideGutter(final PsiMethod[] methods, boolean isImplements) { - myIsImplements = isImplements; - myTooltipText = getTooltipText(methods); - myClickAction = new AnAction() { - - public void actionPerformed(final AnActionEvent e) { - if (methods.length == 0) { - } else if (methods.length == 1) { - // only one navigation target - final Navigatable method = methods[0]; - if (method.canNavigateToSource()) { - method.navigate(true); - } - } else { - // show popup for selecting navigation target from list - final JBPopup gotoDeclarationPopup = NavigationUtil - .getPsiElementPopup(methods, GROOVY_METHOD_LIST_CELL_RENDERER, GroovyBundle.message("goto.override.method.declaration")); - - gotoDeclarationPopup.show(new RelativePoint((MouseEvent)e.getInputEvent())); - } - } - }; - } - - private String getTooltipText(PsiMethod[] methods) { - assert methods.length > 0; - final PsiClass containingClass = methods[0].getContainingClass(); - assert containingClass != null; //otherwise it could not have been overridden - String classDescr = containingClass.getQualifiedName(); - if (classDescr == null) classDescr = containingClass.getName(); - if (myIsImplements) { - return GroovyBundle.message("implements.method.from.super", classDescr); - } - return GroovyBundle.message("overrides.method.from.super", classDescr); - } - - @Nullable - public AnAction getClickAction() { - return myClickAction; - } - - @NotNull - public Icon getIcon() { - if (myIsImplements) { - return IconLoader.getIcon("/gutter/implementingMethod.png"); - } - return IconLoader.getIcon("/gutter/overridingMethod.png"); - } - - class GrMethodsListCellRenderer extends PsiElementListCellRenderer { - public String getElementText(PsiElement element) { -// assert element instanceof GrMethod; - - return GroovyElementPresentation.getPresentableText(element); - } - - protected String getContainerText(PsiElement psiElement, String s) { - return null; - } - - protected int getIconFlags() { - return Iconable.ICON_FLAG_CLOSED; - } - } -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java new file mode 100644 index 000000000000..6d7add42b39f --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java @@ -0,0 +1,203 @@ +/* + * 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.plugins.groovy.annotator.intentions; + +import com.intellij.codeInsight.CodeInsightUtilBase; +import com.intellij.codeInsight.completion.JavaCompletionUtil; +import com.intellij.codeInsight.daemon.QuickFixBundle; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.ide.util.MethodCellRenderer; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.popup.PopupChooserBuilder; +import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.search.PsiShortNamesCache; +import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.proximity.PsiProximityComparator; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author Maxim.Medvedev + */ +public class GroovyStaticImportMethodFix implements IntentionAction { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.annotator.intentions.GroovyStaticImportMethodFix"); + private final SmartPsiElementPointer myMethodCall; + private List myCandidates = null; + + public GroovyStaticImportMethodFix(@NotNull GrCall methodCallExpression) { + myMethodCall = SmartPointerManager.getInstance(methodCallExpression.getProject()).createSmartPsiElementPointer(methodCallExpression); + } + + @NotNull + public String getText() { + String text = "Static Import Method"; + if (getCandidates().size() == 1) { + final int options = PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_CONTAINING_CLASS | PsiFormatUtil.SHOW_FQ_NAME; + text += " '" + PsiFormatUtil.formatMethod(getCandidates().get(0), PsiSubstitutor.EMPTY, options, 0) + "'"; + } + else { + text += "..."; + } + return text; + } + + @NotNull + public String getFamilyName() { + return getText(); + } + + @Nullable + private static GrReferenceExpression getMethodExpression(GrCall call) { + GrExpression result = null; + if (call instanceof GrMethodCallExpression) { + result = ((GrMethodCallExpression)call).getInvokedExpression(); + } + else if (call instanceof GrApplicationStatement) { + result = ((GrApplicationStatement)call).getFunExpression(); + } + + return result instanceof GrReferenceExpression ? (GrReferenceExpression)result : null; + } + + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return myMethodCall != null && + myMethodCall.getElement() != null && + myMethodCall.getElement().isValid() && + getMethodExpression(myMethodCall.getElement()) != null && + getMethodExpression(myMethodCall.getElement()).getQualifierExpression() == null && + file.getManager().isInProject(file) && + file.getManager().isInProject(file) && + !getCandidates().isEmpty(); + } + + @NotNull + private List getMethodsToImport() { + final JavaPsiFacade facade = JavaPsiFacade.getInstance(myMethodCall.getProject()); + PsiShortNamesCache cache = facade.getShortNamesCache(); + + GrCall element = myMethodCall.getElement(); + LOG.assertTrue(element != null); + GrReferenceExpression reference = getMethodExpression(element); + LOG.assertTrue(reference != null); + GrArgumentList argumentList = element.getArgumentList(); + String name = reference.getReferenceName(); + + ArrayList list = new ArrayList(); + if (name == null) return list; + GlobalSearchScope scope = element.getResolveScope(); + PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, 20); + List applicableList = new ArrayList(); + for (PsiMethod method : methods) { + ProgressManager.checkCanceled(); + PsiClass aClass = method.getContainingClass(); + if (aClass != null && JavaCompletionUtil.isInExcludedPackage(aClass)) continue; + if (!method.hasModifierProperty(PsiModifier.STATIC)) continue; + PsiFile file = method.getContainingFile(); + if (file instanceof PsiClassOwner + //do not show methods from default package + && ((PsiClassOwner)file).getPackageName().length() != 0 && PsiUtil.isAccessible(element, method)) { + list.add(method); + if (PsiUtil.isApplicable(PsiUtil.getArgumentTypes(element, false, true), method, PsiSubstitutor.EMPTY, false)) { + applicableList.add(method); + } + } + } + List result = applicableList.isEmpty() ? list : applicableList; + Collections.sort(result, new PsiProximityComparator(argumentList)); + return result; + } + + public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) { + if (!CodeInsightUtilBase.prepareFileForWrite(file)) return; + if (getCandidates().size() == 1) { + final PsiMethod toImport = getCandidates().get(0); + doImport(toImport); + } + else { + chooseAndImport(editor); + } + } + + private void doImport(final PsiMethod toImport) { + CommandProcessor.getInstance().executeCommand(toImport.getProject(), new Runnable() { + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + try { + GrCall element = myMethodCall.getElement(); + if (element != null) { + getMethodExpression(element).bindToElementViaStaticImport(toImport.getContainingClass()); + } + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + + } + }); + + } + }, getText(), this); + + } + + private void chooseAndImport(Editor editor) { + final JList list = new JList(getCandidates().toArray(new PsiMethod[getCandidates().size()])); + list.setCellRenderer(new MethodCellRenderer(true)); + new PopupChooserBuilder(list). + setTitle(QuickFixBundle.message("static.import.method.choose.method.to.import")). + setMovable(true). + setItemChoosenCallback(new Runnable() { + public void run() { + PsiMethod selectedValue = (PsiMethod)list.getSelectedValue(); + if (selectedValue == null) return; + LOG.assertTrue(selectedValue.isValid()); + doImport(selectedValue); + } + }).createPopup(). + showInBestPositionFor(editor); + } + + public boolean startInWriteAction() { + return true; + } + + private List getCandidates() { + if (myCandidates == null) { + myCandidates = getMethodsToImport(); + } + return myCandidates; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrReferenceExpression.java index d90e73a06bf6..1ccc4cc70460 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrReferenceExpression.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions; +import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.tree.IElementType; @@ -47,4 +48,6 @@ public interface GrReferenceExpression extends GrExpression, GrReferenceElement, GroovyResolveResult[] getSameNameVariants(); void setQualifierExpression(GrReferenceExpression qualifierExpression); + + GrReferenceExpression bindToElementViaStaticImport(@NotNull PsiClass qualifierClass); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java index 83e9c24821be..7f9f2c6bd01a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java @@ -29,10 +29,8 @@ import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; -import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; -import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; /** * @author ven @@ -132,15 +130,7 @@ public abstract class GrReferenceElementImpl extends GroovyPsiElementImpl implem return PsiTreeUtil.getParentOfType(this, GrDocComment.class) == null && !(getContainingFile() instanceof GroovyCodeFragment) && PsiTreeUtil.getParentOfType(this, GrImportStatement.class) == null; } - private PsiElement bindWithQualifiedRef(String qName) { - final GrTypeArgumentList list = getTypeArgumentList(); - final String typeArgs = (list != null) ? list.getText() : ""; - final String text = qName + typeArgs; - final GrCodeReferenceElement qualifiedRef = GroovyPsiElementFactory.getInstance(getProject()).createTypeOrPackageReference(text); - getNode().getTreeParent().replaceChild(getNode(), qualifiedRef.getNode()); - PsiUtil.shortenReference(qualifiedRef); - return qualifiedRef; - } + protected abstract PsiElement bindWithQualifiedRef(String qName); protected boolean bindsCorrectly(PsiElement element) { return isReferenceTo(element); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java index efb2ffddebeb..3c40bac3dd73 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java @@ -17,7 +17,6 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions; import com.intellij.lang.ASTNode; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; @@ -55,6 +54,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrRefere import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod; +import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList; import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType; import org.jetbrains.plugins.groovy.lang.psi.impl.GrReferenceElementImpl; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager; @@ -71,8 +72,6 @@ import java.util.EnumSet; * @author ilyas */ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements GrReferenceExpression { - private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceExpressionImpl"); - public GrReferenceExpressionImpl(@NotNull ASTNode node) { super(node); } @@ -146,6 +145,16 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements return doHandleElementRename(newElementName); } + @Override + protected PsiElement bindWithQualifiedRef(String qName) { + final GrTypeArgumentList list = getTypeArgumentList(); + final String typeArgs = (list != null) ? list.getText() : ""; + final String text = qName + typeArgs; + GrReferenceExpression qualifiedRef = GroovyPsiElementFactory.getInstance(getProject()).createReferenceExpressionFromText(text); + getNode().getTreeParent().replaceChild(getNode(), qualifiedRef.getNode()); + return qualifiedRef; + } + private PsiElement doHandleElementRename(String newElementName) throws IncorrectOperationException { if (!PsiUtil.isValidReferenceName(newElementName)) { PsiElement element = GroovyPsiElementFactory.getInstance(getProject()).createStringLiteral(newElementName); @@ -180,15 +189,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements private static final OurTypesCalculator TYPES_CALCULATOR = new OurTypesCalculator(); - public GrReferenceExpression getElementToCompare() { - return this; - } - - public int compareTo(GrReferenceExpression grReferenceExpression) { - if (this.equals(grReferenceExpression)) return 0; - else return getText().compareTo(grReferenceExpression.getText()); - } - public PsiType getNominalType() { return GroovyPsiManager.getInstance(getProject()).getTypeInferenceHelper().doWithInferenceDisabled(new Computable() { public PsiType compute() { @@ -665,4 +665,21 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements } } + + public GrReferenceExpression bindToElementViaStaticImport(@NotNull PsiClass qualifierClass) { + if (getQualifier() != null) { + throw new IncorrectOperationException("Reference has qualifier"); + } + + if (StringUtil.isEmpty(getReferenceName())) { + throw new IncorrectOperationException("Reference has empty name"); + } + final PsiFile file = getContainingFile(); + if (file instanceof GroovyFile) { + final GrImportStatement statement = GroovyPsiElementFactory.getInstance(getProject()) + .createImportStatementFromText("import static " + qualifierClass.getQualifiedName() + "." + getReferenceName()); + ((GroovyFile)file).addImport(statement); + } + return this; + } } \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index da7951ea4f08..e4d6fa8b2ff9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -349,6 +349,14 @@ public class TypesUtil { return GrClosureType.create(returnType, paramTypes, opts, manager, scope, LanguageLevel.JDK_1_5); } } + else if (GrStringUtil.GROOVY_LANG_GSTRING.equals(type1.getCanonicalText()) && + CommonClassNames.JAVA_LANG_STRING.equals(type2.getInternalCanonicalText())) { + return type2; + } + else if (GrStringUtil.GROOVY_LANG_GSTRING.equals(type2.getCanonicalText()) && + CommonClassNames.JAVA_LANG_STRING.equals(type1.getInternalCanonicalText())) { + return type1; + } return GenericsUtil.getLeastUpperBound(type1, type2, manager); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java index a99dd5d428f2..c89295c286b0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java @@ -33,6 +33,7 @@ import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression; @@ -40,6 +41,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousC import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; +import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList; import org.jetbrains.plugins.groovy.lang.psi.impl.GrReferenceElementImpl; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; @@ -64,6 +66,17 @@ public class GrCodeReferenceElementImpl extends GrReferenceElementImpl implement super(node); } + @Override + protected PsiElement bindWithQualifiedRef(String qName) { + final GrTypeArgumentList list = getTypeArgumentList(); + final String typeArgs = (list != null) ? list.getText() : ""; + final String text = qName + typeArgs; + final GrCodeReferenceElement qualifiedRef = GroovyPsiElementFactory.getInstance(getProject()).createTypeOrPackageReference(text); + getNode().getTreeParent().replaceChild(getNode(), qualifiedRef.getNode()); + PsiUtil.shortenReference(qualifiedRef); + return qualifiedRef; + } + public void accept(GroovyElementVisitor visitor) { visitor.visitCodeReferenceElement(this); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java index a0af3e28198a..69fa1301397c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java @@ -144,7 +144,7 @@ public class ResolveUtil { if (!membersProcessor.processNonCodeMembers(type, processor, place, forCompletion)) return false; } - if (type instanceof PsiArrayType) { + if (type instanceof PsiArrayType && visited.size() == 1) { //implicit super types PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); PsiClassType t = factory.createTypeByFQClassName("java.lang.Object", GlobalSearchScope.allScope(project)); @@ -154,11 +154,9 @@ public class ResolveUtil { t = factory.createTypeByFQClassName("java.io.Serializable", GlobalSearchScope.allScope(project)); if (!processNonCodeMethods(t, processor, project, visited, place, forCompletion)) return false; } - else { - for (PsiType superType : type.getSuperTypes()) { - if (!processNonCodeMethods(TypeConversionUtil.erasure(superType), processor, project, visited, place, forCompletion)) { - return false; - } + for (PsiType superType : type.getSuperTypes()) { + if (!processNonCodeMethods(TypeConversionUtil.erasure(superType), processor, project, visited, place, forCompletion)) { + return false; } } } 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 f114047df02b..b988a1b9d915 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java @@ -199,4 +199,6 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public void testOverlyLongMethodInspection() throws Exception { doTest(new GroovyOverlyLongMethodInspection()); } + + public void testStringAndGStringUpperBound() throws Exception {doTest();} } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/enterAction/gdoc10.test b/plugins/groovy/testdata/groovy/enterAction/gdoc10.test index d94133ca199f..e23d901a79ea 100644 --- a/plugins/groovy/testdata/groovy/enterAction/gdoc10.test +++ b/plugins/groovy/testdata/groovy/enterAction/gdoc10.test @@ -7,4 +7,5 @@ def foo(int x, int y){} * @param y * @return */ + def foo(int x, int y){} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/enterAction/gdoc11.test b/plugins/groovy/testdata/groovy/enterAction/gdoc11.test index 018419abb4ce..62b69b69fc7d 100644 --- a/plugins/groovy/testdata/groovy/enterAction/gdoc11.test +++ b/plugins/groovy/testdata/groovy/enterAction/gdoc11.test @@ -6,4 +6,5 @@ void foo(int x, int y){} * @param x * @param y */ + void foo(int x, int y){} \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/StringAndGStringUpperBound.groovy b/plugins/groovy/testdata/highlighting/StringAndGStringUpperBound.groovy new file mode 100644 index 000000000000..00af95a21eec --- /dev/null +++ b/plugins/groovy/testdata/highlighting/StringAndGStringUpperBound.groovy @@ -0,0 +1,2 @@ +def foo(String s) {} +foo(this.is(5) ? "ac" : "jk${2}") diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitTestFramework.java b/plugins/junit/src/com/intellij/execution/junit/JUnitTestFramework.java index 91c8b56b3745..5abcc25cf8df 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitTestFramework.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitTestFramework.java @@ -66,4 +66,8 @@ public class JUnitTestFramework implements TestFramework { } return inClass; } + + public boolean isTestMethodOrConfig(PsiMethod psiMethod) { + return JUnitUtil.isTestMethodOrConfig(psiMethod); + } } \ No newline at end of file diff --git a/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java b/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java index acd48cc9fa97..0edf7adca7ff 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java +++ b/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java @@ -60,6 +60,9 @@ public class JUnit3OutputObjectRegistry extends OutputObjectRegistry { } addTestClass(packet, fullName); } + else if (test instanceof TestRunnerUtil.SuiteMethodWrapper) { + addTestClass(packet, ((TestRunnerUtil.SuiteMethodWrapper)test).getClassName()); + } else { addUnknownTest(packet, test); } diff --git a/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java b/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java index 4989d5db9a7c..51d8f6c03488 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java +++ b/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java @@ -17,6 +17,7 @@ package com.intellij.junit3; import junit.framework.Test; import junit.framework.TestCase; +import junit.framework.TestResult; import junit.framework.TestSuite; import junit.runner.BaseTestRunner; @@ -116,6 +117,7 @@ public class TestRunnerUtil { } try { test = (Test)suiteMethod.invoke(null, new Class[0]); // static method + test = new SuiteMethodWrapper(test, suiteClassName); } catch (final InvocationTargetException e) { final String message = MessageFormat.format(ourBundle.getString("junit.failed.to.invoke.suite"), new Object[]{testClass + " " + e.getTargetException().toString()}); @@ -235,4 +237,30 @@ public class TestRunnerUtil { } } } + + public static class SuiteMethodWrapper implements Test { + private Test mySuite; + private String myClassName; + + public SuiteMethodWrapper(Test suite, String className) { + mySuite = suite; + myClassName = className; + } + + public String getClassName() { + return myClassName; + } + + public int countTestCases() { + return mySuite.countTestCases(); + } + + public void run(TestResult result) { + mySuite.run(result); + } + + public Test getSuite() { + return mySuite; + } + } } diff --git a/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java b/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java index 5fb3b0ad51fa..ba0a54cdb163 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java +++ b/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java @@ -36,6 +36,9 @@ public class TreeSender { private static Vector getTestCasesOf(Test test) { Vector testCases = new Vector(); + if (test instanceof TestRunnerUtil.SuiteMethodWrapper) { + test = ((TestRunnerUtil.SuiteMethodWrapper)test).getSuite(); + } if (test instanceof TestSuite) { TestSuite testSuite = (TestSuite)test; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java index 2850926f6df9..81d62d7b4625 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java @@ -178,6 +178,9 @@ public class SvnConfigurable implements Configurable { configuration.setConfigurationDirectory(myConfigurationDirectoryText.getText()); configuration.setUseDefaultConfiguation(myUseDefaultCheckBox.isSelected()); configuration.setIsUseDefaultProxy(myUseCommonProxy.isSelected()); + if ((! configuration.DETECT_NESTED_COPIES) && (configuration.DETECT_NESTED_COPIES != myDetectNestedWorkingCopiesCheckBox.isSelected())) { + SvnVcs.getInstance(myProject).invokeRefreshSvnRoots(true); + } configuration.DETECT_NESTED_COPIES = myDetectNestedWorkingCopiesCheckBox.isSelected(); configuration.UPDATE_LOCK_ON_DEMAND = myLockOnDemand.isSelected(); configuration.setIgnoreSpacesInAnnotate(myIgnoreWhitespaceDifferenciesInCheckBox.isSelected()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java index 272cd962f912..6d4b81273d3f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java @@ -83,7 +83,7 @@ public class SvnConfiguration implements ProjectComponent, JDOMExternalizable { public boolean MERGE_DIFF_USE_ANCESTRY = true; public boolean UPDATE_LOCK_ON_DEMAND = false; public boolean IGNORE_SPACES_IN_MERGE = false; - public boolean DETECT_NESTED_COPIES = false; + public boolean DETECT_NESTED_COPIES = true; public boolean IGNORE_SPACES_IN_ANNOTATE = true; public boolean SHOW_MERGE_SOURCES_IN_ANNOTATE = true; diff --git a/plugins/testng/src/com/theoryinpractice/testng/util/TestNGUtil.java b/plugins/testng/src/com/theoryinpractice/testng/util/TestNGUtil.java index aef188828bbe..24cc13eaeedd 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/util/TestNGUtil.java +++ b/plugins/testng/src/com/theoryinpractice/testng/util/TestNGUtil.java @@ -477,6 +477,10 @@ public class TestNGUtil implements TestFramework return inClass; } + public boolean isTestMethodOrConfig(PsiMethod psiMethod) { + return hasTest(psiMethod) || hasConfig(psiMethod); + } + public static boolean checkTestNGInClasspath(PsiElement psiElement) { final Project project = psiElement.getProject(); final PsiManager manager = PsiManager.getInstance(project); diff --git a/xml/impl/src/com/intellij/xml/DefaultXmlExtension.java b/xml/impl/src/com/intellij/xml/DefaultXmlExtension.java index 26f740e8618b..985295a8ad62 100644 --- a/xml/impl/src/com/intellij/xml/DefaultXmlExtension.java +++ b/xml/impl/src/com/intellij/xml/DefaultXmlExtension.java @@ -244,7 +244,7 @@ public class DefaultXmlExtension extends XmlExtension { @NonNls String nsDeclarationAttrName = null; for(XmlTag t = context; t != null; t = t.getParentTag()) { if (t.hasNamespaceDeclarations()) { - if (nsDeclarationAttrName == null) nsDeclarationAttrName = "xmlns:"+namespacePrefix; + if (nsDeclarationAttrName == null) nsDeclarationAttrName = namespacePrefix.length() > 0 ? "xmlns:"+namespacePrefix:"xmlns"; if (t.getAttributeValue(nsDeclarationAttrName) != null) return true; } }