diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImmediateClassType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImmediateClassType.java index 06947461b9ef..bba0cfe69f22 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImmediateClassType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImmediateClassType.java @@ -171,7 +171,7 @@ public class PsiImmediateClassType extends PsiClassType { PsiClass parentClass = null; if (!aClass.hasModifierProperty(PsiModifier.STATIC)) { final PsiElement parent = aClass.getParent(); - if (parent instanceof PsiClass) { + if (parent instanceof PsiClass && !(parent instanceof PsiAnonymousClass)) { parentClass = (PsiClass)parent; } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index d4c8d662af43..7ab5099e12a9 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -118,7 +118,7 @@ public class RenameDialog extends RefactoringDialog { myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) { @Override protected boolean shouldSelectAll() { - return myEditor.getSettings().isPreselectRename(); + return myEditor == null || myEditor.getSettings().isPreselectRename(); } }; if (myPsiElement instanceof PsiFile && myEditor == null) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameFileAction.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameFileAction.java new file mode 100644 index 000000000000..a0aa127ec7b1 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameFileAction.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.refactoring.rename; + +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; + +/** + * @author ven + */ +public class RenameFileAction extends AnAction implements DumbAware { + public static final String RENAME_FILE = "Rename File"; + + public void actionPerformed(final AnActionEvent e) { + final PsiFile file = e.getData(LangDataKeys.PSI_FILE); + assert file != null; + final VirtualFile virtualFile = file.getVirtualFile(); + assert virtualFile != null; + final Project project = e.getData(PlatformDataKeys.PROJECT); + assert project != null; + new RenameDialog(project, file, file, null).show(); + } + + public void update(AnActionEvent e) { + PsiFile file = e.getData(LangDataKeys.PSI_FILE); + Presentation presentation = e.getPresentation(); + boolean enabled = file != null && e.getPlace() != ActionPlaces.EDITOR_POPUP && e.getData(PlatformDataKeys.PROJECT) != null; + presentation.setEnabled(enabled); + presentation.setVisible(enabled); + if (enabled) { + presentation.setText(RENAME_FILE); + presentation.setDescription(RENAME_FILE); + } + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java index 244021290c1c..6dfcfde538f9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java @@ -46,8 +46,8 @@ import com.intellij.ui.docking.DragSession; import com.intellij.ui.switcher.SwitchProvider; import com.intellij.ui.switcher.SwitchTarget; import com.intellij.ui.tabs.*; -import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.ui.tabs.impl.JBEditorTabs; +import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.util.ui.AwtVisitor; import com.intellij.util.ui.TimedDeadzone; import com.intellij.util.ui.UIUtil; @@ -86,7 +86,7 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget public ActionGroup get() { return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP); } - }, ActionPlaces.EDITOR_POPUP, false).setNavigationActionsEnabled(false).addTabMouseListener(new TabMouseListener()).getPresentation() + }, ActionPlaces.EDITOR_TAB_POPUP, false).setNavigationActionsEnabled(false).addTabMouseListener(new TabMouseListener()).getPresentation() .setTabDraggingEnabled(true).setUiDecorator(new UiDecorator() { @NotNull public UiDecoration getDecoration() { diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 12a87ccd6ed0..7238c588fb27 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -254,6 +254,7 @@ class = "com.intellij.refactoring.actions.RefactoringQuickListPopupAction" text = "Refactor This..." description="Context aware popup with list of refactoring actions"/> + @@ -572,6 +573,8 @@ + + diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index ee955978e75c..9a1384fa312a 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -1046,11 +1046,6 @@ - - - diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java index 0ee85f5a733f..3f85a1e6649b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java @@ -124,7 +124,7 @@ public class GroovyCodeFragmentFactory implements CodeFragmentFactory { //javaText.append("System.out.println(java.util.Arrays.toString(new Exception().getStackTrace()));\n"); //javaText.append("System.out.println(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), |.+com\\\\.springsource\\\\.loaded\\\\.).+\")\n"); - javaText.append("if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), №.+com\\\\.springsource\\\\.loaded\\\\.).+\")) {\n"); + javaText.append("if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), $OR$.+com\\\\.springsource\\\\.loaded\\\\.).+\")) {\n"); javaText.append(" |thiz0 = thiz;\n"); javaText.append(" } else {\n"); javaText.append(" |thiz0 = this;\n"); @@ -176,7 +176,7 @@ public class GroovyCodeFragmentFactory implements CodeFragmentFactory { final PsiElementFactory factory = JavaPsiFacade.getInstance(toEval.getProject()).getElementFactory(); String hiddenJavaVars = StringUtil.replace(javaText.toString(), "|", "_$$_$$$_$$$$$$$$$_" + new Random().nextInt(42)); - hiddenJavaVars = hiddenJavaVars.replace('№', '|'); + hiddenJavaVars = hiddenJavaVars.replaceAll("\\$OR\\$", "|"); final String finalText = StringUtil.replace(StringUtil.replace(hiddenJavaVars, TEXT, groovyText), IMPORTS, imports); JavaCodeFragment result = JavaCodeFragmentFactory.getInstance(project).createCodeBlockCodeFragment(finalText, null, true); if (contextClass != null) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/javaToGrovyRename/RenameJavaFileToGroovyFileAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/javaToGrovyRename/RenameJavaFileToGroovyFileAction.java deleted file mode 100644 index d94b4fdc43fc..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/javaToGrovyRename/RenameJavaFileToGroovyFileAction.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.groovy.refactoring.javaToGrovyRename; - -import com.intellij.lang.Language; -import com.intellij.lang.StdLanguages; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.DataKeys; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.application.AccessToken; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.plugins.groovy.GroovyFileType; -import org.jetbrains.plugins.groovy.extensions.GroovyScriptType; -import org.jetbrains.plugins.groovy.extensions.GroovyScriptTypeDetector; -import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; -import org.jetbrains.plugins.groovy.util.LibrariesUtil; - -/** - * @author ven - */ -public class RenameJavaFileToGroovyFileAction extends AnAction implements DumbAware { - public void actionPerformed(final AnActionEvent e) { - final PsiFile file = e.getData(DataKeys.PSI_FILE); - assert isEnabled(file); - assert file != null; - VirtualFile virtualFile = file.getVirtualFile(); - assert virtualFile != null; - String newExt = file.getLanguage() == StdLanguages.JAVA ? GroovyFileType.DEFAULT_EXTENSION : StdFileTypes.JAVA.getDefaultExtension(); - - final String newName = virtualFile.getNameWithoutExtension() + "." + newExt; - final Project project = e.getData(DataKeys.PROJECT); - CommandProcessor.getInstance().executeCommand(project, new Runnable() { - public void run() { - AccessToken accessToken = WriteAction.start(); - - try { - try { - file.setName(newName); - } catch (final IncorrectOperationException e1) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - Messages.showErrorDialog(project, "Cannot rename java file" + e1.getMessage(), "Canot Rename"); - } - }); - } - } - finally { - accessToken.finish(); - } - } - }, "Rename File", null); - } - - public void update(AnActionEvent e) { - PsiFile file = e.getData(DataKeys.PSI_FILE); - Presentation presentation = e.getPresentation(); - boolean enabled = isEnabled(file); - presentation.setEnabled(enabled); - presentation.setVisible(enabled); - if (enabled) { - assert file != null; - presentation.setText(file.getLanguage() == StdLanguages.JAVA ? "Rename To Groovy" : "Rename To Java"); - presentation.setDescription(file.getLanguage() == StdLanguages.JAVA ? "Rename Java File to Groovy" : "Rename Groovy File to Java"); - } - } - - private static boolean isEnabled(PsiFile file) { - if (file == null) { - return false; - } - - final Language language = file.getLanguage(); - if (language == GroovyFileType.GROOVY_LANGUAGE) { - if (((GroovyFile)file).isScript()) { - final GroovyScriptType type = GroovyScriptTypeDetector.getScriptType((GroovyFile)file); - if (type != GroovyScriptTypeDetector.DEFAULT_TYPE) { - return false; - } - } - return true; - } - - if (!(language == StdLanguages.JAVA)) { - return false; - } - - final Module module = ModuleUtil.findModuleForPsiElement(file); - return module != null && LibrariesUtil.hasGroovySdk(module); - } -}