Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Kirill.Safonov
2010-01-13 17:48:51 +03:00
28 changed files with 363 additions and 48 deletions
+2 -2
View File
@@ -10,10 +10,10 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="library" name="JUnit4" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
<orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="xml" />
<orderEntry type="module" module-name="testFramework" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
<orderEntry type="library" name="Jaxen" level="project" />
</component>
</module>
Binary file not shown.
@@ -19,14 +19,14 @@ import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.importProject.LibraryDescriptor;
import com.intellij.ide.util.importProject.ModuleDescriptor;
import com.intellij.ide.util.importProject.ModuleInsight;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.ide.util.projectWizard.SourcePathsBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.*;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
@@ -307,6 +307,6 @@ public class ProjectFromSourcesBuilder extends ProjectBuilder implements SourceP
@Override
public boolean isSuitableSdk(final Sdk sdk) {
return sdk.getSdkType() instanceof JavaSdkType;
return sdk.getSdkType() == JavaSdk.getInstance();
}
}
@@ -208,11 +208,12 @@ public class JavaDocExternalFilter {
final boolean[] fail = new boolean[1];
final Exception [] ex = new Exception[1];
final HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
Reader stream = null;
try {
stream = getReaderByUrl(url, ProgressManager.getInstance().getProgressIndicator());
stream = getReaderByUrl(url, httpConfigurable, ProgressManager.getInstance().getProgressIndicator());
}
catch (IOException e) {
ex[0] = e;
@@ -283,7 +284,7 @@ public class JavaDocExternalFilter {
@Nullable
private static Reader getReaderByUrl(final String surl, final ProgressIndicator pi) throws IOException {
private static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
if (surl.startsWith(JAR_PROTOCOL)) {
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));
@@ -295,7 +296,7 @@ public class JavaDocExternalFilter {
}
URL url = BrowserUtil.getURL(surl);
HttpConfigurable.getInstance().prepareURL(url.toString());
httpConfigurable.prepareURL(url.toString());
final URLConnection urlConnection = url.openConnection();
final String contentEncoding = urlConnection.getContentEncoding();
final InputStream inputStream =
@@ -434,11 +435,13 @@ public class JavaDocExternalFilter {
private final String surl;
private final MyDocBuilder myBuilder;
private final Exception [] myExceptions = new Exception[1];
private final HttpConfigurable myHttpConfigurable;
public MyJavadocFetcher(final String surl, MyDocBuilder builder) {
this.surl = surl;
myBuilder = builder;
ourFree = false;
myHttpConfigurable = HttpConfigurable.getInstance();
}
public static boolean isFree() {
@@ -457,7 +460,7 @@ public class JavaDocExternalFilter {
Reader stream = null;
try {
stream = getReaderByUrl(surl, new ProgressIndicatorBase());
stream = getReaderByUrl(surl, myHttpConfigurable, new ProgressIndicatorBase());
}
catch (ProcessCanceledException e) {
return;
@@ -95,6 +95,7 @@ public class JavaRefactoringSettings implements PersistentStateComponent<JavaRef
public boolean INLINE_CLASS_SEARCH_IN_NON_JAVA = true;
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_INHERITORS = true;
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_PARAMETER_IN_HIERARCHY = true;
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_VARIABLES = true;
public static JavaRefactoringSettings getInstance() {
@@ -117,6 +118,14 @@ public class JavaRefactoringSettings implements PersistentStateComponent<JavaRef
this.RENAME_VARIABLES = RENAME_VARIABLES;
}
public boolean isRenameParameterInHierarchy() {
return RENAME_PARAMETER_IN_HIERARCHY;
}
public void setRenameParameterInHierarchy(boolean rename) {
this.RENAME_PARAMETER_IN_HIERARCHY = rename;
}
public JavaRefactoringSettings getState() {
return this;
}
@@ -20,8 +20,10 @@
*/
package com.intellij.refactoring.move.moveClassesOrPackages;
import com.intellij.CommonBundle;
import com.intellij.codeInsight.ChangeContextUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
@@ -150,11 +152,22 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
@Override
public void performRefactoring(UsageInfo[] usages) {
//try to create all directories beforehand
for (PsiClass psiClass : myClassesToMove.keySet()) {
try {
myClassesToMove.get(psiClass).findOrCreateTargetDirectory();
}
catch (IncorrectOperationException e) {
Messages.showErrorDialog(myProject, e.getMessage(), CommonBundle.getErrorTitle());
return;
}
}
final Map<PsiElement, PsiElement> oldToNewElementsMapping = new HashMap<PsiElement, PsiElement>();
for (PsiClass psiClass : myClassesToMove.keySet()) {
ChangeContextUtil.encodeContextInfo(psiClass, true);
final RefactoringElementListener listener = getTransaction().getElementListener(psiClass);
final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, myClassesToMove.get(psiClass).findOrCreateTargetDirectory());
final PsiDirectory moveDestination = myClassesToMove.get(psiClass).getTargetDirectory();
final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination);
oldToNewElementsMapping.put(psiClass, newClass);
listener.elementMoved(newClass);
}
@@ -241,7 +254,7 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
myRelativePath = relativePath;
}
public PsiDirectory findOrCreateTargetDirectory() {
public PsiDirectory findOrCreateTargetDirectory() throws IncorrectOperationException{
if (myTargetDirectory == null) {
final PsiDirectory root = myParentDirectory.findOrCreateTargetDirectory();
@@ -0,0 +1,60 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* User: anna
* Date: 12-Jan-2010
*/
package com.intellij.refactoring.rename.naming;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
public class AutomaticParametersRenamer extends AutomaticRenamer {
public AutomaticParametersRenamer(PsiParameter param, String newParamName) {
final PsiElement scope = param.getDeclarationScope();
if (scope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)scope;
final int parameterIndex = method.getParameterList().getParameterIndex(param);
for (PsiMethod overrider : OverridingMethodsSearch.search(method)) {
final PsiParameter inheritedParam = overrider.getParameterList().getParameters()[parameterIndex];
myElements.add(inheritedParam);
suggestAllNames(inheritedParam.getName(), newParamName);
}
}
}
public String getDialogTitle() {
return "Rename parameters";
}
public String getDialogDescription() {
return "Rename parameter in hierarchy to:";
}
@Override
public String entityName() {
return "Parameter";
}
@Override
public boolean isSelectedByDefault() {
return true;
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* User: anna
* Date: 12-Jan-2010
*/
package com.intellij.refactoring.rename.naming;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter;
import com.intellij.refactoring.JavaRefactoringSettings;
import com.intellij.usageView.UsageInfo;
import java.util.Collection;
public class AutomaticParametersRenamerFactory implements AutomaticRenamerFactory{
public boolean isApplicable(PsiElement element) {
return element instanceof PsiParameter && ((PsiParameter)element).getDeclarationScope() instanceof PsiMethod;
}
public String getOptionName() {
return "Rename parameters in hierarchy";
}
public boolean isEnabled() {
return JavaRefactoringSettings.getInstance().isRenameParameterInHierarchy();
}
public void setEnabled(boolean enabled) {
JavaRefactoringSettings.getInstance().setRenameParameterInHierarchy(enabled);
}
public AutomaticRenamer createRenamer(PsiElement element, String newName, Collection<UsageInfo> usages) {
return new AutomaticParametersRenamer((PsiParameter)element, newName);
}
}
@@ -0,0 +1,12 @@
public class Test {
int myI;
void foo(int <caret>i){
myI = i;
}
}
class TestImpl extends Test {
void foo(int i){
super.foo(i);
}
}
@@ -0,0 +1,12 @@
public class Test {
int myI;
void foo(int i){
myI = i;
}
}
class TestImpl extends Test {
void foo(int pp){
super.foo(pp);
}
}
@@ -51,6 +51,10 @@ public class RenameLocalTest extends LightCodeInsightTestCase {
doTestInplaceRenameCollisionsResolved("myI");
}
public void testRenameInPlaceParamInOverriderAutomaticRenamer() throws Exception {
doTestInplaceRenameCollisionsResolved("pp");
}
//reference itself won't be renamed
private void doTestInplaceRenameCollisionsResolved(String newName) throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
@@ -64,6 +68,7 @@ public class RenameLocalTest extends LightCodeInsightTestCase {
final ResolveSnapshotProvider.ResolveSnapshot snapshot = resolveSnapshotProvider.createSnapshot(methodScope);
assertNotNull(snapshot);
final int offset = element.getTextOffset();
VariableInplaceRenamer renamer = new VariableInplaceRenamer((PsiNameIdentifierOwner)element, getEditor());
((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(true);
try {
@@ -74,6 +79,7 @@ public class RenameLocalTest extends LightCodeInsightTestCase {
snapshot.apply(newName);
TemplateManagerImpl.getTemplateState(myEditor).gotoEnd();
renamer.performAutomaticRename(newName, PsiTreeUtil.getParentOfType(myFile.findElementAt(offset), PsiNameIdentifierOwner.class));
((TestLookupManager)LookupManager.getInstance(getProject())).clearLookup();
((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(false);
}
@@ -21,7 +21,9 @@ import com.intellij.injected.editor.EditorWindow;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
@@ -29,6 +31,8 @@ import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.roots.ContentEntry;
@@ -112,7 +116,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
return configureByFiles(projectFile, vFiles);
}
protected VirtualFile configureByFile(String filePath, String projectRoot) throws Exception {
protected VirtualFile configureByFile(@NonNls String filePath, String projectRoot) throws Exception {
String fullPath = getTestDataPath() + filePath;
final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/'));
@@ -586,11 +590,21 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
}
}
protected void backspace() {
EditorActionManager actionManager = EditorActionManager.getInstance();
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
protected void undo() {
UndoManager undoManager = UndoManager.getInstance(myProject);
TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(getEditor());
undoManager.undo(textEditor);
}
actionHandler.execute(getEditor(), DataManager.getInstance().getDataContext());
protected void backspace() {
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
public void run() {
EditorActionManager actionManager = EditorActionManager.getInstance();
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
actionHandler.execute(getEditor(), DataManager.getInstance().getDataContext());
}
}, "backspace", getEditor().getDocument());
}
protected void ctrlShiftF7() {
@@ -143,6 +143,8 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runStartupActivities();
((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities();
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
myRunCommandForTest = wrapInCommand();
}
protected void tearDown() throws Exception {
@@ -307,17 +309,36 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
public @interface CanChangeDocumentDuringHighlighting {}
private boolean canChangeDocumentDuringHighlighting() {
return annotatedWith(CanChangeDocumentDuringHighlighting.class);
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface DoNotWrapInCommand {}
private boolean wrapInCommand() {
return !annotatedWith(DoNotWrapInCommand.class);
}
private boolean annotatedWith(Class annotationClass) {
String methodName = "test" + getTestName(false);
Class aClass = getClass();
if (aClass.getAnnotation(annotationClass) != null) return true;
Method method = null;
try {
Class<? extends DaemonAnalyzerTestCase> aClass = getClass();
if (aClass.getAnnotation(CanChangeDocumentDuringHighlighting.class) != null) return true;
method = aClass.getDeclaredMethod(methodName);
while (aClass != null) {
try {
method = aClass.getDeclaredMethod(methodName);
break;
}
catch (NoSuchMethodException e) {
aClass = aClass.getSuperclass();
}
}
catch (NoSuchMethodException e) {
if (method == null) {
fail(methodName);
}
CanChangeDocumentDuringHighlighting annotation = method.getAnnotation(CanChangeDocumentDuringHighlighting.class);
Object annotation = method.getAnnotation(annotationClass);
return annotation != null;
}
+1 -1
View File
@@ -12,7 +12,7 @@
<orderEntry type="module" module-name="boot" />
<orderEntry type="module" module-name="vcs-api" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="library" name="JUnit3" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit3" level="project" />
<orderEntry type="library" name="Velocity" level="project" />
<orderEntry type="library" name="commons-collections" level="project" />
<orderEntry type="module" module-name="vcs-impl" />
@@ -29,6 +29,7 @@ import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.command.CommandAdapter;
import com.intellij.openapi.command.CommandEvent;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.impl.UndoManagerImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.DocCommandGroupId;
@@ -269,16 +270,33 @@ public class DaemonListeners implements Disposable {
if (file instanceof PsiCodeFragment) return true;
Project project = file.getProject();
if (!ModuleUtil.projectContainsFile(project, virtualFile, false)) return false;
if (!FileDocumentManager.getInstance().isFileModified(virtualFile)) return false;
Result vcs = vcsThinksItChanged(virtualFile, project);
if (vcs == Result.CHANGED) return true;
if (vcs == Result.UNCHANGED) return false;
return canUndo(virtualFile);
}
private boolean canUndo(VirtualFile virtualFile) {
for (FileEditor editor : FileEditorManager.getInstance(myProject).getEditors(virtualFile)) {
if (UndoManagerImpl.getInstance(myProject).isUndoAvailable(editor)) return true;
}
return false;
}
private static enum Result {
CHANGED, UNCHANGED, NOT_SURE
}
private Result vcsThinksItChanged(VirtualFile virtualFile, Project project) {
FilePath path = new FilePathImpl(virtualFile);
boolean vcsIsThinking = !VcsDirtyScopeManager.getInstance(myProject).whatFilesDirty(Arrays.asList(path)).isEmpty();
if (vcsIsThinking) return false;
if (vcsIsThinking) return Result.UNCHANGED; // do not modify file which is in the process of updating
AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(virtualFile);
if (activeVcs == null) return true;
if (activeVcs == null) return Result.NOT_SURE;
FileStatus status = FileStatusManager.getInstance(project).getStatus(virtualFile);
return status == FileStatus.MODIFIED || status == FileStatus.ADDED;
return status == FileStatus.MODIFIED || status == FileStatus.ADDED ? Result.CHANGED : Result.UNCHANGED;
}
private class MyApplicationListener extends ApplicationAdapter {
@@ -84,7 +84,7 @@ public class IdIndex extends FileBasedIndexExtension<IdIndexEntry, Integer> {
};
public int getVersion() {
return 8;
return 9; // TODO: version should enumerate all word scanner versions and build version upon that set
}
public boolean dependsOnFileContent() {
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.lang.TitledHandler;
import com.intellij.refactoring.util.RadioUpDownListener;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.Nullable;
@@ -101,10 +102,12 @@ public class RenameHandlerRegistry {
private static class HandlersChooser extends DialogWrapper {
private final String[] myRenamers;
private String mySelection;
private JRadioButton[] myRButtons;
protected HandlersChooser(Project project, String [] renamers) {
super(project);
myRenamers = renamers;
myRButtons = new JRadioButton[myRenamers.length];
mySelection = renamers[0];
setTitle(RefactoringBundle.message("select.refactoring.title"));
init();
@@ -119,8 +122,10 @@ public class RenameHandlerRegistry {
radioPanel.add(descriptionLabel);
final ButtonGroup bg = new ButtonGroup();
boolean selected = true;
int rIdx = 0;
for (final String renamer : myRenamers) {
final JRadioButton rb = new JRadioButton(renamer, selected);
myRButtons[rIdx++] = rb;
final ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (rb.isSelected()) {
@@ -133,9 +138,15 @@ public class RenameHandlerRegistry {
bg.add(rb);
radioPanel.add(rb);
}
new RadioUpDownListener(myRButtons);
return radioPanel;
}
@Override
public JComponent getPreferredFocusedComponent() {
return myRButtons[0];
}
public String getSelection() {
return mySelection;
}
@@ -303,7 +303,7 @@ public class RenameProcessor extends BaseRefactoringProcessor {
return myCommandName;
}
private static UsageInfo[] extractUsagesForElement(PsiElement element, UsageInfo[] usages) {
public static UsageInfo[] extractUsagesForElement(PsiElement element, UsageInfo[] usages) {
final ArrayList<UsageInfo> extractedUsages = new ArrayList<UsageInfo>(usages.length);
for (UsageInfo usage : usages) {
LOG.assertTrue(usage instanceof MoveRenameUsageInfo);
@@ -42,6 +42,7 @@ import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -182,7 +183,7 @@ public class RenameUtil {
}
public static void doRenameGenericNamedElement(PsiElement namedElement, String newName, UsageInfo[] usages,
RefactoringElementListener listener) throws IncorrectOperationException {
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
PsiWritableMetaData writableMetaData = null;
if (namedElement instanceof PsiMetaOwner) {
final PsiMetaData metaData = ((PsiMetaOwner)namedElement).getMetaData();
@@ -224,7 +225,9 @@ public class RenameUtil {
}
}
}
listener.elementRenamed(namedElement);
if (listener != null) {
listener.elementRenamed(namedElement);
}
}
public static void rename(UsageInfo info, String newName) throws IncorrectOperationException {
@@ -35,6 +35,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
@@ -46,9 +47,15 @@ import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.rename.AutomaticRenamingDialog;
import com.intellij.refactoring.rename.NameSuggestionProvider;
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.RenameUtil;
import com.intellij.refactoring.rename.naming.AutomaticRenamer;
import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.TextOccurrencesUtil;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.PairProcessor;
import com.intellij.util.containers.Stack;
import gnu.trove.THashMap;
@@ -161,6 +168,7 @@ public class VariableInplaceRenamer {
}
final PsiElement scope1 = scope;
final int renameOffset = myElementToRename.getTextOffset();
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@@ -174,17 +182,18 @@ public class VariableInplaceRenamer {
Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(myEditor);
topLevelEditor.getCaretModel().moveToOffset(range.getStartOffset());
TemplateManager.getInstance(myProject).startTemplate(topLevelEditor, template, new TemplateEditingAdapter() {
private String myNewName = null;
public void beforeTemplateFinished(final TemplateState templateState, Template template) {
finish();
if (snapshot != null) {
TextResult value = templateState.getVariableValue(PRIMARY_VARIABLE_NAME);
if (value != null) {
final String newName = value.toString();
if (LanguageNamesValidation.INSTANCE.forLanguage(scope1.getLanguage()).isIdentifier(newName, myProject)) {
myNewName = value.toString();
if (LanguageNamesValidation.INSTANCE.forLanguage(scope1.getLanguage()).isIdentifier(myNewName, myProject)) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
snapshot.apply(newName);
snapshot.apply(myNewName);
}
});
}
@@ -192,6 +201,14 @@ public class VariableInplaceRenamer {
}
}
@Override
public void templateFinished(Template template) {
super.templateFinished(template);
if (myNewName != null) {
performAutomaticRename(myNewName, PsiTreeUtil.getParentOfType(containingFile.findElementAt(renameOffset), PsiNameIdentifierOwner.class));
}
}
public void templateCancelled(Template template) {
finish();
}
@@ -218,6 +235,43 @@ public class VariableInplaceRenamer {
return true;
}
public void performAutomaticRename(final String newName, final PsiElement elementToRename) {
for (AutomaticRenamerFactory renamerFactory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
if (renamerFactory.isApplicable(elementToRename)) {
final List<UsageInfo> usages = new ArrayList<UsageInfo>();
final AutomaticRenamer renamer =
renamerFactory.createRenamer(elementToRename, newName, new ArrayList<UsageInfo>());
if (renamer.hasAnythingToRename()) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final AutomaticRenamingDialog renamingDialog = new AutomaticRenamingDialog(myProject, renamer);
renamingDialog.show();
if (!renamingDialog.isOK()) return;
}
final Runnable runnable = new Runnable() {
public void run() {
renamer.findUsages(usages, false, false);
}
};
if (!ProgressManager.getInstance()
.runProcessWithProgressSynchronously(runnable, RefactoringBundle.message("searching.for.variables"), true, myProject)) {
return;
}
final UsageInfo[] usageInfos = usages.toArray(new UsageInfo[usages.size()]);
for (final PsiNamedElement element : renamer.getRenames().keySet()) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
RenameUtil.doRenameGenericNamedElement(element, renamer.getRenames().get(element), RenameProcessor.extractUsagesForElement(element, usageInfos), null);
}
});
}
}
}
}
}
private static VirtualFile getTopLevelVirtualFile(final FileViewProvider fileViewProvider) {
VirtualFile file = fileViewProvider.getVirtualFile();
if (file instanceof VirtualFileWindow) file = ((VirtualFileWindow)file).getDelegate();
+1 -1
View File
@@ -6,7 +6,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="library" name="Mac" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Mac" level="project" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jna" level="project" />
@@ -27,11 +27,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.Alarm;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -62,8 +64,9 @@ public class ProgressTipPanel {
myProject = project;
myCurrentFeature = 0;
//noinspection HardCodedStringLiteral
myBrowser.setContentType("text/html");
final HTMLEditorKit editorKit = new HTMLEditorKit();
myBrowser.setEditorKit(editorKit);
myBrowser.setContentType(UIUtil.HTML_MIME);
myScrollPane.setPreferredSize(new Dimension(600, 200));
myBrowser.setEditable(false);
+1 -1
View File
@@ -9,7 +9,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="library" name="JUnit4" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
</component>
</module>
@@ -310,7 +310,20 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
if (updateUnversionedFiles && !wasEverythingDirty) {
composite.cleanScope(adjustedScope);
}
actualUpdate(wasEverythingDirty, composite, builder, adjustedScope, vcs, changeListWorker, gate);
try {
actualUpdate(wasEverythingDirty, composite, builder, adjustedScope, vcs, changeListWorker, gate);
}
catch (Throwable t) {
LOG.info(t);
if (t instanceof Error) {
throw (Error) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
throw new RuntimeException(t);
}
if (myUpdateException != null) break;
}
@@ -15,6 +15,7 @@
*/
package git4idea.changes;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
@@ -35,6 +36,7 @@ import java.util.Set;
* Git repository change provider
*/
public class GitChangeProvider implements ChangeProvider {
private static final Logger LOG = Logger.getInstance("#git4idea.changes.GitChangeProvider");
/**
* the project
*/
@@ -56,7 +58,11 @@ public class GitChangeProvider implements ChangeProvider {
final ChangelistBuilder builder,
final ProgressIndicator progress,
final ChangeListManagerGate addGate) throws VcsException {
Collection<VirtualFile> roots = GitUtil.gitRootsForPaths(dirtyScope.getAffectedContentRoots());
final Collection<VirtualFile> affected = dirtyScope.getAffectedContentRoots();
Collection<VirtualFile> roots = GitUtil.gitRootsForPaths(affected);
if (roots.size() != affected.size()) {
LOG.info("affected content roots size: " + affected.size() + " roots size: " + roots.size());
}
final MyNonChangedHolder holder = new MyNonChangedHolder(myProject, dirtyScope.getDirtyFilesNoExpand());
@@ -37,13 +37,17 @@ public class TestResultsSender implements TestListener {
}
public synchronized void addError(Test test, Throwable throwable) {
if (throwable instanceof AssertionError) {
doAddFailure(test, (Error)throwable);
}
else {
stopMeter(test);
prepareDefectPacket(test, throwable).send();
try {
final Class aClass = Class.forName("java.lang.AssertionError");
if (aClass.isInstance(throwable)) {
doAddFailure(test, (Error)throwable);
return;
}
}
catch (ClassNotFoundException ignored) {}
stopMeter(test);
prepareDefectPacket(test, throwable).send();
}
public synchronized void addFailure(Test test, AssertionFailedError assertion) {
+1
View File
@@ -999,6 +999,7 @@
<renamePsiElementProcessor implementation="com.intellij.refactoring.rename.RenameJavaVariableProcessor"/>
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticVariableRenamerFactory"/>
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticParametersRenamerFactory"/>
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticInheritorRenamerFactory"/>
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.ConstructorParameterOnFieldRenameRenamerFactory"/>
@@ -124,8 +124,9 @@ public class DefaultXmlExtension extends XmlExtension {
final String name = tag.getLocalName();
final Set<String> byTagName = getNamespacesByTagName(name, file);
if (!byTagName.isEmpty()) {
byTagName.removeAll(Arrays.asList(tag.knownNamespaces()));
return byTagName;
Set<String> filtered = new HashSet<String>(byTagName);
filtered.removeAll(Arrays.asList(tag.knownNamespaces()));
return filtered;
}
final Set<String> set = guessNamespace(file, name);
set.removeAll(Arrays.asList(tag.knownNamespaces()));