merge copy-paste after excessive inline in e6fda5
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 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.codegen;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Stepan Koltsov
|
||||||
|
*/
|
||||||
|
public class GenerationUtils {
|
||||||
|
|
||||||
|
public static ClassFileFactory compileFileGetClassFileFactory(@NotNull JetFile psiFile) {
|
||||||
|
return compileFileGetGenerationState(psiFile).getFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenerationState compileFileGetGenerationState(JetFile psiFile) {
|
||||||
|
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
||||||
|
GenerationState state = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
||||||
|
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
|||||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
|
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||||
@@ -143,6 +144,17 @@ public class AnalyzerFacadeForJVM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AnalyzeExhaust analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
|
JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||||
|
AnalyzingUtils.checkForSyntacticErrors(file);
|
||||||
|
|
||||||
|
AnalyzeExhaust analyzeExhaust = analyzeOneFileWithJavaIntegration(file, flowDataTraceFactory);
|
||||||
|
|
||||||
|
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||||
|
|
||||||
|
return analyzeExhaust;
|
||||||
|
}
|
||||||
|
|
||||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory);
|
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,14 +120,14 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String generateToText() {
|
protected String generateToText() {
|
||||||
AnalyzingUtils.checkForSyntacticErrors(myFile);
|
return generateCommon(ClassBuilderFactories.TEXT).createText();
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(myFile, JetControlFlowDataTraceFactory.EMPTY);
|
}
|
||||||
GenerationState state = new GenerationState(getProject(), ClassBuilderFactories.TEXT, analyzeExhaust, Collections.singletonList(myFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
private GenerationState generateCommon(ClassBuilderFactory classBuilderFactory) {
|
||||||
|
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(myFile, JetControlFlowDataTraceFactory.EMPTY);
|
||||||
|
GenerationState state = new GenerationState(getProject(), classBuilderFactory, analyzeExhaust, Collections.singletonList(myFile));
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
|
return state;
|
||||||
return state.createText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class generateNamespaceClass() {
|
protected Class generateNamespaceClass() {
|
||||||
@@ -166,15 +166,9 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
|||||||
@NotNull
|
@NotNull
|
||||||
protected ClassFileFactory generateClassesInFile() {
|
protected ClassFileFactory generateClassesInFile() {
|
||||||
try {
|
try {
|
||||||
AnalyzingUtils.checkForSyntacticErrors(myFile);
|
ClassBuilderFactory classBuilderFactory = ClassBuilderFactories.binaries(false);
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(myFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(myFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
return generateCommon(classBuilderFactory).getFactory();
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
return state.getFactory();
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
System.out.println(generateToText());
|
System.out.println(generateToText());
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@@ -26,15 +26,8 @@ import junit.framework.Test;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
|
||||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
|
||||||
import org.jetbrains.jet.codegen.GenerationState;
|
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
@@ -82,15 +75,7 @@ public class CompileJavaAgainstKotlinTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
ClassFileFactory classFileFactory = GenerationUtils.compileFileGetClassFileFactory(psiFile);
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(jetCoreEnvironment.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
|
||||||
|
|
||||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.codegen.*;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -41,7 +37,6 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
@@ -94,16 +89,7 @@ public class CompileKotlinAgainstKotlinTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
ClassFileFactory classFileFactory = GenerationUtils.compileFileGetClassFileFactory(psiFile);
|
||||||
|
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(jetCoreEnvironment.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
|
||||||
|
|
||||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, aDir.getPath());
|
CompileEnvironment.writeToOutputDirectory(classFileFactory, aDir.getPath());
|
||||||
|
|
||||||
@@ -121,15 +107,7 @@ public class CompileKotlinAgainstKotlinTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
ClassFileFactory classFileFactory = GenerationUtils.compileFileGetClassFileFactory(psiFile);
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(jetCoreEnvironment.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
|
||||||
|
|
||||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, bDir.getPath());
|
CompileEnvironment.writeToOutputDirectory(classFileFactory, bDir.getPath());
|
||||||
|
|
||||||
|
|||||||
@@ -85,11 +85,9 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
|
psiFile, JetControlFlowDataTraceFactory.EMPTY)
|
||||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY)
|
.getBindingContext();
|
||||||
.getBindingContext();
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(bindingContext);
|
|
||||||
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel("test"));
|
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,26 +26,18 @@ import junit.framework.Test;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
|
||||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
|
||||||
import org.jetbrains.jet.codegen.GenerationState;
|
|
||||||
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.FqName;
|
import org.jetbrains.jet.lang.resolve.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile Kotlin and then parse model from .class files.
|
* Compile Kotlin and then parse model from .class files.
|
||||||
@@ -75,19 +67,13 @@ public class ReadKotlinBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
GenerationState state = GenerationUtils.compileFileGetGenerationState(psiFile);
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(jetCoreEnvironment.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
ClassFileFactory classFileFactory = state.getFactory();
|
||||||
|
|
||||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
||||||
|
|
||||||
NamespaceDescriptor namespaceFromSource = (NamespaceDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiFile);
|
NamespaceDescriptor namespaceFromSource = (NamespaceDescriptor) state.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiFile);
|
||||||
|
|
||||||
Assert.assertEquals("test", namespaceFromSource.getName());
|
Assert.assertEquals("test", namespaceFromSource.getName());
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.codegen.*;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -48,7 +44,6 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -85,16 +80,7 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
|||||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||||
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||||
|
|
||||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
ClassFileFactory classFileFactory = GenerationUtils.compileFileGetClassFileFactory(psiFile);
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
|
||||||
GenerationState state = new GenerationState(jetCoreEnvironment.getProject(), ClassBuilderFactories.binaries(false),
|
|
||||||
analyzeExhaust, Collections.singletonList(psiFile));
|
|
||||||
|
|
||||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
|
||||||
analyzeExhaust.getBindingContext();
|
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
|
||||||
|
|
||||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user