diagnostics for EA-73611
This commit is contained in:
@@ -492,6 +492,11 @@ public class ReplInterpreter {
|
||||
return this.delegateFactory.getPackageMemberDeclarationProvider(packageFqName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void diagnoseMissingPackageFragment(KtFile file) {
|
||||
this.delegateFactory.diagnoseMissingPackageFragment(file);
|
||||
}
|
||||
|
||||
public static class AdaptablePackageMemberDeclarationProvider extends DelegatePackageMemberDeclarationProvider {
|
||||
@NotNull
|
||||
private PackageMemberDeclarationProvider delegateProvider;
|
||||
|
||||
+10
-2
@@ -243,9 +243,17 @@ public class LazyDeclarationResolver {
|
||||
KtDeclaration parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(declaration);
|
||||
boolean isTopLevel = parentDeclaration == null;
|
||||
if (isTopLevel) { // for top level declarations we search directly in package because of possible conflicts with imports
|
||||
FqName fqName = ((KtFile) declaration.getContainingFile()).getPackageFqName();
|
||||
KtFile ktFile = (KtFile) declaration.getContainingFile();
|
||||
FqName fqName = ktFile.getPackageFqName();
|
||||
LazyPackageDescriptor packageDescriptor = topLevelDescriptorProvider.getPackageFragment(fqName);
|
||||
assert packageDescriptor != null;
|
||||
if (packageDescriptor == null) {
|
||||
if (topLevelDescriptorProvider instanceof LazyClassContext) {
|
||||
((LazyClassContext) topLevelDescriptorProvider).getDeclarationProviderFactory().diagnoseMissingPackageFragment(ktFile);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Cannot find package fragment for file " + ktFile.getName() + " with package " + fqName);
|
||||
}
|
||||
}
|
||||
return packageDescriptor.getMemberScope();
|
||||
}
|
||||
else {
|
||||
|
||||
+6
@@ -20,6 +20,7 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.storage.MemoizedFunctionToNullable;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
|
||||
@@ -43,4 +44,9 @@ public abstract class AbstractDeclarationProviderFactory implements DeclarationP
|
||||
public PackageMemberDeclarationProvider getPackageMemberDeclarationProvider(@NotNull FqName packageFqName) {
|
||||
return packageDeclarationProviders.invoke(packageFqName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void diagnoseMissingPackageFragment(KtFile file) {
|
||||
throw new IllegalStateException("Cannot find package fragment for file " + file.getName() + " with package " + file.getPackageFqName());
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.lazy.declarations;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo;
|
||||
|
||||
public interface DeclarationProviderFactory {
|
||||
@@ -27,4 +28,6 @@ public interface DeclarationProviderFactory {
|
||||
|
||||
@Nullable
|
||||
PackageMemberDeclarationProvider getPackageMemberDeclarationProvider(@NotNull FqName packageFqName);
|
||||
|
||||
void diagnoseMissingPackageFragment(KtFile file);
|
||||
}
|
||||
|
||||
+4
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
@@ -133,6 +134,9 @@ class LocalClassDescriptorHolder(
|
||||
throw UnsupportedOperationException("Should not be called for top-level declarations")
|
||||
}
|
||||
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile?) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
override val annotationResolver = this@LocalClassDescriptorHolder.annotationResolver
|
||||
override val lookupTracker: LookupTracker = LookupTracker.DO_NOTHING
|
||||
|
||||
+7
-2
@@ -18,12 +18,12 @@ package org.jetbrains.kotlin.idea.stubindex.resolve
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||
|
||||
public class PluginDeclarationProviderFactory(
|
||||
private val project: Project,
|
||||
@@ -53,4 +53,9 @@ public class PluginDeclarationProviderFactory(
|
||||
|
||||
return StubBasedPackageMemberDeclarationProvider(name, project, indexedFilesScope)
|
||||
}
|
||||
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile) {
|
||||
throw IllegalStateException("Cannot find package fragment for file ${file.name} with package ${file.packageFqName}, " +
|
||||
"vFile ${file.virtualFile}, nonIndexed ${file in nonIndexedFiles}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user