Loading descriptors from incremental cache instead of package classes.
This commit is contained in:
+15
@@ -18,6 +18,7 @@ package org.jetbrains.jet.cli.common.modules;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,6 +42,9 @@ public interface ModuleDescription {
|
||||
@NotNull
|
||||
List<String> getAnnotationsRoots();
|
||||
|
||||
@Nullable
|
||||
String getIncrementalCacheDir();
|
||||
|
||||
class Impl implements ModuleDescription {
|
||||
|
||||
private String name;
|
||||
@@ -48,6 +52,7 @@ public interface ModuleDescription {
|
||||
private final List<String> sources = new SmartList<String>();
|
||||
private final List<String> classpath = new SmartList<String>();
|
||||
private final List<String> annotations = new SmartList<String>();
|
||||
private String incrementalCacheDir;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
@@ -69,6 +74,10 @@ public interface ModuleDescription {
|
||||
annotations.add(path);
|
||||
}
|
||||
|
||||
public void setIncrementalCacheDir(String incrementalCacheDir) {
|
||||
this.incrementalCacheDir = incrementalCacheDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
@@ -99,6 +108,12 @@ public interface ModuleDescription {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getIncrementalCacheDir() {
|
||||
return incrementalCacheDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name +
|
||||
|
||||
+8
-2
@@ -40,6 +40,7 @@ public class ModuleXmlParser {
|
||||
public static final String MODULE = "module";
|
||||
public static final String NAME = "name";
|
||||
public static final String OUTPUT_DIR = "outputDir";
|
||||
public static final String INCREMENTAL_CACHE = "incrementalCache";
|
||||
public static final String SOURCES = "sources";
|
||||
public static final String PATH = "path";
|
||||
public static final String CLASSPATH = "classpath";
|
||||
@@ -117,7 +118,11 @@ public class ModuleXmlParser {
|
||||
throw createError(qName);
|
||||
}
|
||||
|
||||
setCurrentState(new InsideModule(getAttribute(attributes, NAME, qName), getAttribute(attributes, OUTPUT_DIR, qName)));
|
||||
setCurrentState(new InsideModule(
|
||||
getAttribute(attributes, NAME, qName),
|
||||
getAttribute(attributes, OUTPUT_DIR, qName),
|
||||
attributes.getValue(INCREMENTAL_CACHE)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,10 +136,11 @@ public class ModuleXmlParser {
|
||||
private class InsideModule extends DefaultHandler {
|
||||
|
||||
private final ModuleDescription.Impl moduleDescription;
|
||||
private InsideModule(String name, String outputDir) {
|
||||
private InsideModule(String name, String outputDir, String incrementalCacheDir) {
|
||||
this.moduleDescription = new ModuleDescription.Impl();
|
||||
this.moduleDescription.setName(name);
|
||||
this.moduleDescription.setOutputDir(outputDir);
|
||||
this.moduleDescription.setIncrementalCacheDir(incrementalCacheDir);
|
||||
result.add(moduleDescription);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,10 @@ public class JVMConfigurationKeys {
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> ENABLE_INLINE =
|
||||
CompilerConfigurationKey.create("enable inline");
|
||||
|
||||
public static final CompilerConfigurationKey<File> INCREMENTAL_CACHE_BASE_DIR =
|
||||
CompilerConfigurationKey.create("incremental cache base dir");
|
||||
|
||||
public static final CompilerConfigurationKey<List<String>> MODULE_IDS =
|
||||
CompilerConfigurationKey.create("module id strings");
|
||||
}
|
||||
|
||||
@@ -1,41 +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.cli.jvm.compiler
|
||||
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.MemberFilter
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils.getPackagePartInternalName
|
||||
import org.jetbrains.jet.descriptors.serialization.NameResolver
|
||||
import org.jetbrains.jet.descriptors.serialization.JavaProtoBuf
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName
|
||||
import org.jetbrains.jet.codegen.AsmUtil
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils
|
||||
|
||||
public class CliSourcesMemberFilter(environment: JetCoreEnvironment): MemberFilter {
|
||||
val packagePartClassNames = environment.getSourceFiles().map { PackagePartClassUtils.getPackagePartInternalName(it) }.toSet()
|
||||
|
||||
override fun acceptPackagePartClass(container: PackageFragmentDescriptor, member: ProtoBuf.Callable, nameResolver: NameResolver): Boolean {
|
||||
if (member.hasExtension(JavaProtoBuf.implClassName)) {
|
||||
val shortName = nameResolver.getName(member.getExtension(JavaProtoBuf.implClassName)!!)
|
||||
val fqName = container.fqName.child(shortName)
|
||||
val internalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(fqName)
|
||||
return internalName !in packagePartClassNames
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public class CompileEnvironmentUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class DescriptionToModuleAdapter implements Module {
|
||||
static class DescriptionToModuleAdapter implements Module {
|
||||
private final ModuleDescription description;
|
||||
|
||||
public DescriptionToModuleAdapter(ModuleDescription description) {
|
||||
@@ -360,5 +360,10 @@ public class CompileEnvironmentUtil {
|
||||
public List<String> getAnnotationsRoots() {
|
||||
return description.getAnnotationsRoots();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIncrementalCacheDir() {
|
||||
return description.getIncrementalCacheDir();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-1
@@ -51,6 +51,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.incremental.CliSourcesMemberFilter;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.plugin.MainFunctionDetector;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
@@ -162,7 +163,18 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
for (String annotationsRoot : module.getAnnotationsRoots()) {
|
||||
configuration.add(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, new File(annotationsRoot));
|
||||
}
|
||||
|
||||
configuration.add(JVMConfigurationKeys.MODULE_IDS, module.getModuleName());
|
||||
}
|
||||
|
||||
Module anyModule = chunk.get(0);
|
||||
if (anyModule instanceof CompileEnvironmentUtil.DescriptionToModuleAdapter) {
|
||||
String incrementalCacheDir = ((CompileEnvironmentUtil.DescriptionToModuleAdapter) anyModule).getIncrementalCacheDir();
|
||||
if (incrementalCacheDir != null) {
|
||||
configuration.put(JVMConfigurationKeys.INCREMENTAL_CACHE_BASE_DIR, new File(incrementalCacheDir));
|
||||
}
|
||||
}
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@@ -286,7 +298,10 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
sharedTrace,
|
||||
Predicates.<PsiFile>alwaysTrue(),
|
||||
sharedModule,
|
||||
new CliSourcesMemberFilter(environment));
|
||||
new CliSourcesMemberFilter(environment.getSourceFiles()),
|
||||
environment.getConfiguration().get(JVMConfigurationKeys.MODULE_IDS),
|
||||
environment.getConfiguration().get(JVMConfigurationKeys.INCREMENTAL_CACHE_BASE_DIR)
|
||||
);
|
||||
}
|
||||
}, environment.getSourceFiles()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user