Big refactoring continued. Migrating to package views and fragments.
This commit is contained in:
@@ -101,14 +101,6 @@ public class BindingContextUtils {
|
||||
return (JetFile) containingFile;
|
||||
}
|
||||
|
||||
// TODO these helper methods are added as a workaround to some compiler bugs in Kotlin...
|
||||
|
||||
// NOTE this is used by KDoc
|
||||
@Nullable
|
||||
public static NamespaceDescriptor namespaceDescriptor(@NotNull BindingContext context, @NotNull JetFile source) {
|
||||
return context.get(BindingContext.FILE_TO_NAMESPACE, source);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement doGetDescriptorToDeclaration(@NotNull BindingContext context, @NotNull DeclarationDescriptor descriptor) {
|
||||
return context.get(DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -51,7 +51,7 @@ public class LibrarySourceHacks {
|
||||
if (!(original instanceof CallableMemberDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
if (!(original.getContainingDeclaration() instanceof NamespaceDescriptor)) {
|
||||
if (!(original.getContainingDeclaration() instanceof PackageFragmentDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -111,7 +111,7 @@ public class DataFlowValueFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static IdentifierInfo createNamespaceInfo(Object id) {
|
||||
private static IdentifierInfo createPackageInfo(Object id) {
|
||||
return new IdentifierInfo(id, true, true);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class DataFlowValueFactory {
|
||||
return getIdForThisReceiver(declarationDescriptor);
|
||||
}
|
||||
else if (expression instanceof JetRootNamespaceExpression) {
|
||||
return createNamespaceInfo(JetModuleUtil.getRootNamespaceType(expression));
|
||||
return createPackageInfo(JetModuleUtil.getRootNamespaceType(expression));
|
||||
}
|
||||
return NO_IDENTIFIER_INFO;
|
||||
}
|
||||
@@ -179,8 +179,8 @@ public class DataFlowValueFactory {
|
||||
VariableDescriptor variableDescriptor = (VariableDescriptor) declarationDescriptor;
|
||||
return combineInfo(receiverInfo, createInfo(variableDescriptor, isStableVariable(variableDescriptor)));
|
||||
}
|
||||
if (declarationDescriptor instanceof NamespaceDescriptor) {
|
||||
return createNamespaceInfo(declarationDescriptor);
|
||||
if (declarationDescriptor instanceof PackageViewDescriptor) {
|
||||
return createPackageInfo(declarationDescriptor);
|
||||
}
|
||||
return NO_IDENTIFIER_INFO;
|
||||
}
|
||||
|
||||
@@ -186,21 +186,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
writableWorker.addFunctionAlias(name, functionDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
writableWorker.addNamespace(namespaceDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
return writableWorker.getDeclaredNamespace(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Multimap<Name, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName() {
|
||||
|
||||
@@ -105,15 +105,15 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
|
||||
int chunkStart = chunkIndex * CLASSES_IN_CHUNK;
|
||||
for (FqName javaClass : affectedClasses.subList(chunkStart, Math.min(chunkStart + CLASSES_IN_CHUNK, affectedClasses.size()))) {
|
||||
ClassDescriptor topLevelClass = javaDescriptorResolver.resolveClass(javaClass, IGNORE_KOTLIN_SOURCES);
|
||||
NamespaceDescriptor topLevelNamespace = javaDescriptorResolver.resolveNamespace(javaClass, IGNORE_KOTLIN_SOURCES);
|
||||
PackageViewDescriptor topLevelPackage = javaDescriptorResolver.getPackageFragmentProvider().getModule().getPackage(javaClass);
|
||||
if (topLevelClass == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
topLevelClass.acceptVoid(visitor);
|
||||
|
||||
if (topLevelNamespace != null) {
|
||||
topLevelNamespace.acceptVoid(visitor);
|
||||
if (topLevelPackage != null) {
|
||||
topLevelPackage.acceptVoid(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTest;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.jet.KotlinTestWithEnvironmentManagement;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
Reference in New Issue
Block a user