This commit is contained in:
Andrey Breslav
2013-08-28 11:45:27 +04:00
parent 2aca1dbbcd
commit 945786e628
6 changed files with 15 additions and 12 deletions
@@ -110,7 +110,7 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
if (declaration == null) {
BuiltInsReferenceResolver libraryReferenceResolver = project
.getComponent(BuiltInsReferenceResolver.class);
Collection<PsiElement> elements = libraryReferenceResolver.resolveStandardLibrarySymbol(descriptor);
Collection<PsiElement> elements = libraryReferenceResolver.resolveBuiltInSymbol(descriptor);
return !elements.isEmpty();
}
@@ -40,7 +40,7 @@ public final class DescriptorToDeclarationUtil {
if (elements.isEmpty()) {
BuiltInsReferenceResolver libraryReferenceResolver =
project.getComponent(BuiltInsReferenceResolver.class);
elements = libraryReferenceResolver.resolveStandardLibrarySymbol(descriptor);
elements = libraryReferenceResolver.resolveBuiltInSymbol(descriptor);
}
if (!elements.isEmpty()) {
@@ -85,14 +85,14 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
jetNamespace.setMemberScope(scope);
List<JetFile> jetBuiltInsFiles = getJetBuiltinsFiles();
List<JetFile> jetBuiltInsFiles = getJetBuiltInsFiles();
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, jetBuiltInsFiles);
builtInsSources = Sets.newHashSet(jetBuiltInsFiles);
bindingContext = context.getBindingContext();
}
private List<JetFile> getJetBuiltinsFiles() {
private List<JetFile> getJetBuiltInsFiles() {
URL url = LightClassUtil.getBuiltInsDirUrl();
VirtualFile vf = VfsUtil.findFileByURL(url);
assert vf != null : "Virtual file not found by URL: " + url;
@@ -167,7 +167,10 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
}
@NotNull
public Collection<PsiElement> resolveStandardLibrarySymbol(@NotNull BindingContext originalContext, @Nullable JetReferenceExpression referenceExpression) {
public Collection<PsiElement> resolveBuiltInSymbol(
@NotNull BindingContext originalContext,
@Nullable JetReferenceExpression referenceExpression
) {
if (bindingContext == null) {
assert DumbService.getInstance(myProject).isDumb() : "Builtins component wasn't initialized properly";
return Collections.emptyList();
@@ -175,11 +178,11 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
DeclarationDescriptor declarationDescriptor = originalContext.get(BindingContext.REFERENCE_TARGET, referenceExpression);
return declarationDescriptor != null ? resolveStandardLibrarySymbol(declarationDescriptor) : Collections.<PsiElement>emptyList();
return declarationDescriptor != null ? resolveBuiltInSymbol(declarationDescriptor) : Collections.<PsiElement>emptyList();
}
@NotNull
public Collection<PsiElement> resolveStandardLibrarySymbol(@NotNull DeclarationDescriptor declarationDescriptor) {
public Collection<PsiElement> resolveBuiltInSymbol(@NotNull DeclarationDescriptor declarationDescriptor) {
if (bindingContext == null) {
assert DumbService.getInstance(myProject).isDumb() : "Builtins component wasn't initialized properly";
return Collections.emptyList();
@@ -101,10 +101,10 @@ public class JetPropertyDelegationMethodsReference implements PsiPolyVariantRefe
results.add(new PsiElementResolveResult(declarationInDecompiledFile));
}
Collection<PsiElement> stdlibSymbols =
project.getComponent(BuiltInsReferenceResolver.class).resolveStandardLibrarySymbol(resultingDescriptor);
Collection<PsiElement> builtInSymbols =
project.getComponent(BuiltInsReferenceResolver.class).resolveBuiltInSymbol(resultingDescriptor);
for (PsiElement symbol : stdlibSymbols) {
for (PsiElement symbol : builtInSymbols) {
results.add(new PsiElementResolveResult(symbol));
}
}
@@ -163,6 +163,6 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
private Collection<PsiElement> resolveStandardLibrarySymbol(@NotNull BindingContext bindingContext) {
return myExpression.getProject().getComponent(BuiltInsReferenceResolver.class)
.resolveStandardLibrarySymbol(bindingContext, myExpression);
.resolveBuiltInSymbol(bindingContext, myExpression);
}
}
@@ -75,7 +75,7 @@ public class BuiltInsReferenceResolverTest extends ResolveTestCase {
BuiltInsReferenceResolver referenceResolver = getProject().getComponent(BuiltInsReferenceResolver.class);
for (DeclarationDescriptor descriptor : getAllStandardDescriptors(KotlinBuiltIns.getInstance().getBuiltInsPackage())) {
if (descriptor instanceof NamespaceDescriptor && "jet".equals(descriptor.getName().asString())) continue;
assertNotNull("Can't resolve " + descriptor, referenceResolver.resolveStandardLibrarySymbol(descriptor));
assertNotNull("Can't resolve " + descriptor, referenceResolver.resolveBuiltInSymbol(descriptor));
}
}