From bff5d1647173fec697f59508c5537ceb6248c26f Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 6 Sep 2011 18:38:34 +0200 Subject: [PATCH 01/13] dot chooses lookup items, even those that contain dot --- .../normal/ExpectedTypesDotSelectsItem.java | 14 ++++++++++++++ .../normal/ExpectedTypesDotSelectsItem_after.java | 14 ++++++++++++++ .../completion/NormalCompletionTest.groovy | 2 +- .../lookup/impl/LookupTypedHandler.java | 12 ++++++------ .../template/impl/LiveTemplateCharFilter.java | 2 ++ .../codeInsight/completion/XmlCharFilter.java | 1 + 6 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java diff --git a/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java new file mode 100644 index 000000000000..154d4a1aa042 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java @@ -0,0 +1,14 @@ +class Super { + public static final Super FOO = null; +} +class Super2 { +} + +class Intermediate { + void foo(Super s, int a) {} + void bar() { + foo(Su) + } +} + + diff --git a/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java new file mode 100644 index 000000000000..b284b6955f22 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java @@ -0,0 +1,14 @@ +class Super { + public static final Super FOO = null; +} +class Super2 { +} + +class Intermediate { + void foo(Super s, int a) {} + void bar() { + foo(Super.) + } +} + + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index a87ed8d43a49..6368592acdef 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -860,8 +860,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { public void testQualifyInnerMembers() throws Throwable { doTest('\n') } public void testSuggestExpectedTypeMembers() throws Throwable { doTest('\n') } - public void testSuggestExpectedTypeMembersInCall() throws Throwable { doTest('\n') } + public void testExpectedTypesDotSelectsItem() throws Throwable { doTest('.') } public void testSuggestExpectedTypeMembersNonImported() throws Throwable { myFixture.addClass("package foo; public class Super { public static final Super FOO = null; }") diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java index c05a879af148..936028d22020 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java @@ -163,14 +163,14 @@ public class LookupTypedHandler extends TypedHandlerDelegate { final LookupElement currentItem = lookup.getCurrentItem(); if (currentItem != null && charTyped != ' ') { if (charTyped != '*' || filtersDecision != CharFilter.Result.SELECT_ITEM_AND_FINISH_LOOKUP) { - String postfix = lookup.getAdditionalPrefix() + charTyped; - final PrefixMatcher matcher = lookup.itemMatcher(currentItem); - if (matcher.cloneWithPrefix(matcher.getPrefix() + postfix).prefixMatches(currentItem)) { + if (charTyped == '*') { return CharFilter.Result.ADD_TO_PREFIX; } - for (final LookupElement element : lookup.getItems()) { - PrefixMatcher elementMatcher = lookup.itemMatcher(element); - if (elementMatcher.cloneWithPrefix(elementMatcher.getPrefix() + postfix).prefixMatches(element)) { + + String postfix = lookup.getAdditionalPrefix() + charTyped; + final PrefixMatcher matcher = lookup.itemMatcher(currentItem); + for (String lookupString : currentItem.getAllLookupStrings()) { + if (lookupString.startsWith(matcher.getPrefix() + postfix)) { return CharFilter.Result.ADD_TO_PREFIX; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java index 12c18d53385d..10809912feb9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java @@ -27,6 +27,8 @@ public class LiveTemplateCharFilter extends CharFilter { public Result acceptChar(char c, int prefixLength, Lookup lookup) { LookupElement item = lookup.getCurrentItem(); if (item instanceof LiveTemplateLookupElement) { + if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX; + if (c == ((LiveTemplateLookupElement)item).getTemplate().getShortcutChar()) { return Result.SELECT_ITEM_AND_FINISH_LOOKUP; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java index 9d5c7f785298..9f099628a0cc 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java @@ -89,6 +89,7 @@ public class XmlCharFilter extends CharFilter { if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX; switch(c){ case '-': + case ':': return Result.ADD_TO_PREFIX; case '/': if (isWithinTag(lookup)) { From 4ddf6456d84f34f2b056cc8a87f2529801354876 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 6 Sep 2011 19:18:09 +0200 Subject: [PATCH 02/13] restore I surround template: create a copy with rulezz for surround templates, start them in a write action --- .../surroundWith/SurroundWithHandler.java | 2 +- .../impl/SurroundWithTemplateHandler.java | 27 ++++++++----------- .../template/impl/TemplateManagerImpl.java | 1 - resources/src/liveTemplates/surround.xml | 4 --- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/SurroundWithHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/SurroundWithHandler.java index 44316279bc0e..338fd74e3ce5 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/SurroundWithHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/SurroundWithHandler.java @@ -66,7 +66,7 @@ public class SurroundWithHandler implements CodeInsightActionHandler{ } public boolean startInWriteAction() { - return false; + return true; } public static void invoke(final Project project, final Editor editor, PsiFile file, Surrounder surrounder){ diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java index e17b016a84b0..ed3c695a9a7c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java @@ -103,28 +103,23 @@ public class SurroundWithTemplateHandler implements CodeInsightActionHandler { } public static ArrayList getApplicableTemplates(Editor editor, PsiFile file, boolean selection) { - int offset = editor.getCaretModel().getOffset(); - int startOffset = offset; - if (selection && editor.getSelectionModel().hasSelection()) { - final int selStart = editor.getSelectionModel().getSelectionStart(); - final int selEnd = editor.getSelectionModel().getSelectionEnd(); - startOffset = (offset == selStart) ? selEnd : selStart; - } + file = (PsiFile)file.copy(); + final Document document = file.getViewProvider().getDocument(); + assert document != null; - if (!selection) { - file = (PsiFile)file.copy(); - final Document document = file.getViewProvider().getDocument(); - assert document != null; - document.insertString(offset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED); - PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); + int startOffset = editor.getCaretModel().getOffset(); + if (selection && editor.getSelectionModel().hasSelection()) { + startOffset = editor.getSelectionModel().getSelectionStart(); + document.deleteString(startOffset, editor.getSelectionModel().getSelectionEnd()); } - + document.insertString(startOffset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED); + PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); + ArrayList list = new ArrayList(); for (TemplateImpl template : TemplateSettings.getInstance().getTemplates()) { if (!template.isDeactivated() && template.isSelectionTemplate() == selection && - (TemplateManagerImpl.isApplicable(file, offset, template) || - (selection && TemplateManagerImpl.isApplicable(file, startOffset, template)))) { + TemplateManagerImpl.isApplicable(file, startOffset, template)) { list.add(template); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java index ffbce303141f..e1b5a73cb9a4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java @@ -486,7 +486,6 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo } public static boolean isApplicable(PsiFile file, int offset, TemplateImpl template) { - TemplateManager instance = getInstance(file.getProject()); TemplateContext context = template.getTemplateContext(); if (isEnabled(file, offset, null, context)) { return true; diff --git a/resources/src/liveTemplates/surround.xml b/resources/src/liveTemplates/surround.xml index d5232bf4f6e5..07c63bd61572 100644 --- a/resources/src/liveTemplates/surround.xml +++ b/resources/src/liveTemplates/surround.xml @@ -39,7 +39,6 @@ From c6ba1713ac5f2fdbcc6c1a5f99e47bb7d2a1d108 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Tue, 6 Sep 2011 21:27:47 +0400 Subject: [PATCH 03/13] Bug fix: IDEA can not determinate type for synthetic parameter 'it' in validation closure. --- .../psi/AbstractClosureParameterEnhancer.java | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/AbstractClosureParameterEnhancer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/AbstractClosureParameterEnhancer.java index 044b52039a89..f264e0a7e32a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/AbstractClosureParameterEnhancer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/AbstractClosureParameterEnhancer.java @@ -1,54 +1,52 @@ package org.jetbrains.plugins.groovy.lang.psi; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiPrimitiveType; import com.intellij.psi.PsiType; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList; -import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.ClosureSyntheticParameter; -import java.util.Arrays; -import java.util.List; - /** * @author peter */ public abstract class AbstractClosureParameterEnhancer extends GrVariableEnhancer { @Override - public PsiType getVariableType(GrVariable variable) { + public final PsiType getVariableType(GrVariable variable) { if (!(variable instanceof GrParameter)) { return null; } - assert variable.isValid(); - GrClosableBlock closure = variable instanceof ClosureSyntheticParameter - ? ((ClosureSyntheticParameter)variable).getClosure() : findClosureWithArgument(variable.getParent()); - if (closure == null) { - return null; + GrClosableBlock closure; + int paramIndex; + + if (variable instanceof ClosureSyntheticParameter) { + closure = ((ClosureSyntheticParameter)variable).getClosure(); + paramIndex = 0; + } + else { + PsiElement eParameterList = variable.getParent(); + if (!(eParameterList instanceof GrParameterList)) return null; + + PsiElement eClosure = eParameterList.getParent(); + if (!(eClosure instanceof GrClosableBlock)) return null; + + closure = (GrClosableBlock)eClosure; + + GrParameterList parameterList = (GrParameterList)eParameterList; + paramIndex = parameterList.getParameterNumber((GrParameter)variable); } - assert closure.isValid(); + PsiType res = getClosureParameterType(closure, paramIndex); - List parameters = Arrays.asList(closure.getAllParameters()); - @SuppressWarnings({"SuspiciousMethodCalls"}) - int index = parameters.indexOf(variable); - assert index >= 0 : parameters + "; " + variable; - return TypesUtil.boxPrimitiveType(getClosureParameterType(closure, index), closure.getManager(), closure.getResolveScope()); - } - - @Nullable - private static GrClosableBlock findClosureWithArgument(@NotNull PsiElement parent) { - if (parent instanceof GrParameterList) { - GrParameterList list = (GrParameterList)parent; - if (list.getParent() instanceof GrClosableBlock) { - return (GrClosableBlock)list.getParent(); - } + if (res instanceof PsiPrimitiveType) { + return ((PsiPrimitiveType)res).getBoxedType(closure); } - return null; + + return res; } @Nullable From 20c572f1b5ad0761f88541ab54643122b046f002 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 6 Sep 2011 19:51:40 +0200 Subject: [PATCH 04/13] smart completion is a java subcontext --- .../codeInsight/template/SmartCompletionContextType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/template/SmartCompletionContextType.java b/java/java-impl/src/com/intellij/codeInsight/template/SmartCompletionContextType.java index e42cbb4b3f3b..91ff722118e9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/SmartCompletionContextType.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/SmartCompletionContextType.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull; */ public class SmartCompletionContextType extends TemplateContextType { public SmartCompletionContextType() { - super("COMPLETION", CodeInsightBundle.message("dialog.edit.template.checkbox.smart.type.completion")); + super("COMPLETION", CodeInsightBundle.message("dialog.edit.template.checkbox.smart.type.completion"), JavaCodeContextType.class); } @Override From f849db0708a55afb361170ec4c65995f84bf4b79 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 6 Sep 2011 17:08:35 +0200 Subject: [PATCH 05/13] testng: update to support testng >= 6.1 (IDEA-73123) --- .../model/IDEARemoteTestRunnerClient.java | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/IDEARemoteTestRunnerClient.java b/plugins/testng/src/com/theoryinpractice/testng/model/IDEARemoteTestRunnerClient.java index f93ced8f8575..1c8e2f23b4e5 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/IDEARemoteTestRunnerClient.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/IDEARemoteTestRunnerClient.java @@ -44,26 +44,20 @@ public class IDEARemoteTestRunnerClient extends AbstractRemoteTestRunnerClient cause.printStackTrace(); } }; - new Thread() { - @Override - public void run() { - try { - messageSender.initReceiver(); - } - catch (SocketTimeoutException e) { - e.printStackTrace(); - } - startListening(new IRemoteSuiteListener[]{myListener}, - new IRemoteTestListener[]{myListener}, - srvConnection - ); - } - }.start(); + try { + messageSender.initReceiver(); + } + catch (SocketTimeoutException e) { + e.printStackTrace(); + } + startListening(new IRemoteSuiteListener[]{myListener}, + new IRemoteTestListener[]{myListener}, + srvConnection); } @Override protected void notifyStart(final GenericMessage genericMessage) { - ApplicationManager.getApplication().invokeAndWait(new Runnable() + ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { for (final IRemoteSuiteListener listener : m_suiteListeners) { @@ -75,7 +69,7 @@ public class IDEARemoteTestRunnerClient extends AbstractRemoteTestRunnerClient @Override protected void notifySuiteEvents(final SuiteMessage suiteMessage) { - ApplicationManager.getApplication().invokeAndWait(new Runnable() + ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { for (final IRemoteSuiteListener listener : m_suiteListeners) { @@ -91,7 +85,7 @@ public class IDEARemoteTestRunnerClient extends AbstractRemoteTestRunnerClient @Override protected void notifyTestEvents(final TestMessage testMessage) { - ApplicationManager.getApplication().invokeAndWait(new Runnable() + ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { for (final IRemoteTestListener listener : m_testListeners) { @@ -107,7 +101,7 @@ public class IDEARemoteTestRunnerClient extends AbstractRemoteTestRunnerClient @Override protected void notifyResultEvents(final TestResultMessage testResultMessage) { - ApplicationManager.getApplication().invokeAndWait(new Runnable() + ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { for (final IRemoteTestListener listener : m_testListeners) { From 8322d5c5cf0fdbec229a0e094d0a5d0bbf5f9365 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 6 Sep 2011 19:26:40 +0200 Subject: [PATCH 06/13] fix formatting (IDEA-73969) --- .../ReplaceDiamondWithExplicitTypeArgumentsIntention.java | 3 ++- .../diamond2explicit/ApplicableDiamondCheckFormatting.java | 4 ++++ .../ApplicableDiamondCheckFormatting_after.java | 4 ++++ .../types/ReplaceDiamondWithExplicitTypeIntentionTest.java | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting_after.java diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java index 9823e94505d7..1e701098d06f 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java @@ -16,6 +16,7 @@ package com.siyeh.ipp.types; import com.intellij.psi.*; +import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.siyeh.ipp.base.Intention; @@ -63,6 +64,6 @@ public class ReplaceDiamondWithExplicitTypeArgumentsIntention extends Intention JavaPsiFacade.getElementFactory(element.getProject()); final PsiJavaCodeReferenceElement newReference = elementFactory.createReferenceFromText(text.toString(), element); - javaCodeReferenceElement.replace(newReference); + CodeStyleManager.getInstance(javaCodeReferenceElement.getProject()).reformat(javaCodeReferenceElement.replace(newReference)); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting.java new file mode 100644 index 000000000000..ee270319a90d --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting.java @@ -0,0 +1,4 @@ +import java.util.HashMap; +class Test { + HashMap map = new HashMap<>(); +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting_after.java new file mode 100644 index 000000000000..97b73e31083d --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamondCheckFormatting_after.java @@ -0,0 +1,4 @@ +import java.util.HashMap; +class Test { + HashMap map = new HashMap(); +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java index e51a00b0667e..f8d48a4a4ece 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java @@ -27,6 +27,10 @@ public class ReplaceDiamondWithExplicitTypeIntentionTest extends IPPTestCase { doTest(); } + public void testApplicableDiamondCheckFormatting() { + doTest(); + } + public void testExplicitTypeArgs() { doTest(); } From 93959db867d6f9867a8819538da521f494b6d6c1 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 6 Sep 2011 19:49:42 +0200 Subject: [PATCH 07/13] move: adjust renderer; layout --- .../MoveClassesOrPackagesDialog.java | 15 ++++++++++++--- .../com/intellij/ide/util/DirectoryChooser.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java index 1d5817e01172..51643024d717 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java @@ -29,6 +29,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.Messages; @@ -275,12 +276,20 @@ public class MoveClassesOrPackagesDialog extends RefactoringDialog { } }; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); - comboBox.setRenderer(new ListCellRendererWrapper(comboBox) { + comboBox.setRenderer(new HtmlListCellRenderer(comboBox.getRenderer()){ @Override - public void customize(JList list, DirectoryChooser.ItemWrapper itemWrapper, int index, boolean selected, boolean hasFocus) { + protected void doCustomize(JList list, + DirectoryChooser.ItemWrapper itemWrapper, + int index, + boolean selected, + boolean hasFocus) { if (itemWrapper != null) { setIcon(itemWrapper.getIcon(fileIndex)); - setText(itemWrapper.getPresentableUrl()); + + final PsiDirectory directory = itemWrapper.getDirectory(); + final VirtualFile virtualFile = directory != null ? directory.getVirtualFile() : null; + append(virtualFile != null ? ProjectUtil.calcRelativeToProjectPath(virtualFile, myProject) : itemWrapper.getPresentableUrl()); + } else { setText("Leave in same source root"); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/DirectoryChooser.java b/platform/lang-impl/src/com/intellij/ide/util/DirectoryChooser.java index d55a10836f03..0f3cf31ca45c 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/DirectoryChooser.java +++ b/platform/lang-impl/src/com/intellij/ide/util/DirectoryChooser.java @@ -124,7 +124,7 @@ public class DirectoryChooser extends DialogWrapper { }); final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true).getComponent(); component.setBorder(null); - panel.add(component, BorderLayout.EAST); + panel.add(component, BorderLayout.WEST); return panel; } From 9137c994d6e3dcfdec2faa2dc10cfb000adb0eda Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 6 Sep 2011 17:20:10 +0200 Subject: [PATCH 08/13] no need for OccurrencesChooser to be abstract --- .../introduceVariable/IntroduceVariableBase.java | 7 +------ .../refactoring/introduce/inplace/OccurrencesChooser.java | 7 +++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index e78953acf83c..1cfb37e69c6c 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -579,12 +579,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme callback.pass(null); } else { - new OccurrencesChooser(editor) { - @Override - protected TextRange getOccurrenceRange(PsiExpression occurrence) { - return occurrence.getTextRange(); - } - }.showChooser(callback, occurrencesMap); + new OccurrencesChooser(editor).showChooser(callback, occurrencesMap); } return wasSucceed[0]; } diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java index 58d848f24320..7304b00cae85 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.util.Pass; import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; import com.intellij.ui.components.JBList; import javax.swing.*; @@ -39,7 +40,7 @@ import java.util.List; * User: anna * Date: 10/14/10 */ -public abstract class OccurrencesChooser { +public class OccurrencesChooser { public static enum ReplaceChoice { NO("Replace this occurrence only"), NO_WRITE("Replace all occurrences but write"), ALL("Replace all {0} occurrences"); @@ -141,7 +142,9 @@ public abstract class OccurrencesChooser { .createPopup().showInBestPositionFor(myEditor); } - protected abstract TextRange getOccurrenceRange(T occurrence); + protected TextRange getOccurrenceRange(T occurrence) { + return occurrence.getTextRange(); + } private void dropHighlighters() { for (RangeHighlighter highlight : myRangeHighlighters) { From 96605d5f23ab1644b79b78270fd1cd167419de99 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 6 Sep 2011 18:35:21 +0200 Subject: [PATCH 09/13] project converters are available in the platform --- .../openapi/project/impl/IdeaProjectManagerImpl.java | 4 +++- .../intellij/openapi/project/impl/ProjectManagerImpl.java | 6 +++--- .../com/intellij/platform/PlatformProjectOpenProcessor.java | 2 +- .../platform-resources/src/META-INF/LangExtensionPoints.xml | 2 ++ platform/platform-resources/src/META-INF/LangExtensions.xml | 4 ++++ .../src/componentSets/PlatformLangComponents.xml | 4 ++-- resources/src/idea/RichPlatformPlugin.xml | 6 ------ 7 files changed, 15 insertions(+), 13 deletions(-) rename {java/idea-ui => platform/lang-impl}/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java (93%) diff --git a/java/idea-ui/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java similarity index 93% rename from java/idea-ui/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java rename to platform/lang-impl/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java index 57df3e44d5bc..ba84982b6c85 100644 --- a/java/idea-ui/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java @@ -23,6 +23,7 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.ex.VirtualFileManagerEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,11 +51,12 @@ public class IdeaProjectManagerImpl extends ProjectManagerImpl { } @Nullable - protected Project convertAndLoadProject(String filePath, boolean convert) throws IOException { + public Project convertAndLoadProject(String filePath, boolean convert, Ref cancelled) throws IOException { final ConversionResult conversionResult; if (convert) { conversionResult = convertProject(filePath); if (conversionResult.openingIsCanceled()) { + cancelled.set(true); return null; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index ec5e75da3db6..b963695d5c66 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -469,8 +469,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt } @Nullable - protected Project convertAndLoadProject(String filePath, boolean convert) throws IOException { - return loadProjectWithProgress(filePath); + public Project convertAndLoadProject(String filePath, boolean convert, Ref cancelled) throws IOException { + return loadProjectWithProgress(filePath, cancelled); } @Nullable @@ -481,7 +481,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt @Override public void run() { try { - final Project project = convertAndLoadProject(filePath, convert); + final Project project = convertAndLoadProject(filePath, convert, new Ref()); if (project == null) { return; } diff --git a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java index fe75759b4123..c48072f9bcae 100644 --- a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java +++ b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java @@ -113,7 +113,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { Ref cancelled = new Ref(); if (projectDir.exists()) { try { - project = ((ProjectManagerImpl) projectManager).loadProjectWithProgress(baseDir.getPath(), cancelled); + project = ((ProjectManagerImpl) projectManager).convertAndLoadProject(baseDir.getPath(), true, cancelled); } catch (Exception e) { // ignore diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 730e624076f5..c1676e4928b1 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -495,4 +495,6 @@ + diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index fa464b836fa0..81d3f9b45ffe 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -156,6 +156,9 @@ + + @@ -678,4 +681,5 @@ + diff --git a/platform/platform-resources/src/componentSets/PlatformLangComponents.xml b/platform/platform-resources/src/componentSets/PlatformLangComponents.xml index 43a7eb66325b..fd3392089f42 100644 --- a/platform/platform-resources/src/componentSets/PlatformLangComponents.xml +++ b/platform/platform-resources/src/componentSets/PlatformLangComponents.xml @@ -17,9 +17,9 @@ com.intellij.openapi.project.ProjectManager - com.intellij.openapi.project.impl.ProjectManagerImpl + com.intellij.openapi.project.impl.IdeaProjectManagerImpl - + com.intellij.ide.RecentProjectsManagerBase com.intellij.ide.RecentDirectoryProjectsManager diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 08b2ad5f3d4f..5d2ac96f1fdd 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -31,9 +31,6 @@ - - @@ -173,9 +170,6 @@ - - From c2e29bc7dcdfd4d8e070507b6f69966c8efab89f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 6 Sep 2011 18:39:32 +0200 Subject: [PATCH 10/13] avoid hard-coding product name --- .../conversion/impl/ui/ConvertProjectDialog.java | 11 ++++++++--- .../src/messages/IdeBundle.properties | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java index 1d276e337c42..3600f5bb65b5 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java @@ -22,6 +22,7 @@ import com.intellij.conversion.impl.ConversionContextImpl; import com.intellij.conversion.impl.ConversionRunner; import com.intellij.conversion.impl.ProjectConversionUtil; import com.intellij.ide.IdeBundle; +import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; @@ -65,8 +66,10 @@ public class ConvertProjectDialog extends DialogWrapper { myBackupDir = ProjectConversionUtil.getBackupDir(context.getProjectBaseDir()); myTextPane.setSize(new Dimension(350, Integer.MAX_VALUE)); - final String message = - IdeBundle.message("label.text.project.has.older.format", context.getProjectFile().getName(), myBackupDir.getAbsolutePath()); + final String message = IdeBundle.message("label.text.project.has.older.format", + context.getProjectFile().getName(), + ApplicationNamesInfo.getInstance().getProductName(), + myBackupDir.getAbsolutePath()); Messages.configureMessagePaneUi(myTextPane, message, false); myTextPane.addHyperlinkListener(new HyperlinkListener() { @@ -145,7 +148,9 @@ public class ConvertProjectDialog extends DialogWrapper { private boolean checkReadOnlyFiles() throws IOException { List files = getReadOnlyFiles(); if (!files.isEmpty()) { - final String message = IdeBundle.message("message.text.unlock.read.only.files", getFilesString(files)); + final String message = IdeBundle.message("message.text.unlock.read.only.files", + ApplicationNamesInfo.getInstance().getProductName(), + getFilesString(files)); final String[] options = {CommonBundle.getContinueButtonText(), CommonBundle.getCancelButtonText()}; if (Messages.showOkCancelDialog(myMainPanel, message, IdeBundle.message("dialog.title.convert.project"), options[0], options[1], null) != 0) { return false; diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index dedc6bf5254b..8c2eb4217dc7 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -234,12 +234,12 @@ error.project.file.is.corrupted=Project file is corrupted title.cannot.convert.project=Cannot Convert Project dialog.title.convert.project=Convert Project -label.text.project.has.older.format=The project ''{0}'' has an older format and will be converted. You won''t be able to open the project by earlier versions of IDEA. Details
\ - Old versions of project files will be saved to: ''{1}'' -message.text.unlock.read.only.files=The following files are read only. IDEA will unlock them.
{0} +label.text.project.has.older.format=The project ''{0}'' has an older format and will be converted. You may not be able to open the project with earlier versions of {1}. Details
\ + Old versions of project files will be saved to: ''{2}'' +message.text.unlock.read.only.files=The following files are read only. {0} will unlock them.
{1} error.message.cannot.make.files.writable=Cannot make the following files writable:\n{0} error.cannot.convert.project=Cannot convert project: {0} -message.files.doesn.t.exists.0.so.the.corresponding.modules.won.t.be.converted.do.you.want.to.continue=The following files doesn''t exists:
\ +message.files.doesn.t.exists.0.so.the.corresponding.modules.won.t.be.converted.do.you.want.to.continue=The following files don''t exists:
\ {0}The corresponding modules won''t be converted. Do you want to continue? select.in.project.settings=Project Structure From ff60789f475fdbfa06057a1b3c51bf14ea7eebc8 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 6 Sep 2011 20:11:21 +0200 Subject: [PATCH 11/13] tooltip text (IDEA-69502) --- .../com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java index 02242dcaa6b0..d892dfb614c5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java @@ -832,11 +832,11 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx { } Set vks = ToolWindowManagerImpl.getActivateToolWindowVKs(); - String text = "Click to show/hide tool windows side bars"; + String text = "Click to show or hide the tool window bars"; if (vks.size() == 1) { Integer stroke = vks.iterator().next(); String keystrokeText = KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(stroke.intValue(), 0)); - text += ".\nUse double click of " + keystrokeText + " to popup them when hidden"; + text += ".\nDouble-press and hold " + keystrokeText + " to show tool window bars when hidden."; } if (!text.equals(getToolTipText())) { setToolTipText(text); From a45e02726c5d726d33db89ac4008558b3408f1de Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 6 Sep 2011 20:27:25 +0200 Subject: [PATCH 12/13] remove unhelpful assertion (IDEA-73526) --- .../com/intellij/openapi/actionSystem/MouseShortcut.java | 7 ------- .../src/com/intellij/openapi/keymap/KeymapUtil.java | 2 +- .../src/com/intellij/openapi/keymap/impl/KeymapImpl.java | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/MouseShortcut.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/MouseShortcut.java index 46e2e29313db..7727808bddfd 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/MouseShortcut.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/MouseShortcut.java @@ -28,13 +28,6 @@ public final class MouseShortcut extends Shortcut { private final int myClickCount; public MouseShortcut(int button, int modifiers, int clickCount) { - if ( - MouseEvent.BUTTON1 != button && - MouseEvent.BUTTON2 != button && - MouseEvent.BUTTON3 != button - ) { - throw new IllegalArgumentException("unknown button: " + button); - } myButton = button; // TODO[vova] check modifiers? myModifiers = mapOldModifiers(modifiers); diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java index 2d4bc36787b7..e7214df6e2bf 100644 --- a/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java @@ -128,7 +128,7 @@ public class KeymapUtil { // do nothing } else { - throw new IllegalStateException("unknown button: " + button); + buttonNum = button; } if (clickCount == 1) { diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java index 04a680c6e65a..22a6260ca7fe 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java @@ -801,7 +801,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme { buffer.append(' '); } else { - throw new IllegalStateException("unknown button: " + button); + buffer.append("button").append(button); } if (shortcut.getClickCount() > 1) { From 6a9190132f8533bf4e81718acc19ad7c8641a362 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 6 Sep 2011 20:48:54 +0200 Subject: [PATCH 13/13] allow use name instead of url attribute --- .../facet/frameworks/LibrariesDownloadAssistant.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java b/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java index 5e95bf4ce172..ddc7987e124e 100644 --- a/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java +++ b/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java @@ -132,8 +132,13 @@ public class LibrariesDownloadAssistant { @Override public LibraryInfo fun(ArtifactItem artifactItem) { String downloadUrl = artifactItem.getUrl(); - if (!downloadUrl.startsWith("http://") && urlPrefix != null) { - downloadUrl = urlPrefix + downloadUrl; + if (urlPrefix != null) { + if (downloadUrl == null) { + downloadUrl = artifactItem.getName(); + } + if (!downloadUrl.startsWith("http://")) { + downloadUrl = urlPrefix + downloadUrl; + } } return new LibraryInfo(artifactItem.getName(), downloadUrl, downloadUrl, artifactItem.getMD5(), artifactItem.getRequiredClasses()); }