Resolving references to builtins: first loading Unit.jet, and then the rest of the library

Test data fixed to get rid of jet.src directory
This commit is contained in:
Andrey Breslav
2012-10-17 14:38:22 +04:00
parent c3881747af
commit 9387c974bd
6 changed files with 24 additions and 9 deletions
@@ -16,6 +16,8 @@
package org.jetbrains.jet.plugin.references;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
@@ -89,7 +91,14 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
jetNamespace.setMemberScope(scope);
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, getJetFiles("jet.src"));
Predicate<JetFile> jetFilesIndependentOfUnit = new Predicate<JetFile>() {
@Override
public boolean apply(@Nullable JetFile file) {
return "Unit.jet".equals(file.getName());
}
};
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace,
getJetFiles("jet", jetFilesIndependentOfUnit));
ClassDescriptor tuple0 = context.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, TUPLE0_FQ_NAME);
assert tuple0 != null;
@@ -99,14 +108,16 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
scope.addClassifierAlias(KotlinBuiltIns.getInstance().UNIT_ALIAS, tuple0);
jetNamespace.setMemberScope(scope);
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, getJetFiles("jet"));
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace,
getJetFiles("jet", Predicates.not(jetFilesIndependentOfUnit)));
AnalyzingUtils.throwExceptionOnErrors(context.getBindingContext());
bindingContext = context.getBindingContext();
}
}
private List<JetFile> getJetFiles(String dir) {
private List<JetFile> getJetFiles(String dir, final Predicate<JetFile> filter) {
URL url = StandardLibraryReferenceResolver.class.getResource("/" + dir + "/");
VirtualFile vf = VfsUtil.findFileByURL(url);
assert vf != null;
@@ -116,7 +127,11 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
return ContainerUtil.mapNotNull(psiDirectory.getFiles(), new Function<PsiFile, JetFile>() {
@Override
public JetFile fun(PsiFile file) {
return file instanceof JetFile ? (JetFile) file : null;
if (file instanceof JetFile) {
JetFile jetFile = (JetFile) file;
return filter.apply(jetFile) ? jetFile : null;
}
return null;
}
});
}
+1 -1
View File
@@ -1,2 +1,2 @@
var x : <ref>Any?
//jet.src/Any.jet:Any
//jet/Any.jet:Any
+1 -1
View File
@@ -1,4 +1,4 @@
fun f(p : () -> String) {
p.<ref>invoke()
}
//jet.src/Functions.jet:invoke
//jet/Functions.jet:invoke
+1 -1
View File
@@ -1,2 +1,2 @@
var x : <ref>Nothing
//jet.src/Nothing.jet:Nothing
//jet/Nothing.jet:Nothing
+1 -1
View File
@@ -1,2 +1,2 @@
var x = #(1, 2).<ref>_1
//jet.src/Tuples.jet:_1
//jet/Tuples.jet:_1
+1 -1
View File
@@ -1,2 +1,2 @@
var x : <ref>Unit?
//jet.src/Unit.jet:Tuple0
//jet/Unit.jet:Tuple0