diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 000000000000..b99a172034b3 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,216 @@ + + + + + + + diff --git a/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java b/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java index dfedbcd7a76f..658f7803bc89 100644 --- a/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java +++ b/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java @@ -38,14 +38,14 @@ import java.beans.PropertyChangeListener; * * @author Alexey Efimov */ -public class ImageEditorImpl implements ImageEditor { +class ImageEditorImpl implements ImageEditor { private final PropertyChangeListener optionsChangeListener = new OptionsChangeListener(); private final Project project; private final ImageContentProvider contentProvider; private final ImageEditorUI editorUI; private boolean disposed; - public ImageEditorImpl(@NotNull Project project, @NotNull final ImageContentProvider contentProvider) { + ImageEditorImpl(@NotNull Project project, @NotNull final ImageContentProvider contentProvider) { this.project = project; this.contentProvider = contentProvider; diff --git a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java index 9c344f6f8a8a..88e89eef1957 100644 --- a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java +++ b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java @@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull; * * @author Alexey Efimov */ -final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { +public final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { @NonNls private static final String EDITOR_TYPE_ID = "images"; private final ImageFileTypeManager typeManager; @@ -45,7 +45,11 @@ final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { @NotNull public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) { - ImageContentProvider contentProvider = new VirtualFileImageContentProvider(file); + return createImageEditor(project, new VirtualFileImageContentProvider(file)); + } + + @NotNull + public static FileEditor createImageEditor(@NotNull Project project, @NotNull ImageContentProvider contentProvider) { ImageFileEditorImpl editor = new ImageFileEditorImpl(project, contentProvider); Disposer.register(editor, contentProvider); return editor; diff --git a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java index da7e9477770b..3239824d4ada 100644 --- a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java @@ -135,7 +135,7 @@ public class JavaExecutionUtil { @Nullable public static PsiClass findMainClass(final Module module, final String mainClassName) { - return findMainClass(module.getProject(), mainClassName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)); + return findMainClass(module.getProject(), mainClassName, module.getModuleRuntimeScope(true)); } @Nullable diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java index a8cc13d35cc7..27a27adf3ae8 100644 --- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java +++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java @@ -53,8 +53,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule { final Module module = getModule(); final GlobalSearchScope scope; if (module != null) { - scope = myClassesInLibraries ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) - : GlobalSearchScope.moduleWithDependenciesScope(module); + scope = myClassesInLibraries ? module.getModuleRuntimeScope(true) : GlobalSearchScope.moduleWithDependenciesScope(module); } else { scope = myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject()); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java index 8c45b50edb9a..adfcabae8431 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java @@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ModifiableModelsProvider; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ui.configuration.FacetsProvider; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import com.intellij.openapi.util.Disposer; import com.intellij.ui.GuiUtils; import com.intellij.util.ui.EmptyIcon; import org.jetbrains.annotations.NotNull; @@ -125,6 +126,7 @@ public class OldFrameworkSupportProviderWrapper extends FrameworkSupportInModule private final FrameworkLibraryVersionFilter myVersionFilter; public FrameworkSupportConfigurableWrapper(FrameworkSupportConfigurable configurable) { + Disposer.register(this, configurable); myConfigurable = configurable; if (configurable instanceof FrameworkSupportWithLibrary) { myVersionFilter = FrameworkLibraryVersionFilter.ALL; diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java index 0f7e7ae14dc1..19f65c5202a3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java @@ -74,6 +74,11 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{ editor.getCaretModel().moveToOffset(textOffset); editor.getSelectionModel().removeSelection(); new VariableInplaceRenamer(variable, editor){ + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected void moveOffsetAfter(boolean success) { super.moveOffsetAfter(success); diff --git a/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form b/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form index 6b25000e046e..3a2b94603d97 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form +++ b/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form @@ -1,16 +1,16 @@
- - + + - + - + @@ -19,7 +19,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -181,7 +181,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -208,7 +208,7 @@ - + @@ -221,12 +221,12 @@ - + - + @@ -235,12 +235,21 @@ - + + + + + + + + + + diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java index 0ae7266d42a5..cafff6e5ccbf 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java @@ -50,6 +50,7 @@ public final class JavadocConfigurable implements Configurable { configuration.OPTION_DOCUMENT_TAG_VERSION = myPanel.myTagVersion.isSelected(); configuration.OPTION_DOCUMENT_TAG_DEPRECATED = myPanel.myTagDeprecated.isSelected(); configuration.OPTION_DEPRECATED_LIST = myPanel.myDeprecatedList.isSelected(); + configuration.OPTION_INCLUDE_LIBS = myPanel.myIncludeLibraryCb.isSelected(); } public void loadFrom(JavadocConfiguration configuration) { @@ -71,6 +72,8 @@ public final class JavadocConfigurable implements Configurable { myPanel.mySeparateIndex.setEnabled(myPanel.myIndex.isSelected()); myPanel.myDeprecatedList.setEnabled(myPanel.myTagDeprecated.isSelected()); + + myPanel.myIncludeLibraryCb.setSelected(configuration.OPTION_INCLUDE_LIBS); } public boolean isModified() { @@ -91,6 +94,7 @@ public final class JavadocConfigurable implements Configurable { isModified |= myPanel.myTagVersion.isSelected() != configuration.OPTION_DOCUMENT_TAG_VERSION; isModified |= myPanel.myTagDeprecated.isSelected() != configuration.OPTION_DOCUMENT_TAG_DEPRECATED; isModified |= myPanel.myDeprecatedList.isSelected() != configuration.OPTION_DEPRECATED_LIST; + isModified |= myPanel.myIncludeLibraryCb.isSelected() != configuration.OPTION_INCLUDE_LIBS; return isModified; } diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index 4913ac98998d..62f82057f7e1 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -83,6 +83,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl private final Project myProject; private AnalysisScope myGenerationScope; private static final Logger LOGGER = Logger.getInstance("#" + JavadocConfiguration.class.getName()); + public boolean OPTION_INCLUDE_LIBS = false; public void setGenerationScope(AnalysisScope generationScope) { myGenerationScope = generationScope; @@ -274,7 +275,11 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl writer.println(source); } writer.println("-sourcepath"); - final PathsList pathsList = OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList(); + OrderEnumerator enumerator = OrderEnumerator.orderEntries(myProject); + if (!OPTION_INCLUDE_LIBS) { + enumerator = enumerator.withoutSdk().withoutLibraries(); + } + final PathsList pathsList = enumerator.getSourcePathsList(); final List files = pathsList.getRootDirs(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); final StringBuilder sourcePath = new StringBuilder(); diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java b/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java index d23682265916..5cc096016683 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java @@ -46,6 +46,7 @@ final class JavadocGenerationPanel extends JPanel { JCheckBox myDeprecatedList; JCheckBox myOpenInBrowserCheckBox; JTextField myLocaleTextField; + JCheckBox myIncludeLibraryCb; JavadocGenerationPanel() { myTfOutputDir.addBrowseFolderListener(JavadocBundle.message("javadoc.generate.output.directory.browse"), null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java index fa229ac8022d..93b9a847d49f 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java @@ -98,6 +98,7 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler { PsiDocumentManager.getInstance(project).commitAllDocuments(); if (processor.isCreateInnerClass()) { processor.moveUsedMethodsToInner(); + PsiDocumentManager.getInstance(project).commitAllDocuments(); DuplicatesImpl.processDuplicates(extractProcessor, project, editor); } ApplicationManager.getApplication().runWriteAction(new Runnable() { diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java index d8e4f27c6595..18b0ea35a282 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java @@ -80,7 +80,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { private PsiMethod myInnerMethod; private boolean myMadeStatic = false; - private final Set myUsages = new HashSet(); + private final Set myUsages = new LinkedHashSet(); private PsiClass myInnerClass; private ChangeSignatureProcessor myChangeSignatureProcessor; private Runnable myCopyMethodToInner; @@ -109,7 +109,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { } } if (isCreateInnerClass()) { - final Set usedMethods = new HashSet(); + final Set usedMethods = new LinkedHashSet(); getMethod().accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) { @@ -224,13 +224,16 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { }; dlg.show(); if (dlg.isOK()) { - for (MemberInfoBase memberInfo : panel.getTable().getSelectedMemberInfos()) { - if (memberInfo.isChecked()) { - myInnerClass.add(memberInfo.getMember().copy()); - memberInfo.getMember().delete(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + for (MemberInfoBase memberInfo : panel.getTable().getSelectedMemberInfos()) { + if (memberInfo.isChecked()) { + myInnerClass.add(memberInfo.getMember().copy()); + memberInfo.getMember().delete(); + } + } } - - } + }); } } } diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java index ec5a46f1d70f..82e69525570c 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java @@ -33,7 +33,10 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.MoveDestination; import com.intellij.refactoring.PackageWrapper; -import com.intellij.ui.*; +import com.intellij.ui.CollectionComboBoxModel; +import com.intellij.ui.ComboboxSpeedSearch; +import com.intellij.ui.ComboboxWithBrowseButton; +import com.intellij.ui.EditorComboBox; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -46,6 +49,7 @@ import java.util.*; * Date: 9/13/11 */ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton { + private static final String LEAVE_IN_SAME_SOURCE_ROOT = "Leave in same source root"; private PsiDirectory myInitialTargetDirectory; private VirtualFile[] mySourceRoots; @@ -81,6 +85,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton new ComboboxSpeedSearch(getComboBox()) { @Override protected String getElementText(Object element) { + if (element == null) return LEAVE_IN_SAME_SOURCE_ROOT; if (element instanceof DirectoryChooser.ItemWrapper) { final VirtualFile virtualFile = ((DirectoryChooser.ItemWrapper)element).getDirectory().getVirtualFile(); final Module module = ModuleUtil.findModuleForFile(virtualFile, project); @@ -105,7 +110,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton setText(getPresentableText(itemWrapper, project)); } else { - setText("Leave in same source root"); + setText(LEAVE_IN_SAME_SOURCE_ROOT); } } }); diff --git a/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java new file mode 100644 index 000000000000..c5fbbd81e4c1 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java @@ -0,0 +1,54 @@ +import java.util.Date; + +public class TestClass { + + private Date expiry; + private Date maturity; + private int commitment; + private double outstanding; + private Iterable payments; + private Date today; + private Date start; + private int riskRating; + + + public double calculate() { + return ( outstandingRiskAmount() * duration() * riskFactor() ) + ( unusedRiskAmount() * duration() * unusedRiskFactor() ); + } + + private double riskFactor() { + return 5.0; + } + + private double unusedRiskFactor() { + return 6.0; + } + + private double unusedRiskAmount() { + return ( commitment - outstanding ); + } + + private double outstandingRiskAmount() { + return outstanding; + } + + private double getUsedPercentage() { + return 1.0; + } + + private double duration() { + if ( expiry == null && maturity != null ) { + return 1.0; + } else if ( expiry != null && maturity == null ) { + return yearsTo( expiry ); + } + return 0.0; + + } + + private double yearsTo( final Date endDate ) { + Date beginDate = ( today == null ? start : today ); + return ( ( endDate.getTime() - beginDate.getTime() )); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after new file mode 100644 index 000000000000..b19b72b035ae --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after @@ -0,0 +1,59 @@ +import java.util.Date; + +public class TestClass { + + private Date expiry; + private Date maturity; + private int commitment; + private double outstanding; + private Iterable payments; + private Date today; + private Date start; + private int riskRating; + + + public double calculate() { + return new InnerClass().invoke(); + } + + private double getUsedPercentage() { + return 1.0; + } + + private double yearsTo( final Date endDate ) { + Date beginDate = ( today == null ? start : today ); + return ( ( endDate.getTime() - beginDate.getTime() )); + } + + private class InnerClass { + public double invoke() { + return ( outstandingRiskAmount() * duration() * riskFactor() ) + ( unusedRiskAmount() * duration() * unusedRiskFactor() ); + } + + private double outstandingRiskAmount() { + return outstanding; + } + + private double duration() { + if ( expiry == null && maturity != null ) { + return 1.0; + } else if ( expiry != null && maturity == null ) { + return yearsTo( expiry ); + } + return 0.0; + + } + + private double riskFactor() { + return 5.0; + } + + private double unusedRiskAmount() { + return ( commitment - outstanding ); + } + + private double unusedRiskFactor() { + return 6.0; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java index b520670d9f5a..082584d0aa84 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java @@ -4,7 +4,8 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.lookup.*; import com.intellij.codeInsight.lookup.impl.LookupImpl; -import com.intellij.testFramework.IdeaTestUtil; +import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.ThrowableRunnable; import org.jetbrains.annotations.NonNls; @SuppressWarnings({"ALL"}) @@ -75,10 +76,16 @@ public class SecondSmartTypeCompletionTest extends LightCompletionTestCase { public void testNewStaticProblem() throws Throwable { doTest(); } public void testChainingPerformance() throws Throwable { - long time = System.currentTimeMillis(); - configure(); - IdeaTestUtil.assertTiming("", 3000, System.currentTimeMillis() - time); - assertNotNull(myItems); + configureByFileNoComplete(BASE_PATH + "/" + getTestName(false) + ".java"); + PlatformTestUtil.startPerformanceTest(getTestName(false), 1000, new ThrowableRunnable() { + @Override + public void run() throws Exception { + configure(); + assertNotNull(myItems); + LookupManager.getInstance(getProject()).hideActiveLookup(); + } + }).cpuBound().assertTiming(); + } public void testArrayMemberAccess() throws Throwable { doTest(); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java index ea43a5ed4b22..bfbef6b40775 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java @@ -110,6 +110,10 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase { public void testWithPrivateMethodUsed() throws Exception { doTest(); } + + public void testWithPrivateMethodUsed1() throws Exception { + doTest(); + } public void testWithPrivateMethodWhichCantBeMoved() throws Exception { doTest(); diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java index 6f78c4cbb31e..e7c99a4b0538 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java @@ -108,6 +108,7 @@ public class ModuleUtil { if (!element.isValid()) return null; Project project = element.getProject(); + if (project.isDefault()) return null; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (element instanceof PsiFileSystemItem && (!(element instanceof PsiFile) || element.getContext() == null)) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 3aed41568a8b..cf271064c67d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -275,8 +275,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass LocalInspectionTool tool = wrapper.getTool(); if (!checkDumbAwareness || tool instanceof DumbAware) { map.putValue(tool, language); - for (Language dialect : lang.getDialects()) { - map.putValue(tool, dialect.getID()); + if (wrapper.applyToDialects()) { + for (Language dialect : lang.getDialects()) { + map.putValue(tool, dialect.getID()); + } } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index c73071840be8..f1d074009100 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -19,6 +19,10 @@ package com.intellij.codeInsight.highlighting; import com.intellij.lang.Language; import com.intellij.lang.LanguageBraceMatching; import com.intellij.lang.PairedBraceMatcher; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.FileType; @@ -30,6 +34,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.HashMap; import java.util.List; @@ -57,6 +62,17 @@ public class BraceMatchingUtil { BRACE_MATCHERS.put(fileType, braceMatcher); } + @TestOnly + public static int getMatchedBraceOffset(Editor editor, boolean forward, PsiFile file) { + Document document = editor.getDocument(); + int offset = editor.getCaretModel().getOffset(); + EditorHighlighter editorHighlighter = ((EditorEx)editor).getHighlighter(); + HighlighterIterator iterator = editorHighlighter.createIterator(offset); + boolean matched = matchBrace(document.getCharsSequence(), file.getFileType(), iterator, forward); + assert matched; + return iterator.getStart(); + } + private static class MatchBraceContext { CharSequence fileText; FileType fileType; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index 20a653a476d9..c81ac0ca7e97 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java @@ -154,7 +154,7 @@ public class LiveTemplateSettingsEditor extends JPanel { panel.add(createTemplateOptionsPanel(), gb.nextLine().next().next().coverColumn(2).weighty(1)); - panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().fillCellNone().anchor(GridBagConstraints.WEST)); + panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().weighty(0).fillCellNone().anchor(GridBagConstraints.WEST)); myTemplateEditor.getDocument().addDocumentListener( new DocumentAdapter() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 7304a1d00504..412d38f4c0c2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -29,14 +29,16 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; -import com.intellij.util.*; +import com.intellij.util.Alarm; +import com.intellij.util.NullableFunction; +import com.intellij.util.ObjectUtils; +import com.intellij.util.PlatformIcons; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.UiNotifyConnector; @@ -46,7 +48,10 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.*; import java.util.*; @@ -92,8 +97,11 @@ public class TemplateListPanel extends JPanel implements Disposable { createTemplateEditor(MOCK_TEMPLATE, "Tab", MOCK_TEMPLATE.createOptions(), MOCK_TEMPLATE.createContext()); add(createExpandByPanel(), BorderLayout.NORTH); - add(createTable(), BorderLayout.CENTER); - add(myDetailsPanel, BorderLayout.SOUTH); + + Splitter splitter = new Splitter(true, 0.9f); + splitter.setFirstComponent(createTable()); + splitter.setSecondComponent(myDetailsPanel); + add(splitter, BorderLayout.CENTER); } public void dispose() { @@ -190,7 +198,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Nullable public JComponent getPreferredFocusedComponent() { - if (getTemplate(getSelectedIndex()) != null) { + if (getTemplate(getSingleSelectedIndex()) != null) { return myCurrentTemplateEditor.getKeyField(); } return null; @@ -290,7 +298,7 @@ public class TemplateListPanel extends JPanel implements Disposable { myCurrentTemplateEditor = new LiveTemplateSettingsEditor(template, shortcut, options, context, new Runnable() { @Override public void run() { - DefaultMutableTreeNode node = getNode(getSelectedIndex()); + DefaultMutableTreeNode node = getNode(getSingleSelectedIndex()); if (node != null) { ((DefaultTreeModel)myTree.getModel()).nodeChanged(node); TemplateSettings.getInstance().setLastSelectedTemplate(template.getGroupName(), template.getKey()); @@ -315,7 +323,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void exportCurrentGroup() { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); if (selected < 0) return; ExportSchemeAction.doExport(getGroup(selected), getSchemesManager()); @@ -332,7 +340,6 @@ public class TemplateListPanel extends JPanel implements Disposable { gbConstraints.weighty = 0; gbConstraints.weightx = 0; gbConstraints.gridy = 0; -// panel.add(createLabel("By default expand with "), gbConstraints); panel.add(new JLabel(CodeInsightBundle.message("templates.dialog.shortcut.chooser.label")), gbConstraints); gbConstraints.gridx = 1; @@ -350,20 +357,6 @@ public class TemplateListPanel extends JPanel implements Disposable { return panel; } - @Nullable - private TemplateKey getTemplateKey(int row) { - JTree tree = myTree; - TreePath path = tree.getPathForRow(row); - if (path != null) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); - if (node.getUserObject() instanceof TemplateImpl) { - return new TemplateKey((TemplateImpl)node.getUserObject()); - } - } - - return null; - } - @Nullable private TemplateImpl getTemplate(int row) { JTree tree = myTree; @@ -392,19 +385,31 @@ public class TemplateListPanel extends JPanel implements Disposable { return null; } - private void moveTemplate(TemplateImpl template, String newGroupName, DefaultMutableTreeNode oldTemplateNode) { - TemplateGroup oldGroup = getTemplateGroup(template.getGroupName()); - if (oldGroup != null) { - oldGroup.removeElement(template); + private void moveTemplates(Map map, String newGroupName) { + List toSelect = new ArrayList(); + for (TemplateImpl template : map.keySet()) { + DefaultMutableTreeNode oldTemplateNode = map.get(template); + + TemplateGroup oldGroup = getTemplateGroup(template.getGroupName()); + if (oldGroup != null) { + oldGroup.removeElement(template); + } + + template.setGroupName(newGroupName); + + DefaultMutableTreeNode parent = (DefaultMutableTreeNode)oldTemplateNode.getParent(); + removeNodeFromParent(oldTemplateNode); + if (parent.getChildCount() == 0) removeNodeFromParent(parent); + + toSelect.add(new TreePath(registerTemplate(template).getPath())); } - template.setGroupName(newGroupName); - - DefaultMutableTreeNode parent = (DefaultMutableTreeNode)oldTemplateNode.getParent(); - removeNodeFromParent(oldTemplateNode); - if (parent.getChildCount() == 0) removeNodeFromParent(parent); - - registerTemplate(template); + myTree.getSelectionModel().clearSelection(); + for (TreePath path : toSelect) { + myTree.expandPath(path.getParentPath()); + myTree.addSelectionPath(path); + myTree.scrollRowToVisible(myTree.getRowForPath(path)); + } } @Nullable @@ -430,7 +435,7 @@ public class TemplateListPanel extends JPanel implements Disposable { private void addRow() { String defaultGroup = TemplateSettings.USER_GROUP_NAME; - final DefaultMutableTreeNode node = getNode(getSelectedIndex()); + final DefaultMutableTreeNode node = getNode(getSingleSelectedIndex()); if (node != null) { if (node.getUserObject() instanceof TemplateImpl) { defaultGroup = ((TemplateImpl) node.getUserObject()).getGroupName(); @@ -456,7 +461,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void copyRow() { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); if (selected < 0) return; TemplateImpl orTemplate = getTemplate(selected); @@ -470,38 +475,45 @@ public class TemplateListPanel extends JPanel implements Disposable { updateTemplateDetails(true); } - private int getSelectedIndex() { - TreePath selectionPath = myTree.getSelectionPath(); - if (selectionPath == null) { - return -1; - } - else { - return myTree.getRowForPath(selectionPath); - } - + private int getSingleSelectedIndex() { + int[] rows = myTree.getSelectionRows(); + return rows != null && rows.length == 1 ? rows[0] : -1; } - private void removeRow() { - int selected = getSelectedIndex(); - TemplateKey templateKey = getTemplateKey(selected); - if (templateKey != null) { - removeTemplateAt(selected); - } - else { - TemplateGroup group = getGroup(selected); - if (group != null) { - int result = Messages.showOkCancelDialog(this, CodeInsightBundle.message("template.delete.group.confirmation.text"), - CodeInsightBundle.message("template.delete.confirmation.title"), - Messages.getQuestionIcon()); - if (result != DialogWrapper.OK_EXIT_CODE) return; + private void removeRows() { + TreeNode toSelect = null; - myTemplateGroups.remove(group); + TreePath[] paths = myTree.getSelectionPaths(); + if (paths == null) return; + + for (TreePath path : paths) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); + Object o = node.getUserObject(); + if (o instanceof TemplateGroup) { + //noinspection SuspiciousMethodCalls + myTemplateGroups.remove(o); + removeNodeFromParent(node); + } else if (o instanceof TemplateImpl) { + TemplateImpl template = (TemplateImpl)o; + TemplateGroup templateGroup = getTemplateGroup(template.getGroupName()); + if (templateGroup != null) { + templateGroup.removeElement(template); + DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); - removeNodeFromParent((DefaultMutableTreeNode)myTree.getPathForRow(selected).getLastPathComponent()); + if (templateGroup.getElements().isEmpty()) { + myTemplateGroups.remove(templateGroup); + removeNodeFromParent(parent); + } else { + toSelect = parent.getChildAfter(node); + removeNodeFromParent(node); + } + } } - } + if (toSelect instanceof DefaultMutableTreeNode) { + setSelectedNode((DefaultMutableTreeNode)toSelect); + } } private JPanel createTable() { @@ -560,14 +572,10 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.setRootVisible(false); myTree.setShowsRootHandles(true); - DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel(); - myTree.setSelectionModel(selModel); - selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener(){ public void valueChanged(final TreeSelectionEvent e) { TemplateSettings templateSettings = TemplateSettings.getInstance(); - TemplateImpl template = getTemplate(getSelectedIndex()); + TemplateImpl template = getTemplate(getSingleSelectedIndex()); if (template != null) { templateSettings.setLastSelectedTemplate(template.getGroupName(), template.getKey()); } else { @@ -610,20 +618,18 @@ public class TemplateListPanel extends JPanel implements Disposable { Point point = dnDActionInfo.getPoint(); if (myTree.getPathForLocation(point.x, point.y) == null) return null; - int selectedIndex = getSelectedIndex(); - TemplateImpl template = getTemplate(selectedIndex); - return template != null ? new DnDDragStartBean(Pair.create(template, getNode(selectedIndex))) : null; + Map templates = getSelectedTemplates(); + + return !templates.isEmpty() ? new DnDDragStartBean(templates) : null; } }). setDisposableParent(this) .setTargetChecker(new DnDTargetChecker() { @Override public boolean update(DnDEvent event) { - @SuppressWarnings("unchecked") Pair pair = (Pair)event.getAttachedObject(); - TemplateImpl template = pair.first; - String oldGroupName = template.getGroupName(); + @SuppressWarnings("unchecked") Set oldGroupNames = getAllGroups((Map)event.getAttachedObject()); TemplateGroup group = getDropGroup(event); - boolean differentGroup = group != null && !oldGroupName.equals(group.getName()); + boolean differentGroup = group != null && !oldGroupNames.contains(group.getName()); boolean possible = differentGroup && !getSchemesManager().isShared(group); event.setDropPossible(possible, differentGroup && !possible ? "Cannot modify a shared group" : ""); return true; @@ -632,8 +638,9 @@ public class TemplateListPanel extends JPanel implements Disposable { .setDropHandler(new DnDDropHandler() { @Override public void drop(DnDEvent event) { - @SuppressWarnings("unchecked") Pair pair = (Pair)event.getAttachedObject(); - moveTemplate(pair.first, ObjectUtils.assertNotNull(getDropGroup(event)).getName(), pair.second); + //noinspection unchecked + moveTemplates((Map)event.getAttachedObject(), + ObjectUtils.assertNotNull(getDropGroup(event)).getName()); } }) .setImageProvider(new NullableFunction() { @@ -665,7 +672,7 @@ public class TemplateListPanel extends JPanel implements Disposable { .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { - removeRow(); + removeRows(); } }) .disableDownAction() @@ -678,7 +685,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void updateButton(AnActionEvent e) { - e.getPresentation().setEnabled(getTemplate(getSelectedIndex()) != null); + e.getPresentation().setEnabled(getTemplate(getSingleSelectedIndex()) != null); } }); if (getSchemesManager().isExportAvailable()) { @@ -690,7 +697,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void updateButton(AnActionEvent e) { - TemplateGroup group = getGroup(getSelectedIndex()); + TemplateGroup group = getGroup(getSingleSelectedIndex()); e.getPresentation().setEnabled(group != null && !getSchemesManager().isShared(group)); } }); @@ -738,7 +745,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void update(AnActionEvent e) { - final int selected = getSelectedIndex(); + final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); boolean enabled = templateGroup != null; e.getPresentation().setEnabled(enabled); @@ -756,24 +763,24 @@ public class TemplateListPanel extends JPanel implements Disposable { final DefaultActionGroup move = new DefaultActionGroup("Move", true) { @Override public void update(AnActionEvent e) { - final int selected = getSelectedIndex(); - final TemplateImpl template = getTemplate(selected); - boolean enabled = template != null; + final Map templates = getSelectedTemplates(); + boolean enabled = !templates.isEmpty(); e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(enabled); if (enabled) { - final String oldGroupName = template.getGroupName(); + Set oldGroups = getAllGroups(templates); + removeAll(); SchemesManager schemesManager = TemplateSettings.getInstance().getSchemesManager(); for (TemplateGroup group : getTemplateGroups()) { final String newGroupName = group.getName(); - if (!Comparing.equal(newGroupName, oldGroupName) && !schemesManager.isShared(group)) { + if (!oldGroups.contains(newGroupName) && !schemesManager.isShared(group)) { add(new DumbAwareAction(newGroupName) { @Override public void actionPerformed(AnActionEvent e) { - moveTemplate(template, newGroupName, getNode(selected)); + moveTemplates(templates, newGroupName); } }); } @@ -782,9 +789,9 @@ public class TemplateListPanel extends JPanel implements Disposable { add(new DumbAwareAction("New group...") { @Override public void actionPerformed(AnActionEvent e) { - String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Move to a new group", null, "", new TemplateGroupInputValidator(null)); + String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Move to a New Group", null, "", new TemplateGroupInputValidator(null)); if (newName != null) { - moveTemplate(template, newName, getNode(selected)); + moveTemplates(templates, newName); } } }); @@ -803,8 +810,33 @@ public class TemplateListPanel extends JPanel implements Disposable { }); } + private static Set getAllGroups(Map templates) { + Set oldGroups = new HashSet(); + for (TemplateImpl template : templates.keySet()) { + oldGroups.add(template.getGroupName()); + } + return oldGroups; + } + + private Map getSelectedTemplates() { + TreePath[] paths = myTree.getSelectionPaths(); + if (paths == null) { + return Collections.emptyMap(); + } + Map templates = new LinkedHashMap(); + for (TreePath path : paths) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); + Object o = node.getUserObject(); + if (!(o instanceof TemplateImpl)) { + return Collections.emptyMap(); + } + templates.put((TemplateImpl)o, node); + } + return templates; + } + private void renameGroup() { - final int selected = getSelectedIndex(); + final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); if (templateGroup == null) return; @@ -819,7 +851,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void updateTemplateDetails(boolean focusKey) { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); CardLayout layout = (CardLayout)myDetailsPanel.getLayout(); if (selected < 0 || getTemplate(selected) == null) { layout.show(myDetailsPanel, NO_SELECTION); @@ -840,7 +872,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } } - private void registerTemplate(TemplateImpl template) { + private CheckedTreeNode registerTemplate(TemplateImpl template) { TemplateGroup newGroup = getTemplateGroup(template.getGroupName()); if (newGroup == null) { newGroup = new TemplateGroup(template.getGroupName()); @@ -862,6 +894,7 @@ public class TemplateListPanel extends JPanel implements Disposable { setSelectedNode(node); } } + return node; } private void insertNewGroup(final TemplateGroup newGroup) { @@ -896,34 +929,6 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.scrollRowToVisible(row); } - private void removeTemplateAt(int row) { - JTree tree = myTree; - TreePath path = tree.getPathForRow(row); - DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); - LOG.assertTrue(node.getUserObject() instanceof TemplateImpl); - - TemplateImpl template = (TemplateImpl)node.getUserObject(); - TemplateGroup templateGroup = getTemplateGroup(template.getGroupName()); - if (templateGroup != null) { - templateGroup.removeElement(template); - } - - DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); - TreePath treePathToSelect = (parent.getChildAfter(node) != null || parent.getChildCount() == 1 ? - tree.getPathForRow(row + 1) : - tree.getPathForRow(row - 1)); - DefaultMutableTreeNode toSelect = treePathToSelect != null ? (DefaultMutableTreeNode)treePathToSelect.getLastPathComponent() : null; - - removeNodeFromParent(node); - if (parent.getChildCount() == 0) { - myTemplateGroups.remove((TemplateGroup)parent.getUserObject()); - removeNodeFromParent(parent); - } - if (toSelect != null) { - setSelectedNode(toSelect); - } - } - private void removeNodeFromParent(DefaultMutableTreeNode node) { TreeNode parent = node.getParent(); int idx = parent.getIndex(node); @@ -985,33 +990,6 @@ public class TemplateListPanel extends JPanel implements Disposable { } } - private static class TemplateKey { - private final String myKey; - private final String myGroupName; - - public TemplateKey(TemplateImpl template) { - String key = template.getKey(); - if (key == null) { - key = ""; - } - myKey = key; - String groupName = template.getGroupName(); - if (groupName == null) { - groupName = ""; - } - myGroupName =groupName; - } - - public boolean equals(Object obj) { - if (!(obj instanceof TemplateKey)) { - return false; - } - TemplateKey templateKey = (TemplateKey)obj; - return myGroupName.equals(templateKey.myGroupName) && myKey.equals(templateKey.myKey); - } - - } - private class TemplateGroupInputValidator implements InputValidator { private final String myOldName; diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index b773ec6cfcba..2774d3f5ae1d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -37,7 +37,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { private final Project myProject; @@ -51,11 +54,15 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { private Pattern myCompiledPattern; private final PatternMatcher myMatcher = new Perl5Matcher(); + + private Map myActionsMap = new HashMap(); public GotoActionModel(Project project, final Component component) { myProject = project; myContextComponent = component; + final ActionGroup mainMenu = (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU); + collectActions(myActionsMap, mainMenu, mainMenu.getTemplatePresentation().getText()); } public String getPromptText() { @@ -113,7 +120,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { final DataContext dataContext = DataManager.getInstance().getDataContext(myContextComponent); - final AnActionEvent event = updateActionBeforShow(anAction, dataContext); + final AnActionEvent event = updateActionBeforeShow(anAction, dataContext); final Presentation presentation = event.getPresentation(); final Color fg = defaultActionForeground(isSelected, presentation); @@ -157,7 +164,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return actionLabel; } - protected AnActionEvent updateActionBeforShow(AnAction anAction, DataContext dataContext) { + protected static AnActionEvent updateActionBeforeShow(AnAction anAction, DataContext dataContext) { final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), ActionManager.getInstance(), 0); @@ -166,7 +173,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return event; } - protected Color defaultActionForeground(boolean isSelected, Presentation presentation) { + protected static Color defaultActionForeground(boolean isSelected, Presentation presentation) { return isSelected ? UIUtil.getListSelectionForeground() : presentation.isEnabled() && presentation.isVisible() ? UIUtil.getListForeground() @@ -175,7 +182,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { public String[] getNames(boolean checkBoxState) { final ArrayList result = new ArrayList(); - collectActionIds(result, (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU)); + for (AnAction action : myActionsMap.keySet()) { + if (action instanceof ActionGroup) continue; + result.add(getActionId(action)); + } if (checkBoxState) { final Set ids = ((ActionManagerImpl)myActionManager).getActionIds(); for (String id : ids) { @@ -188,22 +198,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return ArrayUtil.toStringArray(result); } - private void collectActionIds(Collection result, ActionGroup group){ - final AnAction[] actions = group.getChildren(null); - for (AnAction action : actions) { - if (action instanceof ActionGroup) { - collectActionIds(result, (ActionGroup)action); - } - else if (action != null) { - result.add(getActionId(action)); - } - } - } - public Object[] getElementsByName(final String id, final boolean checkBoxState, final String pattern) { final HashMap map = new HashMap(); - final ActionGroup mainMenu = (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU); - collectActions(id, map, mainMenu, mainMenu.getTemplatePresentation().getText()); + final AnAction act = myActionManager.getAction(id); + map.put(act, myActionsMap.get(act)); if (checkBoxState) { final Set ids = ((ActionManagerImpl)myActionManager).getActionIds(); for (AnAction action : map.keySet()) { //do not add already included actions @@ -219,15 +217,15 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return map.entrySet().toArray(new Map.Entry[map.size()]); } - private void collectActions(String id, Map result, ActionGroup group, final String containingGroupName){ + private static void collectActions(Map result, ActionGroup group, final String containingGroupName){ final AnAction[] actions = group.getChildren(null); for (AnAction action : actions) { if (action != null) { if (action instanceof ActionGroup) { final ActionGroup actionGroup = (ActionGroup)action; final String groupName = actionGroup.getTemplatePresentation().getText(); - collectActions(id, result, actionGroup, groupName != null ? groupName : containingGroupName); - } else if (getActionId(action) == id) { + collectActions(result, actionGroup, groupName != null ? groupName : containingGroupName); + } else { final String groupName = group.getTemplatePresentation().getText(); result.put(action, groupName != null && groupName.length() > 0 ? groupName : containingGroupName); } @@ -265,6 +263,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { (description != null && myMatcher.matches(description, compiledPattern))) { return true; } + final String groupName = myActionsMap.get(anAction); + if (groupName != null && text != null && myMatcher.matches(groupName + " " + text, compiledPattern)) { + return true; + } } return false; } @@ -292,7 +294,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { pattern = pattern.substring(0, 80); } - final @NonNls StringBuffer buffer = new StringBuffer(".*"); + final @NonNls StringBuilder buffer = new StringBuilder(".*"); pattern = pattern.toLowerCase(); for (int i = 0; i < pattern.length(); i++) { final char c = pattern.charAt(i); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index 2514e0e182ed..25f3fffbed51 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.LocalQuickFixProvider; import com.intellij.lang.LangBundle; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Iconable; @@ -61,6 +62,8 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc QuickFixProvider, LocalQuickFixProvider, EmptyResolveMessageProvider, BindablePsiReference { + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference"); + public static final FileReference[] EMPTY = new FileReference[0]; private static final TObjectHashingStrategy RESOLVE_RESULT_HASHING_STRATEGY = new TObjectHashingStrategy() { @Override @@ -123,7 +126,11 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc protected Collection getContexts() { final FileReference contextRef = getContextReference(); if (contextRef == null) { - return myFileReferenceSet.getDefaultContexts(); + Collection defaultContexts = myFileReferenceSet.getDefaultContexts(); + for (PsiFileSystemItem context : defaultContexts) { + LOG.assertTrue(context != null, myFileReferenceSet.getClass() + " provided a null context"); + } + return defaultContexts; } ResolveResult[] resolveResults = contextRef.multiResolve(false); ArrayList result = new ArrayList(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java index c57894747d03..c2a2981a89aa 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java @@ -80,6 +80,11 @@ public class InplaceVariableIntroducer extends VariableInp initOccurrencesMarkers(); } + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException { return null; 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 9da647f7a4f4..07ecad7713a7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -115,7 +115,12 @@ public class RenameDialog extends RefactoringDialog { private void createNewNameComponent() { String[] suggestedNames = getSuggestedNames(); - myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor); + myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) { + @Override + protected boolean shouldSelectAll() { + return false; + } + }; if (myPsiElement instanceof PsiFile && myEditor == null) { myNameSuggestionsField.selectNameWithoutExtension(); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 15c1267fd004..fc32f5e340b4 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -404,6 +404,8 @@ public class VariableInplaceRenamer { myEditor.getCaretModel().moveToOffset(rangeMarker.isValid() ? rangeMarker.getStartOffset() : offset); if (selectedRange != null){ myEditor.getSelectionModel().setSelection(selectedRange.getStartOffset(), selectedRange.getEndOffset()); + } else if (!shouldSelectAll()){ + myEditor.getSelectionModel().removeSelection(); } } }; @@ -444,6 +446,10 @@ public class VariableInplaceRenamer { return true; } + protected boolean shouldSelectAll() { + return false; + } + protected void navigateToAlreadyStarted(Document oldDocument, int exitCode) { final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(oldDocument); if (file != null) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java index ccdf4202f269..fda256aca006 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java +++ b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java @@ -36,7 +36,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.EventListenerList; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.EventListener; import java.util.List; @@ -104,7 +105,7 @@ public class NameSuggestionsField extends JPanel { if (selectionModel.hasSelection() && selected != null && !selected.isEmpty()) { myEditor.getSelectionModel().setSelection(selected.getStartOffset(), selected.getEndOffset()); } - else { + else if (shouldSelectAll()) { myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()); } break; @@ -113,6 +114,10 @@ public class NameSuggestionsField extends JPanel { }); } + protected boolean shouldSelectAll() { + return true; + } + public void selectNameWithoutExtension() { SwingUtilities.invokeLater(new Runnable() { public void run() { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index f683f2eab0f2..a6861357baf9 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -308,7 +308,7 @@ public class Messages { doNotAskOption); } - return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon); + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } public static int showOkCancelDialog(Project project, String message, String title, String okText, String cancelText, Icon icon) { diff --git a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java index 1e75289c3297..0e5046e5ab64 100644 --- a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java +++ b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java @@ -25,15 +25,12 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.mac.foundation.Foundation; import com.intellij.ui.mac.foundation.ID; -import com.intellij.ui.mac.foundation.MacUtil; -import com.sun.jna.Callback; import com.sun.jna.IntegerType; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import sun.awt.datatransfer.DataTransferer; -import javax.swing.*; import java.awt.*; import java.awt.datatransfer.*; import java.io.IOException; @@ -182,35 +179,8 @@ public class ClipboardSynchronizer implements ApplicationComponent { } private static class MacClipboardHandler extends ClipboardHandler { - - private static final String CLIPBOARD_CONTENTS = "CLIPBOARD_CONTENTS"; - private static final String MAC_CLIPBOARD_SYNC_ACTIVE = "Mac.Clipboard.Sync.Active"; private Pair myFullTransferable; - private static Callback myClipboardQueryCallback = new Callback() { - public void callback(ID self, String selector, ID params) { - JRootPane pane = getRootPane(); - if (pane != null) { - Transferable transferable = getClipboardContentNatively(); - if (transferable != null) { - pane.putClientProperty(CLIPBOARD_CONTENTS, transferable); - } - - pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, null); - } - } - }; - - static { - if (SystemInfo.isMac) { - final ID delegateClass = Foundation.allocateObjcClassPair(Foundation.getClass("NSObject"), "ClipboardSynchronizer_"); - if (!Foundation.addMethod(delegateClass, Foundation.createSelector("run:"), myClipboardQueryCallback, "v*")) { - throw new RuntimeException("Unable to add method to objective-c delegate class!"); - } - Foundation.registerObjcClassPair(delegateClass); - } - } - @Nullable private Transferable doGetContents() throws IllegalStateException { if (Registry.is("ide.mac.useNativeClipboard")) { @@ -277,59 +247,21 @@ public class ClipboardSynchronizer implements ApplicationComponent { } } - @Nullable - private static JRootPane getRootPane() { - Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); - if (window == null) return null; - return SwingUtilities.getRootPane(window); - } - @Nullable public static Transferable getContentsSafe() { final Ref result = new Ref(); - final JRootPane pane = getRootPane(); - if (pane != null) { - try { - Runnable run = new Runnable() { - @Override - public void run() { - ID synchronizer_ = Foundation.getClass("ClipboardSynchronizer_"); - final ID synchronizer = Foundation.invoke(Foundation.invoke(synchronizer_, "alloc"), "init"); - Foundation - .invoke(synchronizer, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("run:"), null, - false); - - pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, Boolean.TRUE); - MacUtil.startModal(pane, MAC_CLIPBOARD_SYNC_ACTIVE); - - Foundation.cfRelease(synchronizer); - - Object contents = pane.getClientProperty(CLIPBOARD_CONTENTS); - pane.putClientProperty(CLIPBOARD_CONTENTS, null); - if (contents != null) { - result.set((Transferable)contents); - } - } - }; - - if (SwingUtilities.isEventDispatchThread()) { - run.run(); - } else { - SwingUtilities.invokeAndWait(run); - } - - Transferable transferable = result.get(); - if (transferable != null) return transferable; - } - catch (InterruptedException e) { - // do nothing - } - catch (InvocationTargetException e) { - // do nothing + + Foundation.executeOnMainThread(new Runnable() { + @Override + public void run() { + Transferable transferable = getClipboardContentNatively(); + if (transferable != null) { + result.set(transferable); } } - - return null; + }, true, true); + + return result.get(); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java index 2fc467d8b923..54e5abbb9aab 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.actions; +import com.intellij.CommonBundle; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.util.ExecUtil; @@ -28,6 +29,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; @@ -234,10 +236,46 @@ public class ShowFilePathAction extends AnAction { return PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); } - public static void showDialog(Project project, String message, String title, File file) { + public static Boolean showDialog(Project project, String message, String title, File file) { + final Boolean[] ref = new Boolean[1]; + final DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { + @Override + public boolean isToBeShown() { + return true; + } + + @Override + public void setToBeShown(boolean value, int exitCode) { + if (!value) { + if (exitCode == 0) { + // yes + ref[0] = true; + } + else { + ref[0] = false; + } + } + } + + @Override + public boolean canBeHidden() { + return true; + } + + @Override + public boolean shouldSaveOptionsOnCancel() { + return true; + } + + @Override + public String getDoNotShowMessage() { + return CommonBundle.message("dialog.options.do.not.ask"); + } + }; if (Messages.showOkCancelDialog(project, message, title, RevealFileAction.getActionName(), - IdeBundle.message("action.close"), Messages.getInformationIcon()) == 0) { + IdeBundle.message("action.close"), Messages.getInformationIcon(), option) == 0) { open(file, file); } + return ref[0]; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index d974d2a90ec7..e7906619043a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -190,7 +190,10 @@ public class FSRecords implements Forceable { myNames = new PersistentStringEnumerator(namesFile); myAttributes = new Storage(attributesFile.getCanonicalPath()); myContents = new RefCountingStorage(contentsFile.getCanonicalPath()); - myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, new PagedFileStorage.StorageLock(false)); + boolean aligned = PagedFileStorage.BUFFER_SIZE % RECORD_SIZE == 0; + assert aligned; // for performance + myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, new PagedFileStorage.StorageLock(false), + PagedFileStorage.BUFFER_SIZE, aligned); if (myRecords.length() == 0) { cleanRecord(0); // Clean header diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index a2e2275e992a..6a54304b2fc4 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -514,32 +514,33 @@ action.CloneElement.text=Clo_ne... action.CloneElement.description=Create a copy of the selected class, file or directory in the same package/directory action.SafeDelete.text=Safe _Delete... action.SafeDelete.description=Delete the selected class, method or field, checking for usages -action.ExtractMethod.text=E_xtract Method... +action.ExtractMethod.text=_Method... action.ExtractMethod.description=Turn the selected code fragment into a method -action.RemoveMiddleman.text=Remove _Middleman +action.RemoveMiddleman.text=Remove _Middleman... action.RemoveMiddleman.description=Get the client to call the delegate directly action.MethodDuplicates.text=Replace Met_hod Code Duplicates... action.MethodDuplicates.description=Finds code in current file that can be transformed into a call of selected method action.InvertBoolean.text=Invert _Boolean... action.InvertBoolean.description=Makes the method return or variable contain the opposite value and corrects the references -action.IntroduceParameterObject.text=Introduce Parameter Ob_ject... +action.IntroduceParameterObject.text=Parameter Ob_ject... action.IntroduceParameterObject.description=Replaces method parameters list with object -action.ExtractClass.text=E_xtract Class... +action.ExtractClass.text=Cla_ss... action.ExtractClass.description=Extract Delegate -action.IntroduceVariable.text=Introduce _Variable... +action.IntroduceVariable.text=_Variable... action.IntroduceVariable.description=Put a result of the selected expression into a variable -action.IntroduceField.text=Introduce _Field... +action.IntroduceField.text=_Field... action.IntroduceField.description=Put a result of the selected expression into a field -action.IntroduceConstant.text=Introduce _Constant... +action.IntroduceConstant.text=_Constant... action.IntroduceConstant.description=Replace selected expression with a constant (static final field) -action.IntroduceParameter.text=Introduce _Parameter... +action.IntroduceParameter.text=_Parameter... action.IntroduceParameter.description=Turn the selected expression into method parameter -action.ExtractInterface.text=Extract _Interface... +action.ExtractInterface.text=_Interface... action.ExtractInterface.description=Extract interface from the selected class -action.ExtractModule.text=Extract _Module... +action.ExtractModule.text=_Module... action.ExtractModule.description=Extract module from the selected class -action.ExtractSuperclass.text=Extract S_uperclass... +action.ExtractSuperclass.text=S_uperclass... action.ExtractSuperclass.description=Extract superclass from the selected class +group.IntroduceActionsGroup.text=E_xtract action.TurnRefsToSuper.text=Use Interface _Where Possible... action.TurnRefsToSuper.description=Change usages of a class to those of its superclass or interface action.MembersPullUp.text=Pu_ll Members Up... @@ -558,7 +559,7 @@ action.ReplaceTempWithQuery.text=Replace Temp with _Query... action.ReplaceTempWithQuery.description=Turn the selected variable into a method action.ReplaceConstructorWithFactory.text=Replace Constructor with F_actory Method... action.ReplaceConstructorWithFactory.description=Create a static factory method and use it instead of a constructor -action.ReplaceMethodWithMethodObject.text=Extract Method Ob_ject... +action.ReplaceMethodWithMethodObject.text=Method Ob_ject... action.ReplaceMethodWithMethodObject.description=Turn the method into its own object so that all the parameters become fields on that object action.Generify.text=Ge_nerify... action.Generify.description=Convert your code to use generic types @@ -566,7 +567,7 @@ action.Migrate.text=_Migrate... action.Migrate.description=Open migration dialog action.Type\ Migration.text=Type Migration... action.Type\ Migration.description=Migrate one type to another -action.ExtractInclude.text=E_xtract Include File... +action.ExtractInclude.text=_Include File... action.ExtractInclude.description=Turn the selected code fragment into included file group.BuildMenu.text=_Build action.CompileProject.text=_Rebuild Project diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index aa4dedba329e..649bcf59210d 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -281,8 +281,6 @@ templates.dialog.table.column.description=Description templates.dialog.table.column.active=Active templates.dialog.shortcut.chooser.label=By default expand with dialog.copy.live.template.title=Copy Live Template -template.delete.confirmation.title=Confirm Delete -template.delete.group.confirmation.text=Do you want to delete this template group? dialog.edit.template.shortcut.default=Default ({0}) dialog.edit.template.template.text.title=&Template text: dialog.edit.template.button.edit.variables=&Edit variables diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index fd6bb8351f10..8e919fa85bad 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -153,7 +153,7 @@ dir.diff.default.trg.folder= show.live.templates.in.completion=false documentation.component.editor.font=false -ide.mac.useNativeClipboard=true +ide.mac.useNativeClipboard=false show.all.classes.on.first.completion=false limited.relevance.sorting.in.completion=false diff --git a/platform/platform-resources/src/codeStyle/preview/preview.xml.template b/platform/platform-resources/src/codeStyle/preview/preview.xml.template index 85b3d0efc4a5..6edd0817d215 100644 --- a/platform/platform-resources/src/codeStyle/preview/preview.xml.template +++ b/platform/platform-resources/src/codeStyle/preview/preview.xml.template @@ -7,9 +7,9 @@ - ReSharper makes C# development a real pleasure. It decreases the time you spend on routine, repetitive + Our product makes development a real pleasure. It decreases the time you spend on routine, repetitive handwork, giving you more time to focus on the task at hand. Its robust set of features for automatic error-checking - and code correction cuts development time and increases your efficiency. You'll find that ReSharper quickly + and code correction cuts development time and increases your efficiency. You'll find that our product quickly pays back it's cost in increased developer productivity and improved code quality. diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 3c78baf31150..abcbcebc27a5 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -261,21 +261,25 @@ - - - - + + + + + + + + + + + + + + + - - - - - - - diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index bde8685224b6..eec7f36d2478 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -313,20 +313,27 @@ public class TestAll implements Test { } return adapter; } - return new TestSuite(testCaseClass){ + + final int[] testsCount = {0}; + TestSuite suite = new TestSuite(testCaseClass) { @Override public void addTest(Test test) { - if (!(test instanceof TestCase)) { + if (!(test instanceof TestCase)) { + testsCount[0]++; super.addTest(test); - } else { - if (isPerformanceTestsRun() ^ (hasPerformance(((TestCase)test).getName()) || hasPerformance(testCaseClass.getSimpleName()))) return; - + } + else { + String name = ((TestCase)test).getName(); + if ("warning".equals(name)) return; // Mute TestSuite's "no tests found" warning + if (isPerformanceTestsRun() ^ (hasPerformance(name) || hasPerformance(testCaseClass.getSimpleName()))) + return; + Method method = findTestMethod((TestCase)test); if (method == null || !TestCaseLoader.isBombed(method)) { + testsCount[0]++; super.addTest(test); } } - } @Nullable @@ -334,6 +341,8 @@ public class TestAll implements Test { return safeFindMethod(testCase.getClass(), testCase.getName()); } }; + + return testsCount[0] > 0 ? suite : null; } return null; @@ -353,6 +362,14 @@ public class TestAll implements Test { } } + private static Set normalizePaths(String[] array) { + Set answer = new LinkedHashSet(array.length); + for (String path : array) { + answer.add(path.replace('\\', '/')); + } + return answer; + } + public static String[] getClassRoots() { String testRoots = System.getProperty("test.roots"); if (testRoots != null) { @@ -363,8 +380,8 @@ public class TestAll implements Test { if (roots != null) { if (Comparing.equal(System.getProperty(TestCaseLoader.SKIP_COMMUNITY_TESTS), "true")) { System.out.println("Skipping community tests"); - Set set = new LinkedHashSet(Arrays.asList(roots)); - set.removeAll(Arrays.asList(ExternalClasspathClassLoader.getExcludeRoots())); + Set set = normalizePaths(roots); + set.removeAll(normalizePaths(ExternalClasspathClassLoader.getExcludeRoots())); roots = set.toArray(new String[set.size()]); } diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java index 4a1a16e79d7f..6a6c14671010 100644 --- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java +++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java @@ -44,7 +44,7 @@ public class PagedFileStorage implements Forceable { private final static int LOWER_LIMIT; private final static int UPPER_LIMIT; - private final static int BUFFER_SIZE; + public final static int BUFFER_SIZE; private static final int UNKNOWN_PAGE = -1; static { diff --git a/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java b/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java index 97a29e9cf152..ec0c822d2373 100644 --- a/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java +++ b/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java @@ -49,7 +49,7 @@ public class JarMemoryLoader { ZipInputStream zipStream = new ZipInputStream(inputStream); try { ZipEntry sizeEntry = zipStream.getNextEntry(); - if (!sizeEntry.getName().equals(SIZE_ENTRY)) return null; + if (sizeEntry == null || !sizeEntry.getName().equals(SIZE_ENTRY)) return null; byte[] bytes = FileUtil.loadBytes(zipStream, 2); int size = ZipShort.getValue(bytes); diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index 29bab41567f2..0030810d4fb5 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -88,6 +88,7 @@ public final class VcsConfiguration implements PersistentStateComponent public boolean INCLUDE_TEXT_INTO_PATCH = false; public boolean INCLUDE_TEXT_INTO_SHELF = false; public boolean CREATE_PATCH_EXPAND_DETAILS_DEFAULT = true; + public Boolean SHOW_PATCH_IN_EXPLORER = null; public enum StandardOption { ADD(VcsBundle.message("vcs.command.name.add")), diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java index 3b26f78c933a..c557a030ab57 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java @@ -16,6 +16,7 @@ package com.intellij.openapi.vcs.changes.patch; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diff.impl.patch.PatchReader; import com.intellij.openapi.diff.impl.patch.PatchSyntaxException; @@ -32,6 +33,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; @@ -47,8 +49,7 @@ import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable; import com.intellij.openapi.vcs.changes.actions.ShowDiffAction; import com.intellij.openapi.vcs.changes.actions.ShowDiffUIContext; import com.intellij.openapi.vcs.changes.ui.*; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.*; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; @@ -94,6 +95,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { private JLabel myPatchFileLabel; private PatchReader myReader; private CommitContext myCommitContext; + private final VirtualFileAdapter myListener; public ApplyPatchDifferentiatedDialog(final Project project, final ApplyPatchExecutor callback, final List executors, @NotNull final ApplyPatchMode applyPatchMode, @NotNull final VirtualFile patchFile) { @@ -163,6 +165,24 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } myPatchFileLabel.setVisible(applyPatchMode.isCanChangePatchFile()); myPatchFile.setVisible(applyPatchMode.isCanChangePatchFile()); + + myListener = new VirtualFileAdapter() { + @Override + public void contentsChanged(VirtualFileEvent event) { + if (myRecentPathFileChange.get() != null && myRecentPathFileChange.get().getVf() != null && + myRecentPathFileChange.get().getVf().equals(event.getFile())) { + myLoadQueue.queue(myUpdater); + } + } + }; + final VirtualFileManager fileManager = VirtualFileManager.getInstance(); + fileManager.addVirtualFileListener(myListener); + Disposer.register(getDisposable(), new Disposable() { + @Override + public void dispose() { + fileManager.removeVirtualFileListener(myListener); + } + }); } public static FileChooserDescriptor createSelectPatchDescriptor() { @@ -239,7 +259,9 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } final VirtualFile file = filePresentation.getVf(); - final PatchReader patchReader = loadPatches(file); + final PatchReader patchReader = loadPatches(filePresentation); + if (patchReader == null) return; + final List matchedPathes = patchReader == null ? Collections.emptyList() : new AutoMatchIterator(myProject).execute(patchReader.getPatches()); @@ -256,10 +278,13 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } @Nullable - private PatchReader loadPatches(final VirtualFile patchFile) { + private PatchReader loadPatches(final FilePresentation filePresentation) { + final VirtualFile patchFile = filePresentation.getVf(); + patchFile.refresh(false, false); if (! patchFile.isValid()) { return null; } + PatchReader reader; try { reader = PatchVirtualFileReader.create(patchFile); @@ -344,6 +369,12 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { group.add(new StripDown()); group.add(new ResetStrip()); group.add(new ZeroStrip()); + group.add(new AnAction("Refresh", "Refresh", IconLoader.getIcon("/actions/sync.png")) { + @Override + public void actionPerformed(AnActionEvent e) { + myLoadQueue.queue(myUpdater); + } + }); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("APPLY_PATCH", group, true); myCenterPanel.add(toolbar.getComponent(), gb); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index ded368b51aae..09a8d9e8a9e4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -207,7 +207,15 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec } WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { public void run() { - ShowFilePathAction.showDialog(myProject, message, VcsBundle.message("create.patch.commit.action.title"), file); + final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); + if (Boolean.TRUE.equals(configuration.SHOW_PATCH_IN_EXPLORER)) { + ShowFilePathAction.open(file, file); + } else if (Boolean.FALSE.equals(configuration.SHOW_PATCH_IN_EXPLORER)) { + return; + } else { + configuration.SHOW_PATCH_IN_EXPLORER = + ShowFilePathAction.showDialog(myProject, message, VcsBundle.message("create.patch.commit.action.title"), file); + } } }, null, myProject); } catch (ProcessCanceledException e) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form index f771e3418650..207841e3db13 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form @@ -152,7 +152,7 @@ - + @@ -184,9 +184,9 @@ - + - + @@ -210,6 +210,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java index e17529dc7d63..a8007ab2fec8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java @@ -19,6 +19,7 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; @@ -60,6 +61,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { private JPanel myAddConfirmationPanel; private JCheckBox myCbOfferToMoveChanges; private JComboBox myFailedCommitChangelistCombo; + private JComboBox myOnPatchCreation; private ButtonGroup myEmptyChangelistRemovingGroup; public VcsGeneralConfigurationPanel(final Project project) { @@ -91,7 +93,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { } myPromptsPanel.setSize(myPromptsPanel.getPreferredSize()); - + myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") + SystemInfo.nativeFileManagerName + " after creation:"); } public void apply() throws ConfigurationException { @@ -109,11 +111,26 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { getAddConfirmation().setValue(getSelected(myOnFileAddingGroup)); getRemoveConfirmation().setValue(getSelected(myOnFileRemovingGroup)); - + applyPatchOption(settings); getReadOnlyStatusHandler().getState().SHOW_DIALOG = myShowReadOnlyStatusDialog.isSelected(); } + private void applyPatchOption(VcsConfiguration settings) { + settings.SHOW_PATCH_IN_EXPLORER = getShowPatchValue(); + } + + private Boolean getShowPatchValue() { + final int index = myOnPatchCreation.getSelectedIndex(); + if (index == 0) { + return null; + } else if (index == 1) { + return true; + } else { + return false; + } + } + private VcsShowConfirmationOption.Value getFailedCommitConfirm() { switch(myFailedCommitChangelistCombo.getSelectedIndex()) { case 0: return VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY; @@ -180,6 +197,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { if (getSelected(myOnFileAddingGroup) != getAddConfirmation().getValue()) return true; if (getSelected(myOnFileRemovingGroup) != getRemoveConfirmation().getValue()) return true; + if (! Comparing.equal(settings.SHOW_PATCH_IN_EXPLORER, getShowPatchValue())) return true; return false; } @@ -207,6 +225,13 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { selectInGroup(myOnFileAddingGroup, getAddConfirmation()); selectInGroup(myOnFileRemovingGroup, getRemoveConfirmation()); + if (settings.SHOW_PATCH_IN_EXPLORER == null) { + myOnPatchCreation.setSelectedIndex(0); + } else if (Boolean.TRUE.equals(settings.SHOW_PATCH_IN_EXPLORER)) { + myOnPatchCreation.setSelectedIndex(1); + } else { + myOnPatchCreation.setSelectedIndex(2); + } } private static void selectInGroup(final JRadioButton[] group, final VcsShowConfirmationOption confirmation) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 1624d79aae9e..3769f684845e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -382,6 +382,12 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name"); Content content = contentManager.findContent(displayName); if (content == null) { + if (myEditorAdapter != null) { + final Editor editor = myEditorAdapter.getEditor(); + if (! editor.isDisposed()) { + EditorFactory.getInstance().releaseEditor(editor); + } + } final EditorFactory editorFactory = EditorFactory.getInstance(); final Editor editor = editorFactory.createViewer(editorFactory.createDocument(""), myProject); EditorSettings editorSettings = editor.getSettings(); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java index dbf2fbaafd75..0c637845975d 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java @@ -229,16 +229,16 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler { if (logDirOutputOsPath != null) { commands.add("-dump"); - commands.add(new File(logDirOutputOsPath, "dump.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "dump.txt").getAbsolutePath())); commands.add("-printseeds"); - commands.add(new File(logDirOutputOsPath, "seeds.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "seeds.txt").getAbsolutePath())); commands.add("-printusage"); - commands.add(new File(logDirOutputOsPath, "usage.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "usage.txt").getAbsolutePath())); commands.add("-printmapping"); - commands.add(new File(logDirOutputOsPath, "mapping.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "mapping.txt").getAbsolutePath())); } LOG.info(AndroidUtils.command2string(commands)); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java index 236c4cbde162..50783b06c374 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java @@ -157,7 +157,7 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom preprocessedManifestFile.getPath(), item.myResourceDirPaths, item.myAssetsDirPath, - outputPath, null, false, 0); + outputPath, null, !releasePackage, 0); AndroidCompileUtil.addMessages(context, messages, presentableFilesMap); } catch (final IOException e) { diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java index ada0c73fd715..29f37c6b6d39 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java @@ -2,6 +2,7 @@ package org.jetbrains.android.uipreview; import com.android.AndroidConstants; import com.android.ide.common.resources.ResourceResolver; +import com.android.ide.common.resources.configuration.FolderConfiguration; import com.android.ide.common.resources.configuration.LanguageQualifier; import com.android.ide.common.resources.configuration.RegionQualifier; import com.android.ide.common.resources.configuration.ScreenSizeQualifier; @@ -252,12 +253,12 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { optionsGroup.addAction(new CheckboxAction("Hide for non-layout files") { @Override public boolean isSelected(AnActionEvent e) { - return mySettings.getState().isHideForNonLayoutFiles(); + return mySettings.getGlobalState().isHideForNonLayoutFiles(); } @Override public void setSelected(AnActionEvent e, boolean state) { - mySettings.getState().setHideForNonLayoutFiles(state); + mySettings.getGlobalState().setHideForNonLayoutFiles(state); } }).setAsSecondary(true); @@ -391,6 +392,7 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } public void setFile(@Nullable PsiFile file) { + final boolean fileChanged = !Comparing.equal(myFile, file); myFile = file; final AndroidPlatform newPlatform = getPlatform(file); @@ -403,9 +405,16 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { if (!myResetFlag) { reset(); myResetFlag = true; + return; } } } + + if (file != null && fileChanged) { + myResetFlag = false; + reset(); + myResetFlag = true; + } } @Nullable @@ -427,9 +436,14 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } return null; } + + @Nullable + private VirtualFile getVirtualFile() { + return myFile != null ? myFile.getVirtualFile() : null; + } private void saveState() { - final AndroidLayoutPreviewToolWindowSettings.State state = mySettings.getState(); + final AndroidLayoutPreviewToolWindowSettings.GlobalState state = mySettings.getGlobalState(); if (myResetFlag) { final LayoutDevice selectedDevice = getSelectedDevice(); @@ -438,8 +452,18 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } final LayoutDeviceConfiguration deviceConfig = getSelectedDeviceConfiguration(); - if (deviceConfig != null) { - state.setDeviceConfiguration(deviceConfig.getName()); + final VirtualFile vFile = getVirtualFile(); + if (deviceConfig != null && vFile != null) { + final LayoutDeviceConfiguration defaultConfig = getDefaultDeviceConfigForFile(vFile); + final String defaultConfigName = defaultConfig != null ? defaultConfig.getName() : null; + final String deviceConfigName = deviceConfig.getName(); + + if (Comparing.equal(deviceConfigName, defaultConfigName)) { + mySettings.removeDeviceConfiguration(vFile); + } + else { + mySettings.setDeviceConfiguration(vFile, deviceConfigName); + } } final UiMode dockMode = getSelectedDockMode(); @@ -473,7 +497,7 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } private void reset() { - final AndroidLayoutPreviewToolWindowSettings.State state = mySettings.getState(); + final AndroidLayoutPreviewToolWindowSettings.GlobalState state = mySettings.getGlobalState(); final String savedDeviceName = state.getDevice(); if (savedDeviceName != null) { @@ -489,17 +513,28 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } } - final String savedDeviceConfigName = state.getDeviceConfiguration(); - if (savedDeviceConfigName != null) { - LayoutDeviceConfiguration savedDeviceConfig = null; - for (LayoutDeviceConfiguration config : myDeviceConfigurations) { - if (savedDeviceConfigName.equals(config.getName())) { - savedDeviceConfig = config; - break; + final VirtualFile vFile = getVirtualFile(); + if (vFile != null) { + final String savedDeviceConfigName = mySettings.getDeviceConfiguration(vFile); + + if (savedDeviceConfigName != null) { + LayoutDeviceConfiguration savedDeviceConfig = null; + for (LayoutDeviceConfiguration config : myDeviceConfigurations) { + if (savedDeviceConfigName.equals(config.getName())) { + savedDeviceConfig = config; + break; + } + } + if (savedDeviceConfig != null) { + myDeviceConfigurationsCombo.setSelectedItem(savedDeviceConfig); } } - if (savedDeviceConfig != null) { - myDeviceConfigurationsCombo.setSelectedItem(savedDeviceConfig); + else { + final LayoutDeviceConfiguration defaultConfig = getDefaultDeviceConfigForFile(vFile); + + if (defaultConfig != null) { + myDeviceConfigurationsCombo.setSelectedItem(defaultConfig); + } } } @@ -556,8 +591,32 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } } + @Nullable + private LayoutDeviceConfiguration getDefaultDeviceConfigForFile(@NotNull VirtualFile vFile) { + final VirtualFile folder = vFile.getParent(); + + if (folder == null) { + return null; + } + final String[] folderSegments = folder.getName().split(AndroidConstants.RES_QUALIFIER_SEP); + + if (folderSegments.length == 0) { + return null; + } + final FolderConfiguration config = FolderConfiguration.getConfig(folderSegments); + + if (config != null) { + for (LayoutDeviceConfiguration deviceConfig : myDeviceConfigurations) { + if (deviceConfig.getConfiguration().isMatchFor(config)) { + return deviceConfig; + } + } + } + return null; + } + private void resetThemes(Collection themes) { - final String savedThemeName = mySettings.getState().getTheme(); + final String savedThemeName = mySettings.getGlobalState().getTheme(); if (savedThemeName != null) { ThemeData savedTheme = null; for (Object o : themes) { diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java index 6391255a280b..827844b76141 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java @@ -185,7 +185,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); - AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getState().setVisible(visible); + AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getGlobalState().setVisible(visible); if (visible && !myVisible) { render(); @@ -244,7 +244,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { } final AndroidLayoutPreviewToolWindowSettings settings = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject); - final boolean hideForNonLayoutFiles = settings.getState().isHideForNonLayoutFiles(); + final boolean hideForNonLayoutFiles = settings.getGlobalState().isHideForNonLayoutFiles(); if (activeEditor == null) { myToolWindowForm.setFile(null); @@ -266,7 +266,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { } myToolWindow.setAvailable(true, null); - final boolean visible = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getState().isVisible(); + final boolean visible = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getGlobalState().isVisible(); if (visible) { myToolWindow.show(null); } @@ -364,12 +364,12 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { synchronized (RENDERING_LOCK) { final StringBuilder warnBuilder = new StringBuilder(); - if (target != null && theme != null && - RenderUtil.renderLayout(myProject, layoutXmlText, layoutXmlFile, imgPath, - target, facet, config, xdpi, ydpi, theme, warnBuilder)) { + if (target != null && theme != null && + RenderUtil.renderLayout(myProject, layoutXmlText, layoutXmlFile, imgPath, + target, facet, config, xdpi, ydpi, theme, warnBuilder)) { warnMessage = warnBuilder.toString(); - final File input = new File(imgPath); - image = ImageIO.read(input); + final File input = new File(imgPath); + image = ImageIO.read(input); } } } diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java index 96d641a1d1ae..ac408eee2f96 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java @@ -5,8 +5,15 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.util.containers.HashMap; +import com.intellij.util.xmlb.annotations.MapAnnotation; +import com.intellij.util.xmlb.annotations.Tag; import org.jetbrains.annotations.NotNull; +import java.util.Map; + /** * @author Eugene.Kudelevsky */ @@ -16,26 +23,93 @@ import org.jetbrains.annotations.NotNull; @Storage(id = "AndroidLayoutPreviewToolWindow", file = "$WORKSPACE_FILE$") } ) -public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateComponent { - private State myState = new State(); +public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateComponent { + private final Map myFile2DeviceConfig = new HashMap(); + private GlobalState myGlobalState = new GlobalState(); public static AndroidLayoutPreviewToolWindowSettings getInstance(@NotNull Project project) { - return ServiceManager.getService(project, AndroidLayoutPreviewToolWindowSettings.class); + return ServiceManager.getService(project, AndroidLayoutPreviewToolWindowSettings.class); + } + + @NotNull + public GlobalState getGlobalState() { + return myGlobalState; + } + + public String getDeviceConfiguration(@NotNull VirtualFile file) { + synchronized (myFile2DeviceConfig) { + return myFile2DeviceConfig.get(file); + } + } + + public void setDeviceConfiguration(@NotNull VirtualFile file, @NotNull String deviceConfiguration) { + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.put(file, deviceConfiguration); + } + } + + public void removeDeviceConfiguration(@NotNull VirtualFile file) { + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.remove(file); + } + } + + @Override + public MyState getState() { + final Map url2DeviceConfig = new HashMap(); + + synchronized (myFile2DeviceConfig) { + for (Map.Entry entry : myFile2DeviceConfig.entrySet()) { + url2DeviceConfig.put(entry.getKey().getUrl(), entry.getValue()); + } + } + final MyState state = new MyState(); + state.setUrl2DeviceConfig(url2DeviceConfig); + state.setState(myGlobalState); + return state; + } + + @Override + public void loadState(MyState state) { + myGlobalState = state.getState(); + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.clear(); + + for (Map.Entry entry : state.getUrl2DeviceConfig().entrySet()) { + final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(entry.getKey()); + + if (file != null) { + myFile2DeviceConfig.put(file, entry.getValue()); + } + } + } + } + + public static class MyState { + private GlobalState myGlobalState = new GlobalState(); + private Map myUrl2DeviceConfig = new HashMap(); + + public GlobalState getState() { + return myGlobalState; } - @Override - public void loadState(State state) { - myState = state; + @Tag("device-configurations") + @MapAnnotation(surroundWithTag = false) + public Map getUrl2DeviceConfig() { + return myUrl2DeviceConfig; + } + + public void setState(GlobalState state) { + myGlobalState = state; + } + + public void setUrl2DeviceConfig(Map url2DeviceConfig) { + myUrl2DeviceConfig = url2DeviceConfig; + } } - @Override - public State getState() { - return myState; - } - - public static class State { + public static class GlobalState { private String myDevice; - private String myDeviceConfiguration; private String myDockMode; private String myNightMode; private String myTargetHashString; @@ -53,14 +127,6 @@ public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateCo myDevice = device; } - public String getDeviceConfiguration() { - return myDeviceConfiguration; - } - - public void setDeviceConfiguration(String deviceConfiguration) { - myDeviceConfiguration = deviceConfiguration; - } - public String getDockMode() { return myDockMode; } diff --git a/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java b/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java index ec82c9a6bf5d..15c9166b4dc3 100644 --- a/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java +++ b/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java @@ -64,9 +64,6 @@ public final class ReflectedProject { iterator.remove(); } else { - if (pair.first != null && pair.first.getProject() == null) { - iterator.remove(); - } if (pair.second == classLoader) { return pair.first; } @@ -76,35 +73,35 @@ public final class ReflectedProject { finally { ourProjectsLock.unlock(); } - final ReflectedProject project = new ReflectedProject(classLoader); - if (project.getProject() != null) { // do not cache partially-loaded stuff + final ReflectedProject reflectedProj = new ReflectedProject(classLoader); + if (reflectedProj.getProject() != null) { // do not cache partially-loaded stuff ourProjectsLock.lock(); try { ourProjects.add(new SoftReference>( - new Pair(project, classLoader) + new Pair(reflectedProj, classLoader) )); } finally { ourProjectsLock.unlock(); } } - return project; + return reflectedProj; } ReflectedProject(final ClassLoader classLoader) { - Object myProject = null; + Object project = null; try { final Class projectClass = classLoader.loadClass("org.apache.tools.ant.Project"); if (projectClass != null) { - myProject = projectClass.newInstance(); + project = projectClass.newInstance(); Method method = projectClass.getMethod(INIT_METHOD_NAME); - method.invoke(myProject); + method.invoke(project); method = getMethod(projectClass, GET_TASK_DEFINITIONS_METHOD_NAME); - myTaskDefinitions = (Hashtable)method.invoke(myProject); + myTaskDefinitions = (Hashtable)method.invoke(project); method = getMethod(projectClass, GET_DATA_TYPE_DEFINITIONS_METHOD_NAME); - myDataTypeDefinitions = (Hashtable)method.invoke(myProject); + myDataTypeDefinitions = (Hashtable)method.invoke(project); method = getMethod(projectClass, GET_PROPERTIES_METHOD_NAME); - myProperties = (Hashtable)method.invoke(myProject); + myProperties = (Hashtable)method.invoke(project); myTargetClass = classLoader.loadClass("org.apache.tools.ant.Target"); } } @@ -118,7 +115,7 @@ public final class ReflectedProject { } else { LOG.info(e); - myProject = null; + project = null; } } catch (InvocationTargetException e) { @@ -128,14 +125,14 @@ public final class ReflectedProject { } else { LOG.info(e); - myProject = null; + project = null; } } catch (Throwable e) { LOG.info(e); - myProject = null; + project = null; } - this.myProject = myProject; + myProject = project; } private static Method getMethod(final Class introspectionHelperClass, final String name) throws NoSuchMethodException { diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java index 2b419614cdf6..ad65a832013a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java @@ -84,7 +84,7 @@ public class GradleScriptType extends GroovyScriptType { @Override public boolean isConfigurationByLocation(@NotNull GroovyScriptRunConfiguration existing, @NotNull Location location) { - final String params = existing.getProgramParameters(); + final String params = existing.getScriptParameters(); final String s = getTaskTarget(location); return s != null && params != null && (params.startsWith(s + " ") || params.equals(s)); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index 8a2545cef8c6..c3ea2c2b2d9e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -890,13 +890,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } } - - if (regex instanceof GrRegex && ((GrRegex)regex).getInjections().length > 0) { - if (!config.isVersionAtLeast(regex, GroovyConfigUtils.GROOVY1_8)) { - myHolder.createErrorAnnotation(regex, GroovyBundle - .message("slashy.strings.with.injections.are.not.allowed.in.groovy.0", config.getSDKVersion(regex))); - } - } } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java index 5b57d0c2c1f4..aff6a430778a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java @@ -126,7 +126,7 @@ public class GantRunner extends GroovyScriptRunner { params.getProgramParametersList().add("--debug"); } - params.getProgramParametersList().addParametersString(configuration.getProgramParameters()); + params.getProgramParametersList().addParametersString(configuration.getScriptParameters()); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java index d2e812af0e8f..faac54dbab44 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java @@ -15,16 +15,16 @@ */ package org.jetbrains.plugins.groovy.gant; +import com.intellij.compiler.options.CompileStepBeforeRun; import com.intellij.execution.Location; import com.intellij.execution.RunManagerEx; -import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.NonClasspathDirectoryScope; -import com.intellij.compiler.options.CompileStepBeforeRun; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +65,7 @@ public class GantScriptType extends GroovyScriptType { @Override public boolean isConfigurationByLocation(@NotNull GroovyScriptRunConfiguration existing, @NotNull Location place) { - final String params = existing.getProgramParameters(); + final String params = existing.getScriptParameters(); final String s = getTargetName(place); return s != null && params != null && (params.startsWith(s + " ") || params.equals(s)); } @@ -93,7 +93,7 @@ public class GantScriptType extends GroovyScriptType { public void tuneConfiguration(@NotNull GroovyFile file, @NotNull GroovyScriptRunConfiguration configuration, Location location) { String target = getTargetName(location); if (target != null) { - configuration.setProgramParameters(target); + configuration.setScriptParameters(target); configuration.setName(configuration.getName() + "." + target); } final CompileStepBeforeRun.MakeBeforeRunTask runTask = diff --git a/plugins/groovy/testdata/highlighting/SlashyStrings.groovy b/plugins/groovy/testdata/highlighting/SlashyStrings.groovy index 17ca8bb6a589..3ba00ecb60f6 100644 --- a/plugins/groovy/testdata/highlighting/SlashyStrings.groovy +++ b/plugins/groovy/testdata/highlighting/SlashyStrings.groovy @@ -2,7 +2,7 @@ print (/abc/) print (/ab c/) -print (/abc${false}def/) +print (/abc${false}def/) print (/abc${false}d ef/) \ No newline at end of file diff --git a/plugins/java-i18n/src/META-INF/plugin.xml b/plugins/java-i18n/src/META-INF/plugin.xml index 74ba4bab516c..398fb92da335 100644 --- a/plugins/java-i18n/src/META-INF/plugin.xml +++ b/plugins/java-i18n/src/META-INF/plugin.xml @@ -49,7 +49,7 @@ - + diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index 832515ed6d5e..865c37124ff6 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -388,9 +388,9 @@ - + - diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java b/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java index e888ad5d421b..b700a27957b6 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java @@ -25,6 +25,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; @@ -106,6 +107,10 @@ public class RenameTo extends ShowSuggestions implements SpellCheckerQuickFix { DataContext dataContext = SimpleDataContext.getSimpleContext(map, DataManager.getInstance().getDataContext(editor.getComponent())); AnAction action = new RenameElementAction(); + final TextRange range = psiElement.getTextRange(); + if (range != null) { + editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()); + } AnActionEvent event = new AnActionEvent(null, dataContext, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.actionPerformed(event); if (provider != null) { diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form index e532db90db9b..bb2cf0d68e45 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form @@ -1,6 +1,6 @@
- + @@ -28,12 +28,22 @@ - + + + + + + + + + + +
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java index 6797b6023f80..f3865d38868b 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java @@ -10,6 +10,7 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.tasks.TaskManager; @@ -49,6 +50,7 @@ public class TaskRepositoriesConfigurable extends BaseConfigurable implements Co private JPanel myToolbarPanel; private JPanel myRepositoryEditor; private JBLabel myServersLabel; + private Splitter mySplitter; private final List myRepositories = new ArrayList(); private final Project myProject; @@ -150,6 +152,8 @@ public class TaskRepositoriesConfigurable extends BaseConfigurable implements Co String name = myRepoNames.get(repository); assert name != null; ((CardLayout)myRepositoryEditor.getLayout()).show(myRepositoryEditor, name); + mySplitter.doLayout(); + mySplitter.repaint(); } } }); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java index 1d8ea494f704..8d5929f712c8 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java @@ -53,7 +53,6 @@ public class TaskCompletionContributor extends CompletionContributor { } if (consumer != null) { - result.stopHere(); String text = parameters.getOriginalFile().getText(); int i = text.lastIndexOf(' ', parameters.getOffset() - 1) + 1; diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 4688bab71e6e..39556a4d4be5 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -1,4 +1,4 @@ - + @@ -59,12 +59,19 @@ - - + - + + + + + + + + + diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java index db610e505cfc..073e4236cd69 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java @@ -84,14 +84,15 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi } protected CreateNSDeclarationIntentionFix(@NotNull final PsiElement element, - @NotNull final String namespacePrefix, XmlFile containingFile) { + @NotNull final String namespacePrefix, + @NotNull XmlFile containingFile) { this(element, namespacePrefix, null, containingFile); } public CreateNSDeclarationIntentionFix(final PsiElement element, final String namespacePrefix, @Nullable final XmlToken token, - XmlFile containingFile) { + @NotNull XmlFile containingFile) { myNamespacePrefix = namespacePrefix; myElement = element; myFile = containingFile; @@ -132,7 +133,7 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if (!myElement.isValid() || !CodeInsightUtilBase.prepareFileForWrite(file)) return; - final Set set = XmlExtension.getExtension(file).guessUnboundNamespaces(myElement, (XmlFile)file); + final Set set = XmlExtension.getExtension(myFile).guessUnboundNamespaces(myElement, myFile); final String[] namespaces = ArrayUtil.toStringArray(set); Arrays.sort(namespaces);