Remove external packages search from file base declaration provider
External package should be found because of proper module configuration
This commit is contained in:
+3
-11
@@ -40,7 +40,6 @@ import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
@@ -100,24 +99,17 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
||||
@NotNull InjectorForJavaDescriptorResolver injector,
|
||||
boolean addBuiltIns
|
||||
) {
|
||||
final JavaClassFinderImpl classFinder = injector.getJavaClassFinder();
|
||||
|
||||
// TODO: Replace with stub declaration provider
|
||||
GlobalContextImpl globalContext = injector.getGlobalContext();
|
||||
FileBasedDeclarationProviderFactory declarationProviderFactory = new FileBasedDeclarationProviderFactory(
|
||||
globalContext.getStorageManager(),
|
||||
files,
|
||||
new Predicate<FqName>() {
|
||||
@Override
|
||||
public boolean apply(FqName fqName) {
|
||||
return classFinder.findPackage(fqName) != null || KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(fqName);
|
||||
}
|
||||
});
|
||||
files);
|
||||
|
||||
ModuleDescriptorImpl module = injector.getModule();
|
||||
|
||||
if (addBuiltIns) {
|
||||
module.addFragmentProvider(DependencyKind.BUILT_INS, KotlinBuiltIns.getInstance().getBuiltInsModule().getPackageFragmentProvider());
|
||||
module.addFragmentProvider(DependencyKind.BUILT_INS,
|
||||
KotlinBuiltIns.getInstance().getBuiltInsModule().getPackageFragmentProvider());
|
||||
}
|
||||
|
||||
return new InjectorForLazyResolve(project, globalContext, module, declarationProviderFactory, trace).getResolveSession();
|
||||
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.lang.resolve.lazy.declarations;
|
||||
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EmptyPackageMemberDeclarationProvider implements PackageMemberDeclarationProvider {
|
||||
|
||||
public static final EmptyPackageMemberDeclarationProvider INSTANCE = new EmptyPackageMemberDeclarationProvider();
|
||||
|
||||
private EmptyPackageMemberDeclarationProvider() {}
|
||||
|
||||
@Override
|
||||
public Collection<FqName> getAllDeclaredPackages() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<NavigatablePsiElement> getPackageDeclarations(FqName fqName) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JetDeclaration> getAllDeclarations() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<JetNamedFunction> getFunctionDeclarations(@NotNull Name name) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<JetProperty> getPropertyDeclarations(@NotNull Name name) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<JetClassOrObject> getClassOrObjectDeclarations(@NotNull Name name) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+5
-19
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.lazy.declarations;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.*;
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import com.intellij.util.Function;
|
||||
@@ -47,24 +46,13 @@ public class FileBasedDeclarationProviderFactory implements DeclarationProviderF
|
||||
private final Set<FqName> declaredPackages = Sets.newHashSet();
|
||||
}
|
||||
|
||||
private final Predicate<FqName> isPackageDeclaredExternally;
|
||||
|
||||
private final StorageManager storageManager;
|
||||
private final NotNullLazyValue<Index> index;
|
||||
|
||||
private final MemoizedFunctionToNullable<FqName, PackageMemberDeclarationProvider> packageDeclarationProviders;
|
||||
|
||||
public FileBasedDeclarationProviderFactory(@NotNull StorageManager storageManager, @NotNull Collection<JetFile> files) {
|
||||
this(storageManager, files, Predicates.<FqName>alwaysFalse());
|
||||
}
|
||||
|
||||
public FileBasedDeclarationProviderFactory(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull final Collection<JetFile> files,
|
||||
@NotNull Predicate<FqName> isPackageDeclaredExternally
|
||||
) {
|
||||
public FileBasedDeclarationProviderFactory(@NotNull StorageManager storageManager, @NotNull final Collection<JetFile> files) {
|
||||
this.storageManager = storageManager;
|
||||
this.isPackageDeclaredExternally = isPackageDeclaredExternally;
|
||||
this.index = storageManager.createLazyValue(new Function0<Index>() {
|
||||
@Override
|
||||
public Index invoke() {
|
||||
@@ -143,14 +131,12 @@ public class FileBasedDeclarationProviderFactory implements DeclarationProviderF
|
||||
|
||||
@Nullable
|
||||
public PackageMemberDeclarationProvider createPackageMemberDeclarationProvider(@NotNull FqName packageFqName) {
|
||||
if (!isPackageDeclaredExplicitly(packageFqName)) {
|
||||
if (isPackageDeclaredExternally.apply(packageFqName)) {
|
||||
return EmptyPackageMemberDeclarationProvider.INSTANCE;
|
||||
}
|
||||
return null;
|
||||
if (isPackageDeclaredExplicitly(packageFqName)) {
|
||||
return new FileBasedPackageMemberDeclarationProvider(
|
||||
storageManager, packageFqName, this, index.invoke().filesByPackage.get(packageFqName));
|
||||
}
|
||||
|
||||
return new FileBasedPackageMemberDeclarationProvider(storageManager, packageFqName, this, index.invoke().filesByPackage.get(packageFqName));
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.libraries;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -219,13 +218,7 @@ public class JetSourceNavigationHelper {
|
||||
GlobalContextImpl globalContext = ContextPackage.GlobalContext();
|
||||
FileBasedDeclarationProviderFactory providerFactory = new FileBasedDeclarationProviderFactory(
|
||||
globalContext.getStorageManager(),
|
||||
getContainingFiles(candidates),
|
||||
new Predicate<FqName>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable FqName fqName) {
|
||||
return KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(fqName);
|
||||
}
|
||||
});
|
||||
getContainingFiles(candidates));
|
||||
|
||||
ModuleDescriptorImpl moduleDescriptor = new ModuleDescriptorImpl(Name.special("<library module>"),
|
||||
AnalyzerFacadeForJVM.DEFAULT_IMPORTS,
|
||||
|
||||
Reference in New Issue
Block a user