mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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() {
|
||||
|
||||
@@ -254,6 +254,7 @@
|
||||
class = "com.intellij.refactoring.actions.RefactoringQuickListPopupAction"
|
||||
text = "Refactor This..." description="Context aware popup with list of refactoring actions"/>
|
||||
<action id="RenameElement" class="com.intellij.refactoring.actions.RenameElementAction"/>
|
||||
<action id="RenameFile" class="com.intellij.refactoring.rename.RenameFileAction"/>
|
||||
<action id="ChangeSignature" class="com.intellij.refactoring.actions.ChangeSignatureAction"/>
|
||||
<separator/>
|
||||
<action id="Move" class="com.intellij.refactoring.actions.MoveAction"/>
|
||||
@@ -572,6 +573,8 @@
|
||||
<reference ref="AddToFavorites"/>
|
||||
<reference ref="AddAllToFavorites"/>
|
||||
<separator/>
|
||||
<reference ref="RenameFile"/>
|
||||
<separator/>
|
||||
<reference ref="MoveToChangeList"/>
|
||||
<separator/>
|
||||
<reference ref="RunContextPopupGroup"/>
|
||||
|
||||
@@ -1046,11 +1046,6 @@
|
||||
<add-to-group group-id="Internal"/>
|
||||
</group>
|
||||
|
||||
<action id="RenameJavaFileToGroovyFileAction"
|
||||
class="org.jetbrains.plugins.groovy.refactoring.javaToGrovyRename.RenameJavaFileToGroovyFileAction"
|
||||
text="Rename To Groovy" description="Rename Java File to Groovy">
|
||||
<add-to-group group-id="EditorTabPopupMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="ExcludeFromStubGeneration"
|
||||
class="org.jetbrains.plugins.groovy.compiler.ExcludeFromStubGenerationAction"
|
||||
text="Exclude from stub generation" description="Don't generate Java stubs for this Groovy file on compilation">
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
-115
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user