From 9f07f117fbfae8c70f0f99b280e062462c103fc7 Mon Sep 17 00:00:00 2001 From: Sergey Lukjanov Date: Fri, 30 Mar 2012 17:46:54 +0400 Subject: [PATCH] Small fixes of import quickfix: 1. Change import popup title and import message; 2. Remove duplicates of top level and extension functions (in the case of overloaded functions) in import quickfix popup. --- .../jetbrains/jet/plugin/JetBundle.properties | 4 +++- .../jet/plugin/actions/JetAddImportAction.java | 3 ++- .../plugin/quickfix/ImportClassAndFunFix.java | 16 ++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index f8784df1890..3cc32fab814 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -27,6 +27,8 @@ replace.with.safe.call=Replace with safe call change.to.backing.field=Change reference to backing field implement.members=Implement members new.kotlin.file.action=Kotlin File +import.fix=Import +imports.chooser.title=Imports livetemplate.description.main=main() function livetemplate.description.soutp=Prints function parameter names and values to System.out @@ -46,4 +48,4 @@ macro.variable.of.type=kotlinVariable() macro.iterable.variable=kotlinIterableVariable() macro.suggest.variable.name=kotlinSuggestVariableName() macro.fun.parameters=functionParameters() -macro.fun.anonymousSuper=anonymousSuper() \ No newline at end of file +macro.fun.anonymousSuper=anonymousSuper() diff --git a/idea/src/org/jetbrains/jet/plugin/actions/JetAddImportAction.java b/idea/src/org/jetbrains/jet/plugin/actions/JetAddImportAction.java index 55060242854..829aa60725e 100644 --- a/idea/src/org/jetbrains/jet/plugin/actions/JetAddImportAction.java +++ b/idea/src/org/jetbrains/jet/plugin/actions/JetAddImportAction.java @@ -34,6 +34,7 @@ import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.FqName; +import org.jetbrains.jet.plugin.JetBundle; import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper; import javax.swing.*; @@ -91,7 +92,7 @@ public class JetAddImportAction implements QuestionAction { } protected BaseListPopupStep getImportSelectionPopup() { - return new BaseListPopupStep(QuickFixBundle.message("class.to.import.chooser.title"), possibleImports) { + return new BaseListPopupStep(JetBundle.message("imports.chooser.title"), possibleImports) { @Override public boolean isAutoSelectionEnabled() { return false; diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java index 847e54b626b..754c905da97 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java @@ -21,7 +21,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.intention.HighPriorityAction; @@ -48,6 +47,7 @@ import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.FqName; import org.jetbrains.jet.lang.resolve.ImportPath; +import org.jetbrains.jet.plugin.JetBundle; import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.actions.JetAddImportAction; import org.jetbrains.jet.plugin.caches.JetCacheManager; @@ -105,13 +105,13 @@ public class ImportClassAndFunFix extends JetHintAction expression, GlobalSearchScope.allScope(project)); - return Collections2.transform(topLevelFunctions, new Function() { + return Sets.newHashSet(Collections2.transform(topLevelFunctions, new Function() { @Override public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) { assert declarationDescriptor != null; return DescriptorUtils.getFQName(declarationDescriptor).toSafe(); } - }); + })); } private static Collection getJetExtensionFunctions( @@ -130,19 +130,19 @@ public class ImportClassAndFunFix extends JetHintAction expression, GlobalSearchScope.allScope(project)); - return Collections2.transform(jetCallableExtensions, new Function() { + return Sets.newHashSet(Collections2.transform(jetCallableExtensions, new Function() { @Override public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) { assert declarationDescriptor != null; return DescriptorUtils.getFQName(declarationDescriptor).toSafe(); } - }); + })); } /* * Searches for possible class names in kotlin context and java facade. */ - public static ArrayList getClassNames(@NotNull String referenceName, @NotNull Project project) { + public static Collection getClassNames(@NotNull String referenceName, @NotNull Project project) { final GlobalSearchScope scope = GlobalSearchScope.allScope(project); Set possibleResolveNames = Sets.newHashSet(); possibleResolveNames.addAll(JetCacheManager.getInstance(project).getNamesCache().getFQNamesByName(referenceName, scope)); @@ -202,13 +202,13 @@ public class ImportClassAndFunFix extends JetHintAction @Override @NotNull public String getText() { - return QuickFixBundle.message("import.class.fix"); + return JetBundle.message("import.fix"); } @Override @NotNull public String getFamilyName() { - return QuickFixBundle.message("import.class.fix"); + return JetBundle.message("import.fix"); } @Override