From c4bc984c94d66092d2bdf7862ad449ad3221f89a Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 6 Mar 2013 17:49:15 +0400 Subject: [PATCH] Renames in FrameworkDetector --- .../jet/plugin/compiler/JetCompiler.java | 4 ++-- .../jet/plugin/compiler/K2JSCompiler.java | 6 +++--- .../completion/JetTypesCompletionHelper.java | 4 ++-- .../handlers/JetClassInsertHandler.java | 4 ++-- ...etector.java => KotlinFrameworkDetector.java} | 14 +++++++------- .../ui/CreateJavaScriptLibraryDialog.java | 16 ++++++++++++++++ .../plugin/project/AnalyzerFacadeProvider.java | 4 ++-- .../jetbrains/jet/plugin/project/IDEAConfig.java | 4 ++-- .../plugin/quickfix/ImportClassAndFunFix.java | 6 +++--- .../plugin/run/JetRunConfigurationProducer.java | 4 ++-- .../KotlinLibrariesNotificationProvider.java | 4 ++-- 11 files changed, 43 insertions(+), 27 deletions(-) rename idea/src/org/jetbrains/jet/plugin/framework/{FrameworkDetector.java => KotlinFrameworkDetector.java} (94%) diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java index 01ee4d60c1e..6dacc43ed48 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java @@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.messages.MessageCollector; import org.jetbrains.jet.compiler.runner.*; import org.jetbrains.jet.plugin.JetFileType; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import java.io.File; import java.io.IOException; @@ -50,7 +50,7 @@ public class JetCompiler implements TranslatingCompiler { return false; } Module module = compileContext.getModuleByFile(virtualFile); - if (module != null && FrameworkDetector.isJsModule(module)) { + if (module != null && KotlinFrameworkDetector.isJsKotlinModule(module)) { return false; } return true; diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java b/idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java index 093363a2487..357a47fa834 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java @@ -42,7 +42,7 @@ import org.jetbrains.jet.compiler.runner.CompilerEnvironment; import org.jetbrains.jet.compiler.runner.CompilerRunnerUtil; import org.jetbrains.jet.compiler.runner.OutputItemsCollectorImpl; import org.jetbrains.jet.plugin.JetFileType; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import java.io.File; import java.io.PrintStream; @@ -63,7 +63,7 @@ public final class K2JSCompiler implements TranslatingCompiler { if (module == null) { return false; } - return FrameworkDetector.isJsModule(module); + return KotlinFrameworkDetector.isJsKotlinModule(module); } @Override @@ -178,7 +178,7 @@ public final class K2JSCompiler implements TranslatingCompiler { } private static void addLibLocationAndTarget(@NotNull Module module, @NotNull ArrayList args) { - Pair, String> libLocationAndTarget = FrameworkDetector.getLibLocationAndTargetForProject(module); + Pair, String> libLocationAndTarget = KotlinFrameworkDetector.getLibLocationAndTargetForProject(module); StringBuilder sb = StringBuilderSpinAllocator.alloc(); AccessToken token = ReadAction.start(); diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetTypesCompletionHelper.java b/idea/src/org/jetbrains/jet/plugin/completion/JetTypesCompletionHelper.java index 5f26ff57562..d00c2cf8247 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/JetTypesCompletionHelper.java +++ b/idea/src/org/jetbrains/jet/plugin/completion/JetTypesCompletionHelper.java @@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.plugin.caches.JetShortNamesCache; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import org.jetbrains.jet.plugin.libraries.DecompiledDataFactory; public class JetTypesCompletionHelper { @@ -45,7 +45,7 @@ public class JetTypesCompletionHelper { jetCompletionResult.addAllElements(namesCache.getJetClassesDescriptors( jetCompletionResult.getShortNameFilter(), jetCompletionResult.getResolveSession())); - if (!FrameworkDetector.isJsModule((JetFile) parameters.getOriginalFile())) { + if (!KotlinFrameworkDetector.isJsKotlinModule((JetFile) parameters.getOriginalFile())) { addAdaptedJavaCompletion(parameters,jetCompletionResult); } } diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetClassInsertHandler.java b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetClassInsertHandler.java index 1ee5d620211..cb20bf87d37 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetClassInsertHandler.java +++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetClassInsertHandler.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.plugin.completion.JetLookupObject; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper; public class JetClassInsertHandler implements InsertHandler { @@ -60,7 +60,7 @@ public class JetClassInsertHandler implements InsertHandler { if (targetElement != null) { ImportInsertHelper.addImportDirectiveOrChangeToFqName(fqn, jetFile, context.getStartOffset(), targetElement); } - else if (FrameworkDetector.isJsModule(jetFile)) { + else if (KotlinFrameworkDetector.isJsKotlinModule(jetFile)) { ImportInsertHelper.addImportDirective(fqn, jetFile); } } diff --git a/idea/src/org/jetbrains/jet/plugin/framework/FrameworkDetector.java b/idea/src/org/jetbrains/jet/plugin/framework/KotlinFrameworkDetector.java similarity index 94% rename from idea/src/org/jetbrains/jet/plugin/framework/FrameworkDetector.java rename to idea/src/org/jetbrains/jet/plugin/framework/KotlinFrameworkDetector.java index c0eb422f7db..5e00821617d 100644 --- a/idea/src/org/jetbrains/jet/plugin/framework/FrameworkDetector.java +++ b/idea/src/org/jetbrains/jet/plugin/framework/KotlinFrameworkDetector.java @@ -46,19 +46,19 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -public class FrameworkDetector { +public class KotlinFrameworkDetector { private static final Key> IS_KOTLIN_JS_MODULE = Key.create("IS_KOTLIN_JS_MODULE"); private static final Key> IS_KOTLIN_JAVA_MODULE = Key.create("IS_KOTLIN_JAVA_MODULE"); - private FrameworkDetector() { + private KotlinFrameworkDetector() { } - public static boolean isJsModule(@NotNull JetFile file) { + public static boolean isJsKotlinModule(@NotNull JetFile file) { Module module = ModuleUtilCore.findModuleForPsiElement(file); - return module != null && isJsModule(module); + return module != null && isJsKotlinModule(module); } - public static boolean isJavaModule(@NotNull final Module module) { + public static boolean isJavaKotlinModule(@NotNull final Module module) { CachedValue result = module.getUserData(IS_KOTLIN_JAVA_MODULE); if (result == null) { result = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider() { @@ -76,7 +76,7 @@ public class FrameworkDetector { return result.getValue(); } - public static boolean isJsModule(@NotNull final Module module) { + public static boolean isJsKotlinModule(@NotNull final Module module) { CachedValue result = module.getUserData(IS_KOTLIN_JS_MODULE); if (result == null) { result = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider() { @@ -138,7 +138,7 @@ public class FrameworkDetector { public static Pair, String> getLibLocationAndTargetForProject(@NotNull Project project) { Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { - if (isJsModule(module)) { + if (isJsKotlinModule(module)) { return getLibLocationAndTargetForProject(module); } } diff --git a/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateJavaScriptLibraryDialog.java b/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateJavaScriptLibraryDialog.java index 568cf100e11..2da80dc5666 100644 --- a/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateJavaScriptLibraryDialog.java +++ b/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateJavaScriptLibraryDialog.java @@ -1,3 +1,19 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.jetbrains.jet.plugin.framework.ui; import com.intellij.openapi.project.Project; diff --git a/idea/src/org/jetbrains/jet/plugin/project/AnalyzerFacadeProvider.java b/idea/src/org/jetbrains/jet/plugin/project/AnalyzerFacadeProvider.java index d0affa27bae..063d1574af7 100644 --- a/idea/src/org/jetbrains/jet/plugin/project/AnalyzerFacadeProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/project/AnalyzerFacadeProvider.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.analyzer.AnalyzerFacade; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; public final class AnalyzerFacadeProvider { @@ -55,7 +55,7 @@ public final class AnalyzerFacadeProvider { @NotNull private static AnalyzerFacade getAnalyzerFacadeForModule(@NotNull Module module) { - if (FrameworkDetector.isJsModule(module)) { + if (KotlinFrameworkDetector.isJsKotlinModule(module)) { return JSAnalyzerFacadeForIDEA.INSTANCE; } return AnalyzerFacadeForJVM.INSTANCE; diff --git a/idea/src/org/jetbrains/jet/plugin/project/IDEAConfig.java b/idea/src/org/jetbrains/jet/plugin/project/IDEAConfig.java index 0c56cd29768..ae52bc41e7f 100644 --- a/idea/src/org/jetbrains/jet/plugin/project/IDEAConfig.java +++ b/idea/src/org/jetbrains/jet/plugin/project/IDEAConfig.java @@ -18,12 +18,12 @@ package org.jetbrains.jet.plugin.project; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.config.LibrarySourcesConfig; public final class IDEAConfig extends LibrarySourcesConfig { public IDEAConfig(@NotNull Project project) { - super(project, "default", FrameworkDetector.getLibLocationAndTargetForProject(project).first, EcmaVersion.defaultVersion()); + super(project, "default", KotlinFrameworkDetector.getLibLocationAndTargetForProject(project).first, EcmaVersion.defaultVersion()); } } diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java index e317d9a6ca9..c3a5ae73995 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ImportClassAndFunFix.java @@ -52,7 +52,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.plugin.JetBundle; import org.jetbrains.jet.plugin.actions.JetAddImportAction; import org.jetbrains.jet.plugin.caches.JetShortNamesCache; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade; import org.jetbrains.jet.plugin.util.JetPsiHeuristicsUtil; @@ -162,7 +162,7 @@ public class ImportClassAndFunFix extends JetHintAction public static Collection getClassNames(@NotNull String referenceName, @NotNull JetFile file, @NotNull KotlinCodeAnalyzer analyzer) { Set possibleResolveNames = Sets.newHashSet(); - if (!FrameworkDetector.isJsModule(file)) { + if (!KotlinFrameworkDetector.isJsKotlinModule(file)) { possibleResolveNames.addAll(getClassesFromCache(referenceName, file)); } else { @@ -199,7 +199,7 @@ public class ImportClassAndFunFix extends JetHintAction } private static PsiShortNamesCache getShortNamesCache(@NotNull JetFile jetFile) { - if (FrameworkDetector.isJsModule(jetFile)) { + if (KotlinFrameworkDetector.isJsKotlinModule(jetFile)) { return JetShortNamesCache.getKotlinInstance(jetFile.getProject()); } diff --git a/idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java b/idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java index ae59521a579..e13c82952ef 100644 --- a/idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java +++ b/idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java @@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.plugin.JetMainDetector; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; public class JetRunConfigurationProducer extends RuntimeConfigurationProducer implements Cloneable { @Nullable @@ -55,7 +55,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im return null; } - if (FrameworkDetector.isJsModule(module)) { + if (KotlinFrameworkDetector.isJsKotlinModule(module)) { return null; } diff --git a/idea/src/org/jetbrains/jet/plugin/versions/KotlinLibrariesNotificationProvider.java b/idea/src/org/jetbrains/jet/plugin/versions/KotlinLibrariesNotificationProvider.java index ff395149370..71b87af7748 100644 --- a/idea/src/org/jetbrains/jet/plugin/versions/KotlinLibrariesNotificationProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/versions/KotlinLibrariesNotificationProvider.java @@ -37,7 +37,7 @@ import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.plugin.JetFileType; -import org.jetbrains.jet.plugin.framework.FrameworkDetector; +import org.jetbrains.jet.plugin.framework.KotlinFrameworkDetector; import org.jetbrains.jet.plugin.framework.JSFrameworkSupportProvider; import org.jetbrains.jet.plugin.framework.JavaFrameworkSupportProvider; import org.jetbrains.jet.plugin.framework.ui.AddSupportForSingleFrameworkDialogFixed; @@ -105,7 +105,7 @@ public class KotlinLibrariesNotificationProvider extends EditorNotifications.Pro } public static boolean isModuleAlreadyConfigured(Module module) { - return isMavenModule(module) || FrameworkDetector.isJsModule(module) || FrameworkDetector.isJavaModule(module); + return isMavenModule(module) || KotlinFrameworkDetector.isJsKotlinModule(module) || KotlinFrameworkDetector.isJavaKotlinModule(module); } private static boolean isMavenModule(@NotNull Module module) {