Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2013-04-11 16:03:34 +02:00
57 changed files with 456 additions and 200 deletions
@@ -0,0 +1,62 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.compiler;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* @author Eugene Zhuravlev
* Date: 4/11/13
*/
public class CompilerSettingsUsageCollector extends UsagesCollector{
public static final String GROUP_ID = "compiler";
@NotNull
@Override
public Set<UsageDescriptor> getUsages(@Nullable Project project) throws CollectUsagesException {
final CompilerWorkspaceConfiguration wsConfig = CompilerWorkspaceConfiguration.getInstance(project);
if (!wsConfig.useOutOfProcessBuild()) {
return Collections.emptySet();
}
final Set<UsageDescriptor> result = new HashSet<UsageDescriptor>();
result.add(new UsageDescriptor("external_build", 1));
if (wsConfig.MAKE_PROJECT_ON_SAVE) {
result.add(new UsageDescriptor("auto_make", 1));
}
if (wsConfig.PARALLEL_COMPILATION) {
result.add(new UsageDescriptor("compile_parallel", 1));
}
return result;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID);
}
}
@@ -85,7 +85,11 @@ public class CompileServerClasspathManager {
else {
//development mode: add directory out/classes/production/<jar-name> to classpath, assuming that jar-name is equal to module name
final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath));
final File dir = new File(baseFile.getParentFile(), moduleName);
File baseOutputDir = baseFile.getParentFile();
if (baseOutputDir.getName().equals("test")) {
baseOutputDir = new File(baseOutputDir.getParentFile(), "production");
}
final File dir = new File(baseOutputDir, moduleName);
if (dir.exists()) {
classpath.add(dir.getPath());
}
@@ -98,12 +102,13 @@ public class CompileServerClasspathManager {
classpath.add(libraryFile.getPath());
}
else {
LOG.error("Cannot add plugin '" + plugin.getName() + "' to external compiler classpath: " +
LOG.error("Cannot add " + relativePath + " from plugin '" + plugin.getName() + "' to external compiler classpath: " +
"library " + libraryFile.getAbsolutePath() + " not found");
}
}
else {
LOG.error("Cannot add plugin '" + plugin.getName() + "' to external compiler classpath: home directory of plugin not found");
LOG.error("Cannot add " + relativePath + " from plugin '" + plugin.getName() +
"' to external compiler classpath: home directory of plugin not found");
}
}
}
@@ -433,7 +433,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
MyGutterIconRenderer renderer = new MyGutterIconRenderer(this);
MyGutterIconRenderer renderer = new MyGutterIconRenderer(getIcon(), getDescription());
highlighter.setGutterIconRenderer(renderer);
}
@@ -597,21 +597,23 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
private class MyGutterIconRenderer extends GutterIconRenderer {
private BreakpointWithHighlighter myBreakpoint;
private final Icon myIcon;
private final String myDescription;
public MyGutterIconRenderer(BreakpointWithHighlighter breakpoint) {
myBreakpoint = breakpoint;
public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) {
myIcon = icon;
myDescription = description;
}
@Override
@NotNull
public Icon getIcon() {
return myBreakpoint.getIcon();
return myIcon;
}
@Override
public String getTooltipText() {
return myBreakpoint.getDescription();
return myDescription;
}
@Override
@@ -18,7 +18,9 @@ package com.intellij.projectImport;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.ElementsChooser;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
@@ -48,14 +50,33 @@ public abstract class SelectImportedProjectsStep<T> extends ProjectImportWizardS
}
};
panel = new JPanel(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
panel = new JPanel(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
panel.add(fileChooser, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
null));
final AnAction selectAllAction = new AnAction(RefactoringBundle.message("select.all.button")) {
@Override
public void actionPerformed(AnActionEvent e) {
fileChooser.setAllElementsMarked(true);
}
};
final AnAction unselectAllAction = new AnAction(RefactoringBundle.message("unselect.all.button")) {
@Override
public void actionPerformed(AnActionEvent e) {
fileChooser.setAllElementsMarked(false);
}
};
final JComponent actionToolbar =
ActionManager.getInstance().createButtonToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(selectAllAction, unselectAllAction));
panel.add(actionToolbar, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK, null, null, null));
openModuleSettingsCheckBox = new JCheckBox(IdeBundle.message("project.import.show.settings.after"));
panel.add(openModuleSettingsCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL,
panel.add(openModuleSettingsCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null));
}
@@ -442,13 +442,47 @@ public class AnnotationsHighlightUtil {
public static HighlightInfo checkCyclicMemberType(PsiTypeElement typeElement, PsiClass aClass) {
LOG.assertTrue(aClass.isAnnotationType());
PsiType type = typeElement.getType();
if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == aClass) {
final Set<PsiClass> checked = new HashSet<PsiClass>();
if (cyclicDependencies(aClass, type, checked)) {
String description = JavaErrorMessages.message("annotation.cyclic.element.type");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create();
}
return null;
}
private static boolean cyclicDependencies(PsiClass aClass, PsiType type, Set<PsiClass> checked) {
final PsiClass resolvedClass = PsiUtil.resolveClassInType(type);
if (resolvedClass != null && resolvedClass.isAnnotationType()) {
if (aClass == resolvedClass) {
return true;
}
if (!checked.add(resolvedClass) || !resolvedClass.getManager().isInProject(resolvedClass)) return false;
final PsiMethod[] methods = resolvedClass.getMethods();
for (PsiMethod method : methods) {
if (cyclicDependencies(aClass, method.getReturnType(), checked)) return true;
}
}
return false;
}
public static HighlightInfo checkClashesWithSuperMethods(@NotNull PsiAnnotationMethod psiMethod) {
final PsiIdentifier nameIdentifier = psiMethod.getNameIdentifier();
if (nameIdentifier != null) {
final PsiMethod[] methods = psiMethod.findDeepestSuperMethods();
for (PsiMethod method : methods) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null) {
final String qualifiedName = containingClass.getQualifiedName();
if (CommonClassNames.JAVA_LANG_OBJECT.equals(qualifiedName) || CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION.equals(qualifiedName)) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(nameIdentifier).descriptionAndTooltip(
"@interface member clashes with '" + HighlightUtil.formatMethod(method) + "' in " + HighlightUtil.formatClass(containingClass)).create();
}
}
}
}
return null;
}
@Nullable
public static HighlightInfo checkAnnotationDeclaration(final PsiElement parent, final PsiReferenceList list) {
if (PsiUtil.isAnnotationMethod(parent)) {
@@ -217,6 +217,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
myHolder.add(AnnotationsHighlightUtil.checkValidAnnotationType(method.getReturnTypeElement()));
myHolder.add(AnnotationsHighlightUtil.checkCyclicMemberType(method.getReturnTypeElement(), method.getContainingClass()));
myHolder.add(AnnotationsHighlightUtil.checkClashesWithSuperMethods(method));
}
@Override public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
@@ -67,7 +67,7 @@ public class ExplicitTypeCanBeDiamondInspection extends BaseJavaLocalInspectionT
LOG.assertTrue(classReference != null);
final PsiReferenceParameterList parameterList = classReference.getParameterList();
LOG.assertTrue(parameterList != null);
holder.registerProblem(parameterList, "Redundant type argument #ref #loc",
holder.registerProblem(parameterList, "Explicit type argument #ref #loc can be replaced with <>",
ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithDiamondFix());
}
}
@@ -30,6 +30,7 @@ public class OverrideImplementExploreUtil {
@NotNull
public static Collection<MethodSignature> getMethodSignaturesToOverride(@NotNull PsiClass aClass) {
if (aClass.isInterface()) return Collections.emptySet();
return getMapToOverrideImplement(aClass, false).keySet();
}
@@ -0,0 +1,9 @@
@interface A1 {
String <error descr="@interface member clashes with 'toString()' in java.lang.Object">toString</error>();
Class <error descr="@interface member clashes with 'annotationType()' in java.lang.annotation.Annotation">annotationType</error>();
int value();
boolean equals();
<error descr="Invalid type for annotation member">void</error> <error descr="@interface member clashes with 'finalize()' in java.lang.Object">finalize</error>();
<error descr="Invalid type for annotation member">void</error> registerNatives();
}
@@ -0,0 +1,27 @@
@interface A1 {
<error descr="Cyclic annotation element type">B1</error> value();
}
@interface B1 {
<error descr="Cyclic annotation element type">A1</error> value();
}
@interface C1 {
A1 value();
}
@interface D1 {
<error descr="Cyclic annotation element type">D1</error> value();
}
enum E1 {
E_1;
@F(E_1)
void foo() {
}
}
@interface F {
E1 value();
}
@@ -1,7 +1,7 @@
import java.util.Collection;
@interface Anno {
Anno[] nested() default {};
<error descr="Cyclic annotation element type">Anno[]</error> nested() default {};
}
abstract class C {
@@ -0,0 +1,3 @@
@interface ff{
<caret>
}
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight;
import com.intellij.codeInsight.generation.JavaOverrideMethodsHandler;
import com.intellij.codeInsight.generation.OverrideImplementUtil;
import com.intellij.codeInsight.generation.PsiMethodMember;
import com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler;
@@ -129,6 +130,16 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
checkResultByFile(BASE_DIR + "after" + name + ".java");
}
public void testInAnnotationType() {
String name = getTestName(false);
configureByFile(BASE_DIR + "before" + name + ".java");
int offset = getEditor().getCaretModel().getOffset();
PsiElement context = getFile().findElementAt(offset);
final PsiClass aClass = PsiTreeUtil.getParentOfType(context, PsiClass.class);
assertTrue(aClass != null && aClass.isAnnotationType());
assertFalse(new JavaOverrideMethodsHandler().isValidFor(getEditor(), getFile()));
}
private void doTest(boolean copyJavadoc) { doTest(copyJavadoc, null); }
private void doTest8(boolean copyJavadoc, @Nullable Boolean toImplement) {
@@ -46,6 +46,9 @@ public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testTypeAnnotations() { doTest8(false); }
public void testRepeatable() { doTest8(false); }
public void testPingPongAnnotationTypesDependencies() { doTest(false);}
public void testClashMethods() { doTest(false);}
private void doTest(boolean checkWarnings) {
setLanguageLevel(LanguageLevel.JDK_1_7);
doTest(BASE_PATH + "/" + getTestName(true) + ".java", checkWarnings, false);
@@ -17,6 +17,7 @@
package com.intellij.ide;
import com.intellij.CommonBundle;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;
@@ -39,6 +40,22 @@ public class IdeBundle {
return CommonBundle.message(getBundle(), key, params);
}
public static String settingsTitle() {
return SystemInfo.isMac ? message("title.settings.mac") : message("title.settings");
}
public static String settingsAction() {
return SystemInfo.isMac ? message("action.settings.mac") : message("action.settings");
}
public static String settingsActionDescription() {
return SystemInfo.isMac ? message("action.settings.description.mac") : message("action.settings.description");
}
public static String settingsActionPath() {
return SystemInfo.isMac ? message("action.settings.path.mac") : message("action.settings.path");
}
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
@@ -137,7 +137,7 @@ public class Executor {
CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess(30*1000);
if (result.isTimeout()) {
throw new RuntimeException("Timeout waiting for Git execution");
throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " "));
}
if (result.getExitCode() != 0) {
@@ -131,13 +131,13 @@
<border type="none"/>
<children/>
</grid>
<component id="978ed" class="javax.swing.JLabel">
<component id="978ed" class="javax.swing.JLabel" binding="myPreferencesLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
</constraints>
<properties>
<font size="11"/>
<text value="You can use the Preferences dialog to configure any of these settings later."/>
<text value=""/>
</properties>
</component>
<grid id="90b80" binding="myExtraOptionsPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -20,6 +20,7 @@ import com.intellij.application.options.colors.NewColorAndFontPanel;
import com.intellij.application.options.colors.SimpleEditorPreview;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.actions.CreateDesktopEntryAction;
import com.intellij.ide.actions.CreateLauncherScriptAction;
import com.intellij.ide.todo.TodoConfiguration;
@@ -76,6 +77,7 @@ public class InitialConfigurationDialog extends DialogWrapper {
private JCheckBox myGlobalEntryCheckBox;
private JPanel myCreateEntryPanel;
private ComboBox myAppearanceComboBox;
private JLabel myPreferencesLabel;
private String myColorSettingsPage;
private SimpleEditorPreview myPreviewEditor;
private ColorAndFontOptions myPreviewOptions;
@@ -177,6 +179,8 @@ public class InitialConfigurationDialog extends DialogWrapper {
myGlobalEntryCheckBox.setSelected(!PathManager.getHomePath().startsWith("/home"));
}
myPreferencesLabel.setText("You can use "+ IdeBundle.settingsActionPath() + " to configure any of these settings later.");
Disposer.register(myDisposable, new Disposable() {
@Override
public void dispose() {
@@ -221,7 +221,9 @@ public class FindDialog extends DialogWrapper {
private void updateReplaceVisibility() {
myReplacePrompt.setVisible(myModel.isReplaceState());
myReplaceComboBox.setVisible(myModel.isReplaceState());
myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState());
if (myCbToSkipResultsWhenOneUsage != null) {
myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState());
}
myCbPreserveCase.setVisible(myModel.isReplaceState());
}
@@ -22,10 +22,6 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.undo.BasicUndoableAction;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.command.undo.UndoableAction;
import com.intellij.openapi.command.undo.UnexpectedUndoException;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.ModifiableModuleModel;
@@ -105,24 +101,6 @@ public class RenameModuleHandler implements RenameHandler, TitledHandler {
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
UndoableAction action = new BasicUndoableAction() {
@Override
public void undo() throws UnexpectedUndoException {
final ModifiableModuleModel modifiableModel = renameModule(oldName);
if (modifiableModel != null) {
modifiableModel.commit();
}
}
@Override
public void redo() throws UnexpectedUndoException {
final ModifiableModuleModel modifiableModel = renameModule(inputString);
if (modifiableModel != null) {
modifiableModel.commit();
}
}
};
UndoManager.getInstance(myProject).undoableActionPerformed(action);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
@@ -107,9 +107,8 @@ public class ParametersList implements Cloneable {
}
public void prependAll(@NonNls final String... parameter) {
for (int i = parameter.length - 1; i >= 0; i--) {
addAt(0, parameter[i]);
}
addAll(parameter);
Collections.rotate(myParameters, parameter.length);
}
public void addParametersString(final String parameters) {
@@ -226,11 +225,14 @@ public class ParametersList implements Cloneable {
}
public void addAll(final String... parameters) {
ContainerUtil.addAll(myParameters, parameters);
addAll(Arrays.asList(parameters));
}
public void addAll(final List<String> parameters) {
myParameters.addAll(parameters);
// Don't use myParameters.addAll(parameters) , it does not call expandMacros(parameter)
for (String parameter : parameters) {
add(parameter);
}
}
@Override
@@ -51,8 +51,10 @@ import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -178,7 +180,8 @@ public class BrowserUtil {
String browserPath = getGeneralSettingsInstance().getBrowserPath();
if (StringUtil.isEmptyOrSpaces(browserPath)) {
showErrorMessage(IdeBundle.message("error.please.specify.path.to.web.browser"), IdeBundle.message("title.browser.not.found"));
showErrorMessage(IdeBundle.message("error.please.specify.path.to.web.browser", IdeBundle.settingsActionPath()),
IdeBundle.message("title.browser.not.found"));
return;
}
@@ -15,6 +15,8 @@
*/
package com.intellij.ide.actions;
import com.intellij.icons.AllIcons;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -31,12 +33,19 @@ import com.intellij.openapi.util.SystemInfo;
import javax.swing.*;
public class ShowSettingsAction extends AnAction implements DumbAware {
public ShowSettingsAction() {
super(IdeBundle.settingsAction(), IdeBundle.settingsActionDescription(), AllIcons.General.Settings);
}
@Override
public void update(AnActionEvent e) {
if (SystemInfo.isMac && e.getPlace().equals(ActionPlaces.MAIN_MENU)) {
// It's called from Preferences in App menu.
e.getPresentation().setVisible(false);
}
if (e.getPlace().equals(ActionPlaces.WELCOME_SCREEN)) {
e.getPresentation().setText(IdeBundle.settingsTitle());
}
}
public void actionPerformed(AnActionEvent e) {
@@ -16,6 +16,7 @@
package com.intellij.openapi.options.newEditor;
import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.DataProvider;
@@ -67,7 +68,7 @@ public class OptionsEditorDialog extends DialogWrapper implements DataProvider{
myGroups = groups;
myPreselected = preselected;
setTitle("Settings");
setTitle(IdeBundle.settingsTitle());
init();
}
@@ -210,17 +210,22 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager {
@Override
public void setEncoding(@Nullable final VirtualFile virtualFileOrDir, @Nullable final Charset charset) {
Charset oldCharset;
if (charset == null) {
myMapping.remove(virtualFileOrDir);
oldCharset = myMapping.remove(virtualFileOrDir);
}
else {
myMapping.put(virtualFileOrDir, charset);
oldCharset = myMapping.put(virtualFileOrDir, charset);
}
myModificationCount++;
if (virtualFileOrDir != null) {
virtualFileOrDir.setCharset(virtualFileOrDir.getBOM() == null ? charset : null);
if (!Comparing.equal(oldCharset, charset)) {
myModificationCount++;
if (virtualFileOrDir != null) {
virtualFileOrDir.setCharset(virtualFileOrDir.getBOM() == null ? charset : null);
}
reloadAllFilesUnder(virtualFileOrDir);
}
reloadAllFilesUnder(virtualFileOrDir);
}
private static void clearAndReload(@NotNull VirtualFile virtualFileOrDir) {
@@ -247,8 +247,6 @@ group.reopen.mac.text=Open _Recent
group.$LRU.description=List of recently opened projects
action.CloseProject.text=Close Pro_ject
action.CloseProject.description=Close current project
action.ShowSettings.text=Se_ttings...
action.ShowSettings.description=Configure application settings
action.ShowProjectStructureSettings.text=Project Structure...
action.ShowProjectStructureSettings.description=Configure project structure
action.TemplateProjectProperties.text=Def_ault Settings...
@@ -1162,8 +1160,6 @@ action.WelcomeScreen.CreateNewProject.description=Start the \"New Project\" Wiza
action.WelcomeScreen.ImportProject.text=Import Project
action.WelcomeScreen.ImportProject.description=Create {0} project structure for directory with existing sources or convert existing project model.
action.WelcomeScreen.JetBrainsTV.IDEA.text=JetBrains TV
action.WelcomeScreen.Settings.text=Settings
action.WelcomeScreen.Settings.description=Edit Settings
action.WelcomeScreen.Plugins.text=Plugins
action.WelcomeScreen.Plugins.description=Manage installed plugins and download new ones from repository
action.WelcomeScreen.Configure.Import.text=Import Settings
@@ -1,7 +1,16 @@
title.settings=Settings
title.settings.mac=Preferences
action.settings=Se_ttings...
action.settings.mac=Preferences...
action.settings.description=Edit application settings
action.settings.description.mac=Edit application preferences
action.settings.path=File | Settings
action.settings.path.mac=Preferences
title.cannot.start.browser=Cannot start browser
error.malformed.url=Malformed url: {0}
error.cannot.start.browser=Cannot start browser: {0}
error.please.specify.path.to.web.browser=Please specify a path to web browser in File | Settings | Web Browsers
error.please.specify.path.to.web.browser=Please specify a path to web browser in {0} | Web Browsers
title.browser.not.found=Browser Not Found
title.browser.path.not.found=Browser Path Not Found
action.sort.alphabetically=Sort Alphabetically
@@ -153,7 +153,7 @@
</group>
<separator/>
<group id="FileMainSettingsGroup">
<action id="ShowSettings" class="com.intellij.ide.actions.ShowSettingsAction" icon="AllIcons.General.Settings"/>
<action id="ShowSettings" class="com.intellij.ide.actions.ShowSettingsAction"/>
<group id="FileOtherSettingsGroup" class="com.intellij.ide.actions.SmartPopupActionGroup">
<action id="TemplateProjectProperties" class="com.intellij.ide.actions.TemplateProjectPropertiesAction"/>
<group id="FileSettingsGroup"/>
@@ -685,6 +685,21 @@ public class ArrayUtil extends ArrayUtilRt {
return indexOf(objects, o) >= 0;
}
public static boolean contains(@Nullable final String s, final String... strings) {
if (s == null) {
for (String str : strings) {
if (str == null) return true;
}
}
else {
for (String str : strings) {
if (s.equals(str)) return true;
}
}
return false;
}
@NotNull
public static int[] newIntArray(int count) {
return count == 0 ? EMPTY_INT_ARRAY : new int[count];
@@ -102,10 +102,12 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
};
}
@Override
public Collection<VirtualFile> getAffectedContentRoots() {
return myAffectedContentRoots;
}
@Override
public Collection<VirtualFile> getAffectedContentRootsWithCheck() {
if (myVcs.allowsNestedRoots()) {
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myVcs.getProject());
@@ -114,7 +116,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
final Set<VirtualFile> result = new HashSet<VirtualFile>(myAffectedContentRoots);
for (VirtualFile root : roots) {
for (VirtualFile dir : myDirtyDirectoriesRecursively.keySet()) {
if (VfsUtil.isAncestor(dir, root, true)) {
if (VfsUtilCore.isAncestor(dir, root, true)) {
result.add(root);
}
}
@@ -124,14 +126,17 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
return myAffectedContentRoots;
}
@Override
public Project getProject() {
return myProject;
}
@Override
public AbstractVcs getVcs() {
return myVcs;
}
@Override
public Set<FilePath> getDirtyFiles() {
final THashSet<FilePath> result = new THashSet<FilePath>();
for (THashSet<FilePath> paths : myDirtyFiles.values()) {
@@ -150,6 +155,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
return result;
}
@Override
public Set<FilePath> getDirtyFilesNoExpand() {
final THashSet<FilePath> paths = new THashSet<FilePath>();
for (THashSet<FilePath> filePaths : myDirtyFiles.values()) {
@@ -158,6 +164,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
return paths;
}
@Override
public Set<FilePath> getRecursivelyDirtyDirectories() {
THashSet<FilePath> result = new THashSet<FilePath>();
for(THashSet<FilePath> dirsByRoot: myDirtyDirectoriesRecursively.values()) {
@@ -172,7 +179,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
for (FilePath dir : dirsByRoot) {
final VirtualFile dirVf = dir.getVirtualFile();
if (dirVf != null) {
if (VfsUtil.isAncestor(dirVf, vf, false)) {
if (VfsUtilCore.isAncestor(dirVf, vf, false)) {
return true;
}
}
@@ -193,6 +200,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
public void addDirtyData(final Collection<FilePath> dirs, final Collection<FilePath> files) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final HashSet<FilePath> newFiles = new HashSet<FilePath>(files);
newFiles.removeAll(dirs); // if the same dir is added recursively and not recursively, prefer recursive mark
@@ -233,15 +241,15 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
}, new PairProcessor<FileOrDir, FileOrDir>() {
@Override
public boolean process(FileOrDir parent, FileOrDir child) {
if (! parent.myRecursive) {// if under non-recursive dirty dir, generally do not remove child with one exception...
if (! child.myRecursive && ! child.myPath.isDirectory()) {
if (Comparing.equal(child.myPath.getParentPath(), parent.myPath)) {
return true; // only if dir non-recursively + non-recursive file child -> can be truncated to dir only
}
}
if (parent.myRecursive) {
return true;
}
// if under non-recursive dirty dir, generally do not remove child with one exception...
if (child.myRecursive || child.myPath.isDirectory()) {
return false;
}
return true;
// only if dir non-recursively + non-recursive file child -> can be truncated to dir only
return Comparing.equal(child.myPath.getParentPath(), parent.myPath);
}
});
set.retainAll(newCollection);
@@ -287,8 +295,10 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
*
* @param newcomer a new directory to add
*/
@Override
public void addDirtyDirRecursively(final FilePath newcomer) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final VirtualFile vcsRoot = myVcsManager.getVcsRootFor(newcomer);
if (vcsRoot == null) return;
@@ -340,8 +350,10 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
*
* @param newcomer a file or directory added to the dirty scope.
*/
@Override
public void addDirtyFile(final FilePath newcomer) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final VirtualFile vcsRoot = myVcsManager.getVcsRootFor(newcomer);
myAffectedContentRoots.add(vcsRoot);
@@ -368,7 +380,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
iterator.remove();
}
}
} else if (dirtyFiles.size() > 0) {
} else if (!dirtyFiles.isEmpty()) {
VirtualFile parent = newcomer.getVirtualFileParent();
if (parent != null && dirtyFiles.contains(new FilePathImpl(parent))) {
return;
@@ -380,6 +392,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
});
}
@Override
public void iterate(final Processor<FilePath> iterator) {
if (myProject.isDisposed()) return;
@@ -459,6 +472,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
@Override
public boolean belongsTo(final FilePath path, final Consumer<AbstractVcs> vcsConsumer) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
if (myProject.isDisposed()) return Boolean.FALSE;
final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path);
@@ -487,7 +501,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
}
}
if (myDirtyFiles.size() > 0) {
if (!myDirtyFiles.isEmpty()) {
FilePath parent;
VirtualFile vParent = path.getVirtualFileParent();
if (vParent != null && vParent.isValid()) {
@@ -521,7 +535,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
@Override @NonNls
public String toString() {
@NonNls StringBuilder result = new StringBuilder("VcsDirtyScope[");
if (myDirtyFiles.size() > 0) {
if (!myDirtyFiles.isEmpty()) {
result.append(" files=");
for (THashSet<FilePath> paths : myDirtyFiles.values()) {
for (FilePath file : paths) {
@@ -529,7 +543,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
}
}
}
if (myDirtyDirectoriesRecursively.size() > 0) {
if (!myDirtyDirectoriesRecursively.isEmpty()) {
result.append(" dirs=");
for(THashSet<FilePath> dirsByRoot: myDirtyDirectoriesRecursively.values()) {
for(FilePath file: dirsByRoot) {
@@ -559,6 +573,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
return myWasEverythingDirty;
}
@Override
public void setWasEverythingDirty(boolean wasEverythingDirty) {
myWasEverythingDirty = wasEverythingDirty;
}
@@ -239,7 +239,12 @@ public final class GitPusher {
GitCommitsByRepoAndBranch commits = pushInfo.getCommits();
for (GitRepository repository : commits.getRepositories()) {
if (commits.get(repository).getAllCommits().size() == 0) { // don't push repositories where there is nothing to push. Note that when a branch is created, several recent commits are stored in the pushInfo.
GitCommitsByBranch commitsForRepo = commits.get(repository);
GitLocalBranch sourceBranch = pushInfo.getPushSpecs().get(repository).getSource();
if (commitsForRepo.get(sourceBranch).getType() == GitPushBranchInfo.Type.STANDARD &&
commitsForRepo.getAllCommits().size() == 0) {
// don't push repositories where there is nothing to push.
// however, do push if new branch is created, even without commits
continue;
}
GitPushRepoResult repoResult = pushRepository(pushInfo, commits, repository);
@@ -77,8 +77,7 @@ public class GeneralStepdefs {
private static void assertNotificationContent(String expected, String actual) {
expected = virtualCommits.replaceVirtualHashes(expected);
assertEquals("Notification content is incorrect", expected, adjustNotificationContent(actual));
assertEquals("Notification content is incorrect", StringUtil.convertLineSeparators(expected), StringUtil.convertLineSeparators(adjustNotificationContent(actual)));
}
private static String adjustNotificationContent(String content) {
@@ -19,6 +19,7 @@ import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.intellij.dvcs.test.MockVcsHelper;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePathImpl;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.LocalChangeList;
@@ -163,8 +164,8 @@ public class GitCherryPickStepdefs {
List<String> actualMessages = Arrays.asList(output.split(RECORD_SEPARATOR));
for (int i = 0; i < expectedMessages.size(); i++) {
String expectedMessage = expectedMessages.get(i).trim();
String actualMessage = actualMessages.get(i).trim();
String expectedMessage = StringUtil.convertLineSeparators(expectedMessages.get(i).trim());
String actualMessage = StringUtil.convertLineSeparators(actualMessages.get(i).trim());
if (!fullBody) {
// the subject (%s) somehow contains both "fix #1" and "cherry-picked from <hash>" in a single line
// which is probably Git misbehavior, so let's compare without taking line breaks and spaces into consideration
@@ -89,7 +89,7 @@ class GitExecutableDetectorWindowsTest {
}
@Test
void "1_8_0 Prefer cmd/git_cmd over cmd/git_exe and bin/git_exe"() {
void "1_8_0 Prefer cmd_git_cmd over cmd_git_exe and bin_git_exe"() {
fs "C:/Program Files (x86)/Git_1.8/bin/git.exe",
"C:/Program Files (x86)/Git_1.8/cmd/git.cmd",
"C:/Program Files (x86)/Git_1.8/cmd/git.exe"
@@ -126,7 +126,7 @@ class GitExecutableDetectorWindowsTest {
}
@Test
void "Program not found, try git.exe"() {
void "Program not found try git_exe"() {
CAN_RUN = [ "git.exe" ]
assertExecutable "git.exe"
}
@@ -57,7 +57,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection {
public void visitCodeReferenceElement(GrCodeReferenceElement refElement) {
super.visitCodeReferenceElement(refElement);
if (canBeReplacedWithImport(refElement)) {
if (canBeSimplified(refElement)) {
registerError(refElement);
}
}
@@ -66,7 +66,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection {
public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
super.visitReferenceExpression(referenceExpression);
if (canBeReplacedWithImport(referenceExpression) || isQualifiedStaticMethodWithUnnecessaryQualifier(referenceExpression)) {
if (canBeSimplified(referenceExpression) || isQualifiedStaticMethodWithUnnecessaryQualifier(referenceExpression)) {
registerError(referenceExpression);
}
}
@@ -138,7 +138,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection {
return true;
}
private static boolean canBeReplacedWithImport(PsiElement element) {
private static boolean canBeSimplified(PsiElement element) {
if (element instanceof GrCodeReferenceElement) {
if (PsiTreeUtil.getParentOfType(element, GrImportStatement.class, GrPackageDefinition.class) != null) return false;
}
@@ -155,22 +155,25 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection {
final PsiElement resolved = ref.resolve();
if (!(resolved instanceof PsiClass)) return false;
if (((PsiClass)resolved).getContainingClass() != null &&
!CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) {
return false;
}
final String name = ((PsiClass)resolved).getName();
if (name == null) return false;
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(element.getProject());
final GrReferenceExpression shortedRef = factory.createReferenceExpressionFromText(name, element);
final GroovyResolveResult resolveResult = shortedRef.advancedResolve();
if (resolveResult.getElement() == null || !resolveResult.isAccessible() || !resolveResult.isStaticsOK()) {
if (element.getManager().areElementsEquivalent(resolved, resolveResult.getElement())) {
return true;
}
if (element.getManager().areElementsEquivalent(resolved, resolveResult.getElement())) {
final PsiClass containingClass = ((PsiClass)resolved).getContainingClass();
if (containingClass != null &&
!CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) {
return false;
}
if (resolveResult.getElement() == null || !resolveResult.isAccessible() || !resolveResult.isStaticsOK()) {
return true;
}
@@ -19,7 +19,7 @@ package org.jetbrains.plugins.groovy.config;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
@@ -45,7 +45,7 @@ import java.util.regex.Pattern;
* @author ilyas
*/
public abstract class GroovyConfigUtils extends AbstractConfigUtils {
@NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all-(.*)\\.jar");
@NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all-(\\d.*)\\.jar");
private static GroovyConfigUtils myGroovyConfigUtils;
@NonNls public static final String GROOVY_JAR_PATTERN_NOVERSION = "groovy\\.jar";
@@ -81,6 +81,9 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
if (groovyJarVersion == null) {
groovyJarVersion = getSDKJarVersion(path + "/embeddable", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
}
if (groovyJarVersion == null) {
groovyJarVersion = getSDKJarVersion(path, GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
}
return groovyJarVersion == null ? UNDEFINED_VERSION : groovyJarVersion;
}
@@ -106,7 +109,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
}
public boolean isVersionAtLeast(PsiElement psiElement, String version, boolean unknownResult) {
Module module = ModuleUtil.findModuleForPsiElement(psiElement);
Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
if (module == null) return unknownResult;
final String sdkVersion = getSDKVersion(module);
if (sdkVersion == null) return unknownResult;
@@ -115,7 +118,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
@NotNull
public String getSDKVersion(PsiElement psiElement) {
final Module module = ModuleUtil.findModuleForPsiElement(psiElement);
final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
if (module == null) {
return NO_VERSION;
}
@@ -128,13 +131,10 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
public boolean isSDKHome(VirtualFile file) {
if (file != null && file.isDirectory()) {
final String path = file.getPath();
if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN).length > 0) {
return true;
}
if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION).length > 0) {
return true;
}
if (GroovyUtils.getFilesInDirectoryByPattern(path + "/embeddable", GROOVY_ALL_JAR_PATTERN).length > 0) {
if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN).length > 0 ||
GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION).length > 0 ||
GroovyUtils.getFilesInDirectoryByPattern(path + "/embeddable", GROOVY_ALL_JAR_PATTERN).length > 0 ||
GroovyUtils.getFilesInDirectoryByPattern(path, GROOVY_JAR_PATTERN).length > 0) {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -82,7 +82,8 @@ public class DefaultGroovyShellRunner extends GroovyShellRunner {
private static boolean hasGroovyAll(Module module) {
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
return facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null &&
return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null ||
facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) &&
facade.findClass("groovy.ui.GroovyMain", scope) != null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
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.refactoring.rename.PropertyForRename;
/**
@@ -59,7 +58,7 @@ public class GroovyFindUsagesProvider implements FindUsagesProvider {
if (element instanceof PsiMethod) return "method";
if (element instanceof PsiField) return "field";
if (element instanceof PsiParameter) return "parameter";
if (element instanceof PsiVariable || element instanceof GrReferenceExpression) return "variable";
if (element instanceof PsiVariable) return "variable";
if (element instanceof GrLabeledStatement) return "label";
if (element instanceof PropertyForRename) return "property";
if (element instanceof GrClosableBlock) return "closure";
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -126,7 +126,7 @@ public class GrReferenceAdjuster {
if (resolved instanceof PsiClass) {
final PsiClass clazz = (PsiClass)resolved;
final String qName = clazz.getQualifiedName();
if (qName != null && addImports && checkIsInnerClass(clazz) && mayInsertImport(ref)) {
if (qName != null && addImports && checkIsInnerClass(clazz, ref) && mayInsertImport(ref)) {
final GroovyFileBase file = (GroovyFileBase)ref.getContainingFile();
final GrImportStatement added = file.addImportForClass(clazz);
if (copy.isReferenceTo(resolved)) return true;
@@ -137,10 +137,11 @@ public class GrReferenceAdjuster {
return false;
}
private static boolean checkIsInnerClass(@NotNull PsiClass resolved) {
private static <Qualifier extends PsiElement> boolean checkIsInnerClass(@NotNull PsiClass resolved, GrQualifiedReference<Qualifier> ref) {
final PsiClass containingClass = resolved.getContainingClass();
return containingClass == null || CodeStyleSettingsManager.getSettings(resolved.getProject())
.getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS;
return containingClass == null ||
PsiTreeUtil.isAncestor(containingClass, ref, true) ||
CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS;
}
@Nullable
@@ -54,8 +54,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
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.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -108,24 +106,6 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
}
return buffer.toString();
}
else if (element instanceof GrReferenceExpression) {
GrReferenceExpression refExpr = (GrReferenceExpression)element;
StringBuilder buffer = new StringBuilder();
PsiType type = null;
if (refExpr.getParent() instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression)refExpr.getParent();
if (refExpr.equals(assignment.getLValue())) {
GrExpression rvalue = assignment.getRValue();
if (rvalue != null) {
type = rvalue.getType();
}
}
}
appendTypeString(buffer, type, originalElement);
buffer.append(" ");
buffer.append(refExpr.getReferenceName());
return buffer.toString();
}
else if (element instanceof PsiMethod) {
StringBuilder buffer = new StringBuilder();
PsiMethod method = (PsiMethod)element;
@@ -360,7 +360,6 @@ public class CompleteReferenceExpression {
private final boolean myFieldPointerOperator;
private final boolean myMethodPointerOperator;
private final boolean myIsMap;
private Set<String> myNonDeclaredVars = new com.intellij.util.containers.HashSet<String>();
private final SubstitutorComputer mySubstitutorComputer;
protected CompleteReferenceProcessor(GrReferenceExpression place, Consumer<LookupElement> consumer, @NotNull PrefixMatcher matcher, CompletionParameters parameters) {
@@ -390,7 +389,7 @@ public class CompleteReferenceExpression {
}
@Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) return true;
if (element instanceof PsiNamedElement) {
@@ -427,10 +426,6 @@ public class CompleteReferenceExpression {
if (element instanceof PsiVariable && !myMatcher.prefixMatches(((PsiVariable)element).getName())) {
return;
}
if (element instanceof GrReferenceExpression) {
String name = ((GrReferenceExpression)element).getReferenceName();
if (!myNonDeclaredVars.add(name)) return;
}
if (element instanceof GrReflectedMethod) {
element = ((GrReflectedMethod)element).getBaseMethod();
@@ -54,7 +54,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
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.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
@@ -599,22 +602,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
return PsiUtil.getSmartReturnType(method);
}
if (resolved instanceof GrReferenceExpression) {
PsiElement parent = resolved.getParent();
if (parent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression)parent;
if (resolved.equals(assignment.getLValue())) {
GrExpression rValue = assignment.getRValue();
if (rValue != null) {
PsiType rType = rValue.getType();
if (rType != null) {
return rType;
}
}
}
}
}
if (resolved == null) {
final PsiType fromClassRef = getTypeFromClassRef(this);
if (fromClassRef != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -276,7 +276,7 @@ public class GrClassImplUtil {
public static boolean processDeclarations(@NotNull GrTypeDefinition grType,
@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
PsiElement lastParent,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
for (final PsiTypeParameter typeParameter : grType.getTypeParameters()) {
if (!ResolveUtil.processElement(processor, typeParameter, state)) return false;
@@ -356,7 +356,7 @@ public class GrClassImplUtil {
final GrTypeDefinitionBody body = grType.getBody();
if (body != null) {
if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.CLASS)) {
for (PsiClass innerClass : getInnerClassesForResolve(grType, lastParent)) {
for (PsiClass innerClass : getInnerClassesForResolve(grType, lastParent, place)) {
final String innerClassName = innerClass.getName();
if (nameHint != null && !innerClassName.equals(nameHint.getName(state))) {
continue;
@@ -373,26 +373,32 @@ public class GrClassImplUtil {
return true;
}
private static List<PsiClass> getInnerClassesForResolve(final GrTypeDefinition grType, PsiElement lastParent) {
if (lastParent instanceof GrReferenceList) {
@NotNull
private static List<PsiClass> getInnerClassesForResolve(@NotNull final GrTypeDefinition grType,
@Nullable final PsiElement lastParent,
@NotNull final PsiElement place) {
if (lastParent instanceof GrReferenceList || PsiTreeUtil.getParentOfType(place, GrReferenceList.class) != null) {
return Arrays.asList(grType.getInnerClasses());
}
List<PsiClass> classes = RecursionManager.doPreventingRecursion(grType, true, new Computable<List<PsiClass>>() {
@Override
public List<PsiClass> compute() {
List<PsiClass> result = new ArrayList<PsiClass>();
for (CandidateInfo info : CollectClassMembersUtil.getAllInnerClasses(grType, false).values()) {
ContainerUtil.addIfNotNull(result, (PsiClass)info.getElement());
final PsiClass inner = (PsiClass)info.getElement();
if (lastParent == null || !inner.getContainingClass().isInterface()) {
ContainerUtil.addIfNotNull(result, inner);
}
}
return result;
}
});
if (classes == null) {
return Arrays.asList(grType.getInnerClasses());
}
return classes;
}
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
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.impl.GroovyResolveResultImpl;
@@ -221,7 +220,6 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
@Nullable
private static ResolveKind getResolveKind(PsiElement element) {
if (element instanceof PsiVariable) return PROPERTY;
if (element instanceof GrReferenceExpression) return PROPERTY;
if (element instanceof PsiMethod) return METHOD;
if (element instanceof PsiPackage) return PACKAGE;
if (element instanceof PsiClass) return CLASS;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -22,13 +22,15 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.HelpID;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
import java.util.Set;
/**
* @author Maxim.Medvedev
*/
@@ -50,16 +52,24 @@ public class ConvertToJavaHandler implements RefactoringActionHandler {
}
private static void invokeInner(Project project, PsiElement[] elements, Editor editor) {
Set<GroovyFile> files = ContainerUtil.newHashSet();
for (PsiElement element : elements) {
if (!(element instanceof GroovyFile)) {
if (!(element instanceof PsiFile)) {
element = element.getContainingFile();
}
if (element instanceof GroovyFile) {
files.add((GroovyFile)element);
}
else {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
CommonRefactoringUtil.showErrorHint(project, editor, GroovyRefactoringBundle.message("convert.to.java.can.work.only.with.groovy"), REFACTORING_NAME, HelpID.EXTRACT_METHOD);
CommonRefactoringUtil.showErrorHint(project, editor, GroovyRefactoringBundle.message("convert.to.java.can.work.only.with.groovy"), REFACTORING_NAME, null);
return;
}
}
}
GroovyFile[] files = new GroovyFile[elements.length];
System.arraycopy(elements, 0, files, 0, elements.length);
new ConvertToJavaProcessor(project, files).run();
new ConvertToJavaProcessor(project, files.toArray(new GroovyFile[files.size()])).run();
}
}
@@ -157,7 +157,7 @@ public class ExpressionGenerator extends Generator {
);
return;
}
else if (resolved instanceof GrReferenceExpression || resolved == null) {
else if (resolved == null) {
final GrExpression qualifier = ((GrReferenceExpression)invoked).getQualifier();
final GrExpression[] args =
generateArgsForInvokeMethod(((GrReferenceExpression)invoked).getReferenceName(), exprs, namedArgs, clArgs, methodCallExpression);
@@ -1,17 +1,17 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Copyright 2000-2013 JetBrains s.r.o.
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
*
* 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.
* 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.resolve;
@@ -82,7 +82,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase {
}
@Nullable
protected <T extends PsiElement> T resolve(String fileName, Class<T> type = null) {
protected <T extends PsiElement> T resolve(String fileName = getTestName(false) + ".groovy", Class<T> type = null) {
PsiReference ref = configureByFile(getTestName(true) + "/" + fileName);
assertNotNull(ref)
final resolved = ref.resolve()
@@ -110,7 +110,9 @@ public class ResolveClassTest extends GroovyResolveTestCase {
public void testInnerEnum() throws Throwable { doTest(); }
public void testInnerClass()throws Throwable {doTest();}
public void testInnerClassInSubclass()throws Throwable {doTest();}
public void testInnerClassUsageInsideOuterSubclass() throws Throwable{doTest();}
public void testInnerClassUsageInsideOuterSubclass() throws Throwable { doTest() }
public void testInnerClassOfInterface() { assertNull(resolve()) }
public void testInnerClassOfClassInSubClass1() { assertNull(resolve()) }
public void testAliasedImportVsImplicitImport() throws Exception {
PsiReference ref = configureByFile("aliasedImportVsImplicitImport/Test.groovy");
@@ -145,6 +147,12 @@ public class ResolveClassTest extends GroovyResolveTestCase {
assertNotNull(resolved);
}
public void testQualifiedRefToInnerClass() {
myFixture.addFileToProject('A.groovy', 'class A {class Bb {}}')
final PsiReference ref = configureByText('b.groovy', 'A.B<ref>b b = new A.Bb()')
assertNotNull(ref.resolve())
}
public void testClassVsPropertyGetter() {
doTest();
}
@@ -0,0 +1,7 @@
class A {
static class BB {}
}
class C extends A {
class D extends B<ref>B {}
}
@@ -0,0 +1,11 @@
public interface IMappingPolicy {
enum PolicyResult {DontImport, UseUndefined, UseAbsent, UseSpecified, UseNull }
class PolicyResultData {}
}
class S implements IMappingPolicy {
def onUnmappedMasterData() {
return new PolicyResu<ref>ltData()
}
}
@@ -60,12 +60,16 @@ public class MavenJUnitPatcher extends JUnitPatcher {
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
if (systemPropertyVariables != null) {
for (Element element : (List<Element>)systemPropertyVariables.getChildren()) {
String propertyName = element.getName();
String value = element.getValue();
List<Element> propertiesDefinitions = (List<Element>)systemPropertyVariables.getChildren();
javaParameters.getVMParametersList().addProperty(propertyName, value);
String[] params = new String[propertiesDefinitions.size()];
int i = 0;
for (Element element : propertiesDefinitions) {
params[i++] = "-D" + element.getName() + "=" + element.getValue();
}
javaParameters.getVMParametersList().prependAll(params);
}
Element environmentVariables = config.getChild("environmentVariables");
@@ -218,7 +218,7 @@ radio.configure.change.auto.15format=1.&5 format
radio.configure.change.auto.16format=1.&6 format
radio.configure.change.auto.17format=1.&7 format
label.where.svn.format.settings.text=To change above setting later, visit 'File | Settings | Version Control'
label.where.svn.format.settings.text=To change above setting later, visit '{0} | Version Control'
label.where.svn.format.can.be.changed.text=''Version Control | Subversion | {0}''
dialog.upgrade.wcopy.format.title=Subversion Working Copy Format
@@ -327,6 +327,7 @@
<moduleConfigurationEditorProvider implementation="com.intellij.openapi.roots.ui.configuration.DefaultModuleEditorsProvider" order="first"/>
<statistics.usagesCollector implementation="com.intellij.openapi.roots.ui.configuration.libraries.impl.LibraryUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.compiler.CompilerSettingsUsageCollector"/>
<getDataRule key="context.ProjectFileDirectory" implementationClass="com.intellij.ide.impl.dataRules.ProjectFileDirectoryRule"/>
@@ -37,6 +37,7 @@ import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.PairFunction;
import com.intellij.util.text.StringTokenizer;
import com.intellij.xml.util.HtmlUtil;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import org.jetbrains.annotations.Nls;
@@ -56,9 +57,6 @@ public class MicrodataUtil {
public static final String ITEM_PROP = "itemprop";
public static final String ITEM_ID = "itemid";
@NonNls private static final String HTTP = "http://";
@NonNls private static final String HTTPS = "https://";
public static boolean hasScopeTag(@Nullable XmlTag tag) {
return findScopeTag(tag) != null;
}
@@ -130,7 +128,7 @@ public class MicrodataUtil {
@Nullable
@Override
public PsiReference fun(String token, Integer offset) {
if (isUrl(token)) {
if (HtmlUtil.hasHtmlPrefix(token)) {
final TextRange range = TextRange.from(offset, token.length());
final URLReference urlReference = new URLReference(element, range, true);
return new URIReferenceProvider.DependentNSReference(element, range, urlReference) {
@@ -167,10 +165,6 @@ public class MicrodataUtil {
return result.toArray(new PsiReference[result.size()]);
}
private static boolean isUrl(String url) {
return url.startsWith(HTTP) || url.startsWith(HTTPS);
}
@Nullable
public static String getStripedAttributeValue(@Nullable XmlTag tag, @Nls String attributeName) {
String value = tag != null ? tag.getAttributeValue(attributeName) : null;
@@ -34,6 +34,7 @@ import com.intellij.psi.xml.XmlAttribute;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.util.HtmlUtil;
import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -62,7 +63,6 @@ public class URIReferenceProvider extends PsiReferenceProvider {
return true;
}
};
@NonNls private static final String HTTP = "http://";
@NonNls private static final String URN = "urn:";
@NonNls private static final String FILE = "file:";
@NonNls private static final String CLASSPATH = "classpath:/";
@@ -162,7 +162,7 @@ public class URIReferenceProvider extends PsiReferenceProvider {
}
static boolean isUrlText(final String s, Project project) {
final boolean surelyUrl = s.startsWith(HTTP) || s.startsWith(URN);
final boolean surelyUrl = HtmlUtil.hasHtmlPrefix(s) || s.startsWith(URN);
if (surelyUrl) return surelyUrl;
int protocolIndex = s.indexOf(":/");
if (protocolIndex > 1 && !s.regionMatches(0,"classpath",0,protocolIndex)) return true;
@@ -64,6 +64,10 @@ public class SchemaPrefixRenameHandler extends VariableInplaceRenameHandler {
@Override
protected void addReferenceAtCaret(Collection<PsiReference> refs) {}
@Override
protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref) {
return false;
}
};
}
}
@@ -597,6 +597,13 @@ public class HtmlUtil {
return isHtmlFile(file) || file.getViewProvider() instanceof TemplateLanguageFileViewProvider;
}
public static boolean hasHtmlPrefix(@NotNull String url) {
return url.startsWith("http://") ||
url.startsWith("https://") ||
url.startsWith("//") || //Protocol-relative URL
url.startsWith("ftp://");
}
public static boolean isHtmlFile(PsiElement element) {
Language language = element.getLanguage();
return language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE;