renaming/code moving to meet the code style
This commit is contained in:
@@ -58,7 +58,7 @@ public class BytecodeCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lets register any compiler plugins
|
// lets register any compiler plugins
|
||||||
env.getMyEnvironment().getCompilerPlugins().addAll(getCompilerPlugins());
|
env.getEnvironment().getCompilerPlugins().addAll(getCompilerPlugins());
|
||||||
|
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,13 +166,13 @@ public class KotlinCompiler {
|
|||||||
environment.setStubs(arguments.stubs);
|
environment.setStubs(arguments.stubs);
|
||||||
|
|
||||||
if (arguments.docOutputDir != null) {
|
if (arguments.docOutputDir != null) {
|
||||||
KDocLoader.install(arguments.docOutputDir, environment.getMyEnvironment());
|
KDocLoader.install(arguments.docOutputDir, environment.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
// install any compiler plugins
|
// install any compiler plugins
|
||||||
List<CompilerPlugin> plugins = arguments.getCompilerPlugins();
|
List<CompilerPlugin> plugins = arguments.getCompilerPlugins();
|
||||||
if (plugins != null) {
|
if (plugins != null) {
|
||||||
environment.getMyEnvironment().getCompilerPlugins().addAll(plugins);
|
environment.getEnvironment().getCompilerPlugins().addAll(plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.stdlib != null) {
|
if (arguments.stdlib != null) {
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ import java.util.jar.*;
|
|||||||
* @author yole
|
* @author yole
|
||||||
*/
|
*/
|
||||||
public class CompileEnvironment {
|
public class CompileEnvironment {
|
||||||
private JetCoreEnvironment myEnvironment;
|
private JetCoreEnvironment environment;
|
||||||
private final Disposable myRootDisposable;
|
private final Disposable rootDisposable;
|
||||||
private final MessageRenderer myMessageRenderer;
|
private final MessageRenderer messageRenderer;
|
||||||
private PrintStream myErrorStream = System.err;
|
private PrintStream errorStream = System.err;
|
||||||
|
|
||||||
private URL myStdlib;
|
private URL stdlibUrl;
|
||||||
|
|
||||||
private boolean ignoreErrors = false;
|
private boolean ignoreErrors = false;
|
||||||
private boolean stubs = false;
|
private boolean stubs = false;
|
||||||
@@ -78,17 +78,17 @@ public class CompileEnvironment {
|
|||||||
*/
|
*/
|
||||||
public CompileEnvironment(MessageRenderer messageRenderer, boolean verbose) {
|
public CompileEnvironment(MessageRenderer messageRenderer, boolean verbose) {
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
myRootDisposable = new Disposable() {
|
rootDisposable = new Disposable() {
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
myEnvironment = new JetCoreEnvironment(myRootDisposable);
|
environment = new JetCoreEnvironment(rootDisposable);
|
||||||
myMessageRenderer = messageRenderer;
|
this.messageRenderer = messageRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErrorStream(PrintStream errorStream) {
|
public void setErrorStream(PrintStream errorStream) {
|
||||||
myErrorStream = errorStream;
|
this.errorStream = errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnoreErrors(boolean ignoreErrors) {
|
public void setIgnoreErrors(boolean ignoreErrors) {
|
||||||
@@ -100,7 +100,7 @@ public class CompileEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
Disposer.dispose(myRootDisposable);
|
Disposer.dispose(rootDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -123,7 +123,7 @@ public class CompileEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ensureRuntime() {
|
public void ensureRuntime() {
|
||||||
ensureRuntime(myEnvironment);
|
ensureRuntime(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureRuntime(@NotNull JetCoreEnvironment env) {
|
public static void ensureRuntime(@NotNull JetCoreEnvironment env) {
|
||||||
@@ -178,7 +178,7 @@ public class CompileEnvironment {
|
|||||||
public boolean compileModuleScript(String moduleScriptFile, @Nullable String jarPath, @Nullable String outputDir, boolean jarRuntime) {
|
public boolean compileModuleScript(String moduleScriptFile, @Nullable String jarPath, @Nullable String outputDir, boolean jarRuntime) {
|
||||||
CompileEnvironment moduleCompilationEnvironment = copyEnvironment(false);
|
CompileEnvironment moduleCompilationEnvironment = copyEnvironment(false);
|
||||||
try {
|
try {
|
||||||
moduleCompilationEnvironment.myStdlib = myStdlib;
|
moduleCompilationEnvironment.stdlibUrl = stdlibUrl;
|
||||||
|
|
||||||
List<Module> modules = moduleCompilationEnvironment.loadModuleScript(moduleScriptFile);
|
List<Module> modules = moduleCompilationEnvironment.loadModuleScript(moduleScriptFile);
|
||||||
|
|
||||||
@@ -220,11 +220,11 @@ public class CompileEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CompileEnvironment copyEnvironment(boolean verbose) {
|
private CompileEnvironment copyEnvironment(boolean verbose) {
|
||||||
CompileEnvironment compileEnvironment = new CompileEnvironment(myMessageRenderer, verbose);
|
CompileEnvironment compileEnvironment = new CompileEnvironment(messageRenderer, verbose);
|
||||||
compileEnvironment.setIgnoreErrors(ignoreErrors);
|
compileEnvironment.setIgnoreErrors(ignoreErrors);
|
||||||
compileEnvironment.setErrorStream(myErrorStream);
|
compileEnvironment.setErrorStream(errorStream);
|
||||||
// copy across any compiler plugins
|
// copy across any compiler plugins
|
||||||
compileEnvironment.getMyEnvironment().getCompilerPlugins().addAll(myEnvironment.getCompilerPlugins());
|
compileEnvironment.getEnvironment().getCompilerPlugins().addAll(environment.getCompilerPlugins());
|
||||||
return compileEnvironment;
|
return compileEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +236,13 @@ public class CompileEnvironment {
|
|||||||
if (!scriptCompileSession.analyze()) {
|
if (!scriptCompileSession.analyze()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final ClassFileFactory factory = scriptCompileSession.generate(true);
|
ClassFileFactory factory = scriptCompileSession.generate(true);
|
||||||
|
|
||||||
return runDefineModules(moduleFile, factory);
|
return runDefineModules(moduleFile, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Module> runDefineModules(String moduleFile, ClassFileFactory factory) {
|
private List<Module> runDefineModules(String moduleFile, ClassFileFactory factory) {
|
||||||
GeneratedClassLoader loader = myStdlib != null ? new GeneratedClassLoader(factory, new URLClassLoader(new URL[] {myStdlib}, AllModules.class.getClassLoader()))
|
GeneratedClassLoader loader = stdlibUrl != null ? new GeneratedClassLoader(factory, new URLClassLoader(new URL[] {stdlibUrl}, AllModules.class.getClassLoader()))
|
||||||
: new GeneratedClassLoader(factory, CompileEnvironment.class.getClassLoader());
|
: new GeneratedClassLoader(factory, CompileEnvironment.class.getClassLoader());
|
||||||
try {
|
try {
|
||||||
Class namespaceClass = loader.loadClass(JvmAbi.PACKAGE_CLASS);
|
Class namespaceClass = loader.loadClass(JvmAbi.PACKAGE_CLASS);
|
||||||
@@ -287,7 +287,7 @@ public class CompileEnvironment {
|
|||||||
moduleCompileSession.addSources(source.getPath());
|
moduleCompileSession.addSources(source.getPath());
|
||||||
}
|
}
|
||||||
for (String classpathRoot : moduleBuilder.getClasspathRoots()) {
|
for (String classpathRoot : moduleBuilder.getClasspathRoots()) {
|
||||||
myEnvironment.addToClasspath(new File(classpathRoot));
|
environment.addToClasspath(new File(classpathRoot));
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureRuntime();
|
ensureRuntime();
|
||||||
@@ -426,7 +426,7 @@ public class CompileEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CompileSession newCompileSession() {
|
private CompileSession newCompileSession() {
|
||||||
return new CompileSession(myEnvironment, myMessageRenderer, myErrorStream, verbose);
|
return new CompileSession(environment, messageRenderer, errorStream, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeToOutputDirectory(ClassFileFactory factory, final String outputDir) {
|
public static void writeToOutputDirectory(ClassFileFactory factory, final String outputDir) {
|
||||||
@@ -451,7 +451,7 @@ public class CompileEnvironment {
|
|||||||
if ( ! path.exists()) {
|
if ( ! path.exists()) {
|
||||||
throw new CompileEnvironmentException("'" + path + "' does not exist");
|
throw new CompileEnvironmentException("'" + path + "' does not exist");
|
||||||
}
|
}
|
||||||
myEnvironment.addToClasspath(path);
|
environment.addToClasspath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,14 +470,14 @@ public class CompileEnvironment {
|
|||||||
addToClasspath(file);
|
addToClasspath(file);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
myStdlib = file.toURL();
|
stdlibUrl = file.toURL();
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e) {
|
catch (MalformedURLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetCoreEnvironment getMyEnvironment() {
|
public JetCoreEnvironment getEnvironment() {
|
||||||
return myEnvironment;
|
return environment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,27 +56,27 @@ import java.util.List;
|
|||||||
* @author yole
|
* @author yole
|
||||||
*/
|
*/
|
||||||
public class CompileSession {
|
public class CompileSession {
|
||||||
private final JetCoreEnvironment myEnvironment;
|
private final JetCoreEnvironment environment;
|
||||||
private final MessageCollector myMessageCollector;
|
private final MessageCollector messageCollector;
|
||||||
private final List<JetFile> mySourceFiles = new ArrayList<JetFile>();
|
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
|
||||||
private List<String> myErrors = new ArrayList<String>();
|
private List<String> errors = new ArrayList<String>();
|
||||||
private boolean stubs = false;
|
private boolean stubs = false;
|
||||||
private final MessageRenderer myMessageRenderer;
|
private final MessageRenderer messageRenderer;
|
||||||
private final PrintStream myErrorStream;
|
private final PrintStream errorStream;
|
||||||
private final boolean myIsVerbose;
|
private final boolean isVerbose;
|
||||||
|
private AnalyzeExhaust bindingContext;
|
||||||
public AnalyzeExhaust getMyBindingContext() {
|
|
||||||
return myBindingContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AnalyzeExhaust myBindingContext;
|
|
||||||
|
|
||||||
public CompileSession(JetCoreEnvironment environment, MessageRenderer messageRenderer, PrintStream errorStream, boolean verbose) {
|
public CompileSession(JetCoreEnvironment environment, MessageRenderer messageRenderer, PrintStream errorStream, boolean verbose) {
|
||||||
myEnvironment = environment;
|
this.environment = environment;
|
||||||
myMessageRenderer = messageRenderer;
|
this.messageRenderer = messageRenderer;
|
||||||
myErrorStream = errorStream;
|
this.errorStream = errorStream;
|
||||||
myIsVerbose = verbose;
|
isVerbose = verbose;
|
||||||
myMessageCollector = new MessageCollector(myMessageRenderer);
|
messageCollector = new MessageCollector(this.messageRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public AnalyzeExhaust getBindingContext() {
|
||||||
|
return bindingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStubs(boolean stubs) {
|
public void setStubs(boolean stubs) {
|
||||||
@@ -87,13 +87,13 @@ public class CompileSession {
|
|||||||
if(path == null)
|
if(path == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VirtualFile vFile = myEnvironment.getLocalFileSystem().findFileByPath(path);
|
VirtualFile vFile = environment.getLocalFileSystem().findFileByPath(path);
|
||||||
if (vFile == null) {
|
if (vFile == null) {
|
||||||
myErrors.add("File/directory not found: " + path);
|
errors.add("File/directory not found: " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!vFile.isDirectory() && vFile.getFileType() != JetFileType.INSTANCE) {
|
if (!vFile.isDirectory() && vFile.getFileType() != JetFileType.INSTANCE) {
|
||||||
myErrors.add("Not a Kotlin file: " + path);
|
errors.add("Not a Kotlin file: " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +110,11 @@ public class CompileSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VirtualFile fileByPath = myEnvironment.getLocalFileSystem().findFileByPath(file.getAbsolutePath());
|
VirtualFile fileByPath = environment.getLocalFileSystem().findFileByPath(file.getAbsolutePath());
|
||||||
if (fileByPath != null) {
|
if (fileByPath != null) {
|
||||||
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(fileByPath);
|
PsiFile psiFile = PsiManager.getInstance(environment.getProject()).findFile(fileByPath);
|
||||||
if(psiFile instanceof JetFile) {
|
if(psiFile instanceof JetFile) {
|
||||||
mySourceFiles.add((JetFile) psiFile);
|
sourceFiles.add((JetFile)psiFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,29 +128,29 @@ public class CompileSession {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (vFile.getFileType() == JetFileType.INSTANCE) {
|
if (vFile.getFileType() == JetFileType.INSTANCE) {
|
||||||
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile);
|
PsiFile psiFile = PsiManager.getInstance(environment.getProject()).findFile(vFile);
|
||||||
if (psiFile instanceof JetFile) {
|
if (psiFile instanceof JetFile) {
|
||||||
mySourceFiles.add((JetFile) psiFile);
|
sourceFiles.add((JetFile)psiFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JetFile> getSourceFileNamespaces() {
|
public List<JetFile> getSourceFileNamespaces() {
|
||||||
return mySourceFiles;
|
return sourceFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean analyze() {
|
public boolean analyze() {
|
||||||
for (String error : myErrors) {
|
for (String error : errors) {
|
||||||
myMessageCollector.report(Severity.ERROR, error, null, -1, -1);
|
messageCollector.report(Severity.ERROR, error, null, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSyntaxErrors();
|
reportSyntaxErrors();
|
||||||
analyzeAndReportSemanticErrors();
|
analyzeAndReportSemanticErrors();
|
||||||
|
|
||||||
myMessageCollector.printTo(myErrorStream);
|
messageCollector.printTo(errorStream);
|
||||||
|
|
||||||
return !myMessageCollector.hasErrors();
|
return !messageCollector.hasErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,18 +169,18 @@ public class CompileSession {
|
|||||||
private void analyzeAndReportSemanticErrors() {
|
private void analyzeAndReportSemanticErrors() {
|
||||||
Predicate<PsiFile> filesToAnalyzeCompletely =
|
Predicate<PsiFile> filesToAnalyzeCompletely =
|
||||||
stubs ? Predicates.<PsiFile>alwaysFalse() : Predicates.<PsiFile>alwaysTrue();
|
stubs ? Predicates.<PsiFile>alwaysFalse() : Predicates.<PsiFile>alwaysTrue();
|
||||||
myBindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
myEnvironment.getProject(), mySourceFiles, filesToAnalyzeCompletely, JetControlFlowDataTraceFactory.EMPTY);
|
environment.getProject(), sourceFiles, filesToAnalyzeCompletely, JetControlFlowDataTraceFactory.EMPTY);
|
||||||
|
|
||||||
for (Diagnostic diagnostic : myBindingContext.getBindingContext().getDiagnostics()) {
|
for (Diagnostic diagnostic : bindingContext.getBindingContext().getDiagnostics()) {
|
||||||
reportDiagnostic(myMessageCollector, diagnostic);
|
reportDiagnostic(messageCollector, diagnostic);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportIncompleteHierarchies(myMessageCollector);
|
reportIncompleteHierarchies(messageCollector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportIncompleteHierarchies(MessageCollector collector) {
|
private void reportIncompleteHierarchies(MessageCollector collector) {
|
||||||
Collection<ClassDescriptor> incompletes = myBindingContext.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
Collection<ClassDescriptor> incompletes = bindingContext.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
||||||
if (!incompletes.isEmpty()) {
|
if (!incompletes.isEmpty()) {
|
||||||
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
|
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
|
||||||
for (ClassDescriptor incomplete : incompletes) {
|
for (ClassDescriptor incomplete : incompletes) {
|
||||||
@@ -191,14 +191,14 @@ public class CompileSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reportSyntaxErrors() {
|
private void reportSyntaxErrors() {
|
||||||
for (JetFile file : mySourceFiles) {
|
for (JetFile file : sourceFiles) {
|
||||||
file.accept(new PsiRecursiveElementWalkingVisitor() {
|
file.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitErrorElement(PsiErrorElement element) {
|
public void visitErrorElement(PsiErrorElement element) {
|
||||||
String description = element.getErrorDescription();
|
String description = element.getErrorDescription();
|
||||||
String message = StringUtil.isEmpty(description) ? "Syntax error" : description;
|
String message = StringUtil.isEmpty(description) ? "Syntax error" : description;
|
||||||
Diagnostic diagnostic = DiagnosticFactory.create(Severity.ERROR, message).on(element);
|
Diagnostic diagnostic = DiagnosticFactory.create(Severity.ERROR, message).on(element);
|
||||||
reportDiagnostic(myMessageCollector, diagnostic);
|
reportDiagnostic(messageCollector, diagnostic);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -213,16 +213,16 @@ public class CompileSession {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassFileFactory generate(boolean module) {
|
public ClassFileFactory generate(boolean module) {
|
||||||
Project project = myEnvironment.getProject();
|
Project project = environment.getProject();
|
||||||
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), myIsVerbose ? new BackendProgress() : Progress.DEAF);
|
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), isVerbose ? new BackendProgress() : Progress.DEAF);
|
||||||
generationState.compileCorrectFiles(myBindingContext, mySourceFiles, CompilationErrorHandler.THROW_EXCEPTION, true);
|
generationState.compileCorrectFiles(bindingContext, sourceFiles, CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||||
ClassFileFactory answer = generationState.getFactory();
|
ClassFileFactory answer = generationState.getFactory();
|
||||||
|
|
||||||
List<CompilerPlugin> plugins = myEnvironment.getCompilerPlugins();
|
List<CompilerPlugin> plugins = environment.getCompilerPlugins();
|
||||||
if (!module) {
|
if (!module) {
|
||||||
if (plugins != null) {
|
if (plugins != null) {
|
||||||
for (CompilerPlugin plugin : plugins) {
|
for (CompilerPlugin plugin : plugins) {
|
||||||
plugin.processFiles(myBindingContext.getBindingContext(), getSourceFileNamespaces());
|
plugin.processFiles(bindingContext.getBindingContext(), getSourceFileNamespaces());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ public class CompileSession {
|
|||||||
private class BackendProgress implements Progress {
|
private class BackendProgress implements Progress {
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
myErrorStream.println(myMessageRenderer.render(Severity.LOGGING, message, null, -1, -1));
|
errorStream.println(messageRenderer.render(Severity.LOGGING, message, null, -1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.jetbrains.jet.compiler.CompileEnvironment;
|
import org.jetbrains.jet.compiler.CompileEnvironment;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -26,7 +25,7 @@ public class CompileTextTest extends CodegenTestCase {
|
|||||||
public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
||||||
CompileEnvironment compileEnvironment = new CompileEnvironment();
|
CompileEnvironment compileEnvironment = new CompileEnvironment();
|
||||||
compileEnvironment.getMyEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
compileEnvironment.getEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
||||||
ClassLoader classLoader = compileEnvironment.compileText(text);
|
ClassLoader classLoader = compileEnvironment.compileText(text);
|
||||||
Class<?> namespace = classLoader.loadClass("namespace");
|
Class<?> namespace = classLoader.loadClass("namespace");
|
||||||
Method x = namespace.getDeclaredMethod("x");
|
Method x = namespace.getDeclaredMethod("x");
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
TestCase.class.getClassLoader()));
|
TestCase.class.getClassLoader()));
|
||||||
|
|
||||||
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(
|
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(
|
||||||
session.getMyBindingContext().getStandardLibrary(),
|
session.getBindingContext().getStandardLibrary(),
|
||||||
session.getMyBindingContext().getBindingContext(),
|
session.getBindingContext().getBindingContext(),
|
||||||
session.getSourceFileNamespaces(),
|
session.getSourceFileNamespaces(),
|
||||||
getProject());
|
getProject());
|
||||||
JetTypeMapper typeMapper = injector.getJetTypeMapper();
|
JetTypeMapper typeMapper = injector.getJetTypeMapper();
|
||||||
@@ -110,7 +110,7 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
if(decl instanceof JetClass) {
|
if(decl instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) decl;
|
JetClass jetClass = (JetClass) decl;
|
||||||
|
|
||||||
ClassDescriptor descriptor = (ClassDescriptor) session.getMyBindingContext().getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
ClassDescriptor descriptor = (ClassDescriptor) session.getBindingContext().getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
||||||
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
||||||
CodegenUtil.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
CodegenUtil.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user