Revert "+-JDK and -NOSTDLIB options"
This reverts commit 8222011874.
+- JDK will be restored in next commit
removal of -STDLIB was requested by Andrey Breslav
This commit is contained in:
@@ -30,7 +30,7 @@ public class GenerationState {
|
||||
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory) {
|
||||
this.project = project;
|
||||
this.standardLibrary = JetStandardLibrary.getJetStandardLibrary(project, true);
|
||||
this.standardLibrary = JetStandardLibrary.getJetStandardLibrary(project);
|
||||
this.factory = new ClassFileFactory(builderFactory, this);
|
||||
this.intrinsics = new IntrinsicMethods(project, standardLibrary);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class GenerationState {
|
||||
|
||||
public void compile(JetFile psiFile) {
|
||||
final JetNamespace namespace = psiFile.getRootNamespace();
|
||||
final BindingContext bindingContext = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS, true).analyzeNamespace(namespace, JetControlFlowDataTraceFactory.EMPTY);
|
||||
final BindingContext bindingContext = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS).analyzeNamespace(namespace, JetControlFlowDataTraceFactory.EMPTY);
|
||||
AnalyzingUtils.throwExceptionOnErrors(bindingContext);
|
||||
compileCorrectNamespaces(bindingContext, Collections.singletonList(namespace));
|
||||
// NamespaceCodegen codegen = forNamespace(namespace);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CompileSession {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final AnalyzingUtils instance = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS, true);
|
||||
final AnalyzingUtils instance = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS);
|
||||
List<JetNamespace> allNamespaces = new ArrayList<JetNamespace>(mySourceFileNamespaces);
|
||||
allNamespaces.addAll(myLibrarySourceFileNamespaces);
|
||||
myBindingContext = instance.analyzeNamespaces(myEnvironment.getProject(), allNamespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AnalyzerFacade {
|
||||
}
|
||||
};
|
||||
|
||||
private static final AnalyzingUtils ANALYZING_UTILS = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS, true);
|
||||
private static final AnalyzingUtils ANALYZING_UTILS = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS);
|
||||
private final static Key<CachedValue<BindingContext>> BINDING_CONTEXT = Key.create("BINDING_CONTEXT");
|
||||
private static final Object lock = new Object();
|
||||
|
||||
|
||||
@@ -17,11 +17,7 @@ public class JetSemanticServices {
|
||||
}
|
||||
|
||||
public static JetSemanticServices createSemanticServices(Project project) {
|
||||
return createSemanticServices(project, true);
|
||||
}
|
||||
|
||||
public static JetSemanticServices createSemanticServices(Project project, boolean loadFullLibrary) {
|
||||
return new JetSemanticServices(JetStandardLibrary.getJetStandardLibrary(project, loadFullLibrary));
|
||||
return new JetSemanticServices(JetStandardLibrary.getJetStandardLibrary(project));
|
||||
}
|
||||
|
||||
private final JetStandardLibrary standardLibrary;
|
||||
|
||||
@@ -28,8 +28,8 @@ import java.util.*;
|
||||
* @author abreslav
|
||||
*/
|
||||
public class AnalyzingUtils {
|
||||
public static AnalyzingUtils getInstance(@NotNull ImportingStrategy importingStrategy, boolean loadStdlib) {
|
||||
return new AnalyzingUtils(importingStrategy, loadStdlib);
|
||||
public static AnalyzingUtils getInstance(@NotNull ImportingStrategy importingStrategy) {
|
||||
return new AnalyzingUtils(importingStrategy);
|
||||
}
|
||||
|
||||
public static void checkForSyntacticErrors(@NotNull PsiElement root) {
|
||||
@@ -53,11 +53,9 @@ public class AnalyzingUtils {
|
||||
}
|
||||
|
||||
private final ImportingStrategy importingStrategy;
|
||||
private final boolean loadStdlib;
|
||||
|
||||
private AnalyzingUtils(ImportingStrategy importingStrategy, boolean loadStdlib) {
|
||||
private AnalyzingUtils(ImportingStrategy importingStrategy) {
|
||||
this.importingStrategy = importingStrategy;
|
||||
this.loadStdlib = loadStdlib;
|
||||
}
|
||||
|
||||
public BindingContext analyzeNamespace(@NotNull JetNamespace namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
@@ -73,7 +71,7 @@ public class AnalyzingUtils {
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project, loadStdlib);
|
||||
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project);
|
||||
|
||||
JetScope libraryScope = semanticServices.getStandardLibrary().getLibraryScope();
|
||||
ModuleDescriptor owner = new ModuleDescriptor("<module>");
|
||||
|
||||
@@ -29,24 +29,16 @@ import java.util.Set;
|
||||
public class JetStandardLibrary {
|
||||
|
||||
// TODO : consider releasing this memory
|
||||
private static JetStandardLibrary cachedFullLibrary = null;
|
||||
private static JetStandardLibrary cachedQuickLibrary = null;
|
||||
private static JetStandardLibrary cachedLibrary = null;
|
||||
// private static final Map<Project, JetStandardLibrary> standardLibraryCache = new HashMap<Project, JetStandardLibrary>();
|
||||
|
||||
// TODO : double checked locking
|
||||
synchronized
|
||||
public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project, boolean loadFullLibrary) {
|
||||
if (loadFullLibrary) {
|
||||
if (cachedFullLibrary == null) {
|
||||
cachedFullLibrary = new JetStandardLibrary(project, true);
|
||||
}
|
||||
return cachedFullLibrary;
|
||||
} else {
|
||||
if (cachedQuickLibrary == null) {
|
||||
cachedQuickLibrary = new JetStandardLibrary(project, false);
|
||||
}
|
||||
return cachedQuickLibrary;
|
||||
public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
|
||||
if (cachedLibrary == null) {
|
||||
cachedLibrary = new JetStandardLibrary(project);
|
||||
}
|
||||
return cachedLibrary;
|
||||
// JetStandardLibrary standardLibrary = standardLibraryCache.get(project);
|
||||
// if (standardLibrary == null) {
|
||||
// standardLibrary = new JetStandardLibrary(project);
|
||||
@@ -55,12 +47,6 @@ public class JetStandardLibrary {
|
||||
// return standardLibrary;
|
||||
}
|
||||
|
||||
public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
|
||||
return getJetStandardLibrary(project, true);
|
||||
}
|
||||
|
||||
private final boolean loadFullLibrary;
|
||||
|
||||
private JetScope libraryScope;
|
||||
|
||||
private ClassDescriptor numberClass;
|
||||
@@ -136,27 +122,20 @@ public class JetStandardLibrary {
|
||||
private NamespaceDescriptor typeInfoNamespace;
|
||||
private Set<FunctionDescriptor> typeInfoFunction;
|
||||
|
||||
private JetStandardLibrary(@NotNull Project project, boolean loadFullLibrary) {
|
||||
this.loadFullLibrary = loadFullLibrary;
|
||||
|
||||
private JetStandardLibrary(@NotNull Project project) {
|
||||
// TODO : review
|
||||
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/Library.jet");
|
||||
try {
|
||||
JetFile file = null;
|
||||
if (loadFullLibrary) {
|
||||
// TODO : review
|
||||
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/Library.jet");
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
file = (JetFile) PsiFileFactory.getInstance(project).createFileFromText("Library.jet",
|
||||
JetFileType.INSTANCE, FileUtil.loadTextAndClose(new InputStreamReader(stream)));
|
||||
}
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
JetFile file = (JetFile) PsiFileFactory.getInstance(project).createFileFromText("Library.jet",
|
||||
JetFileType.INSTANCE, FileUtil.loadTextAndClose(new InputStreamReader(stream)));
|
||||
|
||||
JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this);
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope");
|
||||
// this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations());
|
||||
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
|
||||
if (loadFullLibrary) {
|
||||
TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
||||
}
|
||||
TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
||||
// this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
||||
|
||||
AnalyzingUtils.throwExceptionOnErrors(bindingTraceContext.getBindingContext());
|
||||
@@ -174,11 +153,6 @@ public class JetStandardLibrary {
|
||||
private void initStdClasses() {
|
||||
if(libraryScope == null) {
|
||||
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
||||
|
||||
if (!loadFullLibrary) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.numberClass = (ClassDescriptor) libraryScope.getClassifier("Number");
|
||||
this.byteClass = (ClassDescriptor) libraryScope.getClassifier("Byte");
|
||||
this.charClass = (ClassDescriptor) libraryScope.getClassifier("Char");
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// -JDK
|
||||
|
||||
fun test() : Unit {
|
||||
var x : Int? = 0
|
||||
var y : Int = 0
|
||||
@@ -15,4 +13,4 @@ fun test() : Unit {
|
||||
x <!USELESS_CAST!>as?<!> Int? : Int?
|
||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int?
|
||||
()
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class CheckerTestUtilTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void test(PsiFile psiFile) {
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(ImportingStrategy.NONE, true), (JetFile) psiFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(ImportingStrategy.NONE), (JetFile) psiFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, bindingContext).toString();
|
||||
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
|
||||
@@ -8,11 +8,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,13 +42,7 @@ public class FullJetPsiCheckerTest extends JetLiteFixture {
|
||||
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
myFile = createPsiFile(myName, clearText);
|
||||
|
||||
boolean loadStdlib = !expectedText.contains("-STDLIB");
|
||||
boolean importJdk = !expectedText.contains("-JDK");
|
||||
|
||||
ImportingStrategy importingStrategy = importJdk ? JavaDefaultImports.JAVA_DEFAULT_IMPORTS : ImportingStrategy.NONE;
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(importingStrategy, loadStdlib), myFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(myFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,12 +40,7 @@ public class QuickJetPsiCheckerTest extends JetLiteFixture {
|
||||
|
||||
createAndCheckPsiFile(name, clearText);
|
||||
JetFile jetFile = (JetFile) myFile;
|
||||
boolean loadStdlib = !expectedText.contains("-STDLIB");
|
||||
boolean importJdk = expectedText.contains("+JDK");
|
||||
|
||||
ImportingStrategy importingStrategy = importJdk ? JavaDefaultImports.JAVA_DEFAULT_IMPORTS : ImportingStrategy.NONE;
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(importingStrategy, loadStdlib), jetFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(ImportingStrategy.NONE), jetFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
@Override
|
||||
protected ExpectedResolveData getExpectedResolveData() {
|
||||
Project project = getProject();
|
||||
JetStandardLibrary lib = JetStandardLibrary.getJetStandardLibrary(project, true);
|
||||
JetStandardLibrary lib = JetStandardLibrary.getJetStandardLibrary(project);
|
||||
Map<String, DeclarationDescriptor> nameToDescriptor = new HashMap<String, DeclarationDescriptor>();
|
||||
nameToDescriptor.put("std::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
|
||||
FunctionDescriptor descriptorForGet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "get", lib.getIntType());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class JetCompiler implements TranslatingCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS, true).analyzeNamespaces(
|
||||
BindingContext bindingContext = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS).analyzeNamespaces(
|
||||
compileContext.getProject(), namespaces,
|
||||
Predicates.<PsiFile>alwaysTrue(),
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
|
||||
@@ -211,7 +211,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
|
||||
|
||||
if (dirty.size() > 0) {
|
||||
final BindingContext context = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS, true).shallowAnalyzeFiles(dirty);
|
||||
final BindingContext context = AnalyzingUtils.getInstance(JavaDefaultImports.JAVA_DEFAULT_IMPORTS).shallowAnalyzeFiles(dirty);
|
||||
state.compileCorrectNamespaces(context, AnalyzingUtils.collectRootNamespaces(dirty));
|
||||
state.getFactory().files();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user