mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -959,10 +959,10 @@ public class CompileDriver {
|
||||
final TranslatorsOutputSink sink = new TranslatorsOutputSink(context, translators);
|
||||
final Set<FileType> generatedTypes = new HashSet<FileType>();
|
||||
Collection<VirtualFile> chunkFiles = chunkMap.get(currentChunk);
|
||||
final Set<VirtualFile> filesToRecompile = new HashSet<VirtualFile>();
|
||||
final Set<VirtualFile> allDependent = new HashSet<VirtualFile>();
|
||||
try {
|
||||
int round = 0;
|
||||
final Set<VirtualFile> filesToRecompile = new HashSet<VirtualFile>();
|
||||
final Set<VirtualFile> allDependent = new HashSet<VirtualFile>();
|
||||
Collection<VirtualFile> dependentFiles = Collections.emptyList();
|
||||
final Function<Pair<int[], Set<VirtualFile>>, Pair<int[], Set<VirtualFile>>> dependencyFilter = new DependentClassesCumulativeFilter();
|
||||
|
||||
@@ -1092,19 +1092,18 @@ public class CompileDriver {
|
||||
indicator.popState();
|
||||
}
|
||||
}
|
||||
|
||||
if (context.getMessageCount(CompilerMessageCategory.ERROR) != 0) {
|
||||
filesToRecompile.addAll(allDependent);
|
||||
}
|
||||
if (filesToRecompile.size() > 0) {
|
||||
sink.add(null, Collections.<TranslatingCompiler.OutputItem>emptyList(), VfsUtil.toVirtualFileArray(filesToRecompile));
|
||||
}
|
||||
}
|
||||
catch (CacheCorruptedException e) {
|
||||
LOG.info(e);
|
||||
context.requestRebuildNextTime(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
if (context.getMessageCount(CompilerMessageCategory.ERROR) != 0) {
|
||||
filesToRecompile.addAll(allDependent);
|
||||
}
|
||||
if (filesToRecompile.size() > 0) {
|
||||
sink.add(null, Collections.<TranslatingCompiler.OutputItem>emptyList(), VfsUtil.toVirtualFileArray(filesToRecompile));
|
||||
}
|
||||
if (context.getMessageCount(CompilerMessageCategory.ERROR) == 0) {
|
||||
// perform update only if there were no errors, so it is guaranteed that the file was processd by all neccesary compilers
|
||||
sink.flushPostponedItems();
|
||||
|
||||
@@ -171,6 +171,7 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
myCacheDisposables.clear();
|
||||
myNewCachesMap.clear();
|
||||
myCompilerToCacheMap.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class FramesPanel extends UpdatableDebuggerView {
|
||||
myThreadsListener = new ThreadsListener();
|
||||
myThreadsCombo.addItemListener(myThreadsListener);
|
||||
|
||||
myFramesList = new FramesList();
|
||||
myFramesList = new FramesList(project);
|
||||
myFramesListener = new FramesListener();
|
||||
myFramesList.addListSelectionListener(myFramesListener);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.debugger.ui.impl;
|
||||
|
||||
import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.xdebugger.impl.frame.DebuggerFramesList;
|
||||
import com.sun.jdi.Method;
|
||||
@@ -29,6 +30,11 @@ import javax.swing.*;
|
||||
public class FramesList extends DebuggerFramesList {
|
||||
private volatile Method mySelectedMethod = null;
|
||||
|
||||
public FramesList(Project project) {
|
||||
super(null);
|
||||
doInit();
|
||||
}
|
||||
|
||||
protected FramesListRenderer createListRenderer() {
|
||||
return new FramesListRenderer();
|
||||
}
|
||||
|
||||
@@ -15,18 +15,24 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.impl;
|
||||
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
|
||||
import com.intellij.debugger.ui.tree.StackFrameDescriptor;
|
||||
import com.intellij.debugger.ui.tree.ValueMarkup;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.ui.DebuggerColors;
|
||||
import com.sun.jdi.Method;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
class FramesListRenderer extends ColoredListCellRenderer {
|
||||
private final EditorColorsScheme myColorScheme;
|
||||
@@ -52,10 +58,13 @@ class FramesListRenderer extends ColoredListCellRenderer {
|
||||
}
|
||||
|
||||
if (selected) {
|
||||
setBackground(com.intellij.util.ui.UIUtil.getListSelectionBackground());
|
||||
setBackground(UIUtil.getListSelectionBackground());
|
||||
}
|
||||
else {
|
||||
setBackground(shouldHighlightAsRecursive ? myColorScheme.getColor(DebuggerColors.RECURSIVE_CALL_ATTRIBUTES) : com.intellij.util.ui.UIUtil.getListBackground());
|
||||
Color bg = descriptor.getBackgroundColor();
|
||||
if (bg == null) bg = UIUtil.getListBackground();
|
||||
if (shouldHighlightAsRecursive) bg = myColorScheme.getColor(DebuggerColors.RECURSIVE_CALL_ATTRIBUTES);
|
||||
setBackground(bg);
|
||||
}
|
||||
|
||||
final String label = descriptor.getLabel();
|
||||
|
||||
+10
@@ -33,12 +33,14 @@ import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.xdebugger.ui.DebuggerIcons;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -52,6 +54,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
|
||||
private boolean myIsSynthetic;
|
||||
private boolean myIsInLibraryContent;
|
||||
private Long myObjectId;
|
||||
private Color myBackgroundColor;
|
||||
|
||||
private static final Icon myObsoleteFrameIcon = IconLoader.getIcon("/debugger/db_obsolete.png");
|
||||
private Icon myIcon = DebuggerIcons.STACK_FRAME_ICON;
|
||||
@@ -72,6 +75,8 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
|
||||
myIsInLibraryContent = true;
|
||||
}
|
||||
else {
|
||||
myBackgroundColor = FileColorManager.getInstance(file.getProject()).getFileColor(file);
|
||||
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(getDebugProcess().getProject()).getFileIndex();
|
||||
final VirtualFile vFile = file.getVirtualFile();
|
||||
myIsInLibraryContent = vFile != null && (projectFileIndex.isInLibraryClasses(vFile) || projectFileIndex.isInLibrarySource(vFile));
|
||||
@@ -102,6 +107,11 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
|
||||
return myFrame.getVirtualMachine().getDebugProcess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackgroundColor() {
|
||||
return myBackgroundColor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Method getMethod() {
|
||||
return myMethodOccurrence.getMethod();
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
package com.intellij.debugger.ui.tree;
|
||||
|
||||
import com.intellij.debugger.engine.StackFrameContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public interface StackFrameDescriptor extends NodeDescriptor, StackFrameContext {
|
||||
@Nullable
|
||||
Color getBackgroundColor();
|
||||
}
|
||||
|
||||
+3
-7
@@ -22,6 +22,7 @@ package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.config.Storage;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -29,13 +30,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class JavaAwareTestConsoleProperties extends TestConsoleProperties {
|
||||
public JavaAwareTestConsoleProperties(final Storage storage, Project project) {
|
||||
super(storage, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return getDebugSession() != null;
|
||||
public JavaAwareTestConsoleProperties(final Storage storage, Project project, Executor executor) {
|
||||
super(storage, project, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -796,10 +796,14 @@ public final class PsiUtil extends PsiUtilBase {
|
||||
}
|
||||
|
||||
public static boolean hasDefaultConstructor(PsiClass clazz, boolean allowProtected) {
|
||||
return hasDefaultConstructor(clazz, allowProtected, true);
|
||||
}
|
||||
|
||||
public static boolean hasDefaultConstructor(PsiClass clazz, boolean allowProtected, boolean checkModifiers) {
|
||||
final PsiMethod[] constructors = clazz.getConstructors();
|
||||
if (constructors.length > 0) {
|
||||
for (PsiMethod cls: constructors) {
|
||||
if ((cls.hasModifierProperty(PsiModifier.PUBLIC) ||
|
||||
if ((!checkModifiers || cls.hasModifierProperty(PsiModifier.PUBLIC) ||
|
||||
allowProtected && cls.hasModifierProperty(PsiModifier.PROTECTED)) &&
|
||||
cls.getParameterList().getParametersCount() == 0) {
|
||||
return true;
|
||||
@@ -807,7 +811,7 @@ public final class PsiUtil extends PsiUtilBase {
|
||||
}
|
||||
} else {
|
||||
final PsiClass superClass = clazz.getSuperClass();
|
||||
return superClass == null || hasDefaultConstructor(superClass, true);
|
||||
return superClass == null || hasDefaultConstructor(superClass, true, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
package com.intellij.lang.injection;
|
||||
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -41,7 +42,7 @@ public abstract class InjectedLanguageManager implements ProjectComponent {
|
||||
public static final ExtensionPointName<MultiHostInjector> MULTIHOST_INJECTOR_EP_NAME = MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME;
|
||||
|
||||
public static InjectedLanguageManager getInstance(Project project) {
|
||||
return project.getComponent(InjectedLanguageManager.class);
|
||||
return ServiceManager.getService(project, InjectedLanguageManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -70,11 +70,11 @@ public class GotoSymbolModel2 extends ContributorsBasedGotoByModel {
|
||||
|
||||
@NotNull
|
||||
public String[] getSeparators() {
|
||||
return new String[] {".", ":"};
|
||||
return new String[] {"."};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpId() {
|
||||
return "procedures.navigating.goto.class";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.util.ui.EmptyTextHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -50,6 +51,12 @@ public class JBList extends JList implements ComponentWithEmptyText, ComponentWi
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
myEmptyTextHelper.paint(g);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
myEmptyTextHelper = new EmptyTextHelper(this) {
|
||||
@Override
|
||||
|
||||
@@ -82,6 +82,12 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
boolean marker = Patches.SUN_BUG_ID_4503845; // Don't remove. It's a marker for find usages
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
myEmptyTextHelper.paint(g);
|
||||
}
|
||||
|
||||
public static DefaultCellEditor createBooleanEditor() {
|
||||
return new DefaultCellEditor(new JCheckBox()) {
|
||||
{
|
||||
|
||||
@@ -18,18 +18,14 @@ package com.intellij.idea;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.PluginsFacade;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IdeaTestApplication extends CommandLineApplication {
|
||||
private DataProvider myDataContext;
|
||||
|
||||
@@ -45,10 +41,6 @@ public class IdeaTestApplication extends CommandLineApplication {
|
||||
return PluginManager.getPlugins();
|
||||
}
|
||||
};
|
||||
|
||||
final File system = new File(PathManager.getSystemPath());
|
||||
FileUtil.delete(system);
|
||||
system.mkdirs();
|
||||
}
|
||||
|
||||
public void setDataProvider(DataProvider dataContext) {
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.intellij.openapi.editor.ex;
|
||||
import com.intellij.openapi.editor.TextChange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Defines a contract for the callbacks for soft wraps management notifications (addition/removal).
|
||||
*
|
||||
@@ -32,4 +34,9 @@ public interface SoftWrapChangeListener {
|
||||
* @param softWrap newly registered soft wrap
|
||||
*/
|
||||
void softWrapAdded(@NotNull TextChange softWrap);
|
||||
|
||||
/**
|
||||
* This method is assumed to be called every time soft wrap(s) is removed.
|
||||
*/
|
||||
void softWrapsRemoved();
|
||||
}
|
||||
|
||||
@@ -334,6 +334,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int softWrapLine = myDocument.getLineNumber(softWrap.getStart());
|
||||
mySizeContainer.update(softWrapLine, softWrapLine, softWrapLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void softWrapsRemoved() {
|
||||
mySoftWrapsChanged = true;
|
||||
mySizeContainer.reset();
|
||||
}
|
||||
});
|
||||
|
||||
EditorHighlighter highlighter = new EmptyEditorHighlighter(myScheme.getAttributes(HighlighterColors.TEXT));
|
||||
@@ -1691,25 +1697,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
if (lIterator.getLineNumber() >= lastLineIndex && position.y <= clip.y + clip.height) {
|
||||
paintAfterFileEndBackground(iterationState, g, position, clip, lineHeight, defaultBackground);
|
||||
}
|
||||
|
||||
// Perform additional activity if soft wrap is added or removed during repainting.
|
||||
// Note: this code lives in this method in assumption that background repainting is the very first activity performed
|
||||
// during whole editor component repaint.
|
||||
if (mySoftWrapsChanged) {
|
||||
mySoftWrapsChanged = false;
|
||||
validateSize();
|
||||
|
||||
// Repaint editor to the bottom in order to ensure that its content is shown correctly after new soft wrap introduction.
|
||||
repaintToScreenBottom(xyToLogicalPosition(position).line);
|
||||
|
||||
// Repaint gutter at all space that is located after active clip in order to ensure that line numbers are correctly redrawn
|
||||
// in accordance with the newly introduced soft wrap(s).
|
||||
myGutterComponent.repaint(0, clip.y, myGutterComponent.getWidth(), myGutterComponent.getHeight() - clip.y);
|
||||
|
||||
// Ask caret model to update visual caret position.
|
||||
//TODO den implement
|
||||
//getCaretModel().moveToOffset(getCaretModel().getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private void paintRectangularSelection(Graphics g) {
|
||||
@@ -1908,6 +1895,22 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
flushCachedChars(g);
|
||||
|
||||
// Perform additional activity if soft wrap is added or removed during repainting.
|
||||
if (mySoftWrapsChanged) {
|
||||
mySoftWrapsChanged = false;
|
||||
validateSize();
|
||||
|
||||
// Repaint editor to the bottom in order to ensure that its content is shown correctly after new soft wrap introduction.
|
||||
repaintToScreenBottom(xyToLogicalPosition(position).line);
|
||||
|
||||
// Repaint gutter at all space that is located after active clip in order to ensure that line numbers are correctly redrawn
|
||||
// in accordance with the newly introduced soft wrap(s).
|
||||
myGutterComponent.repaint(0, clip.y, myGutterComponent.getWidth(), myGutterComponent.getHeight() - clip.y);
|
||||
|
||||
// Ask caret model to update visual caret position.
|
||||
getCaretModel().moveToOffset(getCaretModel().getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean paintSelection() {
|
||||
|
||||
+11
-5
@@ -19,10 +19,7 @@ import com.intellij.openapi.editor.ex.SoftWrapChangeListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
@@ -125,7 +122,9 @@ public class SoftWrapsStorage {
|
||||
if (index < 0 || index >= myWraps.size()) {
|
||||
return null;
|
||||
}
|
||||
return myWraps.remove(index);
|
||||
TextChangeImpl removed = myWraps.remove(index);
|
||||
notifyListenersAboutRemoval();
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,6 +132,7 @@ public class SoftWrapsStorage {
|
||||
*/
|
||||
public void removeAll() {
|
||||
myWraps.clear();
|
||||
notifyListenersAboutRemoval();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,4 +144,10 @@ public class SoftWrapsStorage {
|
||||
public boolean addSoftWrapChangeListener(@NotNull SoftWrapChangeListener listener) {
|
||||
return myListeners.add(listener);
|
||||
}
|
||||
|
||||
private void notifyListenersAboutRemoval() {
|
||||
for (SoftWrapChangeListener listener : myListeners) {
|
||||
listener.softWrapsRemoved();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
throw new Exception(myCancelRequest);
|
||||
}
|
||||
|
||||
waitFor.assertCompleted("Tree cleanup was not performed");
|
||||
waitFor.assertCompleted("Tree cleanup was not performed. isCancelledReadyState=" + getBuilder().getUi().isCancelledReady());
|
||||
|
||||
Assert.assertTrue(getMyBuilder().myWasCleanedUp);
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
|
||||
|
||||
public void testClear() throws Exception {
|
||||
getBuilder().getUi().setClearOnHideDelay(10 * Time.SECOND);
|
||||
getBuilder().getUi().setClearOnHideDelay(1 * Time.SECOND);
|
||||
|
||||
buildStructure(myRoot);
|
||||
|
||||
@@ -2079,11 +2079,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testDeferredSelection() throws Exception {
|
||||
super.testDeferredSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNodeDescriptorUpdateDelay() {
|
||||
return 300;
|
||||
|
||||
@@ -66,6 +66,9 @@
|
||||
serviceImplementation="com.intellij.ide.util.PlatformModuleRendererFactory"/>
|
||||
<projectService serviceInterface="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable$Factory"
|
||||
serviceImplementation="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable$Factory"/>
|
||||
<projectService serviceInterface="com.intellij.lang.injection.InjectedLanguageManager"
|
||||
serviceImplementation="com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl"/>
|
||||
|
||||
|
||||
<refactoring.copyHandler implementation="com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler"/>
|
||||
<refactoring.moveHandler implementation="com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesHandler" id="moveFileOrDir"/>
|
||||
|
||||
@@ -189,11 +189,6 @@
|
||||
<skipForDefaultProject/>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.lang.injection.InjectedLanguageManager</interface-class>
|
||||
<implementation-class>com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.pom.wrappers.PsiEventWrapperAspect</interface-class>
|
||||
<implementation-class>com.intellij.pom.wrappers.PsiEventWrapperAspect</implementation-class>
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<group id="InspectCodeGroup">
|
||||
<separator/>
|
||||
<action id="InspectCode" class="com.intellij.codeInspection.actions.CodeInspectionAction"/>
|
||||
<action id="ViewOfflineInspection" class="com.intellij.codeInspection.actions.ViewOfflineResultsAction"/>
|
||||
|
||||
<add-to-group group-id="CodeMenu" anchor="last"/>
|
||||
</group>
|
||||
|
||||
+5
-2
@@ -16,6 +16,7 @@
|
||||
package com.intellij.execution.testframework.sm;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.CommandLineState;
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
@@ -131,16 +132,18 @@ public class SMTestRunnerConnectionUtil {
|
||||
* @param processHandler Process handler
|
||||
* @param commandLineState Command line state
|
||||
* @param config User run configuration settings
|
||||
* @param executor Executor
|
||||
* @return Console view
|
||||
* @throws ExecutionException If IDEA cannot execute process this Exception will
|
||||
* be caught and shown in error message box
|
||||
*/
|
||||
public static ConsoleView attachRunner(@NotNull final String testFrameworkName, @NotNull final ProcessHandler processHandler,
|
||||
@NotNull final CommandLineState commandLineState,
|
||||
@NotNull final RuntimeConfiguration config
|
||||
@NotNull final RuntimeConfiguration config,
|
||||
@NotNull final Executor executor
|
||||
) throws ExecutionException {
|
||||
// final String testFrameworkName
|
||||
final TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName);
|
||||
final TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor);
|
||||
|
||||
return attachRunner(testFrameworkName, processHandler, consoleProperties,
|
||||
commandLineState.getRunnerSettings(),
|
||||
|
||||
+6
-31
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.util.config.Storage;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author: Roman Chernyatchik
|
||||
@@ -32,40 +30,17 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties {
|
||||
/**
|
||||
* @param config
|
||||
* @param testFrameworkName Prefix for storage which keeps runner settings. E.g. "RubyTestUnit"
|
||||
* @param executor
|
||||
*/
|
||||
public SMTRunnerConsoleProperties(final RuntimeConfiguration config,
|
||||
final String testFrameworkName)
|
||||
final String testFrameworkName,
|
||||
Executor executor)
|
||||
{
|
||||
super(new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()), config.getProject());
|
||||
super(new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()), config.getProject(),
|
||||
executor);
|
||||
myConfiguration = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return getDebugSession() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
final XDebugSession debuggerSession = getDebugSession();
|
||||
return debuggerSession != null && debuggerSession.isPaused();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public XDebugSession getDebugSession() {
|
||||
final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(getProject());
|
||||
if (debuggerManager == null) {
|
||||
return null;
|
||||
}
|
||||
final XDebugSession[] sessions = debuggerManager.getDebugSessions();
|
||||
for (final XDebugSession debuggerSession : sessions) {
|
||||
if (getConsole() == debuggerSession.getRunContentDescriptor().getExecutionConsole()) {
|
||||
return debuggerSession;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RuntimeConfiguration getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
@@ -86,7 +87,7 @@ public abstract class BaseSMTRunnerTestCase extends LightPlatformTestCase {
|
||||
protected TestConsoleProperties createConsoleProperties() {
|
||||
final RuntimeConfiguration runConfiguration = createRunConfiguration();
|
||||
|
||||
final TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, "SMRunnerTests");
|
||||
final TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, "SMRunnerTests", DefaultDebugExecutor.getDebugExecutorInstance());
|
||||
TestConsoleProperties.HIDE_PASSED_TESTS.set(consoleProperties, false);
|
||||
|
||||
return consoleProperties;
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner.ui;
|
||||
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import com.intellij.execution.testframework.PoolOfTestIcons;
|
||||
import com.intellij.execution.testframework.sm.UITestUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
|
||||
@@ -638,7 +639,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
public MyRenderer(final boolean isPaused,
|
||||
final UITestUtil.FragmentsContainer fragmentsContainer) {
|
||||
super(new SMTRunnerConsoleProperties(createRunConfiguration(), "SMRunnerTests") {
|
||||
super(new SMTRunnerConsoleProperties(createRunConfiguration(), "SMRunnerTests", DefaultDebugExecutor.getDebugExecutorInstance()) {
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return isPaused;
|
||||
|
||||
+14
-3
@@ -20,7 +20,9 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.util.StoringPropertyContainer;
|
||||
@@ -31,6 +33,8 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.config.BooleanProperty;
|
||||
import com.intellij.util.config.Storage;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -46,14 +50,16 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
public static final BooleanProperty SHOW_STATISTICS = new BooleanProperty("showStatistics", false);
|
||||
|
||||
private final Project myProject;
|
||||
private final Executor myExecutor;
|
||||
private ConsoleView myConsole;
|
||||
|
||||
protected final HashMap<AbstractProperty, ArrayList<TestFrameworkPropertyListener>> myListeners =
|
||||
new HashMap<AbstractProperty, ArrayList<TestFrameworkPropertyListener>>();
|
||||
|
||||
public TestConsoleProperties(final Storage storage, Project project) {
|
||||
public TestConsoleProperties(final Storage storage, Project project, Executor executor) {
|
||||
super(storage);
|
||||
myProject = project;
|
||||
myExecutor = executor;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
@@ -92,9 +98,14 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean isDebug();
|
||||
public boolean isDebug() {
|
||||
return myExecutor.getId() == DefaultDebugExecutor.EXECUTOR_ID;
|
||||
}
|
||||
|
||||
public abstract boolean isPaused();
|
||||
public boolean isPaused() {
|
||||
final XDebugSession debuggerSession = XDebuggerManager.getInstance(myProject).getDebugSession(getConsole());
|
||||
return debuggerSession != null && debuggerSession.isPaused();
|
||||
}
|
||||
|
||||
protected <T> void onPropertyChanged(final AbstractProperty<T> property, final T value) {
|
||||
final ArrayList<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<orderEntry type="module" module-name="platform-api" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="xdebugger-api" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class NameUtil {
|
||||
firstIdentifierLetter = true;
|
||||
}
|
||||
else {
|
||||
if (prevIsUppercase) {
|
||||
if (c == ':' || prevIsUppercase) {
|
||||
buffer.append("[A-Za-z\\s0-9\\$]*");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.xdebugger;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointManager;
|
||||
@@ -43,6 +44,9 @@ public abstract class XDebuggerManager {
|
||||
@NotNull
|
||||
public abstract XDebugSession[] getDebugSessions();
|
||||
|
||||
@Nullable
|
||||
public abstract XDebugSession getDebugSession(@NotNull ExecutionConsole executionConsole);
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends XDebugProcess> Collection<? extends T> getDebugProcesses(Class<T> processClass);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.xdebugger.frame;
|
||||
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
@@ -66,6 +67,7 @@ public abstract class XStackFrame extends XValueContainer {
|
||||
public void customizePresentation(final SimpleColoredComponent component) {
|
||||
XSourcePosition position = getSourcePosition();
|
||||
if (position != null) {
|
||||
//FileColorManager.getInstance()
|
||||
component.append(position.getFile().getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
component.append(":" + (position.getLine()+1), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
component.setIcon(DebuggerIcons.STACK_FRAME_ICON);
|
||||
|
||||
@@ -21,26 +21,27 @@ import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentListener;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.xdebugger.*;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
|
||||
import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter;
|
||||
@@ -208,6 +209,17 @@ public class XDebuggerManagerImpl extends XDebuggerManager
|
||||
return mySessions.toArray(new XDebugSession[mySessions.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public XDebugSession getDebugSession(@NotNull ExecutionConsole executionConsole) {
|
||||
for (final XDebugSession debuggerSession : getDebugSessions()) {
|
||||
if (executionConsole == debuggerSession.getRunContentDescriptor().getExecutionConsole()) {
|
||||
return debuggerSession;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends XDebugProcess> Collection<? extends T> getDebugProcesses(Class<T> processClass) {
|
||||
|
||||
+8
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.xdebugger.impl.frame;
|
||||
|
||||
import com.intellij.ide.OccurenceNavigator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
|
||||
@@ -27,8 +28,14 @@ import javax.swing.event.ListSelectionListener;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class DebuggerFramesList extends JBList implements OccurenceNavigator {
|
||||
public DebuggerFramesList() {
|
||||
protected final Project myProject;
|
||||
|
||||
public DebuggerFramesList(Project project) {
|
||||
super(new DefaultListModel());
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
protected void doInit() {
|
||||
getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
setCellRenderer(createListRenderer());
|
||||
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
|
||||
+30
-1
@@ -15,12 +15,18 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.frame;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -28,8 +34,13 @@ import javax.swing.*;
|
||||
public class XDebuggerFramesList extends DebuggerFramesList {
|
||||
private XStackFrame mySelectedFrame;
|
||||
|
||||
public XDebuggerFramesList(Project project) {
|
||||
super(project);
|
||||
doInit();
|
||||
}
|
||||
|
||||
protected ListCellRenderer createListRenderer() {
|
||||
return new XDebuggerFrameListRenderer();
|
||||
return new XDebuggerFrameListRenderer(myProject);
|
||||
}
|
||||
|
||||
protected void onFrameChanged(final Object selectedValue) {
|
||||
@@ -49,6 +60,14 @@ public class XDebuggerFramesList extends DebuggerFramesList {
|
||||
}
|
||||
|
||||
private static class XDebuggerFrameListRenderer extends ColoredListCellRenderer {
|
||||
private final FileColorManager myColorsManager;
|
||||
private final PsiManager myPsiManager;
|
||||
|
||||
public XDebuggerFrameListRenderer(Project project) {
|
||||
myPsiManager = PsiManager.getInstance(project);
|
||||
myColorsManager = FileColorManager.getInstance(project);
|
||||
}
|
||||
|
||||
protected void customizeCellRenderer(final JList list,
|
||||
final Object value,
|
||||
final int index,
|
||||
@@ -64,6 +83,16 @@ public class XDebuggerFramesList extends DebuggerFramesList {
|
||||
}
|
||||
|
||||
XStackFrame stackFrame = (XStackFrame)value;
|
||||
if (!selected) {
|
||||
XSourcePosition position = stackFrame.getSourcePosition();
|
||||
if (position != null) {
|
||||
PsiFile f = myPsiManager.findFile(position.getFile());
|
||||
if (f != null) {
|
||||
Color c = myColorsManager.getFileColor(f);
|
||||
if (c != null) setBackground(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
stackFrame.customizePresentation(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class XFramesView extends XDebugViewBase {
|
||||
myThreadComboBox.addItemListener(new MyItemListener());
|
||||
myMainPanel.add(myThreadComboBox, BorderLayout.NORTH);
|
||||
|
||||
myFramesList = new XDebuggerFramesList();
|
||||
myFramesList = new XDebuggerFramesList(session.getProject());
|
||||
myFramesList.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(final ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) return;
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
def field
|
||||
|
||||
def Foo(<spot>def field</spot>) {
|
||||
<spot>this.field = field</spot>
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
def field
|
||||
|
||||
def Foo() {
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<span style="font-family: verdana,serif; font-size: small;">This intention adds parameter to constructor for uninitialized field</span>
|
||||
</body>
|
||||
</html>
|
||||
@@ -85,6 +85,7 @@
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editorNotificationProvider implementation="org.jetbrains.plugins.groovy.annotator.ConfigureGroovyLibraryNotificationProvider"/>
|
||||
<refactoring.introduceParameterMethodUsagesProcessor implementation="org.jetbrains.plugins.groovy.refactoring.introduceParameter.java2groovy.GroovyIntroduceParameterMethodUsagesProcessor"/>
|
||||
<refactoring.changeSignatureUsageProcessor implementation="org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureUsageProcessor" id="groovyProcessor" order="before javaProcessor"/>
|
||||
|
||||
@@ -285,6 +286,11 @@
|
||||
<categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
|
||||
<className>org.jetbrains.plugins.groovy.intentions.control.DemorgansLawIntention</className>
|
||||
</intentionAction>
|
||||
<intentionAction>
|
||||
<bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
|
||||
<categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
|
||||
<className>org.jetbrains.plugins.groovy.intentions.control.CreateParameterForFieldIntention</className>
|
||||
</intentionAction>
|
||||
<intentionAction>
|
||||
<bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
|
||||
<categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
|
||||
|
||||
@@ -339,3 +339,5 @@ method.duplicate=Method with signature {0} is already defined in the class ''{1}
|
||||
ambiguous.code.block=Ambiguous code block
|
||||
cyclic.inheritance.involving.0=Cyclic inheritance involving ''{0}''
|
||||
there.is.no.default.constructor.available.in.class.0=There is no default constructor available in class ''{0}''
|
||||
groovy.library.is.not.configured.for.module=Groovy SDK is not configured for module ''{0}''
|
||||
configure.groovy.library=Configure Groovy SDK...
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.ide.util.frameworkSupport.AddFrameworkSupportDialog;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import com.intellij.ui.EditorNotifications;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class ConfigureGroovyLibraryNotificationProvider implements EditorNotifications.Provider<EditorNotificationPanel> {
|
||||
private static final Key<EditorNotificationPanel> KEY = Key.create("configure.groovy.library");
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public ConfigureGroovyLibraryNotificationProvider(Project project, final EditorNotifications notifications) {
|
||||
myProject = project;
|
||||
project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@Override
|
||||
public void beforeRootsChange(ModuleRootEvent event) {}
|
||||
|
||||
@Override
|
||||
public void rootsChanged(ModuleRootEvent event) {
|
||||
notifications.updateAllNotifications();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file) {
|
||||
if (file.getFileType() != GroovyFileType.GROOVY_FILE_TYPE) return null;
|
||||
|
||||
final Module module = ModuleUtil.findModuleForFile(file, myProject);
|
||||
if (module == null) return null;
|
||||
|
||||
final Library[] libraries = GroovyConfigUtils.getInstance().getSDKLibrariesByModule(module);
|
||||
if (libraries.length > 0) return null;
|
||||
|
||||
final EditorNotificationPanel panel = new EditorNotificationPanel();
|
||||
panel.setText(GroovyBundle.message("groovy.library.is.not.configured.for.module", module.getName()));
|
||||
panel.createActionLabel(GroovyBundle.message("configure.groovy.library"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AddFrameworkSupportDialog dialog = AddFrameworkSupportDialog.createDialog(module);
|
||||
if (dialog != null) {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatem
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.GroovyExpectedTypesProvider;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
@@ -441,6 +442,22 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
|
||||
@Override
|
||||
public void visitListOrMap(GrListOrMap listOrMap) {
|
||||
for (PsiType type : GroovyExpectedTypesProvider.getDefaultExpectedTypes(listOrMap)) {
|
||||
if (type instanceof PsiClassType &&
|
||||
!type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) &&
|
||||
!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE) &&
|
||||
!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
final PsiElement startToken = listOrMap.getFirstChild();
|
||||
if (startToken != null && startToken.getNode().getElementType() == GroovyTokenTypes.mLBRACK) {
|
||||
myHolder.createInfoAnnotation(startToken, null).setTextAttributes(DefaultHighlighter.LITERAL_CONVERSION);
|
||||
}
|
||||
final PsiElement endToken = listOrMap.getLastChild();
|
||||
if (endToken != null && endToken.getNode().getElementType() == GroovyTokenTypes.mRBRACK) {
|
||||
myHolder.createInfoAnnotation(endToken, null).setTextAttributes(DefaultHighlighter.LITERAL_CONVERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MultiMap<String, GrNamedArgument> map = new MultiMap<String, GrNamedArgument>();
|
||||
|
||||
for (GrNamedArgument element : listOrMap.getNamedArguments()) {
|
||||
|
||||
@@ -103,7 +103,6 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
|
||||
final JavaParameters parameters = new JavaParameters();
|
||||
final PathsList classPathBuilder = parameters.getClassPath();
|
||||
classPathBuilder.add(PathUtil.getJarPathForClass(GroovycRunner.class));
|
||||
|
||||
final ModuleChunk chunk = createChunk(module, compileContext);
|
||||
|
||||
@@ -119,6 +118,8 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
appendOutputPath(module, classPathBuilder, true);
|
||||
}
|
||||
|
||||
classPathBuilder.add(PathUtil.getJarPathForClass(GroovycRunner.class));
|
||||
|
||||
final List<String> patchers = new SmartList<String>();
|
||||
for (final GroovyCompilerExtension extension : GroovyCompilerExtension.EP_NAME.getExtensions()) {
|
||||
extension.enhanceCompilationClassPath(chunk, classPathBuilder);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GroovyCompilerLoader extends AbstractProjectComponent {
|
||||
compilerManager.addCompilableFileType(GroovyFileType.GROOVY_FILE_TYPE);
|
||||
|
||||
compilerManager.addTranslatingCompiler(new GroovycStubGenerator(myProject),
|
||||
new HashSet<FileType>(Arrays.asList(GroovyFileType.GROOVY_FILE_TYPE)),
|
||||
new HashSet<FileType>(Arrays.asList(StdFileTypes.JAVA, GroovyFileType.GROOVY_FILE_TYPE)),
|
||||
new HashSet<FileType>(Arrays.asList(StdFileTypes.JAVA)));
|
||||
|
||||
compilerManager.addTranslatingCompiler(new GroovyCompiler(myProject),
|
||||
|
||||
+21
-37
@@ -589,17 +589,7 @@ public class GroovyToJavaGenerator {
|
||||
/************* parameters **********/
|
||||
GrParameter[] parameterList = constructor.getParameters();
|
||||
|
||||
text.append("(");
|
||||
|
||||
for (int i = 0; i < parameterList.length; i++) {
|
||||
if (i > 0) text.append(", ");
|
||||
|
||||
GrParameter parameter = parameterList[i];
|
||||
|
||||
text.append(getTypeText(parameter.getTypeElementGroovy())).append(" ").append(parameter.getName());
|
||||
}
|
||||
|
||||
text.append(") ");
|
||||
writeParameterList(text, parameterList);
|
||||
|
||||
final Set<String> throwsTypes = collectThrowsTypes(constructor, new THashSet<PsiMethod>());
|
||||
if (!throwsTypes.isEmpty()) {
|
||||
@@ -684,7 +674,8 @@ public class GroovyToJavaGenerator {
|
||||
}
|
||||
|
||||
private static void writeVariableDeclarations(StringBuffer text, GrVariableDeclaration variableDeclaration) {
|
||||
final String type = getTypeText(variableDeclaration.getTypeElementGroovy());
|
||||
GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
|
||||
final String type = typeElement == null ? CommonClassNames.JAVA_LANG_OBJECT : getTypeText(typeElement.getType(), typeElement, false);
|
||||
final String initializer = getDefaultValueText(type);
|
||||
|
||||
final GrModifierList modifierList = variableDeclaration.getModifierList();
|
||||
@@ -728,11 +719,27 @@ public class GroovyToJavaGenerator {
|
||||
text.append(getTypeText(retType, method, false));
|
||||
text.append(" ");
|
||||
|
||||
//append method name
|
||||
text.append(name);
|
||||
|
||||
/************* parameters **********/
|
||||
writeParameterList(text, parameters);
|
||||
|
||||
if (!isAbstract) {
|
||||
/************* body **********/
|
||||
text.append("{\n");
|
||||
text.append(" return ");
|
||||
|
||||
text.append(getDefaultValueText(getTypeText(retType, method, false)));
|
||||
|
||||
text.append(";");
|
||||
|
||||
text.append("\n }");
|
||||
} else {
|
||||
text.append(";");
|
||||
}
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
private static void writeParameterList(StringBuffer text, PsiParameter[] parameters) {
|
||||
text.append("(");
|
||||
|
||||
//writes myParameters
|
||||
@@ -751,21 +758,6 @@ public class GroovyToJavaGenerator {
|
||||
}
|
||||
text.append(")");
|
||||
text.append(" ");
|
||||
|
||||
if (!isAbstract) {
|
||||
/************* body **********/
|
||||
text.append("{\n");
|
||||
text.append(" return ");
|
||||
|
||||
text.append(getDefaultValueText(getTypeText(retType, method, false)));
|
||||
|
||||
text.append(";");
|
||||
|
||||
text.append("\n }");
|
||||
} else {
|
||||
text.append(";");
|
||||
}
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
private static boolean writeMethodModifiers(StringBuffer text, PsiModifierList modifierList, String[] modifiers) {
|
||||
@@ -813,14 +805,6 @@ public class GroovyToJavaGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getTypeText(GrTypeElement typeElement) {
|
||||
if (typeElement == null) {
|
||||
return CommonClassNames.JAVA_LANG_OBJECT;
|
||||
}
|
||||
|
||||
return getTypeText(typeElement.getType(), typeElement, false);
|
||||
}
|
||||
|
||||
private static String getTypeText(@Nullable PsiType type, @Nullable PsiElement context, boolean allowVarargs) {
|
||||
if (context != null && type instanceof PsiClassType) {
|
||||
final String accessible = findAccessibleSuperClass(context, ((PsiClassType)type).resolve());
|
||||
|
||||
+19
-22
@@ -24,10 +24,10 @@ import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompilerPaths;
|
||||
import com.intellij.openapi.compiler.ex.CompileContextEx;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -62,18 +62,21 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
|
||||
@Override
|
||||
public void compile(CompileContext compileContext, Chunk<Module> moduleChunk, VirtualFile[] virtualFiles, OutputSink sink) {
|
||||
final CompileScope scope = compileContext.getCompileScope();
|
||||
final VirtualFile[] javaFiles = scope.getFiles(StdFileTypes.JAVA, true);
|
||||
if (javaFiles.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasJava = false;
|
||||
for (VirtualFile javaFile : javaFiles) {
|
||||
final Module module = ModuleUtil.findModuleForFile(javaFile, myProject);
|
||||
if (module != null && moduleChunk.containsNode(module)) {
|
||||
|
||||
final ExcludedEntriesConfiguration excluded = GroovyCompilerConfiguration.getExcludeConfiguration(myProject);
|
||||
|
||||
List<VirtualFile> total = new ArrayList<VirtualFile>();
|
||||
for (final VirtualFile virtualFile : virtualFiles) {
|
||||
final FileType fileType = virtualFile.getFileType();
|
||||
if (fileType == StdFileTypes.JAVA) {
|
||||
hasJava = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!excluded.isExcluded(virtualFile)) {
|
||||
if (fileType == GroovyFileType.GROOVY_FILE_TYPE) {
|
||||
total.add(virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,17 +84,6 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
return;
|
||||
}
|
||||
|
||||
final ExcludedEntriesConfiguration excluded = GroovyCompilerConfiguration.getExcludeConfiguration(myProject);
|
||||
|
||||
List<VirtualFile> total = new ArrayList<VirtualFile>();
|
||||
for (final VirtualFile virtualFile : virtualFiles) {
|
||||
if (!excluded.isExcluded(virtualFile)) {
|
||||
if (virtualFile.getFileType() == GroovyFileType.GROOVY_FILE_TYPE) {
|
||||
total.add(virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -99,6 +91,11 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
super.compile(compileContext, moduleChunk, VfsUtil.toVirtualFileArray(total), sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompilableFile(VirtualFile file, CompileContext context) {
|
||||
return super.isCompilableFile(file, context) || StdFileTypes.JAVA.equals(file.getFileType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void compileFiles(CompileContext compileContext, Module module,
|
||||
final List<VirtualFile> toCompile, OutputSink sink, boolean tests) {
|
||||
|
||||
+49
-98
@@ -15,18 +15,13 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.findUsages;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.TextOccurenceProcessor;
|
||||
import com.intellij.psi.search.UsageSearchContext;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.QueryExecutor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.util.GroovyPropertyUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
@@ -34,125 +29,81 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrAliasedImportedElementSearcher implements QueryExecutor<PsiReference, ReferencesSearch.SearchParameters> {
|
||||
private static final ThreadLocal<Object> I_WAS_HERE = new ThreadLocal<Object>();
|
||||
public class GrAliasedImportedElementSearcher extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
|
||||
|
||||
public boolean execute(final ReferencesSearch.SearchParameters parameters, final Processor<PsiReference> consumer) {
|
||||
final PsiElement elementToSearch = parameters.getElementToSearch();
|
||||
if (!(elementToSearch instanceof PsiMember)) return true;
|
||||
if (I_WAS_HERE.get() != null) return true;
|
||||
public GrAliasedImportedElementSearcher() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
try {
|
||||
I_WAS_HERE.set(Boolean.TRUE);
|
||||
final TextOccurenceProcessor processor = new MyTextOccurenceProcessor(elementToSearch, consumer);
|
||||
@Override
|
||||
public void processQuery(ReferencesSearch.SearchParameters parameters, Processor<PsiReference> consumer) {
|
||||
final PsiElement target = parameters.getElementToSearch();
|
||||
if (!(target instanceof PsiMember) || !(target instanceof PsiNamedElement)) return;
|
||||
|
||||
final SearchScope groovySearchScope = PsiUtil.restrictScopeToGroovyFiles(new Computable<SearchScope>() {
|
||||
public SearchScope compute() {
|
||||
return parameters.getEffectiveSearchScope();
|
||||
}
|
||||
});
|
||||
final String name = ((PsiNamedElement)target).getName();
|
||||
if (name == null) return;
|
||||
|
||||
if (!ReferencesSearch.search(elementToSearch, groovySearchScope).forEach(new MyProcessor(null, processor))) return false;
|
||||
final SearchScope onlyGroovy = PsiUtil.restrictScopeToGroovyFiles(parameters.getEffectiveSearchScope());
|
||||
|
||||
if (elementToSearch instanceof PsiMethod && isAccessor(elementToSearch)) {
|
||||
final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
|
||||
public PsiField compute() {
|
||||
return GroovyPropertyUtils.findFieldForAccessor((PsiMethod)elementToSearch, true);
|
||||
}
|
||||
});
|
||||
if (target instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)target;
|
||||
if (GroovyPropertyUtils.isSimplePropertyAccessor(method)) {
|
||||
final PsiField field = GroovyPropertyUtils.findFieldForAccessor(method, true);
|
||||
if (field != null) {
|
||||
final String prefix = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
public String compute() {
|
||||
return GroovyPropertyUtils.getAccessorPrefix((PsiMethod)elementToSearch);
|
||||
}
|
||||
});
|
||||
if (prefix == null) return true;
|
||||
if (!ReferencesSearch.search(field, groovySearchScope).forEach(new MyProcessor(prefix, processor))) return false;
|
||||
final String propertyName = field.getName();
|
||||
if (propertyName != null) {
|
||||
final MyProcessor processor = new MyProcessor(method, GroovyPropertyUtils.getAccessorPrefix(method));
|
||||
parameters.getOptimizer().searchWord(propertyName, onlyGroovy, UsageSearchContext.IN_CODE, true, processor);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
I_WAS_HERE.set(null);
|
||||
}
|
||||
|
||||
parameters.getOptimizer().searchWord(name, onlyGroovy, UsageSearchContext.IN_CODE, true, new MyProcessor(target, null));
|
||||
|
||||
}
|
||||
|
||||
private static Boolean isAccessor(final PsiElement elementToSearch) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
return GroovyPropertyUtils.isSimplePropertyAccessor((PsiMethod)elementToSearch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static class MyProcessor implements Processor<PsiReference> {
|
||||
private static class MyProcessor extends RequestResultProcessor {
|
||||
private final PsiElement myTarget;
|
||||
private final String prefix;
|
||||
private final TextOccurenceProcessor processor;
|
||||
|
||||
MyProcessor(@Nullable String prefix, TextOccurenceProcessor processor) {
|
||||
MyProcessor(PsiElement target, @Nullable String prefix) {
|
||||
myTarget = target;
|
||||
this.prefix = prefix;
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
public boolean process(PsiReference psiReference) {
|
||||
final PsiElement element = psiReference.getElement();
|
||||
if (element == null) return true;
|
||||
|
||||
@Override
|
||||
public boolean processTextOccurrence(final PsiElement element, int offsetInElement, Processor<PsiReference> consumer) {
|
||||
String alias = getAlias(element);
|
||||
if (alias == null) return true;
|
||||
|
||||
final PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
|
||||
public PsiFile compute() {
|
||||
return element.getContainingFile();
|
||||
}
|
||||
});
|
||||
final PsiReference reference = element.getReference();
|
||||
if (reference == null) {
|
||||
return true;
|
||||
}
|
||||
if (!reference.isReferenceTo(myTarget instanceof GrAccessorMethod ? ((GrAccessorMethod)myTarget).getProperty() : myTarget)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final SearchRequestCollector collector = new SearchRequestCollector();
|
||||
final SearchScope fileScope = new LocalSearchScope(element.getContainingFile());
|
||||
collector.searchWord(alias, fileScope, UsageSearchContext.IN_CODE, true, myTarget);
|
||||
if (prefix != null) {
|
||||
if (!PsiManager.getInstance(element.getProject()).getSearchHelper()
|
||||
.processElementsWithWord(processor, GlobalSearchScope.fileScope(containingFile), prefix + GroovyPropertyUtils.capitalize(alias),
|
||||
UsageSearchContext.IN_CODE,
|
||||
false)) {
|
||||
return false;
|
||||
}
|
||||
collector.searchWord(prefix + GroovyPropertyUtils.capitalize(alias), fileScope, UsageSearchContext.IN_CODE, true, myTarget);
|
||||
}
|
||||
|
||||
return PsiManager.getInstance(element.getProject()).getSearchHelper()
|
||||
.processElementsWithWord(processor, GlobalSearchScope.fileScope(containingFile), alias, UsageSearchContext.IN_CODE, false);
|
||||
|
||||
return element.getManager().getSearchHelper().processRequests(collector, consumer);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getAlias(final PsiElement element) {
|
||||
return ApplicationManager.getApplication().runReadAction(new NullableComputable<String>() {
|
||||
public String compute() {
|
||||
if (!(element.getParent() instanceof GrImportStatement)) return null;
|
||||
final GrImportStatement importStatement = (GrImportStatement)element.getParent();
|
||||
if (!importStatement.isAliasedImport()) return null;
|
||||
return importStatement.getImportedName();
|
||||
}
|
||||
});
|
||||
if (!(element.getParent() instanceof GrImportStatement)) return null;
|
||||
final GrImportStatement importStatement = (GrImportStatement)element.getParent();
|
||||
if (!importStatement.isAliasedImport()) return null;
|
||||
return importStatement.getImportedName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class MyTextOccurenceProcessor implements TextOccurenceProcessor {
|
||||
private final PsiElement elementToSearch;
|
||||
private final Processor<PsiReference> consumer;
|
||||
|
||||
public MyTextOccurenceProcessor(PsiElement elementToSearch, Processor<PsiReference> consumer) {
|
||||
this.elementToSearch = elementToSearch;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public boolean execute(PsiElement element, int offsetInElement) {
|
||||
final PsiReference[] refs = element.getParent().getReferences();
|
||||
for (PsiReference ref : refs) {
|
||||
if (ReferenceRange.containsOffsetInElement(ref, offsetInElement)) {
|
||||
if (ref.isReferenceTo(elementToSearch)) {
|
||||
return consumer.process(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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.findUsages;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightMemberReference;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.DirectClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
* Date: May 2, 2009 3:48:53 PM
|
||||
*/
|
||||
public class GroovyConstructorUsagesSearchHelper {
|
||||
private GroovyConstructorUsagesSearchHelper() {
|
||||
}
|
||||
|
||||
public static boolean execute(final PsiMethod constructor, SearchScope searchScope, final Processor<PsiReference> consumer) {
|
||||
if (!constructor.isConstructor()) return true;
|
||||
|
||||
if (searchScope instanceof GlobalSearchScope) {
|
||||
searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, GroovyFileType.GROOVY_FILE_TYPE);
|
||||
}
|
||||
|
||||
final PsiClass clazz = ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiClass>() {
|
||||
public PsiClass compute() {
|
||||
return constructor.getContainingClass();
|
||||
}
|
||||
});
|
||||
if (clazz == null) return true;
|
||||
|
||||
|
||||
//enum constants
|
||||
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
if (!clazz.isEnum()) return true;
|
||||
if (!(clazz instanceof GroovyPsiElement)) return true;
|
||||
final PsiField[] fields = clazz.getFields();
|
||||
for (PsiField field : fields) {
|
||||
if (field instanceof GrEnumConstant) {
|
||||
final PsiReference ref = field.getReference();
|
||||
if (ref.isReferenceTo(constructor)) {
|
||||
if (!consumer.process(ref)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ReferencesSearch.search(clazz, searchScope, true).forEach(new ReadActionProcessor<PsiReference>() {
|
||||
@Override
|
||||
public boolean processInReadAction(PsiReference ref) {
|
||||
final PsiElement element = ref.getElement();
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
GrNewExpression newExpression = null;
|
||||
if (element.getParent() instanceof GrNewExpression) {
|
||||
newExpression = (GrNewExpression)element.getParent();
|
||||
}
|
||||
else if (element.getParent() instanceof GrAnonymousClassDefinition) {
|
||||
newExpression = (GrNewExpression)element.getParent().getParent();
|
||||
}
|
||||
if (newExpression != null) {
|
||||
final PsiMethod resolvedConstructor = newExpression.resolveConstructor();
|
||||
final PsiManager manager = constructor.getManager();
|
||||
if (manager.areElementsEquivalent(resolvedConstructor, constructor) && !consumer.process(ref)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//this()
|
||||
if (clazz instanceof GrTypeDefinition) {
|
||||
if (!processConstructors(constructor, consumer, clazz, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//super : does not work now, need to invent a way for it to work without repository
|
||||
if (!DirectClassInheritorsSearch.search(clazz, searchScope).forEach(new Processor<PsiClass>() {
|
||||
public boolean process(PsiClass inheritor) {
|
||||
if (inheritor instanceof GrTypeDefinition) {
|
||||
if (!processConstructors(constructor, consumer, inheritor, false)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean processConstructors(final PsiMethod constructor, final Processor<PsiReference> consumer, final PsiClass clazz,
|
||||
final boolean processThisRefs) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
return processClassConstructors(clazz, constructor, consumer, processThisRefs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean processClassConstructors(PsiClass clazz,
|
||||
PsiMethod searchedConstructor,
|
||||
Processor<PsiReference> consumer,
|
||||
boolean processThisRefs) {
|
||||
final PsiMethod[] constructors = clazz.getConstructors();
|
||||
if (constructors.length == 0) {
|
||||
processImplicitConstructorCall(clazz, consumer, searchedConstructor);
|
||||
}
|
||||
for (PsiMethod constructor : constructors) {
|
||||
final GrOpenBlock block = ((GrMethod)constructor).getBlock();
|
||||
if (block != null) {
|
||||
final GrStatement[] statements = block.getStatements();
|
||||
if (statements.length > 0 && statements[0] instanceof GrConstructorInvocation) {
|
||||
final GrConstructorInvocation invocation = (GrConstructorInvocation)statements[0];
|
||||
if (invocation.isThisCall() == processThisRefs &&
|
||||
invocation.getManager().areElementsEquivalent(invocation.resolveConstructor(), searchedConstructor) &&
|
||||
!consumer.process(invocation.getThisOrSuperKeyword())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
processImplicitConstructorCall(constructor, consumer, searchedConstructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void processImplicitConstructorCall(final PsiMember usage,
|
||||
final Processor<PsiReference> processor,
|
||||
final PsiMethod constructor) {
|
||||
if (constructor instanceof GrMethod) {
|
||||
GrParameter[] grParameters = (GrParameter[])constructor.getParameterList().getParameters();
|
||||
if (grParameters.length > 0 && !grParameters[0].isOptional()) return;
|
||||
}
|
||||
else if (constructor.getParameterList().getParameters().length > 0) return;
|
||||
|
||||
|
||||
PsiManager manager = constructor.getManager();
|
||||
if (manager.areElementsEquivalent(usage, constructor) || manager.areElementsEquivalent(constructor.getContainingClass(), usage.getContainingClass())) return;
|
||||
processor.process(new LightMemberReference(manager, usage, PsiSubstitutor.EMPTY) {
|
||||
public PsiElement getElement() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public TextRange getRangeInElement() {
|
||||
if (usage instanceof PsiClass) {
|
||||
PsiIdentifier identifier = ((PsiClass)usage).getNameIdentifier();
|
||||
if (identifier != null) return TextRange.from(identifier.getStartOffsetInParent(), identifier.getTextLength());
|
||||
}
|
||||
else if (usage instanceof PsiMethod) {
|
||||
PsiIdentifier identifier = ((PsiMethod)usage).getNameIdentifier();
|
||||
if (identifier != null) return TextRange.from(identifier.getStartOffsetInParent(), identifier.getTextLength());
|
||||
}
|
||||
return super.getRangeInElement();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
+87
-92
@@ -16,12 +16,10 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.findUsages;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -49,7 +47,6 @@ import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
|
||||
import org.jetbrains.plugins.groovy.gpp.GppTypeConverter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
@@ -67,7 +64,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.GroovyExpectedTypesProvider;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -90,10 +86,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
static void processConstructorUsages(final PsiMethod constructor, final SearchScope searchScope, final Processor<PsiReference> consumer, final SearchRequestCollector collector, final boolean searchGppCalls) {
|
||||
if (!constructor.isConstructor()) return;
|
||||
|
||||
SearchScope onlyGroovy = searchScope;
|
||||
if (onlyGroovy instanceof GlobalSearchScope) {
|
||||
onlyGroovy = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)onlyGroovy, GroovyFileType.GROOVY_FILE_TYPE);
|
||||
}
|
||||
SearchScope onlyGroovy = PsiUtil.restrictScopeToGroovyFiles(searchScope);
|
||||
|
||||
final PsiClass clazz = constructor.getContainingClass();
|
||||
if (clazz == null) return;
|
||||
@@ -110,27 +103,20 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
}
|
||||
}
|
||||
|
||||
final Set<PsiMethod> processedMethods = new ConcurrentHashSet<PsiMethod>();
|
||||
final LiteralConstructorSearcher literalProcessor = new LiteralConstructorSearcher(constructor, consumer);
|
||||
|
||||
ReferencesSearch.searchOptimized(clazz, searchScope, true, collector, true, new PairProcessor<PsiReference, SearchRequestCollector>() {
|
||||
final Processor<GrNewExpression> newExpressionProcessor = new Processor<GrNewExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiReference ref, SearchRequestCollector collector) {
|
||||
final PsiElement element = ref.getElement();
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
if (!processGroovyConstructorUsages((GrCodeReferenceElement)element, constructor, consumer, ref, !searchGppCalls)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (searchGppCalls) {
|
||||
final PsiMethod method = getMethodToSearchForCallsWithLiteralArguments(element, clazz);
|
||||
if (method != null && processedMethods.add(method)) {
|
||||
processGppMethodCalls(clazz, constructor, consumer, searchScope, collector, method);
|
||||
}
|
||||
public boolean process(GrNewExpression grNewExpression) {
|
||||
final PsiMethod resolvedConstructor = grNewExpression.resolveConstructor();
|
||||
if (constructor.getManager().areElementsEquivalent(resolvedConstructor, constructor)) {
|
||||
return consumer.process(grNewExpression.getReferenceElement());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
processGroovyClassUsages(clazz, searchScope, collector, searchGppCalls, newExpressionProcessor, literalProcessor);
|
||||
|
||||
//this()
|
||||
if (clazz instanceof GrTypeDefinition) {
|
||||
@@ -139,8 +125,9 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
}
|
||||
}
|
||||
//super()
|
||||
DirectClassInheritorsSearch.search(clazz, onlyGroovy).forEach(new Processor<PsiClass>() {
|
||||
public boolean process(PsiClass inheritor) {
|
||||
DirectClassInheritorsSearch.search(clazz, onlyGroovy).forEach(new ReadActionProcessor<PsiClass>() {
|
||||
@Override
|
||||
public boolean processInReadAction(PsiClass inheritor) {
|
||||
if (inheritor instanceof GrTypeDefinition) {
|
||||
if (!processConstructors(constructor, consumer, inheritor, false)) return false;
|
||||
}
|
||||
@@ -149,16 +136,53 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
});
|
||||
}
|
||||
|
||||
public static void processGroovyClassUsages(final PsiClass clazz,
|
||||
final SearchScope scope,
|
||||
SearchRequestCollector collector,
|
||||
final boolean searchGppCalls,
|
||||
final Processor<GrNewExpression> newExpressionProcessor,
|
||||
final LiteralConstructorSearcher literalProcessor) {
|
||||
final Set<PsiMethod> processedMethods = new ConcurrentHashSet<PsiMethod>();
|
||||
|
||||
ReferencesSearch.searchOptimized(clazz, scope, true, collector, true, new PairProcessor<PsiReference, SearchRequestCollector>() {
|
||||
@Override
|
||||
public boolean process(PsiReference ref, SearchRequestCollector collector) {
|
||||
final PsiElement element = ref.getElement();
|
||||
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
if (!processGroovyConstructorUsages((GrCodeReferenceElement)element, !searchGppCalls, newExpressionProcessor, literalProcessor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (searchGppCalls) {
|
||||
final PsiMethod method = getMethodToSearchForCallsWithLiteralArguments(element, clazz);
|
||||
if (method != null && processedMethods.add(method)) {
|
||||
processGppMethodCalls(clazz, scope, collector, method, literalProcessor);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiMethod getMethodToSearchForCallsWithLiteralArguments(PsiElement element, PsiClass targetClass) {
|
||||
private static PsiMethod getMethodToSearchForCallsWithLiteralArguments(PsiElement element, PsiClass targetClass) {
|
||||
final PsiParameter parameter = PsiTreeUtil.getParentOfType(element, PsiParameter.class);
|
||||
if (parameter != null) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(parameter, PsiMethod.class);
|
||||
if (method != null && Arrays.asList(method.getParameterList().getParameters()).contains(parameter)) {
|
||||
final PsiType parameterType = parameter.getType();
|
||||
if (parameterType instanceof PsiClassType) {
|
||||
if (method.getManager().areElementsEquivalent(targetClass, ((PsiClassType)parameterType).resolve())) {
|
||||
return method;
|
||||
if (method != null) {
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
final int idx = Arrays.asList(parameters).indexOf(parameter);
|
||||
if (idx >= 0) {
|
||||
PsiType parameterType = parameter.getType();
|
||||
if (parameterType instanceof PsiArrayType && idx == parameters.length - 1) {
|
||||
parameterType = ((PsiArrayType)parameterType).getComponentType();
|
||||
}
|
||||
if (parameterType instanceof PsiClassType) {
|
||||
if (method.getManager().areElementsEquivalent(targetClass, ((PsiClassType)parameterType).resolve())) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,10 +191,9 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
}
|
||||
|
||||
private static void processGppMethodCalls(final PsiClass targetClass,
|
||||
final PsiMethod originalTarget,
|
||||
final Processor<PsiReference> originalProcessor,
|
||||
SearchScope scope,
|
||||
SearchRequestCollector originalCollector, @NotNull PsiMethod currentTarget) {
|
||||
SearchRequestCollector originalCollector, @NotNull PsiMethod currentTarget,
|
||||
final LiteralConstructorSearcher literalProcessor) {
|
||||
final SearchScope gppScope = getGppScope(targetClass.getProject()).intersectWith(scope);
|
||||
final ReadActionProcessor<PsiReference> gppCallProcessor = new ReadActionProcessor<PsiReference>() {
|
||||
@Override
|
||||
@@ -183,7 +206,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
boolean checkedTypedContext = false;
|
||||
|
||||
for (GrExpression argument : argList.getExpressionArguments()) {
|
||||
if (argument instanceof GrListOrMap && !((GrListOrMap)argument).isMap()) {
|
||||
if (argument instanceof GrListOrMap) {
|
||||
if (!checkedTypedContext) {
|
||||
if (!GppTypeConverter.hasTypedContext(parent)) {
|
||||
return true;
|
||||
@@ -194,7 +217,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
for (PsiType psiType : GroovyExpectedTypesProvider.getDefaultExpectedTypes(argument)) {
|
||||
if (psiType instanceof PsiClassType &&
|
||||
targetClass.getManager().areElementsEquivalent(targetClass, ((PsiClassType)psiType).resolve()) &&
|
||||
!checkListInstantiation(originalTarget, originalProcessor, (GrListOrMap)argument, (PsiClassType)psiType)) {
|
||||
!literalProcessor.processLiteral((GrListOrMap)argument, (PsiClassType)psiType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +237,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
}
|
||||
}
|
||||
|
||||
static GlobalSearchScope getGppScope(final Project project) {
|
||||
private static GlobalSearchScope getGppScope(final Project project) {
|
||||
return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<GlobalSearchScope>() {
|
||||
@Override
|
||||
public Result<GlobalSearchScope> compute() {
|
||||
@@ -223,22 +246,24 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
});
|
||||
}
|
||||
|
||||
static boolean processGroovyConstructorUsages(GrCodeReferenceElement element,
|
||||
final PsiMethod constructor,
|
||||
final Processor<PsiReference> consumer,
|
||||
PsiReference ref, boolean usualCallsOnly) {
|
||||
private static boolean processGroovyConstructorUsages(GrCodeReferenceElement element,
|
||||
boolean usualCallsOnly,
|
||||
final Processor<GrNewExpression> newExpressionProcessor,
|
||||
final LiteralConstructorSearcher literalProcessor) {
|
||||
PsiElement parent = element.getParent();
|
||||
|
||||
if (parent instanceof GrAnonymousClassDefinition) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent instanceof GrNewExpression) {
|
||||
final PsiMethod resolvedConstructor = ((GrNewExpression)parent).resolveConstructor();
|
||||
if (constructor.getManager().areElementsEquivalent(resolvedConstructor, constructor) && !consumer.process(ref)) {
|
||||
return false;
|
||||
}
|
||||
return newExpressionProcessor.process((GrNewExpression)parent);
|
||||
}
|
||||
else if (!usualCallsOnly && parent instanceof GrTypeElement) {
|
||||
|
||||
if (usualCallsOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parent instanceof GrTypeElement) {
|
||||
final GrTypeElement typeElement = (GrTypeElement)parent;
|
||||
|
||||
final PsiElement grandpa = typeElement.getParent();
|
||||
@@ -246,7 +271,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
final GrVariable[] vars = ((GrVariableDeclaration)grandpa).getVariables();
|
||||
if (vars.length == 1) {
|
||||
final GrVariable variable = vars[0];
|
||||
if (!checkListInstantiation(constructor, consumer, variable.getInitializerGroovy(), typeElement)) {
|
||||
if (!checkLiteralInstantiation(variable.getInitializerGroovy(), typeElement, literalProcessor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +282,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
ControlFlowUtils.visitAllExitPoints(method.getBlock(), new ControlFlowUtils.ExitPointVisitor() {
|
||||
@Override
|
||||
public boolean visitExitPoint(Instruction instruction, @Nullable GrExpression returnValue) {
|
||||
if (!checkListInstantiation(constructor, consumer, returnValue, typeElement)) {
|
||||
if (!checkLiteralInstantiation(returnValue, typeElement, literalProcessor)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -268,14 +293,14 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
else if (grandpa instanceof GrTypeCastExpression) {
|
||||
final GrTypeCastExpression cast = (GrTypeCastExpression)grandpa;
|
||||
if (cast.getCastTypeElement() == typeElement &&
|
||||
!checkListInstantiation(constructor, consumer, cast.getOperand(), typeElement)) {
|
||||
!checkLiteralInstantiation(cast.getOperand(), typeElement, literalProcessor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (grandpa instanceof GrSafeCastExpression) {
|
||||
final GrSafeCastExpression cast = (GrSafeCastExpression)grandpa;
|
||||
if (cast.getCastTypeElement() == typeElement &&
|
||||
!checkListInstantiation(constructor, consumer, cast.getOperand(), typeElement)) {
|
||||
!checkLiteralInstantiation(cast.getOperand(), typeElement, literalProcessor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +308,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
return true;
|
||||
}
|
||||
|
||||
static GlobalSearchScope calcGppScope(Project project) {
|
||||
private static GlobalSearchScope calcGppScope(Project project) {
|
||||
final GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
|
||||
final GlobalSearchScope maximal = GlobalSearchScope.getScopeRestrictedByFileTypes(allScope, GroovyFileType.GROOVY_FILE_TYPE);
|
||||
GlobalSearchScope gppExtensions = new DelegatingGlobalSearchScope(maximal) {
|
||||
@@ -310,51 +335,21 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
return gppExtensions;
|
||||
}
|
||||
|
||||
static boolean checkListInstantiation(PsiMethod constructor,
|
||||
Processor<PsiReference> consumer,
|
||||
GrExpression expression, final GrTypeElement typeElement) {
|
||||
private static boolean checkLiteralInstantiation(GrExpression expression,
|
||||
final GrTypeElement typeElement,
|
||||
final LiteralConstructorSearcher literalProcessor) {
|
||||
|
||||
if (expression instanceof GrListOrMap) {
|
||||
final GrListOrMap list = (GrListOrMap)expression;
|
||||
if (!list.isMap()) {
|
||||
final PsiType expectedType = typeElement.getType();
|
||||
if (expectedType instanceof PsiClassType) {
|
||||
return checkListInstantiation(constructor, consumer, list, (PsiClassType)expectedType);
|
||||
}
|
||||
final PsiType expectedType = typeElement.getType();
|
||||
if (expectedType instanceof PsiClassType) {
|
||||
return literalProcessor.processLiteral((GrListOrMap)expression, (PsiClassType)expectedType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean checkListInstantiation(PsiMethod constructor,
|
||||
Processor<PsiReference> consumer,
|
||||
GrListOrMap list,
|
||||
PsiClassType expectedType) {
|
||||
final PsiType listType = list.getType();
|
||||
if (listType instanceof GrTupleType) {
|
||||
for (GroovyResolveResult candidate : PsiUtil.getConstructorCandidates(expectedType, ((GrTupleType)listType).getComponentTypes(), list)) {
|
||||
if (constructor.getManager().areElementsEquivalent(candidate.getElement(), constructor)) {
|
||||
if (!consumer.process(PsiReferenceBase.createSelfReference(list, TextRange.from(0, list.getTextLength()), constructor))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean processConstructors(final PsiMethod constructor, final Processor<PsiReference> consumer, final PsiClass clazz,
|
||||
private static boolean processConstructors(final PsiMethod searchedConstructor, final Processor<PsiReference> consumer, final PsiClass clazz,
|
||||
final boolean processThisRefs) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
return processClassConstructors(clazz, constructor, consumer, processThisRefs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static boolean processClassConstructors(PsiClass clazz,
|
||||
PsiMethod searchedConstructor,
|
||||
Processor<PsiReference> consumer,
|
||||
boolean processThisRefs) {
|
||||
final PsiMethod[] constructors = clazz.getConstructors();
|
||||
if (constructors.length == 0) {
|
||||
processImplicitConstructorCall(clazz, consumer, searchedConstructor);
|
||||
@@ -367,7 +362,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
final GrConstructorInvocation invocation = (GrConstructorInvocation)statements[0];
|
||||
if (invocation.isThisCall() == processThisRefs &&
|
||||
invocation.getManager().areElementsEquivalent(invocation.resolveConstructor(), searchedConstructor) &&
|
||||
!consumer.process(invocation)) {
|
||||
!consumer.process(invocation.getThisOrSuperKeyword())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -379,7 +374,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
return true;
|
||||
}
|
||||
|
||||
static void processImplicitConstructorCall(final PsiMember usage,
|
||||
private static void processImplicitConstructorCall(final PsiMember usage,
|
||||
final Processor<PsiReference> processor,
|
||||
final PsiMethod constructor) {
|
||||
if (constructor instanceof GrMethod) {
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.jetbrains.plugins.groovy.findUsages;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.plugins.groovy.gpp.GppReferenceContributor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrMapType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class LiteralConstructorSearcher {
|
||||
private final PsiMethod myConstructor;
|
||||
private final Processor<PsiReference> myConsumer;
|
||||
|
||||
public LiteralConstructorSearcher(PsiMethod constructor, Processor<PsiReference> consumer) {
|
||||
myConstructor = constructor;
|
||||
myConsumer = consumer;
|
||||
}
|
||||
|
||||
private static boolean checkLiteralInstantiation(PsiMethod constructor,
|
||||
Processor<PsiReference> consumer,
|
||||
GrListOrMap literal,
|
||||
PsiClassType expectedType) {
|
||||
final PsiType listType = literal.getType();
|
||||
if (listType instanceof GrTupleType) {
|
||||
if (GppReferenceContributor.isConstructorCall(expectedType, ((GrTupleType)listType).getComponentTypes(), constructor, literal)) {
|
||||
return consumer.process(PsiReferenceBase.createSelfReference(literal, TextRange.from(0, literal.getTextLength()), constructor));
|
||||
}
|
||||
}
|
||||
else if (listType instanceof GrMapType) {
|
||||
final PsiType constructorArgs = ((GrMapType)listType).getValueType("super");
|
||||
if (constructorArgs == null) {
|
||||
if (constructor.getParameterList().getParametersCount() == 0) {
|
||||
if (!consumer.process(PsiReferenceBase.createSelfReference(literal, TextRange.from(0, literal.getTextLength()), constructor))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
for (GrNamedArgument argument : literal.getNamedArguments()) {
|
||||
final GrArgumentLabel label = argument.getLabel();
|
||||
if (label != null && "super".equals(label.getName())) {
|
||||
final PsiReference reference = label.getReference();
|
||||
if (reference != null && reference.isReferenceTo(constructor)) {
|
||||
return consumer.process(reference);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//no 'super', only default constructor applicable
|
||||
if (constructor.getParameterList().getParametersCount() == 0) {
|
||||
return consumer.process(PsiReferenceBase.createSelfReference(literal, TextRange.from(0, literal.getTextLength()), constructor));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean processLiteral(GrListOrMap list, PsiClassType expectedType) {
|
||||
return checkLiteralInstantiation(myConstructor, myConsumer, list, expectedType);
|
||||
}
|
||||
}
|
||||
+20
-15
@@ -81,14 +81,20 @@ public class GppClosureParameterTypeProvider extends AbstractClosureParameterEnh
|
||||
|
||||
@Nullable
|
||||
public static Pair<PsiMethod, PsiSubstitutor> getOverriddenMethod(GrNamedArgument namedArgument) {
|
||||
return ContainerUtil.getFirstItem(getOverriddenMethodVariants(namedArgument), null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<Pair<PsiMethod, PsiSubstitutor>> getOverriddenMethodVariants(GrNamedArgument namedArgument) {
|
||||
|
||||
final GrArgumentLabel label = namedArgument.getLabel();
|
||||
if (label == null) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final String methodName = label.getName();
|
||||
if (methodName == null) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final PsiElement map = namedArgument.getParent();
|
||||
@@ -96,20 +102,16 @@ public class GppClosureParameterTypeProvider extends AbstractClosureParameterEnh
|
||||
for (PsiType expected : GroovyExpectedTypesProvider.getDefaultExpectedTypes((GrExpression)map)) {
|
||||
if (expected instanceof PsiClassType) {
|
||||
final List<Pair<PsiMethod, PsiSubstitutor>> pairs = getMethodsToOverrideImplementInInheritor((PsiClassType)expected, false);
|
||||
final List<Pair<PsiMethod, PsiSubstitutor>> withName =
|
||||
ContainerUtil.findAll(pairs, new Condition<Pair<PsiMethod, PsiSubstitutor>>() {
|
||||
return ContainerUtil.findAll(pairs, new Condition<Pair<PsiMethod, PsiSubstitutor>>() {
|
||||
public boolean value(Pair<PsiMethod, PsiSubstitutor> pair) {
|
||||
return methodName.equals(pair.first.getName());
|
||||
}
|
||||
});
|
||||
if (withName.size() == 1) {
|
||||
return withName.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -126,19 +128,22 @@ public class GppClosureParameterTypeProvider extends AbstractClosureParameterEnh
|
||||
if (type instanceof PsiClassType) {
|
||||
List<Pair<PsiMethod, PsiSubstitutor>> result = getMethodsToOverrideImplementInInheritor((PsiClassType)type, true);
|
||||
if (result.size() == 1) {
|
||||
final Pair<PsiMethod, PsiSubstitutor> pair = result.get(0);
|
||||
return ContainerUtil.map2Array(pair.first.getParameterList().getParameters(), PsiType.class, new Function<PsiParameter, PsiType>() {
|
||||
public PsiType fun(PsiParameter psiParameter) {
|
||||
return pair.second.substitute(psiParameter.getType());
|
||||
}
|
||||
});
|
||||
return getParameterTypes(result.get(0));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PsiType[] getParameterTypes(final Pair<PsiMethod, PsiSubstitutor> pair) {
|
||||
return ContainerUtil.map2Array(pair.first.getParameterList().getParameters(), PsiType.class, new Function<PsiParameter, PsiType>() {
|
||||
public PsiType fun(PsiParameter psiParameter) {
|
||||
return pair.second.substitute(psiParameter.getType());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Pair<PsiMethod, PsiSubstitutor>> getMethodsToOverrideImplementInInheritor(PsiClassType classType, boolean toImplement) {
|
||||
public static List<Pair<PsiMethod, PsiSubstitutor>> getMethodsToOverrideImplementInInheritor(PsiClassType classType, boolean toImplement) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
|
||||
final PsiClass psiClass = resolveResult.getElement();
|
||||
if (psiClass == null) {
|
||||
|
||||
@@ -7,18 +7,58 @@ import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrSafeCastExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.GroovyExpectedTypesProvider;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class GppReferenceContributor extends PsiReferenceContributor {
|
||||
public static boolean mayInvokeConstructor(PsiClassType expectedType, PsiMethod constructor, GrExpression args) {
|
||||
if (args == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiType type = args.getType();
|
||||
if (type == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type instanceof GrTupleType) {
|
||||
return isConstructorCall(expectedType, ((GrTupleType)type).getComponentTypes(), constructor, args);
|
||||
}
|
||||
|
||||
return isConstructorCall(expectedType, new PsiType[]{type}, constructor, args);
|
||||
}
|
||||
|
||||
public static boolean isConstructorCall(PsiClassType expectedType,
|
||||
PsiType[] argTypes,
|
||||
PsiMethod constructor,
|
||||
GroovyPsiElement context) {
|
||||
for (GroovyResolveResult candidate : PsiUtil.getConstructorCandidates(expectedType, argTypes, context)) {
|
||||
if (constructor.getManager().areElementsEquivalent(candidate.getElement(), constructor)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(GrArgumentLabel.class), new PsiReferenceProvider() {
|
||||
@@ -34,7 +74,7 @@ public class GppReferenceContributor extends PsiReferenceContributor {
|
||||
});
|
||||
}
|
||||
|
||||
private static class GppMapMemberReference extends PsiReferenceBase<GrArgumentLabel> {
|
||||
private static class GppMapMemberReference extends PsiReferenceBase.Poly<GrArgumentLabel> {
|
||||
|
||||
public GppMapMemberReference(PsiElement element) {
|
||||
super((GrArgumentLabel)element);
|
||||
@@ -45,30 +85,98 @@ public class GppReferenceContributor extends PsiReferenceContributor {
|
||||
return element instanceof PsiMethod && super.isReferenceTo(element);
|
||||
}
|
||||
|
||||
public PsiElement resolve() {
|
||||
final GrNamedArgument namedArgument = (GrNamedArgument) getElement().getParent();
|
||||
for (PsiType type : GroovyExpectedTypesProvider.getDefaultExpectedTypes((GrExpression)namedArgument.getParent())) {
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveResult[] multiResolve(boolean incompleteCode) {
|
||||
final GrArgumentLabel context = getElement();
|
||||
final GrNamedArgument namedArgument = (GrNamedArgument) context.getParent();
|
||||
for (PsiType type : getTargetConversionTypes((GrExpression)namedArgument.getParent())) {
|
||||
if (type instanceof PsiClassType) {
|
||||
final GrExpression value = namedArgument.getExpression();
|
||||
if (value != null && InheritanceUtil.isInheritor(value.getType(), GrClosableBlock.GROOVY_LANG_CLOSURE)) {
|
||||
final Pair<PsiMethod,PsiSubstitutor> method = GppClosureParameterTypeProvider.getOverriddenMethod(namedArgument);
|
||||
if (method != null) {
|
||||
return method.first;
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass != null) {
|
||||
final GrExpression value = namedArgument.getExpression();
|
||||
|
||||
final List<ResolveResult> applicable = addMethodCandidates(classType, value);
|
||||
|
||||
final String memberName = getValue();
|
||||
if ("super".equals(memberName) && GppTypeConverter.hasTypedContext(myElement)) {
|
||||
applicable.addAll(addConstructorCandidates(classType, psiClass, value));
|
||||
}
|
||||
} else {
|
||||
final PsiClass psiClass = ((PsiClassType)type).resolve();
|
||||
if (psiClass != null) {
|
||||
final String propertyName = getValue();
|
||||
final PsiMethod setter = PropertyUtil.findPropertySetter(psiClass, propertyName, false, true);
|
||||
|
||||
if (value == null || applicable.isEmpty()) {
|
||||
final PsiMethod setter = PropertyUtil.findPropertySetter(psiClass, memberName, false, true);
|
||||
if (setter != null) {
|
||||
return setter;
|
||||
applicable.add(new PsiElementResolveResult(setter));
|
||||
} else {
|
||||
final PsiField field = PropertyUtil.findPropertyField(psiClass.getProject(), psiClass, memberName, false);
|
||||
if (field != null) {
|
||||
applicable.add(new PsiElementResolveResult(field));
|
||||
}
|
||||
}
|
||||
return PropertyUtil.findPropertyField(psiClass.getProject(), psiClass, propertyName, false);
|
||||
}
|
||||
|
||||
return applicable.toArray(new ResolveResult[applicable.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return ResolveResult.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
private static Set<PsiType> getTargetConversionTypes(GrExpression expression) {
|
||||
//todo hack
|
||||
if (expression.getParent() instanceof GrSafeCastExpression) {
|
||||
final PsiType type = ((GrSafeCastExpression)expression.getParent()).getType();
|
||||
if (type != null) {
|
||||
return Collections.singleton(type);
|
||||
}
|
||||
}
|
||||
|
||||
return GroovyExpectedTypesProvider.getDefaultExpectedTypes(expression);
|
||||
}
|
||||
|
||||
|
||||
private static List<ResolveResult> addConstructorCandidates(PsiClassType classType, PsiClass psiClass, GrExpression value) {
|
||||
List<ResolveResult> applicable = CollectionFactory.arrayList();
|
||||
final List<ResolveResult> byName = CollectionFactory.arrayList();
|
||||
for (PsiMethod constructor : psiClass.getConstructors()) {
|
||||
final ResolveResult resolveResult = new PsiElementResolveResult(constructor);
|
||||
byName.add(resolveResult);
|
||||
if (mayInvokeConstructor(classType, constructor, value)) {
|
||||
applicable.add(resolveResult);
|
||||
}
|
||||
}
|
||||
if (applicable.isEmpty()) {
|
||||
applicable.addAll(byName);
|
||||
}
|
||||
return applicable;
|
||||
}
|
||||
|
||||
private List<ResolveResult> addMethodCandidates(PsiClassType classType, GrExpression value) {
|
||||
PsiType valueType = value == null ? null : value.getType();
|
||||
final List<ResolveResult> applicable = CollectionFactory.arrayList();
|
||||
|
||||
if (value == null || InheritanceUtil.isInheritor(valueType, GrClosableBlock.GROOVY_LANG_CLOSURE)) {
|
||||
final List<ResolveResult> byName = CollectionFactory.arrayList();
|
||||
for (Pair<PsiMethod, PsiSubstitutor> variant : GppClosureParameterTypeProvider.getMethodsToOverrideImplementInInheritor(classType, false)) {
|
||||
final PsiMethod method = variant.first;
|
||||
if (getValue().equals(method.getName())) {
|
||||
final ResolveResult resolveResult = new PsiElementResolveResult(method);
|
||||
byName.add(resolveResult);
|
||||
if (valueType instanceof GrClosureType) {
|
||||
final PsiType[] psiTypes = GppClosureParameterTypeProvider.getParameterTypes(variant);
|
||||
if (GppTypeConverter.isClosureOverride(psiTypes, (GrClosureType)valueType, myElement)) {
|
||||
applicable.add(resolveResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (applicable.isEmpty()) {
|
||||
return byName;
|
||||
}
|
||||
}
|
||||
return applicable;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -72,24 +72,29 @@ public class GppTypeConverter extends GrTypeConverter {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isMethodCallConversion(context) && hasDefaultConstructor(lType)) {
|
||||
if ((!isMethodCallConversion(context) || hasTypedContext(context)) && hasDefaultConstructor(lType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (rType instanceof GrClosureType) {
|
||||
final PsiType[] methodParameters = GppClosureParameterTypeProvider.findSingleAbstractMethodSignature(lType);
|
||||
final GrClosureSignature signature = ((GrClosureType)rType).getSignature();
|
||||
if (methodParameters != null && GrClosureSignatureUtil.isSignatureApplicable(signature, methodParameters, context)) {
|
||||
return true;
|
||||
}
|
||||
if (isClosureOverride(methodParameters, (GrClosureType)rType, context)) return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isClosureOverride(PsiType[] methodParameters, GrClosureType closureType, GroovyPsiElement context) {
|
||||
final GrClosureSignature signature = closureType.getSignature();
|
||||
if (methodParameters != null && GrClosureSignatureUtil.isSignatureApplicable(signature, methodParameters, context)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasDefaultConstructor(PsiType type) {
|
||||
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
|
||||
return psiClass != null && PsiUtil.hasDefaultConstructor(psiClass, true);
|
||||
return psiClass != null && PsiUtil.hasDefaultConstructor(psiClass, true, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public class DefaultHighlighter {
|
||||
|
||||
@NonNls
|
||||
static final String UNRESOLVED_ACCESS_ID = "Unresolved reference access";
|
||||
static final String LITERAL_CONVERSION_ID = "List/map to object conversion";
|
||||
|
||||
|
||||
public static TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey(LINE_COMMENT_ID,
|
||||
@@ -148,7 +149,13 @@ public class DefaultHighlighter {
|
||||
UNRESOLVED_ACCESS_ATTRIBUTES.setEffectColor(Color.GRAY);
|
||||
UNRESOLVED_ACCESS_ATTRIBUTES.setEffectType(EffectType.LINE_UNDERSCORE);
|
||||
}
|
||||
public static final TextAttributes LITERAL_CONVERSION_ATTRIBUTES = HighlighterColors.TEXT.getDefaultAttributes().clone();
|
||||
static{
|
||||
LITERAL_CONVERSION_ATTRIBUTES.setForegroundColor(Color.BLUE);
|
||||
LITERAL_CONVERSION_ATTRIBUTES.setFontType(Font.BOLD);
|
||||
}
|
||||
public static TextAttributesKey UNRESOLVED_ACCESS = TextAttributesKey.createTextAttributesKey(UNRESOLVED_ACCESS_ID, UNRESOLVED_ACCESS_ATTRIBUTES);
|
||||
public static TextAttributesKey LITERAL_CONVERSION = TextAttributesKey.createTextAttributesKey(LITERAL_CONVERSION_ID, LITERAL_CONVERSION_ATTRIBUTES);
|
||||
|
||||
private DefaultHighlighter() {
|
||||
}
|
||||
|
||||
+5
-1
@@ -64,6 +64,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage {
|
||||
new AttributesDescriptor(DefaultHighlighter.BAD_CHARACTER_ID, DefaultHighlighter.BAD_CHARACTER),
|
||||
new AttributesDescriptor(DefaultHighlighter.WRONG_STRING_ID, DefaultHighlighter.WRONG_STRING),
|
||||
new AttributesDescriptor(DefaultHighlighter.UNRESOLVED_ACCESS_ID, DefaultHighlighter.UNRESOLVED_ACCESS),
|
||||
new AttributesDescriptor(DefaultHighlighter.LITERAL_CONVERSION_ID, DefaultHighlighter.LITERAL_CONVERSION),
|
||||
new AttributesDescriptor(DefaultHighlighter.ANNOTATION_ID, DefaultHighlighter.ANNOTATION),
|
||||
new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.STATIC_FIELD),
|
||||
new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.INSTANCE_FIELD),
|
||||
@@ -101,7 +102,9 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage {
|
||||
"<classref>Demo</classref>.<statfield>panel</statfield>.size = " +
|
||||
"<classref>Demo</classref>.<statmet>foo</statmet>(\"123${456}789\".toInteger()) \n" +
|
||||
"'JetBrains'.matches(/Jw+Bw+/) \n" +
|
||||
"def x=1 + <unresolved>unresolved</unresolved>"
|
||||
"def x=1 + <unresolved>unresolved</unresolved>\n" +
|
||||
"def f1 = []\n" +
|
||||
"<classref>File</classref> f=<literal>[</literal>'path'<literal>]</literal>"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -116,6 +119,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage {
|
||||
map.put("doctag", DefaultHighlighter.DOC_COMMENT_TAG);
|
||||
map.put("unresolved", DefaultHighlighter.UNRESOLVED_ACCESS);
|
||||
map.put("classref", DefaultHighlighter.CLASS_REFERENCE);
|
||||
map.put("literal", DefaultHighlighter.LITERAL_CONVERSION);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
+7
-1
@@ -85,4 +85,10 @@ map.param.name=Map parameter &name:
|
||||
convert.param.to.map.entry=Convert parameter to map entry
|
||||
|
||||
convert.java.style.array.intention.name=Convert java-style array creation
|
||||
convert.java.style.array.intention.family.name=Convert Java-Style Array Creation to Groovy Syntax
|
||||
convert.java.style.array.intention.family.name=Convert Java-Style Array Creation to Groovy Syntax
|
||||
|
||||
create.parameter.for.field.intention.name = Add constructor parameter for field
|
||||
create.parameter.for.field.intention.family.name = Add constructor parameter for field
|
||||
cannot.suggest.parameter.name=Cannot suggest parameter name
|
||||
create.parameter.for.field=Add parameter for field ''{0}''
|
||||
create.parameter.for.fields=Add parameter for field...
|
||||
@@ -19,15 +19,16 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.annotator.intentions.QuickfixUtil;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.BoolUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.annotator.intentions.QuickfixUtil;
|
||||
|
||||
|
||||
public abstract class Intention implements IntentionAction {
|
||||
@@ -51,10 +52,10 @@ public abstract class Intention implements IntentionAction {
|
||||
return;
|
||||
}
|
||||
assert element.isValid() : element;
|
||||
processIntention(element);
|
||||
processIntention(element, project, editor);
|
||||
}
|
||||
|
||||
protected abstract void processIntention(@NotNull PsiElement element)
|
||||
protected abstract void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-3
@@ -15,15 +15,19 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.closure;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -36,7 +40,7 @@ public class ConvertClosureArgToItIntention extends Intention {
|
||||
return new SingleArgClosurePredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrClosableBlock closure =
|
||||
(GrClosableBlock) element;
|
||||
|
||||
+14
-22
@@ -23,7 +23,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -53,27 +52,8 @@ public class EachToForIntention extends Intention {
|
||||
return new EachToForPredicate();
|
||||
}
|
||||
|
||||
private GrVariable var = null;
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
super.invoke(project, editor, file);
|
||||
if (var == null) return;
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
final Document doc = documentManager.getDocument(file);
|
||||
if (doc == null) return;
|
||||
|
||||
|
||||
documentManager.doPostponedOperationsAndUnblockDocument(doc);
|
||||
editor.getCaretModel().moveToOffset(var.getTextOffset());
|
||||
new VariableInplaceRenamer(var, editor).performInplaceRename();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrMethodCallExpression expression = (GrMethodCallExpression)element;
|
||||
final GrClosableBlock block = expression.getClosureArguments()[0];
|
||||
final GrParameterList parameterList = block.getParameterList();
|
||||
@@ -114,7 +94,19 @@ public class EachToForIntention extends Intention {
|
||||
final GrStatement statement = elementFactory.createStatementFromText(builder.toString());
|
||||
final GrForStatement forStatement = (GrForStatement)expression.replaceWithStatement(statement);
|
||||
final GrForClause clause = forStatement.getClause();
|
||||
this.var = clause.getDeclaredVariables()[0];
|
||||
GrVariable variable = clause.getDeclaredVariables()[0];
|
||||
|
||||
if (variable == null) return;
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
final Document doc = documentManager.getDocument(element.getContainingFile());
|
||||
if (doc == null) return;
|
||||
|
||||
documentManager.doPostponedOperationsAndUnblockDocument(doc);
|
||||
editor.getCaretModel().moveToOffset(variable.getTextOffset());
|
||||
new VariableInplaceRenamer(variable, editor).performInplaceRename();
|
||||
}
|
||||
|
||||
private static class EachToForPredicate implements PsiElementPredicate {
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.closure;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -39,7 +41,7 @@ public class ForToEachIntention extends Intention {
|
||||
return new ForToEachPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrForStatement parentStatement =
|
||||
(GrForStatement) element;
|
||||
|
||||
+6
-2
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.closure;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -32,7 +36,7 @@ public class MakeClosureCallExplicitIntention extends Intention {
|
||||
return new ImplicitClosureCallPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrMethodCallExpression expression =
|
||||
(GrMethodCallExpression) element;
|
||||
|
||||
+6
-2
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.closure;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -33,7 +37,7 @@ public class MakeClosureCallImplicitIntention extends Intention {
|
||||
return new ExplicitClosureCallPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrMethodCallExpression expression =
|
||||
(GrMethodCallExpression) element;
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.comments;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -38,7 +40,7 @@ public class ChangeToCStyleCommentIntention extends Intention {
|
||||
return new EndOfLineCommentPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final PsiComment selectedComment = (PsiComment) element;
|
||||
PsiComment firstComment = selectedComment;
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.comments;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -31,7 +33,7 @@ public class ChangeToEndOfLineCommentIntention extends Intention {
|
||||
return new CStyleCommentPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final PsiComment comment = (PsiComment) element;
|
||||
final JavaPsiFacade manager = JavaPsiFacade.getInstance(comment.getProject());
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -29,7 +31,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres
|
||||
* @author ilyas
|
||||
*/
|
||||
public class ConditionalToElvisIntention extends Intention {
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrConditionalExpression expr =
|
||||
(GrConditionalExpression) element;
|
||||
|
||||
|
||||
+317
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
* 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.intentions.control;
|
||||
|
||||
import com.intellij.ide.util.DefaultPsiElementCellRenderer;
|
||||
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.project.Project;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.changeSignature.JavaThrownExceptionInfo;
|
||||
import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.refactoring.DefaultGroovyVariableNameValidator;
|
||||
import org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeInfoImpl;
|
||||
import org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureProcessor;
|
||||
import org.jetbrains.plugins.groovy.refactoring.changeSignature.GrParameterInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class CreateParameterForFieldIntention extends Intention {
|
||||
private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.intentions.control.CreateParameterForFieldIntention");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return super.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element, final Project project, final Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final List<GrField> candidates = findFieldCandidates(element);
|
||||
if (candidates != null) {
|
||||
performForConstructor(element, project, editor, candidates);
|
||||
}
|
||||
else {
|
||||
final List<GrMethod> constructors = findConstructorCandidates(element);
|
||||
performForField(element, project, editor, constructors);
|
||||
}
|
||||
}
|
||||
|
||||
private static void performForField(PsiElement element, final Project project, Editor editor, List<GrMethod> constructors) {
|
||||
final GrField field = PsiTreeUtil.getParentOfType(element, GrField.class);
|
||||
if (constructors.size() == 0) return;
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
for (GrMethod constructor : constructors) {
|
||||
addParameter(field, constructor, project);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final JList list = new JBList(constructors.toArray(new GrMethod[constructors.size()]));
|
||||
list.setCellRenderer(new MethodCellRenderer(true));
|
||||
|
||||
new PopupChooserBuilder(list).setTitle(GroovyIntentionsBundle.message("create.parameter.for.field.intention.name")).
|
||||
setMovable(true).
|
||||
setItemChoosenCallback(new Runnable() {
|
||||
public void run() {
|
||||
final Object[] selectedValues = list.getSelectedValues();
|
||||
Arrays.sort(selectedValues, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((GrMethod)o2).getParameterList().getParametersCount() - ((GrMethod)o1).getParameterList().getParametersCount();
|
||||
}
|
||||
});
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Object selectedValue : selectedValues) {
|
||||
LOG.assertTrue(((GrMethod)selectedValue).isValid());
|
||||
addParameter(field, ((GrMethod)selectedValue), project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, GroovyIntentionsBundle.message("create.parameter.for.field.intention.name"), null);
|
||||
}
|
||||
}).createPopup().showInBestPositionFor(editor);
|
||||
|
||||
}
|
||||
|
||||
private static void performForConstructor(PsiElement element, final Project project, Editor editor, List<GrField> candidates) {
|
||||
final GrMethod constructor = PsiTreeUtil.getParentOfType(element, GrMethod.class);
|
||||
if (candidates.size() == 0) return;
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
for (GrField candidate : candidates) {
|
||||
addParameter(candidate, constructor, project);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final JList list = new JBList(candidates.toArray(new GrField[candidates.size()]));
|
||||
list.setCellRenderer(new DefaultPsiElementCellRenderer());
|
||||
|
||||
new PopupChooserBuilder(list).setTitle(GroovyIntentionsBundle.message("create.parameter.for.field.intention.name")).
|
||||
setMovable(true).
|
||||
setItemChoosenCallback(new Runnable() {
|
||||
public void run() {
|
||||
final Object[] selectedValues = list.getSelectedValues();
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Object selectedValue : selectedValues) {
|
||||
LOG.assertTrue(((GrField)selectedValue).isValid());
|
||||
addParameter(((GrField)selectedValue), constructor, project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, GroovyIntentionsBundle.message("create.parameter.for.field.intention.name"), null);
|
||||
}
|
||||
}).createPopup().showInBestPositionFor(editor);
|
||||
}
|
||||
|
||||
private static void addParameter(final GrField selectedValue, final GrMethod constructor, final Project project) {
|
||||
List<GrParameterInfo> parameters = new ArrayList<GrParameterInfo>();
|
||||
GrParameter[] constructorParameters = constructor.getParameters();
|
||||
for (int i = 0; i < constructorParameters.length; i++) {
|
||||
parameters.add(new GrParameterInfo(constructorParameters[i], i));
|
||||
}
|
||||
final String[] suggestedNames =
|
||||
JavaCodeStyleManager.getInstance(project).suggestVariableName(VariableKind.PARAMETER, selectedValue.getName(), null, null).names;
|
||||
|
||||
final DefaultGroovyVariableNameValidator nameValidator =
|
||||
new DefaultGroovyVariableNameValidator(constructor, Collections.<String>emptyList(), false);
|
||||
String parameterName = ContainerUtil.find(suggestedNames, new Condition<String>() {
|
||||
@Override
|
||||
public boolean value(String name) {
|
||||
return nameValidator.validateName(name, false).length() > 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (parameterName == null) {
|
||||
parameterName = nameValidator.validateName(suggestedNames[0], true);
|
||||
}
|
||||
parameters.add(new GrParameterInfo(parameterName, "null", "", selectedValue.getTypeGroovy(), -1));
|
||||
|
||||
PsiClassType[] exceptionTypes = constructor.getThrowsList().getReferencedTypes();
|
||||
ThrownExceptionInfo[] thrownExceptionInfos = new ThrownExceptionInfo[exceptionTypes.length];
|
||||
for (int i = 0; i < exceptionTypes.length; i++) {
|
||||
new JavaThrownExceptionInfo(i, exceptionTypes[i]);
|
||||
}
|
||||
|
||||
final GrChangeInfoImpl grChangeInfo =
|
||||
new GrChangeInfoImpl(constructor, null, null, constructor.getName(), parameters, thrownExceptionInfos, false);
|
||||
final GrChangeSignatureProcessor processor = new GrChangeSignatureProcessor(project, grChangeInfo);
|
||||
final Ref<Boolean> success = Ref.create(Boolean.FALSE);
|
||||
processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
success.set(Boolean.TRUE);
|
||||
}
|
||||
});
|
||||
processor.run();
|
||||
|
||||
if (success.get()) {
|
||||
final GrOpenBlock block = constructor.getBlock();
|
||||
LOG.assertTrue(block != null);
|
||||
final GrStatement statement = block.addStatementBefore(
|
||||
GroovyPsiElementFactory.getInstance(project).createStatementFromText(selectedValue.getName() + " = " + parameterName), null);
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)((GrAssignmentExpression)statement).getLValue();
|
||||
if (!PsiManager.getInstance(project).areElementsEquivalent(ref.resolve(), selectedValue)) {
|
||||
PsiUtil.qualifyMemberReference(ref, selectedValue, selectedValue.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiElementPredicate getElementPredicate() {
|
||||
return new MyPredicate();
|
||||
}
|
||||
|
||||
static class MyPredicate implements PsiElementPredicate {
|
||||
@Override
|
||||
public boolean satisfiedBy(PsiElement element) {
|
||||
final List<GrField> candidates = findFieldCandidates(element);
|
||||
if (candidates != null && candidates.size() > 0) return true;
|
||||
final List<GrMethod> constructors = findConstructorCandidates(element);
|
||||
return constructors != null && constructors.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static List<GrField> findFieldCandidates(PsiElement element) {
|
||||
final GrMethod constructor = PsiTreeUtil.getParentOfType(element, GrMethod.class);
|
||||
if (constructor == null || !constructor.isConstructor()) return null;
|
||||
if (constructor.getBlock() == null) return null;
|
||||
if (PsiTreeUtil.isAncestor(constructor.getBlock(), element, false)) {
|
||||
return null;
|
||||
}
|
||||
final PsiClass clazz = constructor.getContainingClass();
|
||||
|
||||
if (!(clazz instanceof GrTypeDefinition)) return null;
|
||||
return findCandidates(constructor, (GrTypeDefinition)clazz);
|
||||
}
|
||||
|
||||
private static List<GrField> findCandidates(GrMethod constructor, final GrTypeDefinition clazz) {
|
||||
final List<GrField> usedFields = new ArrayList<GrField>();
|
||||
//ContainerUtil.addAll(fields, clazz.getFields());
|
||||
final GrOpenBlock block = constructor.getBlock();
|
||||
LOG.assertTrue(block != null);
|
||||
|
||||
final PsiManager manager = clazz.getManager();
|
||||
block.accept(new GroovyRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
|
||||
super.visitReferenceExpression(referenceExpression);
|
||||
final PsiElement resolved = referenceExpression.resolve();
|
||||
if (resolved instanceof GrField &&
|
||||
manager.areElementsEquivalent(((GrField)resolved).getContainingClass(), clazz) &&
|
||||
PsiUtil.isAccessedForWriting(referenceExpression)) {
|
||||
usedFields.add((GrField)resolved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeDefinition(GrTypeDefinition typeDefinition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClosure(GrClosableBlock closure) {
|
||||
}
|
||||
});
|
||||
|
||||
List<GrField> fields = new ArrayList<GrField>();
|
||||
for (final GrField field : clazz.getFields()) {
|
||||
if (field.getInitializerGroovy() != null) continue;
|
||||
if (ContainerUtil.find(usedFields, new Condition<PsiField>() {
|
||||
@Override
|
||||
public boolean value(PsiField o) {
|
||||
return manager.areElementsEquivalent(o, field);
|
||||
}
|
||||
}) == null) {
|
||||
fields.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static List<GrMethod> findConstructorCandidates(PsiElement element) {
|
||||
final GrField field = PsiTreeUtil.getParentOfType(element, GrField.class);
|
||||
if (field == null) return null;
|
||||
return findConstructorCandidates(field, (GrTypeDefinition)field.getContainingClass());
|
||||
}
|
||||
|
||||
private static List<GrMethod> findConstructorCandidates(final GrField field, GrTypeDefinition psiClass) {
|
||||
final List<GrMethod> result = new ArrayList<GrMethod>();
|
||||
final PsiMethod[] constructors = psiClass.getConstructors();
|
||||
final PsiManager manager = field.getManager();
|
||||
for (PsiMethod constructor : constructors) {
|
||||
final List<GrField> fields = findCandidates(((GrMethod)constructor), psiClass);
|
||||
if (ContainerUtil.find(fields, new Condition<GrField>() {
|
||||
@Override
|
||||
public boolean value(GrField grField) {
|
||||
return manager.areElementsEquivalent(grField, field);
|
||||
}
|
||||
}) != null) {
|
||||
result.add((GrMethod)constructor);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -15,16 +15,18 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.MutablyNamedIntention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.BoolUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ComparisonUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ParenthesesUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.MutablyNamedIntention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -47,7 +49,7 @@ public class DemorgansLawIntention extends MutablyNamedIntention {
|
||||
return new ConjunctionPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
GrBinaryExpression exp =
|
||||
(GrBinaryExpression) element;
|
||||
|
||||
+6
-2
@@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
@@ -33,7 +37,7 @@ public class ExpandBooleanIntention extends Intention {
|
||||
return new ExpandBooleanPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrStatement containingStatement = (GrStatement) element;
|
||||
if (ExpandBooleanPredicate.isBooleanAssignment(containingStatement)) {
|
||||
|
||||
+6
-2
@@ -15,13 +15,17 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.MutablyNamedIntention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ComparisonUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
@@ -41,7 +45,7 @@ public class FlipComparisonIntention extends MutablyNamedIntention {
|
||||
return new ComparisonPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrBinaryExpression exp =
|
||||
(GrBinaryExpression) element;
|
||||
|
||||
+6
-2
@@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.BoolUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConditionalExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
@@ -31,7 +35,7 @@ public class FlipConditionalIntention extends Intention {
|
||||
return new ConditionalPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrConditionalExpression exp =
|
||||
(GrConditionalExpression) element;
|
||||
|
||||
+6
-2
@@ -15,12 +15,16 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.MutablyNamedIntention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -45,7 +49,7 @@ public class FlipConjunctionIntention extends MutablyNamedIntention {
|
||||
return new ConjunctionPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrBinaryExpression exp =
|
||||
(GrBinaryExpression) element;
|
||||
|
||||
+7
-3
@@ -15,13 +15,17 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
|
||||
public class MergeElseIfIntention extends Intention {
|
||||
@@ -31,7 +35,7 @@ public class MergeElseIfIntention extends Intention {
|
||||
return new MergeElseIfPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrIfStatement parentStatement = (GrIfStatement) element;
|
||||
GrBlockStatement elseBlockStatement = (GrBlockStatement) parentStatement.getElseBranch();
|
||||
|
||||
+6
-2
@@ -15,13 +15,17 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ConditionalUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ParenthesesUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -34,7 +38,7 @@ public class MergeIfAndIntention extends Intention {
|
||||
return new MergeIfAndPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrIfStatement parentStatement =
|
||||
(GrIfStatement) element;
|
||||
|
||||
+4
-2
@@ -15,14 +15,16 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ComparisonUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.MutablyNamedIntention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.intentions.utils.ComparisonUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
@@ -42,7 +44,7 @@ public class NegateComparisonIntention extends MutablyNamedIntention {
|
||||
return new ComparisonPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrBinaryExpression exp =
|
||||
(GrBinaryExpression) element;
|
||||
|
||||
+6
-2
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.control;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
|
||||
@@ -29,7 +33,7 @@ public class SplitElseIfIntention extends Intention {
|
||||
return new SplitElseIfPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrIfStatement parentStatement = (GrIfStatement) element;
|
||||
assert parentStatement != null;
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -40,7 +42,7 @@ public class ConvertClosureToMethodIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
element = element.getParent();
|
||||
StringBuilder builder = new StringBuilder(element.getTextLength());
|
||||
final GrField field = (GrField)element;
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
@@ -50,7 +52,7 @@ public class ConvertConcatenationToGstringIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
StringBuilder builder = new StringBuilder(element.getTextLength());
|
||||
if (element instanceof GrBinaryExpression) {
|
||||
performIntention((GrBinaryExpression)element, builder);
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
@@ -44,7 +46,7 @@ public class ConvertGStringToStringIntention extends Intention {
|
||||
return new ConvertibleGStringLiteralPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrLiteral exp = (GrLiteral)element;
|
||||
IntentionUtils.replaceExpression(convertGStringLiteralToStringLiteral(exp), exp);
|
||||
}
|
||||
|
||||
+6
-2
@@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@@ -31,7 +35,7 @@ public class ConvertIntegerToDecimalIntention extends Intention {
|
||||
return new ConvertIntegerToDecimalPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrLiteral exp = (GrLiteral) element;
|
||||
@NonNls String textString = exp.getText();
|
||||
|
||||
+6
-2
@@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@@ -32,7 +36,7 @@ public class ConvertIntegerToHexIntention extends Intention {
|
||||
return new ConvertIntegerToHexPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrLiteral exp = (GrLiteral) element;
|
||||
String textString = exp.getText();
|
||||
|
||||
+6
-2
@@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@@ -32,7 +36,7 @@ public class ConvertIntegerToOctalIntention extends Intention {
|
||||
return new ConvertIntegerToOctalPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrLiteral exp = (GrLiteral) element;
|
||||
@NonNls String textString = exp.getText();
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,7 +33,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrM
|
||||
*/
|
||||
public class ConvertJavaStyleArrayIntention extends Intention {
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrClosableBlock block = ((GrMethodCallExpression)element).getClosureArguments()[0];
|
||||
final String text = block.getText();
|
||||
int start = block.getLBrace().getStartOffsetInParent() + 1;
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -40,7 +42,7 @@ public class ConvertMethodToClosureIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
element = element.getParent();
|
||||
final GrMethod method = (GrMethod)element;
|
||||
StringBuilder builder = new StringBuilder(method.getTextLength());
|
||||
|
||||
+6
-2
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
|
||||
public class ConvertStringToGStringIntention extends Intention {
|
||||
@@ -28,7 +32,7 @@ public class ConvertStringToGStringIntention extends Intention {
|
||||
return new StringLiteralPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrLiteral exp = (GrLiteral)element;
|
||||
final String textString = exp.getText();
|
||||
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,7 +35,7 @@ public class IndexedExpressionConversionIntention extends Intention {
|
||||
return new IndexedExpressionConversionPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
|
||||
final GrIndexProperty arrayIndexExpression = (GrIndexProperty) element;
|
||||
|
||||
+7
-3
@@ -15,15 +15,19 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.*;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
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.api.statements.arguments.GrArgumentList;
|
||||
|
||||
public class IndexingMethodConversionIntention extends Intention {
|
||||
|
||||
@@ -32,7 +36,7 @@ public class IndexingMethodConversionIntention extends Intention {
|
||||
return new IndexingMethodConversionPredicate();
|
||||
}
|
||||
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
|
||||
throws IncorrectOperationException {
|
||||
final GrMethodCallExpression callExpression =
|
||||
(GrMethodCallExpression) element;
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,7 +41,7 @@ public class RemoveParenthesesFromMethodCallIntention extends Intention {
|
||||
return element instanceof GrStatementOwner;
|
||||
}
|
||||
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
final GrMethodCallExpression expression = (GrMethodCallExpression) element;
|
||||
final StringBuilder newStatementText = new StringBuilder();
|
||||
newStatementText.append(expression.getInvokedExpression().getText());
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,7 +38,7 @@ public class RemoveUnnecessaryBracesInGStringIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
GrStringUtil.removeUnnecessaryBracesInGString((GrString)element);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.style;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -31,6 +33,7 @@ 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 static org.jetbrains.plugins.groovy.lang.psi.util.PsiElementUtil.*;
|
||||
|
||||
/**
|
||||
@@ -42,7 +45,7 @@ public class JavaStylePropertiesInvocationIntention extends Intention {
|
||||
return super.isStopElement(element) || element instanceof GrClosableBlock;
|
||||
}
|
||||
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
assert element instanceof GrMethodCallExpression || element instanceof GrApplicationStatement;
|
||||
GrCall call = ((GrCall) element);
|
||||
GrExpression invoked = call instanceof GrMethodCallExpression ?
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions.style;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
@@ -51,12 +52,12 @@ public class ReplaceAbstractClassInstanceByMapIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement psiElement) throws IncorrectOperationException {
|
||||
Project project = psiElement.getProject();
|
||||
protected void processIntention(@NotNull PsiElement psiElement, Project project, Editor editor) throws IncorrectOperationException {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
final GrNewExpression newExpr = (GrNewExpression)psiElement;
|
||||
GrCodeReferenceElement ref = newExpr.getReferenceElement();
|
||||
assert ref != null;
|
||||
|
||||
final PsiElement resolved = ref.resolve();
|
||||
assert resolved instanceof PsiClass;// && ((PsiClass)resolved).isInterface();
|
||||
|
||||
+3
-3
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.intentions.style.parameterToEntry;
|
||||
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.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -83,8 +84,7 @@ public class ConvertParameterToMapEntryIntention extends Intention {
|
||||
@NonNls private static final String MAP_TYPE_TEXT = "Map";
|
||||
@NonNls private static final String[] MY_POSSIBLE_NAMES = new String[]{"attrs", "args", "params", "map"};
|
||||
|
||||
protected void processIntention(@NotNull final PsiElement element) throws IncorrectOperationException {
|
||||
final Project project = element.getProject();
|
||||
protected void processIntention(@NotNull final PsiElement element, final Project project, Editor editor) throws IncorrectOperationException {
|
||||
// Method or closure to be refactored
|
||||
final GrParametersOwner owner = PsiTreeUtil.getParentOfType(element, GrParametersOwner.class);
|
||||
final Collection<PsiElement> occurrences = new ArrayList<PsiElement>();
|
||||
@@ -207,7 +207,7 @@ public class ConvertParameterToMapEntryIntention extends Intention {
|
||||
call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY;
|
||||
|
||||
final GrClosureSignatureUtil.ArgInfo<PsiElement>[] argInfos =
|
||||
GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope());
|
||||
GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, argumentList, closureArguments);
|
||||
if (argInfos == null) continue;
|
||||
final GrClosureSignatureUtil.ArgInfo<PsiElement> argInfo = argInfos[index];
|
||||
|
||||
|
||||
+1
-1
@@ -264,7 +264,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
else if (call instanceof GrCallExpression) {
|
||||
GrCallExpression constructorCall = (GrCallExpression)call;
|
||||
ContainerUtil.addAll(results, constructorCall.getMethodVariants(null));
|
||||
ContainerUtil.addAll(results, constructorCall.getCallVariants(null));
|
||||
final PsiType type = ((GrCallExpression)call).getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClass psiClass = ((PsiClassType)type).resolve();
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class GroovyParameterInfoHandler implements ParameterInfoHandler<GroovyPs
|
||||
}
|
||||
|
||||
public void showParameterInfo(@NotNull GroovyPsiElement place, CreateParameterInfoContext context) {
|
||||
GroovyResolveResult[] variants = ResolveUtil.getMethodVariants(place);
|
||||
GroovyResolveResult[] variants = ResolveUtil.getCallVariants(place);
|
||||
final List<GroovyResolveResult> namedElements = ContainerUtil.findAll(variants, new Condition<GroovyResolveResult>() {
|
||||
public boolean value(GroovyResolveResult groovyResolveResult) {
|
||||
final PsiElement element = groovyResolveResult.getElement();
|
||||
|
||||
+14
-1
@@ -65,8 +65,21 @@ public class ConstructorBody implements GroovyElementTypes {
|
||||
|
||||
private static boolean parseExplicitConstructor(PsiBuilder builder, GroovyParser parser) {
|
||||
TypeArguments.parse(builder);
|
||||
boolean result = false;
|
||||
if (ParserUtils.lookAhead(builder, kTHIS, mLPAREN)) {
|
||||
final PsiBuilder.Marker marker = builder.mark();
|
||||
ParserUtils.getToken(builder, kTHIS);
|
||||
marker.done(THIS_REFERENCE_EXPRESSION);
|
||||
result = true;
|
||||
}
|
||||
if (ParserUtils.lookAhead(builder, kSUPER, mLPAREN)) {
|
||||
final PsiBuilder.Marker marker = builder.mark();
|
||||
ParserUtils.getToken(builder, kSUPER);
|
||||
marker.done(SUPER_REFERENCE_EXPRESSION);
|
||||
result = true;
|
||||
}
|
||||
|
||||
if ((ParserUtils.getToken(builder, kTHIS) || ParserUtils.getToken(builder, kSUPER)) && ParserUtils.lookAhead(builder, mLPAREN)) {
|
||||
if (result) {
|
||||
PsiBuilder.Marker marker = builder.mark();
|
||||
ParserUtils.getToken(builder, mLPAREN);
|
||||
ArgumentList.parseArgumentList(builder, mRPAREN, parser);
|
||||
|
||||
+145
-56
@@ -3,6 +3,8 @@ package org.jetbrains.plugins.groovy.lang.psi;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
@@ -11,13 +13,67 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParent
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.arithmetic.GrRangeExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
private final Map<String, String> simpleTypes = new HashMap<String, String>();
|
||||
private final Set<String> iterations = new HashSet<String>();
|
||||
|
||||
public ClosureParameterEnhancer() {
|
||||
simpleTypes.put("times", "java.lang.Integer");
|
||||
simpleTypes.put("upto", "java.lang.Integer");
|
||||
simpleTypes.put("downto", "java.lang.Integer");
|
||||
simpleTypes.put("step", "java.lang.Integer");
|
||||
simpleTypes.put("withObjectOutputStream", "java.io.ObjectOutputStream");//todo
|
||||
simpleTypes.put("withObjectInputStream", "java.io.ObjectInputStream");
|
||||
simpleTypes.put("withOutputStream", "java.io.OutputStream");
|
||||
simpleTypes.put("withInputStream", "java.io.InputStream");
|
||||
simpleTypes.put("withDataOutputStream", "java.io.DataOutputStream");
|
||||
simpleTypes.put("withDataInputStream", "java.io.DataInputStream");
|
||||
simpleTypes.put("eachLine", "java.lang.String");
|
||||
simpleTypes.put("eachFile", "java.io.File");
|
||||
simpleTypes.put("eachDir", "java.io.File");
|
||||
simpleTypes.put("eachFileRecurse", "java.io.File");
|
||||
simpleTypes.put("traverse", "java.io.File");
|
||||
simpleTypes.put("eachDirRecurse", "java.io.File");
|
||||
simpleTypes.put("eachFileMatch", "java.io.File");
|
||||
simpleTypes.put("eachDirMatch", "java.io.File");
|
||||
simpleTypes.put("withReader", "java.io.Reader");
|
||||
simpleTypes.put("withWriter", "java.io.Writer");
|
||||
simpleTypes.put("withWriterAppend", "java.io.Writer");
|
||||
simpleTypes.put("withPrintWriter", "java.io.PrintWriter");
|
||||
simpleTypes.put("eachByte", "byte");
|
||||
simpleTypes.put("transformChar", "String");
|
||||
simpleTypes.put("transformLine", "String");
|
||||
simpleTypes.put("filterLine", "String");
|
||||
simpleTypes.put("accept", "java.net.Socket");
|
||||
|
||||
iterations.add("each");
|
||||
iterations.add("any");
|
||||
iterations.add("every");
|
||||
iterations.add("reverseEach");
|
||||
iterations.add("collect");
|
||||
iterations.add("collectAll");
|
||||
iterations.add("find");
|
||||
iterations.add("findAll");
|
||||
iterations.add("retainAll");
|
||||
iterations.add("removeAll");
|
||||
iterations.add("split");
|
||||
iterations.add("groupBy");
|
||||
iterations.add("groupEntriesBy");
|
||||
iterations.add("findLastIndexOf");
|
||||
iterations.add("findIndexValues");
|
||||
iterations.add("findIndexOf");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -28,11 +84,11 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
}
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(closure.getProject()).getElementFactory();
|
||||
String methodName = findMethodName((GrMethodCallExpression)parent);
|
||||
//final GrExpression invokedExpression = methodCall.getInvokedExpression();
|
||||
//PsiType type = findQualifierType(methodCall);
|
||||
|
||||
GrExpression expression = ((GrMethodCallExpression)parent).getInvokedExpression();
|
||||
if (!(expression instanceof GrReferenceExpression)) return null;
|
||||
final PsiElement resolved = ((GrReferenceExpression)expression).resolve();
|
||||
if (!(resolved instanceof GrGdkMethod)) return null;
|
||||
|
||||
GrExpression qualifier = ((GrReferenceExpression)expression).getQualifierExpression();
|
||||
if (qualifier == null) return null;
|
||||
@@ -42,74 +98,103 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("each".equals(methodName) ||
|
||||
"every".equals(methodName) ||
|
||||
"collect".equals(methodName) ||
|
||||
"find".equals(methodName) ||
|
||||
"findAll".equals(methodName) ||
|
||||
"findIndexOf".equals(methodName)) {
|
||||
PsiType res = findTypeForCollection(qualifier, factory, closure);
|
||||
if (closure.getParameters().length <= 1 && res != null) {
|
||||
return res;
|
||||
}
|
||||
final PsiParameter[] params = closure.getAllParameters();
|
||||
|
||||
if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
if (closure.getParameters().length <= 1) {
|
||||
return getEntryForMap(type, factory, closure);
|
||||
}
|
||||
if (closure.getParameters().length == 2) {
|
||||
if (index == 0) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, true);
|
||||
}
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 1, true);
|
||||
if (params.length == 1 && simpleTypes.containsKey(methodName)) {
|
||||
return factory.createTypeFromText(simpleTypes.get(methodName), closure);
|
||||
}
|
||||
|
||||
if (iterations.contains(methodName)) {
|
||||
if (params.length == 1) {
|
||||
return findTypeForIteration(qualifier, factory, closure);
|
||||
}
|
||||
if (params.length == 2 && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
if (index == 0) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, true);
|
||||
}
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 1, true);
|
||||
}
|
||||
}
|
||||
else if ("with".equals(methodName) && closure.getParameters().length <= 1) {
|
||||
else if ("with".equals(methodName) && params.length == 1) {
|
||||
return type;
|
||||
}
|
||||
else {
|
||||
final PsiParameter[] paramCount = closure.getAllParameters();
|
||||
if ("eachWithIndex".equals(methodName)) {
|
||||
PsiType res = findTypeForCollection(qualifier, factory, closure);
|
||||
if (closure.getParameters().length == 2 && res != null) {
|
||||
else if ("eachWithIndex".equals(methodName)) {
|
||||
PsiType res = findTypeForIteration(qualifier, factory, closure);
|
||||
if (params.length == 2 && res != null) {
|
||||
if (index == 0) {
|
||||
return res;
|
||||
}
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, closure);
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
if (params.length == 2) {
|
||||
if (index == 0) {
|
||||
return res;
|
||||
return getEntryForMap(type, factory, closure);
|
||||
}
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, closure);
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
if (paramCount.length == 2) {
|
||||
if (index == 0) {
|
||||
return getEntryForMap(type, factory, closure);
|
||||
}
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, closure);
|
||||
if (params.length == 3) {
|
||||
if (index == 0) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, true);
|
||||
}
|
||||
if (paramCount.length == 3) {
|
||||
if (index == 0) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, true);
|
||||
}
|
||||
if (index == 1) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 1, true);
|
||||
}
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, closure);
|
||||
if (index == 1) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 1, true);
|
||||
}
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, closure);
|
||||
}
|
||||
}
|
||||
else if ("inject".equals(methodName) && paramCount.length == 2) {
|
||||
if (index == 0) {
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, closure);
|
||||
}
|
||||
}
|
||||
else if ("inject".equals(methodName) && params.length == 2) {
|
||||
if (index == 0) {
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, closure);
|
||||
}
|
||||
|
||||
PsiType res = findTypeForCollection(qualifier, factory, closure);
|
||||
if (res != null) {
|
||||
return res;
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
return getEntryForMap(type, factory, closure);
|
||||
PsiType res = findTypeForIteration(qualifier, factory, closure);
|
||||
if (res != null) {
|
||||
return res;
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
return getEntryForMap(type, factory, closure);
|
||||
}
|
||||
}
|
||||
else if ("eachPermutation".equals(methodName) && params.length == 1) {
|
||||
final PsiType itemType = findTypeForIteration(qualifier, factory, closure);
|
||||
if (itemType != null) {
|
||||
return factory.createTypeFromText("java.util.ArrayList<" + itemType.getCanonicalText() + ">", closure);
|
||||
}
|
||||
return factory.createTypeFromText("java.util.ArrayList", closure);
|
||||
}
|
||||
else if ("withDefault".equals(methodName)) {
|
||||
if (params.length == 1 && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, true);
|
||||
}
|
||||
}
|
||||
else if ("sort".equals(methodName)) {
|
||||
if (params.length < 3) {
|
||||
return findTypeForIteration(qualifier, factory, closure);
|
||||
}
|
||||
}
|
||||
else if ("withStream".equals(methodName)) {
|
||||
final PsiMethod method = ((GrMethodCallExpression)parent).resolveMethod();
|
||||
if (method != null) {
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (parameters.length > 0) {
|
||||
return parameters[0].getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("withStreams".equals(methodName)) {
|
||||
if (index == 0) {
|
||||
return factory.createTypeFromText("java.io.InputStream", closure);
|
||||
}
|
||||
else if (index == 1) return factory.createTypeFromText("java.io.OutputStream", closure);
|
||||
}
|
||||
else if ("withObjectStreams".equals(methodName)) {
|
||||
if (index == 0) {
|
||||
return factory.createTypeFromText("java.io.ObjectInputStream", closure);
|
||||
}
|
||||
else if (index == 1) return factory.createTypeFromText("java.io.ObjectOutputStream", closure);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -121,11 +206,11 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
if (key != null && key != PsiType.NULL && value != null && value != PsiType.NULL) {
|
||||
return factory.createTypeFromText("java.util.Map.Entry<" + key.getCanonicalText() + ", " + value.getCanonicalText() + ">", context);
|
||||
}
|
||||
return null;
|
||||
return factory.createTypeFromText("java.util.Map.Entry", context);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiType findTypeForCollection(GrExpression qualifier, PsiElementFactory factory, PsiElement context) {
|
||||
public static PsiType findTypeForIteration(GrExpression qualifier, PsiElementFactory factory, PsiElement context) {
|
||||
PsiType iterType = qualifier.getType();
|
||||
if (iterType == null) return null;
|
||||
if (iterType instanceof PsiArrayType) {
|
||||
@@ -136,10 +221,10 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
return types.length == 1 ? types[0] : null;
|
||||
}
|
||||
|
||||
if (factory.createTypeFromText("groovy.lang.IntRange", context).isAssignableFrom(iterType)) {
|
||||
if (InheritanceUtil.isInheritor(iterType, "groovy.lang.IntRange")) {
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_INTEGER, context);
|
||||
}
|
||||
if (factory.createTypeFromText("groovy.lang.ObjectRange", context).isAssignableFrom(iterType)) {
|
||||
if (InheritanceUtil.isInheritor(iterType, "groovy.lang.ObjectRange")) {
|
||||
PsiElement element = qualifier;
|
||||
element = removeBrackets(element);
|
||||
if (element instanceof GrReferenceExpression) {
|
||||
@@ -160,6 +245,10 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
if (iterType.equalsToText(CommonClassNames.JAVA_LANG_STRING) || iterType.equalsToText("java.io.File")) {
|
||||
return factory.createTypeFromText(CommonClassNames.JAVA_LANG_STRING, context);
|
||||
}
|
||||
|
||||
if (InheritanceUtil.isInheritor(iterType, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
return getEntryForMap(iterType, factory, context);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -16,18 +16,17 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiPolyVariantReference;
|
||||
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.GrConstructorCall;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrThisSuperReferenceExpression;
|
||||
|
||||
/**
|
||||
* User: Dmitry.Krasilschikov
|
||||
* Date: 29.05.2007
|
||||
*/
|
||||
public interface GrConstructorInvocation extends GrStatement, GrConstructorCall, PsiPolyVariantReference {
|
||||
public interface GrConstructorInvocation extends GrStatement, GrConstructorCall {
|
||||
boolean isSuperCall();
|
||||
|
||||
boolean isThisCall();
|
||||
@@ -35,7 +34,7 @@ public interface GrConstructorInvocation extends GrStatement, GrConstructorCall,
|
||||
@NotNull
|
||||
GrArgumentList getArgumentList();
|
||||
|
||||
PsiElement getThisOrSuperKeyword();
|
||||
GrThisSuperReferenceExpression getThisOrSuperKeyword();
|
||||
|
||||
@Nullable
|
||||
PsiClass getDelegatedClass();
|
||||
|
||||
+1
-5
@@ -4,12 +4,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public interface GrSuperReferenceExpression extends GrExpression {
|
||||
@Nullable
|
||||
GrReferenceExpression getQualifier();
|
||||
public interface GrSuperReferenceExpression extends GrThisSuperReferenceExpression {
|
||||
}
|
||||
+1
-5
@@ -4,12 +4,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public interface GrThisReferenceExpression extends GrExpression {
|
||||
@Nullable
|
||||
GrReferenceExpression getQualifier();
|
||||
public interface GrThisReferenceExpression extends GrThisSuperReferenceExpression {
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.lang.psi.api.statements.expressions;
|
||||
|
||||
import com.intellij.psi.PsiPolyVariantReference;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public interface GrThisSuperReferenceExpression extends GrExpression, PsiPolyVariantReference {
|
||||
@Nullable
|
||||
GrReferenceExpression getQualifier();
|
||||
}
|
||||
+1
-1
@@ -43,7 +43,7 @@ public interface GrCallExpression extends GrExpression, GrCall {
|
||||
PsiMethod resolveMethod();
|
||||
|
||||
@NotNull
|
||||
GroovyResolveResult[] getMethodVariants(@Nullable GrExpression upToArgument);
|
||||
GroovyResolveResult[] getCallVariants(@Nullable GrExpression upToArgument);
|
||||
|
||||
//PsiElement addNamedArgument(GrNamedArgument argument);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user