mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.wizard;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
@@ -37,6 +38,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -113,10 +115,11 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
|
||||
panel.add(buttonPanel, BorderLayout.EAST);
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
panel.add(buttonPanel, BorderLayout.EAST);
|
||||
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
|
||||
|
||||
myHelpButton.putClientProperty("JButton.buttonType", "help");
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
myHelpButton.setText("");
|
||||
@@ -127,7 +130,6 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
leftPanel.add(myHelpButton);
|
||||
}
|
||||
leftPanel.add(myCancelButton);
|
||||
|
||||
panel.add(leftPanel, BorderLayout.WEST);
|
||||
|
||||
buttonPanel.add(myFinishButton);
|
||||
@@ -139,20 +141,31 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
else {
|
||||
panel.add(buttonPanel, BorderLayout.CENTER);
|
||||
GroupLayout layout = new GroupLayout(buttonPanel);
|
||||
buttonPanel.setLayout(layout);
|
||||
layout.setAutoCreateGaps(true);
|
||||
|
||||
final GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
|
||||
final GroupLayout.ParallelGroup vGroup = layout.createParallelGroup();
|
||||
final Collection<Component> buttons = Lists.newArrayListWithExpectedSize(5);
|
||||
final boolean helpAvailable = ApplicationInfo.contextHelpAvailable();
|
||||
|
||||
if (helpAvailable && UIUtil.isUnderGTKLookAndFeel()) {
|
||||
add(hGroup, vGroup, buttons, myHelpButton);
|
||||
}
|
||||
add(hGroup, vGroup, null, Box.createHorizontalGlue());
|
||||
if (mySteps.size() > 1) {
|
||||
buttonPanel.add(myPreviousButton);
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonPanel.add(myNextButton);
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
add(hGroup, vGroup, buttons, myPreviousButton, myNextButton);
|
||||
}
|
||||
add(hGroup, vGroup, buttons, myFinishButton, myCancelButton);
|
||||
if (helpAvailable && !UIUtil.isUnderGTKLookAndFeel()) {
|
||||
add(hGroup, vGroup, buttons, myHelpButton);
|
||||
}
|
||||
|
||||
buttonPanel.add(myFinishButton);
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonPanel.add(myCancelButton);
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
if (ApplicationInfo.contextHelpAvailable()) {
|
||||
buttonPanel.add(myHelpButton);
|
||||
}
|
||||
layout.setHorizontalGroup(hGroup);
|
||||
layout.setVerticalGroup(vGroup);
|
||||
layout.linkSize(buttons.toArray(new Component[buttons.size()]));
|
||||
}
|
||||
|
||||
myPreviousButton.setEnabled(false);
|
||||
@@ -201,6 +214,17 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static void add(final GroupLayout.Group hGroup,
|
||||
final GroupLayout.Group vGroup,
|
||||
@Nullable final Collection<Component> collection,
|
||||
final Component... components) {
|
||||
for (Component component : components) {
|
||||
hGroup.addComponent(component);
|
||||
vGroup.addComponent(component);
|
||||
if (collection != null) collection.add(component);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TallImageComponent extends OpaquePanel {
|
||||
private Icon myIcon;
|
||||
|
||||
|
||||
@@ -368,6 +368,10 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (UIUtil.isUnderGTKLookAndFeel() && Arrays.asList(actions).contains(getHelpAction())) {
|
||||
leftSideActions = ArrayUtil.append(leftSideActions, getHelpAction());
|
||||
actions = ArrayUtil.remove(actions, getHelpAction());
|
||||
}
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
final JPanel lrButtonsPanel = new JPanel(new GridBagLayout());
|
||||
|
||||
@@ -30,8 +30,8 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.sun.jdi.AbsentInformationException;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
@@ -69,7 +69,7 @@ public class GradlePositionManager extends ScriptPositionManagerHelper {
|
||||
}
|
||||
|
||||
public boolean isAppropriateScriptFile(@NotNull final PsiFile scriptFile) {
|
||||
return GroovyScriptTypeDetector.isSpecificScriptFile((GroovyFile)scriptFile, GradleScriptType.INSTANCE);
|
||||
return scriptFile instanceof GroovyFile && GroovyScriptTypeDetector.isSpecificScriptFile((GroovyFile)scriptFile, GradleScriptType.INSTANCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -260,7 +260,7 @@ class.is.not.expected.here=Class is not expected here
|
||||
fix.package.name=Fix package name
|
||||
|
||||
#dynamic properties
|
||||
add.dynamic.property=Add dynamic property ''{0}''
|
||||
add.dynamic.property=Add Dynamic Property ''{0}''
|
||||
duplicate.element.in.the.map=Duplicate element in the map
|
||||
dynamic.toolwindow.search.elements=Search dynamic element
|
||||
dynamic.toolwindow.property.filter=Property Filter
|
||||
@@ -271,16 +271,16 @@ create.field.from.usage=Create Field ''{0}''
|
||||
create.method.from.usage=Create Method ''{0}''
|
||||
create.variable.from.usage=Create Variable ''{0}''
|
||||
add.dynamic.element=Add dynamic element
|
||||
add.dynamic.method=Add dynamic method
|
||||
add.dynamic.method=Add Dynamic Method
|
||||
dynamic.type=Type
|
||||
dynamic.name=Name
|
||||
dynamic.properties.table.name=Method arguments
|
||||
dynamic.method.return.type=Return type
|
||||
dynamic.method.property.type=Property type
|
||||
are.you.sure.to.delete.dynamic.property=Are you sure to delete ''{0}''?
|
||||
dynamic.property.deletion=Deletion dynamic property
|
||||
dynamic.property.deletion=Deletion Dynamic Property
|
||||
are.you.sure.to.delete.elements=Are you sure to delete ''{0}'' elements?
|
||||
dynamic.element.deletion=Dynamic element deletion
|
||||
dynamic.element.deletion=Dynamic Element Deletion
|
||||
dynamic.window=Dynamic window
|
||||
dynamic.properties.table.no.arguments=Arguments list is empty.
|
||||
assignment.expected='=' expected
|
||||
@@ -304,7 +304,7 @@ break.outside.loop=The break statement with named labels is only allowed inside
|
||||
Constructor=Constructor
|
||||
Getter=Getter
|
||||
Setter=Setter
|
||||
groovy.like.library.found=Groovy library found
|
||||
groovy.like.library.found=Groovy Library Found
|
||||
groovy.like.library.found.text=Do you want to set up Groovy for module ''{0}'' \n\
|
||||
with found library ''{1}'' (Groovy version {2})?
|
||||
compile.groovy.files=&Compile Groovy files
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
generate.equals.and.hashcode.already.defined.warning.anonymous=equals() and hashCode() already defined
|
||||
generate.equals.and.hashcode.already.defined.warning=equals() and hashCode() already defined
|
||||
generate.equals.and.hashcode.already.defined.title=equals() and hashCode() already defined
|
||||
generate.equals.and.hashcode.already.defined.title=equals() and hashCode() Already Defined
|
||||
generate.equals.compare.nested.arrays.comment= // Compare nested arrays - values of {0} here
|
||||
generate.equals.compare.arrays.comment= // Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
@@ -787,7 +787,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
assert file != null;
|
||||
|
||||
PsiDirectory psiDirectory = file.getContainingDirectory();
|
||||
if (psiDirectory != null) {
|
||||
if (psiDirectory != null && file instanceof GroovyFile) {
|
||||
PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
|
||||
if (aPackage != null) {
|
||||
String packageName = aPackage.getQualifiedName();
|
||||
|
||||
+2
@@ -79,6 +79,8 @@ public class GrMoveToDirFix implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!(file instanceof GroovyFile)) return;
|
||||
|
||||
final String packageName = ((GroovyFile)file).getPackageName();
|
||||
final Module module = ModuleUtil.findModuleForFile(file.getVirtualFile(), project);
|
||||
PsiDirectory directory = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, null, true);
|
||||
|
||||
+12
-9
@@ -40,14 +40,15 @@ import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTable;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTableModel;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTableTree;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
@@ -66,6 +67,7 @@ import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -247,7 +249,7 @@ public class DynamicToolWindowWrapper {
|
||||
myTreeTable.setTreeCellRenderer(treeCellRenderer);
|
||||
|
||||
myTreeTable.setRootVisible(false);
|
||||
myTreeTable.setSelectionMode(DefaultTreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
|
||||
myTreeTable.setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
|
||||
|
||||
final MyPropertyTypeCellEditor typeCellEditor = new MyPropertyTypeCellEditor();
|
||||
|
||||
@@ -318,11 +320,11 @@ public class DynamicToolWindowWrapper {
|
||||
final String qualifiedName = ((PsiClass)element).getQualifiedName();
|
||||
|
||||
return new RefactoringElementListener() {
|
||||
public void elementMoved(PsiElement newElement) {
|
||||
public void elementMoved(@NotNull PsiElement newElement) {
|
||||
renameElement(qualifiedName, newElement);
|
||||
}
|
||||
|
||||
public void elementRenamed(PsiElement newElement) {
|
||||
public void elementRenamed(@NotNull PsiElement newElement) {
|
||||
renameElement(qualifiedName, newElement);
|
||||
}
|
||||
|
||||
@@ -358,7 +360,7 @@ public class DynamicToolWindowWrapper {
|
||||
final int selectionRow = myTreeTable.getTree().getLeadSelectionRow();
|
||||
myTreeTable.editCellAt(selectionRow, TYPE_COLUMN, event);
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_F2, KeyEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_F2, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
|
||||
|
||||
// todo use "myTreeTable.setAutoCreateRowSorter(true);" since 1.6
|
||||
|
||||
@@ -510,7 +512,7 @@ public class DynamicToolWindowWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
class ClassColumnInfo extends ColumnInfo<DefaultMutableTreeNode, DNamedElement> {
|
||||
static class ClassColumnInfo extends ColumnInfo<DefaultMutableTreeNode, DNamedElement> {
|
||||
public ClassColumnInfo(String name) {
|
||||
super(name);
|
||||
}
|
||||
@@ -565,7 +567,7 @@ public class DynamicToolWindowWrapper {
|
||||
if (!(childObject instanceof DItemElement)) break;
|
||||
|
||||
filterText = getFilter();
|
||||
if (filterText == null || "".equals(filterText)) {
|
||||
if (filterText == null || filterText.isEmpty()) {
|
||||
((DItemElement)childObject).setHightlightedText("");
|
||||
|
||||
dynamicNodes.add(dynamicNode);
|
||||
@@ -689,7 +691,8 @@ public class DynamicToolWindowWrapper {
|
||||
}
|
||||
|
||||
private static String[] mapToUnqualified(final String[] argumentsNames) {
|
||||
return ContainerUtil.map2Array(argumentsNames, String.class, new Function<String, String>() {
|
||||
return ContainerUtil.map2Array(argumentsNames, String.class, new NullableFunction<String, String>() {
|
||||
@Nullable
|
||||
public String fun(final String s) {
|
||||
if (s == null) return null;
|
||||
int index = s.lastIndexOf(".");
|
||||
@@ -741,7 +744,7 @@ public class DynamicToolWindowWrapper {
|
||||
|
||||
if (element == null) return null;
|
||||
return element.getContainingFile();
|
||||
} else if (LangDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
|
||||
} else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
|
||||
return new DeleteProvider() {
|
||||
@Override
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
|
||||
+4
-7
@@ -148,7 +148,7 @@ public abstract class DynamicDialog extends DialogWrapper {
|
||||
setStatusTextAndIcon(null, "");
|
||||
}
|
||||
|
||||
private void setStatusTextAndIcon(final Icon icon, final String text) {
|
||||
private void setStatusTextAndIcon(@Nullable final Icon icon, final String text) {
|
||||
myTypeStatusLabel.setIcon(icon);
|
||||
myTypeStatusLabel.setText(text);
|
||||
pack();
|
||||
@@ -177,7 +177,7 @@ public abstract class DynamicDialog extends DialogWrapper {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myClassComboBox.requestFocus();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -191,7 +191,7 @@ public abstract class DynamicDialog extends DialogWrapper {
|
||||
final EditorComboBoxEditor comboEditor = new EditorComboBoxEditor(myProject, GroovyFileType.GROOVY_FILE_TYPE);
|
||||
|
||||
final Document document = createDocument("");
|
||||
assert document != null;
|
||||
LOG.assertTrue(document != null);
|
||||
|
||||
comboEditor.setItem(document);
|
||||
|
||||
@@ -213,7 +213,7 @@ public abstract class DynamicDialog extends DialogWrapper {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myTypeComboBox.requestFocus();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
|
||||
final EditorTextField editorTextField = (EditorTextField) myTypeComboBox.getEditor().getEditorComponent();
|
||||
@@ -228,9 +228,6 @@ public abstract class DynamicDialog extends DialogWrapper {
|
||||
});
|
||||
|
||||
PsiType type = typeConstraints.length == 1 ? typeConstraints[0].getDefaultType() : TypesUtil.getJavaLangObject(myContext);
|
||||
if (type == null) {
|
||||
type = TypesUtil.getJavaLangObject(myContext);
|
||||
}
|
||||
myTypeComboBox.getEditor().setItem(createDocument(type.getCanonicalText()));
|
||||
}
|
||||
|
||||
|
||||
@@ -95,9 +95,6 @@ public abstract class BaseInspection extends GroovySuppressableInspectionTool {
|
||||
final BaseInspectionVisitor visitor = buildGroovyVisitor(problemsHolder, isOnTheFly);
|
||||
groovyFile.accept(visitor);
|
||||
final List<ProblemDescriptor> problems = problemsHolder.getResults();
|
||||
if (problems == null) {
|
||||
return null;
|
||||
}
|
||||
return problems.toArray(new ProblemDescriptor[problems.size()]);
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ dynamic.property=Dynamic property
|
||||
unresolved.type.status=Type ''{0}'' is not resolved
|
||||
resolved.type.status=Type ''{0}'' is resolved
|
||||
no.type.specified=No type specified
|
||||
dynamic.element=Dynamic element
|
||||
dynamic.element=Dynamic Element
|
||||
|
||||
########################################################################################################################
|
||||
# InpectorGroovy properties
|
||||
@@ -57,7 +57,7 @@ pointless.boolean.display.name=Pointless boolean expression
|
||||
pointless.boolean.quickfix=Simplify
|
||||
|
||||
Cannot.perform.undo.operation=Cannot perform undo operation
|
||||
Undo.disable=Undo disabled
|
||||
Undo.disable=Undo Disabled
|
||||
field.already.defined=Variables with field names
|
||||
|
||||
access.to.inaccessible.element=Access to inaccessible element
|
||||
|
||||
+3
-1
@@ -108,7 +108,9 @@ public class GroovyAccessibilityInspection extends BaseInspection {
|
||||
String[] modifiers = {PsiModifier.PROTECTED, PsiModifier.PUBLIC, PsiModifier.PACKAGE_LOCAL};
|
||||
PsiClass accessObjectClass = PsiTreeUtil.getParentOfType(location, PsiClass.class, false);
|
||||
if (accessObjectClass == null) {
|
||||
accessObjectClass = ((GroovyFile)location.getContainingFile()).getScriptClass();
|
||||
final PsiFile file = location.getContainingFile();
|
||||
if (!(file instanceof GroovyFile)) return GroovyFix.EMPTY_ARRAY;
|
||||
accessObjectClass = ((GroovyFile)file).getScriptClass();
|
||||
}
|
||||
for (int i = ArrayUtil.indexOf(modifiers, minModifier); i < modifiers.length; i++) {
|
||||
String modifier = modifiers[i];
|
||||
|
||||
@@ -138,7 +138,8 @@ public class GroovyCompiler extends GroovyCompilerBase {
|
||||
"You seem to have global Groovy AST transformations defined in your project,\n" +
|
||||
"but they won't be applied to your code because they are not marked as compiler resources.\n" +
|
||||
"Do you want to add them to compiler resource list?\n" +
|
||||
"(you can do it yourself later in Settings | Compiler | Resource patterns)", "AST Transformations found",
|
||||
"(you can do it yourself later in Settings | Compiler | Resource patterns)",
|
||||
"AST Transformations Found",
|
||||
GroovyIcons.GROOVY_ICON_32x32);
|
||||
if (result == 0) {
|
||||
CompilerConfiguration.getInstance(myProject).addResourceFilePattern(AST_TRANSFORM_FILE_NAME);
|
||||
|
||||
@@ -103,7 +103,8 @@ public class GrabDependencies implements IntentionAction {
|
||||
assert vfile != null;
|
||||
|
||||
if (JavaPsiFacade.getInstance(project).findClass("org.apache.ivy.core.report.ResolveReport", file.getResolveScope()) == null) {
|
||||
Messages.showErrorDialog("Sorry, but IDEA cannot @Grab the dependencies without Ivy. Please add Ivy to your module dependencies and re-run the action.", "Ivy missing");
|
||||
Messages.showErrorDialog("Sorry, but IDEA cannot @Grab the dependencies without Ivy. Please add Ivy to your module dependencies and re-run the action.",
|
||||
"Ivy Missing");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ do.not.create.first.new=Use &existing first parameter as map for named arguments
|
||||
convert.cannot.itself=Refactoring is not available for map parameter itself
|
||||
perform.refactoring=Performing refactoring
|
||||
map.param.name=Map parameter &name:
|
||||
convert.param.to.map.entry=Convert parameter to map entry
|
||||
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
|
||||
@@ -102,7 +102,7 @@ create.parameter.for.field=Add parameter for field ''{0}''
|
||||
create.parameter.for.fields=Add parameter for field...
|
||||
closure.used.as.variable=Closure is passed as argument. Refactoring can break semantic.
|
||||
|
||||
convert.map.to.class.intention.name=Convert to class
|
||||
convert.map.to.class.intention.name=Convert to Class
|
||||
convert.map.to.class.intention.family.name=Convert Groovy native map to class instances
|
||||
do.you.want.to.change.method.return.type=Do you want to change return type of ''{0}'' method
|
||||
do.you.want.to.change.variable.type=Do you want to change type of ''{0}''
|
||||
|
||||
+2
-2
@@ -40,7 +40,6 @@ import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
@@ -77,7 +76,8 @@ public class ConvertMapToClassIntention extends Intention {
|
||||
final GrListOrMap map = (GrListOrMap)element;
|
||||
final GrNamedArgument[] namedArguments = map.getNamedArguments();
|
||||
LOG.assertTrue(map.getInitializers().length == 0);
|
||||
final String packageName = ((GroovyFileBase)map.getContainingFile()).getPackageName();
|
||||
final PsiFile file = map.getContainingFile();
|
||||
final String packageName = file instanceof GroovyFileBase ? ((GroovyFileBase)file).getPackageName() : "";
|
||||
|
||||
final CreateClassDialog dialog =
|
||||
new CreateClassDialog(project, GroovyBundle.message("create.class.family.name"), "", packageName, CreateClassKind.CLASS, true,
|
||||
|
||||
+8
-2
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.intentions.conversions;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
@@ -50,8 +51,13 @@ class RemoveParenthesesFromMethodPredicate implements PsiElementPredicate {
|
||||
if (rightParen != null) rightParen.delete();
|
||||
newStatementText.append(argumentList.getText());
|
||||
}
|
||||
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(element.getProject());
|
||||
final GrStatement newStatement = factory.createStatementFromText(newStatementText.toString());
|
||||
final GrStatement newStatement;
|
||||
try {
|
||||
newStatement = GroovyPsiElementFactory.getInstance(element.getProject()).createStatementFromText(newStatementText.toString());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
return false;
|
||||
}
|
||||
if (newStatement instanceof GrApplicationStatement) {
|
||||
final GrCommandArgumentList newArgList = ((GrApplicationStatement)newStatement).getArgumentList();
|
||||
if (newArgList == null && argumentList == null ||
|
||||
|
||||
+7
-4
@@ -29,7 +29,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
|
||||
|
||||
/**
|
||||
@@ -41,10 +44,10 @@ public class ImportOnDemandIntention extends Intention {
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
LOG.assertTrue(element instanceof GrReferenceElement);
|
||||
if (!(element instanceof GrReferenceElement)) return;
|
||||
final GrReferenceElement ref = (GrReferenceElement)element;
|
||||
final PsiElement resolved = ref.resolve();
|
||||
LOG.assertTrue(resolved instanceof PsiClass);
|
||||
if (!(resolved instanceof PsiClass)) return;
|
||||
|
||||
final String qname = ((PsiClass)resolved).getQualifiedName();
|
||||
|
||||
@@ -52,7 +55,7 @@ public class ImportOnDemandIntention extends Intention {
|
||||
GroovyPsiElementFactory.getInstance(project).createImportStatementFromText(qname, true, true, null);
|
||||
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
LOG.assertTrue(containingFile instanceof GroovyFile);
|
||||
if (!(containingFile instanceof GroovyFile)) return;
|
||||
((GroovyFile)containingFile).addImport(importStatement);
|
||||
|
||||
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile), true)) {
|
||||
|
||||
+8
-7
@@ -43,19 +43,20 @@ public class ImportStaticIntention extends Intention {
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
|
||||
LOG.assertTrue(element instanceof GrReferenceExpression);
|
||||
if (!(element instanceof GrReferenceExpression)) return;
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)element;
|
||||
final PsiElement resolved = ref.resolve();
|
||||
LOG.assertTrue(resolved instanceof PsiMember);
|
||||
if (!(resolved instanceof PsiMember)) return;
|
||||
|
||||
final PsiClass containingClass = ((PsiMember)resolved).getContainingClass();
|
||||
LOG.assertTrue(containingClass != null);
|
||||
if (containingClass == null) return;
|
||||
final String qname = containingClass.getQualifiedName();
|
||||
final String name = ((PsiMember)resolved).getName();
|
||||
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
LOG.assertTrue(containingFile instanceof GroovyFile);
|
||||
((GroovyFile)containingFile).accept(new GroovyRecursiveElementVisitor() {
|
||||
if (!(containingFile instanceof GroovyFile)) return;
|
||||
final GroovyFile file = (GroovyFile)containingFile;
|
||||
file.accept(new GroovyRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(GrReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
@@ -72,7 +73,7 @@ public class ImportStaticIntention extends Intention {
|
||||
GroovyPsiElementFactory.getInstance(project).createImportStatementFromText(qname + "." + name, true, false, null);
|
||||
|
||||
|
||||
((GroovyFile)containingFile).addImport(importStatement);
|
||||
file.addImport(importStatement);
|
||||
|
||||
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
|
||||
final PsiElement refElement = reference.getElement();
|
||||
@@ -82,7 +83,7 @@ public class ImportStaticIntention extends Intention {
|
||||
}
|
||||
|
||||
|
||||
((GroovyFile)containingFile).accept(new GroovyRecursiveElementVisitor() {
|
||||
file.accept(new GroovyRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(GrReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ public class GroovyMapParameterDialog extends DialogWrapper {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myNameComboBox.requestFocus();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
for (String possibleName : possibleNames) {
|
||||
myNameComboBox.addItem(possibleName);
|
||||
|
||||
@@ -91,36 +91,38 @@ public class GrReferenceAdjuster {
|
||||
final PsiElement resolved = resolveRef(ref, uncomplete);
|
||||
if (resolved == null) return false;
|
||||
|
||||
if (!CodeStyleSettingsManager.getSettings(ref.getProject()).INSERT_INNER_CLASS_IMPORTS && resolved instanceof PsiClass && ((PsiClass)resolved).getContainingClass() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final GrQualifiedReference<Qualifier> copy = getCopy(ref);
|
||||
|
||||
copy.setQualifier(null);
|
||||
if (!copy.isReferenceTo(resolved)) {
|
||||
if (resolved instanceof PsiClass) {
|
||||
final GroovyFileBase file = (GroovyFileBase)ref.getContainingFile();
|
||||
final PsiClass clazz = (PsiClass)resolved;
|
||||
final String qName = clazz.getQualifiedName();
|
||||
if (qName != null) {
|
||||
if (addImports && mayInsertImport(ref)) {
|
||||
final GrImportStatement added = file.addImportForClass(clazz);
|
||||
if (!copy.isReferenceTo(resolved)) {
|
||||
file.removeImport(added);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!checkCopyWithoutQualifier(ref, addImports, resolved)) return false;
|
||||
ref.setQualifier(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static <Qualifier extends PsiElement> boolean checkCopyWithoutQualifier(GrQualifiedReference<Qualifier> ref,
|
||||
boolean addImports,
|
||||
PsiElement resolved) {
|
||||
final GrQualifiedReference<Qualifier> copy = getCopy(ref);
|
||||
copy.setQualifier(null);
|
||||
|
||||
if (copy.isReferenceTo(resolved)) return true;
|
||||
|
||||
if (resolved instanceof PsiClass) {
|
||||
final PsiClass clazz = (PsiClass)resolved;
|
||||
final String qName = clazz.getQualifiedName();
|
||||
if (qName != null && addImports && checkIsInnerClass(clazz) && mayInsertImport(ref)) {
|
||||
final GroovyFileBase file = (GroovyFileBase)ref.getContainingFile();
|
||||
final GrImportStatement added = file.addImportForClass(clazz);
|
||||
if (copy.isReferenceTo(resolved)) return true;
|
||||
file.removeImport(added);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkIsInnerClass(PsiClass resolved) {
|
||||
final PsiClass containingClass = resolved.getContainingClass();
|
||||
return containingClass == null || CodeStyleSettingsManager.getSettings(resolved.getProject()).INSERT_INNER_CLASS_IMPORTS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <Qualifier extends PsiElement> PsiElement resolveRef(GrQualifiedReference<Qualifier> ref, boolean uncomplete) {
|
||||
if (!uncomplete) return ref.resolve();
|
||||
@@ -176,7 +178,8 @@ public class GrReferenceAdjuster {
|
||||
private static <Qualifier extends PsiElement> boolean mayInsertImport(GrQualifiedReference<Qualifier> ref) {
|
||||
return PsiTreeUtil.getParentOfType(ref, GrDocComment.class) == null &&
|
||||
!(ref.getContainingFile() instanceof GroovyCodeFragment) &&
|
||||
PsiTreeUtil.getParentOfType(ref, GrImportStatement.class) == null;
|
||||
PsiTreeUtil.getParentOfType(ref, GrImportStatement.class) == null &&
|
||||
ref.getContainingFile() instanceof GroovyFileBase;
|
||||
}
|
||||
|
||||
public static boolean seemsToBeQualifiedClassName(@Nullable GrExpression expr) {
|
||||
|
||||
+2
-1
@@ -55,7 +55,8 @@ public class GroovyClassNameInsertHandler implements InsertHandler<JavaPsiClassR
|
||||
PsiFile file = context.getFile();
|
||||
Editor editor = context.getEditor();
|
||||
int endOffset = editor.getCaretModel().getOffset();
|
||||
if (PsiTreeUtil.findElementOfClassAtOffset(file, endOffset - 1, GrImportStatement.class, false) != null) {
|
||||
if (PsiTreeUtil.findElementOfClassAtOffset(file, endOffset - 1, GrImportStatement.class, false) != null ||
|
||||
!(file instanceof GroovyFileBase)) {
|
||||
AllClassesGetter.INSERT_FQN.handleInsert(context, item);
|
||||
return;
|
||||
}
|
||||
|
||||
+1
@@ -100,6 +100,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
|
||||
if (ref != null &&
|
||||
ref.getQualifier() == null &&
|
||||
context.getFile() instanceof GroovyFile &&
|
||||
!importAlreadyExists(member, ((GroovyFile)context.getFile()), ref) &&
|
||||
!PsiManager.getInstance(context.getProject()).areElementsEquivalent(ref.resolve(), member)) {
|
||||
ref.bindToElementViaStaticImport(containingClass);
|
||||
|
||||
-11
@@ -25,10 +25,8 @@ import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
|
||||
/**
|
||||
@@ -67,13 +65,4 @@ public class AfterNewClassInsertHandler implements InsertHandler<LookupItem<PsiC
|
||||
AutoPopupController.getInstance(context.getProject()).autoPopupParameterInfo(context.getEditor(), null);
|
||||
}
|
||||
}
|
||||
|
||||
private static GroovyPsiElement obtainPlace(InsertionContext context) {
|
||||
PsiElement place = context.getFile().findElementAt(context.getStartOffset());
|
||||
assert place != null;
|
||||
if (place instanceof GroovyPsiElement) {
|
||||
return (GroovyPsiElement)place;
|
||||
}
|
||||
return (GroovyFileBase)place.getContainingFile();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -39,7 +39,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.completion.smartEnter.fixers.*;
|
||||
import org.jetbrains.plugins.groovy.lang.completion.smartEnter.processors.GroovyPlainEnterProcessor;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.formatter.GrControlStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
@@ -196,7 +195,7 @@ public class GroovySmartEnterProcessor extends SmartEnterProcessor {
|
||||
reformat(atCaret);
|
||||
commit(editor);
|
||||
|
||||
atCaret = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) psiFile), rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), atCaret.getClass());
|
||||
atCaret = GroovyRefactoringUtil.findElementInRange(psiFile, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), atCaret.getClass());
|
||||
|
||||
// atCaret = CodeInsightUtil.findElementInRange(psiFile, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), atCaret.getClass());
|
||||
|
||||
|
||||
+1
-2
@@ -52,7 +52,6 @@ import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
@@ -612,7 +611,7 @@ public abstract class GrTypeDefinitionImpl extends GrStubElementBase<GrTypeDefin
|
||||
}
|
||||
|
||||
if (renameFile) {
|
||||
final GroovyFileBase file = (GroovyFileBase)getContainingFile();
|
||||
final PsiFile file = getContainingFile();
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
final String ext;
|
||||
if (virtualFile != null) {
|
||||
|
||||
@@ -294,7 +294,7 @@ public class MvcConsole implements Disposable {
|
||||
catch (final IOException e) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Messages.showErrorDialog(e.getMessage(), "Cannot start process");
|
||||
Messages.showErrorDialog(e.getMessage(), "Cannot Start Process");
|
||||
|
||||
try {
|
||||
if (onDone != null && !module.isDisposed()) onDone.run();
|
||||
@@ -359,7 +359,7 @@ public class MvcConsole implements Disposable {
|
||||
super("Kill process", "Kill process", KILL_PROCESS_ICON);
|
||||
}
|
||||
|
||||
public void setHandler(OSProcessHandler handler) {
|
||||
public void setHandler(@Nullable OSProcessHandler handler) {
|
||||
myHandler = handler;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public abstract class GroovyRefactoringUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends PsiElement> T findElementInRange(final GroovyFileBase file,
|
||||
public static <T extends PsiElement> T findElementInRange(final PsiFile file,
|
||||
int startOffset,
|
||||
int endOffset,
|
||||
final Class<T> klass) {
|
||||
|
||||
+17
-1
@@ -20,14 +20,17 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.UsageViewDescriptorAdapter;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
@@ -93,7 +96,20 @@ public class ConvertToJavaProcessor extends BaseRefactoringProcessor {
|
||||
document.setText(builder.toString());
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(document);
|
||||
String fileName = getNewFileName(file);
|
||||
PsiElement newFile = file.setName(fileName);
|
||||
PsiElement newFile;
|
||||
try {
|
||||
newFile = file.setName(fileName);
|
||||
}
|
||||
catch (final IncorrectOperationException e) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Messages.showMessageDialog(myProject, e.getMessage(), RefactoringBundle.message("error.title"), Messages.getErrorIcon());
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
// don't move classes to new files with corresponding class names and reformat
|
||||
|
||||
+2
-3
@@ -74,8 +74,7 @@ public class ExtractMethodUtil {
|
||||
}
|
||||
startElement = startElement.getParent();
|
||||
PsiElement parent = startElement.getParent();
|
||||
if (parent instanceof GroovyFile &&
|
||||
((GroovyFile) parent).getScriptClass() == owner) {
|
||||
if (parent instanceof GroovyFile && ((GroovyFile) parent).getScriptClass() == owner) {
|
||||
return startElement.getNextSibling();
|
||||
}
|
||||
}
|
||||
@@ -418,7 +417,7 @@ public class ExtractMethodUtil {
|
||||
|
||||
static PsiElement[] getElementsInOffset(PsiFile file, int startOffset, int endOffset) {
|
||||
PsiElement[] elements;
|
||||
GrExpression expr = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) file), startOffset, endOffset, GrExpression.class);
|
||||
GrExpression expr = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrExpression.class);
|
||||
|
||||
if (expr != null) {
|
||||
PsiElement parent = expr.getParent();
|
||||
|
||||
+4
-5
@@ -42,7 +42,6 @@ import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
@@ -243,8 +242,8 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
|
||||
throw new GrIntroduceRefactoringError(RefactoringBundle.message("readonly.occurences.found"));
|
||||
}
|
||||
|
||||
GrExpression selectedExpr = findExpression((GroovyFileBase)file, startOffset, endOffset);
|
||||
final GrVariable variable = findVariable((GroovyFile)file, startOffset, endOffset);
|
||||
GrExpression selectedExpr = findExpression(file, startOffset, endOffset);
|
||||
final GrVariable variable = findVariable(file, startOffset, endOffset);
|
||||
if (variable != null) {
|
||||
checkVariable(variable);
|
||||
}
|
||||
@@ -281,7 +280,7 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GrVariable findVariable(GroovyFile file, int startOffset, int endOffset) {
|
||||
public static GrVariable findVariable(PsiFile file, int startOffset, int endOffset) {
|
||||
GrVariable var = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrVariable.class);
|
||||
if (var == null) {
|
||||
final GrVariableDeclaration variableDeclaration =
|
||||
@@ -299,7 +298,7 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GrExpression findExpression(GroovyFileBase file, int startOffset, int endOffset) {
|
||||
public static GrExpression findExpression(PsiFile file, int startOffset, int endOffset) {
|
||||
GrExpression selectedExpr = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrExpression.class);
|
||||
while (selectedExpr instanceof GrParenthesizedExpression) selectedExpr = ((GrParenthesizedExpression)selectedExpr).getOperand();
|
||||
if (selectedExpr == null) return null;
|
||||
|
||||
+2
-3
@@ -53,7 +53,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyIcons;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner;
|
||||
@@ -145,8 +144,8 @@ public class GrIntroduceParameterHandler implements RefactoringActionHandler {
|
||||
throw new GrIntroduceRefactoringError(RefactoringBundle.message("readonly.occurences.found"));
|
||||
}
|
||||
|
||||
GrExpression selectedExpr = GrIntroduceHandlerBase.findExpression((GroovyFileBase)file, startOffset, endOffset);
|
||||
final GrVariable variable = GrIntroduceHandlerBase.findVariable((GroovyFile)file, startOffset, endOffset);
|
||||
GrExpression selectedExpr = GrIntroduceHandlerBase.findExpression(file, startOffset, endOffset);
|
||||
final GrVariable variable = GrIntroduceHandlerBase.findVariable(file, startOffset, endOffset);
|
||||
if (variable == null && selectedExpr == null) {
|
||||
throw new GrIntroduceRefactoringError(null);
|
||||
}
|
||||
|
||||
+5
-1
@@ -18,10 +18,10 @@ package org.jetbrains.plugins.groovy.completion;
|
||||
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
import com.intellij.codeInsight.completion.StaticallyImportable
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
import com.intellij.codeInsight.completion.StaticallyImportable
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -110,6 +110,10 @@ class Expected {
|
||||
|
||||
Expected exp = fooField'''
|
||||
}
|
||||
|
||||
void testInnerClassReferenceWithoutQualifier() {
|
||||
doSmartTest()
|
||||
}
|
||||
|
||||
def getFileText(PsiFile file) {
|
||||
return PsiDocumentManager.getInstance(project).getDocument(file).text
|
||||
|
||||
+2
-3
@@ -28,7 +28,6 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -144,9 +143,9 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
|
||||
int endOffset = editor.getSelectionModel().getSelectionEnd();
|
||||
editor.getCaretModel().moveToOffset(endOffset);
|
||||
|
||||
GroovyPsiElement selectedArea = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) file), startOffset, endOffset, GrReferenceExpression.class);
|
||||
GroovyPsiElement selectedArea = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrReferenceExpression.class);
|
||||
if (selectedArea == null) {
|
||||
PsiElement identifier = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) file), startOffset, endOffset, PsiElement.class);
|
||||
PsiElement identifier = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, PsiElement.class);
|
||||
if (identifier != null){
|
||||
Assert.assertTrue("Selected area doesn't point to method", identifier.getParent() instanceof GrVariable);
|
||||
selectedArea = (GroovyPsiElement)identifier.getParent();
|
||||
|
||||
+2
-3
@@ -26,7 +26,6 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -92,9 +91,9 @@ public class InlineVariableTest extends LightCodeInsightFixtureTestCase {
|
||||
editor.getCaretModel().moveToOffset(endOffset);
|
||||
|
||||
GroovyPsiElement selectedArea =
|
||||
GroovyRefactoringUtil.findElementInRange(((GroovyFileBase)file), startOffset, endOffset, GrReferenceExpression.class);
|
||||
GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrReferenceExpression.class);
|
||||
if (selectedArea == null) {
|
||||
PsiElement identifier = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase)file), startOffset, endOffset, PsiElement.class);
|
||||
PsiElement identifier = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, PsiElement.class);
|
||||
if (identifier != null) {
|
||||
Assert.assertTrue("Selected area doesn't point to var", identifier.getParent() instanceof GrVariable);
|
||||
selectedArea = (GroovyPsiElement)identifier.getParent();
|
||||
|
||||
+1
-2
@@ -23,7 +23,6 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
@@ -79,7 +78,7 @@ public class IntroduceVariableValidatorTest extends LightCodeInsightFixtureTestC
|
||||
|
||||
myEditor.getSelectionModel().setSelection(startOffset, endOffset);
|
||||
|
||||
GrExpression selectedExpr = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) myFixture.getFile()), startOffset, endOffset, GrExpression.class);
|
||||
GrExpression selectedExpr = GroovyRefactoringUtil.findElementInRange(myFixture.getFile(), startOffset, endOffset, GrExpression.class);
|
||||
|
||||
Assert.assertNotNull("Selected expression reference points to null", selectedExpr);
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
static class Bar {}
|
||||
{
|
||||
List<Bar> l = new AL<caret>
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
static class Bar {}
|
||||
{
|
||||
List<Bar> l = new ArrayList<Bar>()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user