Skip to content

Commit

Permalink
Renames in FrameworkDetector
Browse files Browse the repository at this point in the history
  • Loading branch information
goodwinnk committed Mar 14, 2013
1 parent ecff401 commit c4bc984
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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;
Expand All @@ -50,7 +50,7 @@ public boolean isCompilableFile(VirtualFile virtualFile, CompileContext compileC
return false;
}
Module module = compileContext.getModuleByFile(virtualFile);
if (module != null && FrameworkDetector.isJsModule(module)) {
if (module != null && KotlinFrameworkDetector.isJsKotlinModule(module)) {
return false;
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
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;
Expand All @@ -63,7 +63,7 @@ public boolean isCompilableFile(VirtualFile file, CompileContext context) {
if (module == null) {
return false;
}
return FrameworkDetector.isJsModule(module);
return KotlinFrameworkDetector.isJsKotlinModule(module);
}

@Override
Expand Down Expand Up @@ -178,7 +178,7 @@ private static VirtualFile[] getSourceFiles(@NotNull Module module) {
}

private static void addLibLocationAndTarget(@NotNull Module module, @NotNull ArrayList<String> args) {
Pair<List<String>, String> libLocationAndTarget = FrameworkDetector.getLibLocationAndTargetForProject(module);
Pair<List<String>, String> libLocationAndTarget = KotlinFrameworkDetector.getLibLocationAndTargetForProject(module);

StringBuilder sb = StringBuilderSpinAllocator.alloc();
AccessToken token = ReadAction.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
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 {
Expand All @@ -45,7 +45,7 @@ static void addJetTypes(
jetCompletionResult.addAllElements(namesCache.getJetClassesDescriptors(
jetCompletionResult.getShortNameFilter(), jetCompletionResult.getResolveSession()));

if (!FrameworkDetector.isJsModule((JetFile) parameters.getOriginalFile())) {
if (!KotlinFrameworkDetector.isJsKotlinModule((JetFile) parameters.getOriginalFile())) {
addAdaptedJavaCompletion(parameters,jetCompletionResult);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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<LookupElement> {
Expand Down Expand Up @@ -60,7 +60,7 @@ public void run() {
if (targetElement != null) {
ImportInsertHelper.addImportDirectiveOrChangeToFqName(fqn, jetFile, context.getStartOffset(), targetElement);
}
else if (FrameworkDetector.isJsModule(jetFile)) {
else if (KotlinFrameworkDetector.isJsKotlinModule(jetFile)) {
ImportInsertHelper.addImportDirective(fqn, jetFile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@
import java.util.Collection;
import java.util.List;

public class FrameworkDetector {
public class KotlinFrameworkDetector {
private static final Key<CachedValue<Boolean>> IS_KOTLIN_JS_MODULE = Key.create("IS_KOTLIN_JS_MODULE");
private static final Key<CachedValue<Boolean>> 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<Boolean> result = module.getUserData(IS_KOTLIN_JAVA_MODULE);
if (result == null) {
result = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider<Boolean>() {
Expand All @@ -76,7 +76,7 @@ public Result<Boolean> compute() {
return result.getValue();
}

public static boolean isJsModule(@NotNull final Module module) {
public static boolean isJsKotlinModule(@NotNull final Module module) {
CachedValue<Boolean> result = module.getUserData(IS_KOTLIN_JS_MODULE);
if (result == null) {
result = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider<Boolean>() {
Expand Down Expand Up @@ -138,7 +138,7 @@ public Library compute() {
public static Pair<List<String>, String> getLibLocationAndTargetForProject(@NotNull Project project) {
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
if (isJsModule(module)) {
if (isJsKotlinModule(module)) {
return getLibLocationAndTargetForProject(module);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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 {

Expand Down Expand Up @@ -55,7 +55,7 @@ private static AnalyzerFacade getDefaultAnalyzerFacade() {

@NotNull
private static AnalyzerFacade getAnalyzerFacadeForModule(@NotNull Module module) {
if (FrameworkDetector.isJsModule(module)) {
if (KotlinFrameworkDetector.isJsKotlinModule(module)) {
return JSAnalyzerFacadeForIDEA.INSTANCE;
}
return AnalyzerFacadeForJVM.INSTANCE;
Expand Down
4 changes: 2 additions & 2 deletions idea/src/org/jetbrains/jet/plugin/project/IDEAConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
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;

Expand Down Expand Up @@ -162,7 +162,7 @@ public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) {
public static Collection<FqName> getClassNames(@NotNull String referenceName, @NotNull JetFile file, @NotNull KotlinCodeAnalyzer analyzer) {
Set<FqName> possibleResolveNames = Sets.newHashSet();

if (!FrameworkDetector.isJsModule(file)) {
if (!KotlinFrameworkDetector.isJsKotlinModule(file)) {
possibleResolveNames.addAll(getClassesFromCache(referenceName, file));
}
else {
Expand Down Expand Up @@ -199,7 +199,7 @@ public FqName apply(@Nullable PsiClass javaClass) {
}

private static PsiShortNamesCache getShortNamesCache(@NotNull JetFile jetFile) {
if (FrameworkDetector.isJsModule(jetFile)) {
if (KotlinFrameworkDetector.isJsKotlinModule(jetFile)) {
return JetShortNamesCache.getKotlinInstance(jetFile.getProject());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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
Expand All @@ -55,7 +55,7 @@ protected RunnerAndConfigurationSettings createConfigurationByElement(@NotNull L
return null;
}

if (FrameworkDetector.isJsModule(module)) {
if (KotlinFrameworkDetector.isJsKotlinModule(module)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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;
Expand Down Expand Up @@ -105,7 +105,7 @@ public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEdi
}

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) {
Expand Down

0 comments on commit c4bc984

Please sign in to comment.