Refactoring: inline KotlinLightClassContextCache behaviour
This commit is contained in:
+10
-2
@@ -134,8 +134,16 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
return new LightClassConstructionContext(session.getBindingContext(), null);
|
return new LightClassConstructionContext(session.getBindingContext(), null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KotlinCacheManager cacheManager = KotlinCacheManager.getInstance(project);
|
BindingContext bindingContext;
|
||||||
return new LightClassConstructionContext(cacheManager.getLightClassContextCache().getLightClassBindingContext(classOrObject), null);
|
if (JetPsiUtil.isLocal(classOrObject)) {
|
||||||
|
bindingContext = AnalyzerFacadeWithCache.getContextForElement(classOrObject);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bindingContext = KotlinCacheManager.getInstance(project)
|
||||||
|
.getPossiblyIncompleteDeclarationsForLightClassGeneration().getBindingContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LightClassConstructionContext(bindingContext, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,6 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.openapi.util.DefaultModificationTracker;
|
import com.intellij.openapi.util.DefaultModificationTracker;
|
||||||
import com.intellij.openapi.util.ModificationTracker;
|
import com.intellij.openapi.util.ModificationTracker;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.asJava.KotlinLightClassContextCache;
|
|
||||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -35,14 +34,12 @@ public class KotlinCacheManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Map<TargetPlatform, DeclarationsCacheProvider> cacheProviders = Maps.newHashMap();
|
private final Map<TargetPlatform, DeclarationsCacheProvider> cacheProviders = Maps.newHashMap();
|
||||||
private final KotlinLightClassContextCache lightClassContextCache;
|
|
||||||
|
|
||||||
private final DefaultModificationTracker kotlinDeclarationsTracker = new DefaultModificationTracker();
|
private final DefaultModificationTracker kotlinDeclarationsTracker = new DefaultModificationTracker();
|
||||||
|
|
||||||
public KotlinCacheManager(@NotNull Project project) {
|
public KotlinCacheManager(@NotNull Project project) {
|
||||||
cacheProviders.put(TargetPlatform.JVM, new JvmDeclarationsCacheProvider(project));
|
cacheProviders.put(TargetPlatform.JVM, new JvmDeclarationsCacheProvider(project));
|
||||||
cacheProviders.put(TargetPlatform.JS, new JSDeclarationsCacheProvider(project));
|
cacheProviders.put(TargetPlatform.JS, new JSDeclarationsCacheProvider(project));
|
||||||
lightClassContextCache = new KotlinLightClassContextCache(project);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,10 +85,6 @@ public class KotlinCacheManager {
|
|||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KotlinLightClassContextCache getLightClassContextCache() {
|
|
||||||
return lightClassContextCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void invalidateCache() {
|
public void invalidateCache() {
|
||||||
kotlinDeclarationsTracker.incModificationCount();
|
kotlinDeclarationsTracker.incModificationCount();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2014 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.asJava
|
|
||||||
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
|
||||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.KotlinCacheManager
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
|
|
||||||
class KotlinLightClassContextCache(val project: Project) {
|
|
||||||
public fun getLightClassBindingContext(classOrObject: JetClassOrObject): BindingContext {
|
|
||||||
if (JetPsiUtil.isLocal(classOrObject)) {
|
|
||||||
return AnalyzerFacadeWithCache.getContextForElement(classOrObject)
|
|
||||||
}
|
|
||||||
|
|
||||||
return KotlinCacheManager.getInstance(project).getPossiblyIncompleteDeclarationsForLightClassGeneration().getBindingContext()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user