mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ public class LineMarkerInfo<T extends PsiElement> {
|
||||
@Nullable private final Function<? super T, String> myTooltipProvider;
|
||||
private final GutterIconRenderer.Alignment myIconAlignment;
|
||||
@Nullable private final GutterIconNavigationHandler<T> myNavigationHandler;
|
||||
public TextAttributesKey textAttributesKey;
|
||||
|
||||
|
||||
public LineMarkerInfo(T element,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -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;
|
||||
|
||||
+9
-4
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+4
@@ -498,5 +498,9 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
public boolean atEnd() {
|
||||
return myBaseIterator.atEnd();
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myBaseIterator.getDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-11
@@ -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<JComboBox>(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));
|
||||
|
||||
|
||||
+7
-8
@@ -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<JComboBox>(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));
|
||||
|
||||
|
||||
+2
@@ -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();
|
||||
}
|
||||
|
||||
+8
-3
@@ -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);
|
||||
}
|
||||
|
||||
+4
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<EditorComboBox> COMPONENT_ACCESSOR = new TextComponentAccessor<EditorComboBox>() {
|
||||
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;
|
||||
|
||||
@@ -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<Collection<ActiveAnnotationGutter>> 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<AnnotationFieldGutter> gutters = new ArrayList<AnnotationFieldGutter>();
|
||||
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<AnnotationFieldGutter> myGutters;
|
||||
private final List<AnAction> myActions;
|
||||
private MySwitchAnnotationSourceAction mySwitchAction;
|
||||
|
||||
public MyAnnotationPresentation(@NotNull final HighlightAnnotationsActions highlighting, @Nullable final AnnotationSourceSwitcher switcher,
|
||||
final EditorGutterComponentEx gutter) {
|
||||
final EditorGutterComponentEx gutter,
|
||||
List<AnnotationFieldGutter> gutters) {
|
||||
myHighlighting = highlighting;
|
||||
mySwitcher = switcher;
|
||||
myGutters = gutters;
|
||||
|
||||
myActions = new ArrayList<AnAction>(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) {
|
||||
|
||||
@@ -43,6 +43,7 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter {
|
||||
private final AnnotationListener myListener;
|
||||
private final boolean myIsGutterAction;
|
||||
private Map<String, Color> 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<String, Color> colorScheme) {
|
||||
myColorScheme = colorScheme;
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowBg(boolean show) {
|
||||
myShowBg = show;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AnnotationFieldGutter> myGutters;
|
||||
private final EditorGutterComponentEx myGutter;
|
||||
|
||||
public ShowHideColorsAction(List<AnnotationFieldGutter> 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");
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+203
@@ -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<GrCall> myMethodCall;
|
||||
private List<PsiMethod> 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<PsiMethod> 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<PsiMethod> list = new ArrayList<PsiMethod>();
|
||||
if (name == null) return list;
|
||||
GlobalSearchScope scope = element.getResolveScope();
|
||||
PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, 20);
|
||||
List<PsiMethod> applicableList = new ArrayList<PsiMethod>();
|
||||
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<PsiMethod> 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<PsiMethod> getCandidates() {
|
||||
if (myCandidates == null) {
|
||||
myCandidates = getMethodsToImport();
|
||||
}
|
||||
return myCandidates;
|
||||
}
|
||||
}
|
||||
+3
@@ -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);
|
||||
}
|
||||
|
||||
+1
-11
@@ -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);
|
||||
|
||||
+29
-12
@@ -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<PsiType>() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+8
@@ -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);
|
||||
}
|
||||
|
||||
+13
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,4 +199,6 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testOverlyLongMethodInspection() throws Exception {
|
||||
doTest(new GroovyOverlyLongMethodInspection());
|
||||
}
|
||||
|
||||
public void testStringAndGStringUpperBound() throws Exception {doTest();}
|
||||
}
|
||||
@@ -7,4 +7,5 @@ def foo(int x, int y){}
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
|
||||
def foo(int x, int y){}
|
||||
@@ -6,4 +6,5 @@ void foo(int x, int y){}
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
|
||||
void foo(int x, int y){}
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo(String s) {}
|
||||
foo(this.is(5) ? "ac" : "jk${2}")
|
||||
@@ -66,4 +66,8 @@ public class JUnitTestFramework implements TestFramework {
|
||||
}
|
||||
return inClass;
|
||||
}
|
||||
|
||||
public boolean isTestMethodOrConfig(PsiMethod psiMethod) {
|
||||
return JUnitUtil.isTestMethodOrConfig(psiMethod);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user