Got rid of "namespace" word in compiler code.
This commit is contained in:
+3
-3
@@ -114,9 +114,9 @@ public class CodegenTestsOnAndroidRunner {
|
||||
[exec] at java.lang.reflect.Method.invokeNative(Native Method)
|
||||
[exec] at org.jetbrains.jet.compiler.android.AbstractCodegenTestCaseOnAndroid.invokeBoxMethod(AbstractCodegenTestCaseOnAndroid.java:35)
|
||||
[exec] ... 13 more
|
||||
[exec] Caused by: java.lang.VerifyError: compiler_testData_codegen_regressions_kt344_jet.namespace$t6$foo$1
|
||||
[exec] at compiler_testData_codegen_regressions_kt344_jet.namespace.t6(dummy.jet:94)
|
||||
[exec] at compiler_testData_codegen_regressions_kt344_jet.namespace.box(dummy.jet:185)
|
||||
[exec] Caused by: java.lang.VerifyError: compiler_testData_codegen_boxWithStdlib_regressions_kt344_kt.Compiler_testData_codegen_boxWithStdlib_regressions_kt344_ktPackage$t6$foo$1
|
||||
[exec] at compiler_testData_codegen_boxWithStdlib_regressions_kt344_kt.Compiler_testData_codegen_boxWithStdlib_regressions_kt344_ktPackage.t6(dummy.jet:94)
|
||||
[exec] at compiler_testData_codegen_boxWithStdlib_regressions_kt344_kt.Compiler_testData_codegen_boxWithStdlib_regressions_kt344_ktPackage.box(dummy.jet:185)
|
||||
[exec] ... 16 more
|
||||
[exec] ...............
|
||||
[exec] Error in testKt529:
|
||||
|
||||
+2
-2
@@ -180,10 +180,10 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateTestMethod(Printer p, String testName, String namespace) {
|
||||
private static void generateTestMethod(Printer p, String testName, String packageName) {
|
||||
p.println("public void test" + testName + "() throws Exception {");
|
||||
p.pushIndent();
|
||||
p.println("invokeBoxMethod(\"" + namespace + "\", \"OK\");");
|
||||
p.println("invokeBoxMethod(\"" + packageName + "\", \"OK\");");
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
p.println();
|
||||
|
||||
@@ -349,7 +349,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
Type[] argTypes = asmMethod.getArgumentTypes();
|
||||
|
||||
// The first line of some namespace file is written to the line number attribute of a static delegate to allow to 'step into' it
|
||||
// The first line of some package file is written to the line number attribute of a static delegate to allow to 'step into' it
|
||||
// This is similar to what javac does with bridge methods
|
||||
Label label = new Label();
|
||||
iv.visitLabel(label);
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public abstract class JetFilesProvider {
|
||||
return ServiceManager.getService(project, JetFilesProvider.class);
|
||||
}
|
||||
|
||||
public final Function<JetFile, Collection<JetFile>> allNamespaceFiles() {
|
||||
public final Function<JetFile, Collection<JetFile>> allPackageFiles() {
|
||||
return new Function<JetFile, Collection<JetFile>>() {
|
||||
@Override
|
||||
public Collection<JetFile> fun(JetFile file) {
|
||||
|
||||
@@ -529,7 +529,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* : functionLiteral
|
||||
* : declaration
|
||||
* : SimpleName
|
||||
* : "package" // foo the root namespace
|
||||
* : "package" // for the root package
|
||||
* ;
|
||||
*/
|
||||
private void parseAtomicExpression() {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JetImportDirective extends JetElementImpl {
|
||||
return visitor.visitImportDirective(this, data);
|
||||
}
|
||||
|
||||
public boolean isAbsoluteInRootNamespace() {
|
||||
public boolean isAbsoluteInRootPackage() {
|
||||
return findChildByType(JetTokens.PACKAGE_KEYWORD) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,8 +301,8 @@ public class JetPsiFactory {
|
||||
importDirectiveBuilder.append(" as ").append(alias.asString());
|
||||
}
|
||||
|
||||
JetFile namespace = createFile(project, importDirectiveBuilder.toString());
|
||||
return namespace.getImportDirectives().iterator().next();
|
||||
JetFile file = createFile(project, importDirectiveBuilder.toString());
|
||||
return file.getImportDirectives().iterator().next();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -31,7 +31,7 @@ public class JetUserType extends JetTypeElement {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public boolean isAbsoluteInRootNamespace() {
|
||||
public boolean isAbsoluteInRootPackage() {
|
||||
return findChildByType(JetTokens.PACKAGE_KEYWORD) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class BindingContextUtils {
|
||||
@Nullable
|
||||
public static JetFile getContainingFile(@NotNull BindingContext context, @NotNull DeclarationDescriptor declarationDescriptor) {
|
||||
// declarationDescriptor may describe a synthesized element which doesn't have PSI
|
||||
// To workaround that, we find a top-level parent (which is inside a NamespaceDescriptor), which is guaranteed to have PSI
|
||||
// To workaround that, we find a top-level parent (which is inside a PackageFragmentDescriptor), which is guaranteed to have PSI
|
||||
DeclarationDescriptor descriptor = DescriptorUtils.findTopLevelParent(declarationDescriptor);
|
||||
if (descriptor == null) return null;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class DeclarationResolver {
|
||||
resolveFunctionAndPropertyHeaders();
|
||||
createFunctionsForDataClasses();
|
||||
importsResolver.processMembersImports();
|
||||
checkRedeclarationsInNamespaces();
|
||||
checkRedeclarationsInPackages();
|
||||
checkRedeclarationsInInnerClassNames();
|
||||
}
|
||||
|
||||
@@ -161,12 +161,12 @@ public class DeclarationResolver {
|
||||
}
|
||||
|
||||
private void resolveFunctionAndPropertyHeaders() {
|
||||
for (Map.Entry<JetFile, WritableScope> entry : context.getNamespaceScopes().entrySet()) {
|
||||
JetFile namespace = entry.getKey();
|
||||
WritableScope namespaceScope = entry.getValue();
|
||||
PackageLikeBuilder packageBuilder = context.getPackageFragments().get(namespace).getBuilder();
|
||||
for (Map.Entry<JetFile, WritableScope> entry : context.getFileScopes().entrySet()) {
|
||||
JetFile file = entry.getKey();
|
||||
WritableScope fileScope = entry.getValue();
|
||||
PackageLikeBuilder packageBuilder = context.getPackageFragments().get(file).getBuilder();
|
||||
|
||||
resolveFunctionAndPropertyHeaders(namespace.getDeclarations(), namespaceScope, namespaceScope, namespaceScope, packageBuilder);
|
||||
resolveFunctionAndPropertyHeaders(file.getDeclarations(), fileScope, fileScope, fileScope, packageBuilder);
|
||||
}
|
||||
for (Map.Entry<JetClassOrObject, MutableClassDescriptor> entry : context.getClasses().entrySet()) {
|
||||
JetClassOrObject classOrObject = entry.getKey();
|
||||
@@ -317,7 +317,7 @@ public class DeclarationResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRedeclarationsInNamespaces() {
|
||||
private void checkRedeclarationsInPackages() {
|
||||
for (MutablePackageFragmentDescriptor packageFragment : Sets.newHashSet(context.getPackageFragments().values())) {
|
||||
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(packageFragment.getFqName())) {
|
||||
// TODO: drop this after built-ins are fully rewritten to Kotlin
|
||||
|
||||
@@ -48,10 +48,10 @@ public interface Importer {
|
||||
};
|
||||
|
||||
class StandardImporter implements Importer {
|
||||
private final WritableScope namespaceScope;
|
||||
private final WritableScope fileScope;
|
||||
|
||||
public StandardImporter(WritableScope namespaceScope) {
|
||||
this.namespaceScope = namespaceScope;
|
||||
public StandardImporter(WritableScope fileScope) {
|
||||
this.fileScope = fileScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,22 +101,22 @@ public interface Importer {
|
||||
}
|
||||
|
||||
for (JetScope scope : scopesToImport) {
|
||||
namespaceScope.importScope(createFilteringScope(scope, descriptor, platformToKotlinClassMap));
|
||||
fileScope.importScope(createFilteringScope(scope, descriptor, platformToKotlinClassMap));
|
||||
}
|
||||
}
|
||||
|
||||
protected void importDeclarationAlias(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName) {
|
||||
if (descriptor instanceof ClassifierDescriptor) {
|
||||
namespaceScope.importClassifierAlias(aliasName, (ClassifierDescriptor) descriptor);
|
||||
fileScope.importClassifierAlias(aliasName, (ClassifierDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof PackageViewDescriptor) {
|
||||
namespaceScope.importPackageAlias(aliasName, (PackageViewDescriptor) descriptor);
|
||||
fileScope.importPackageAlias(aliasName, (PackageViewDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
namespaceScope.importFunctionAlias(aliasName, (FunctionDescriptor) descriptor);
|
||||
fileScope.importFunctionAlias(aliasName, (FunctionDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof VariableDescriptor) {
|
||||
namespaceScope.importVariableAlias(aliasName, (VariableDescriptor) descriptor);
|
||||
fileScope.importVariableAlias(aliasName, (VariableDescriptor) descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ public interface Importer {
|
||||
|
||||
private final List<DelayedImportEntry> imports = Lists.newArrayList();
|
||||
|
||||
public DelayedImporter(@NotNull WritableScope namespaceScope) {
|
||||
super(namespaceScope);
|
||||
public DelayedImporter(@NotNull WritableScope fileScope) {
|
||||
super(fileScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,8 +82,8 @@ public class ImportsResolver {
|
||||
|
||||
private void processImports(@NotNull LookupMode lookupMode) {
|
||||
for (JetFile file : context.getPackageFragments().keySet()) {
|
||||
WritableScope namespaceScope = context.getNamespaceScopes().get(file);
|
||||
processImportsInFile(lookupMode, namespaceScope, Lists.newArrayList(file.getImportDirectives()));
|
||||
WritableScope fileScope = context.getFileScopes().get(file);
|
||||
processImportsInFile(lookupMode, fileScope, Lists.newArrayList(file.getImportDirectives()));
|
||||
}
|
||||
for (JetScript script : context.getScripts().keySet()) {
|
||||
WritableScope scriptScope = context.getScriptScopes().get(script);
|
||||
@@ -97,7 +97,7 @@ public class ImportsResolver {
|
||||
|
||||
private static void processImportsInFile(
|
||||
LookupMode lookupMode,
|
||||
@NotNull WritableScope namespaceScope,
|
||||
@NotNull WritableScope fileScope,
|
||||
@NotNull List<JetImportDirective> importDirectives,
|
||||
@NotNull ModuleDescriptor module,
|
||||
@NotNull BindingTrace trace,
|
||||
@@ -106,9 +106,9 @@ public class ImportsResolver {
|
||||
) {
|
||||
@NotNull JetScope rootScope = module.getPackage(FqName.ROOT).getMemberScope();
|
||||
|
||||
Importer.DelayedImporter delayedImporter = new Importer.DelayedImporter(namespaceScope);
|
||||
Importer.DelayedImporter delayedImporter = new Importer.DelayedImporter(fileScope);
|
||||
if (lookupMode == LookupMode.EVERYTHING) {
|
||||
namespaceScope.clearImports();
|
||||
fileScope.clearImports();
|
||||
}
|
||||
|
||||
for (ImportPath defaultImportPath : module.getDefaultImports()) {
|
||||
@@ -116,7 +116,7 @@ public class ImportsResolver {
|
||||
trace, "transient trace to resolve default imports"); //not to trace errors of default imports
|
||||
|
||||
JetImportDirective defaultImportDirective = importsFactory.createImportDirective(defaultImportPath);
|
||||
qualifiedExpressionResolver.processImportReference(defaultImportDirective, rootScope, namespaceScope, delayedImporter,
|
||||
qualifiedExpressionResolver.processImportReference(defaultImportDirective, rootScope, fileScope, delayedImporter,
|
||||
temporaryTrace, module, lookupMode);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ImportsResolver {
|
||||
|
||||
for (JetImportDirective importDirective : importDirectives) {
|
||||
Collection<? extends DeclarationDescriptor> descriptors =
|
||||
qualifiedExpressionResolver.processImportReference(importDirective, rootScope, namespaceScope, delayedImporter,
|
||||
qualifiedExpressionResolver.processImportReference(importDirective, rootScope, fileScope, delayedImporter,
|
||||
trace, module, lookupMode);
|
||||
if (!descriptors.isEmpty()) {
|
||||
resolvedDirectives.put(importDirective, descriptors);
|
||||
@@ -141,7 +141,7 @@ public class ImportsResolver {
|
||||
|
||||
if (lookupMode == LookupMode.EVERYTHING) {
|
||||
for (JetImportDirective importDirective : importDirectives) {
|
||||
reportUselessImport(importDirective, namespaceScope, resolvedDirectives, trace);
|
||||
reportUselessImport(importDirective, fileScope, resolvedDirectives, trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class ImportsResolver {
|
||||
|
||||
private static void reportUselessImport(
|
||||
@NotNull JetImportDirective importDirective,
|
||||
@NotNull WritableScope namespaceScope,
|
||||
@NotNull WritableScope fileScope,
|
||||
@NotNull Map<JetImportDirective, Collection<? extends DeclarationDescriptor>> resolvedDirectives,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
@@ -181,13 +181,13 @@ public class ImportsResolver {
|
||||
for (DeclarationDescriptor wasResolved : resolvedDirectives.get(importDirective)) {
|
||||
DeclarationDescriptor isResolved = null;
|
||||
if (wasResolved instanceof ClassDescriptor) {
|
||||
isResolved = namespaceScope.getClassifier(aliasName);
|
||||
isResolved = fileScope.getClassifier(aliasName);
|
||||
}
|
||||
else if (wasResolved instanceof VariableDescriptor) {
|
||||
isResolved = namespaceScope.getLocalVariable(aliasName);
|
||||
isResolved = fileScope.getLocalVariable(aliasName);
|
||||
}
|
||||
else if (wasResolved instanceof PackageViewDescriptor) {
|
||||
isResolved = namespaceScope.getPackage(aliasName);
|
||||
isResolved = fileScope.getPackage(aliasName);
|
||||
}
|
||||
if (isResolved == null || isResolved.equals(wasResolved)) {
|
||||
uselessHiddenImport = false;
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.PackageType;
|
||||
|
||||
public class JetModuleUtil {
|
||||
public static PackageType getRootPackageType(JetElement expression) {
|
||||
// TODO: this is a stub: at least the modules' root namespaces must be indexed here
|
||||
// TODO: this is a stub: at least the modules' root packages must be indexed here
|
||||
return new PackageType(SpecialNames.ROOT_PACKAGE, JetScope.EMPTY, ReceiverValue.NO_RECEIVER);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-19
@@ -35,7 +35,7 @@ import java.util.Set;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
|
||||
public class QualifiedExpressionResolver {
|
||||
private static final Predicate<DeclarationDescriptor> CLASSIFIERS_AND_NAMESPACES = new Predicate<DeclarationDescriptor>() {
|
||||
private static final Predicate<DeclarationDescriptor> CLASSIFIERS_AND_PACKAGE_VIEWS = new Predicate<DeclarationDescriptor>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof ClassifierDescriptor || descriptor instanceof PackageViewDescriptor;
|
||||
@@ -70,7 +70,7 @@ public class QualifiedExpressionResolver {
|
||||
@NotNull ModuleDescriptor module,
|
||||
@NotNull LookupMode lookupMode
|
||||
) {
|
||||
if (importDirective.isAbsoluteInRootNamespace()) {
|
||||
if (importDirective.isAbsoluteInRootPackage()) {
|
||||
trace.report(UNSUPPORTED.on(importDirective, "TypeHierarchyResolver")); // TODO
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class QualifiedExpressionResolver {
|
||||
public Collection<? extends DeclarationDescriptor> lookupDescriptorsForUserType(@NotNull JetUserType userType,
|
||||
@NotNull JetScope outerScope, @NotNull BindingTrace trace) {
|
||||
|
||||
if (userType.isAbsoluteInRootNamespace()) {
|
||||
if (userType.isAbsoluteInRootPackage()) {
|
||||
trace.report(Errors.UNSUPPORTED.on(userType, "package"));
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -241,9 +241,9 @@ public class QualifiedExpressionResolver {
|
||||
|
||||
@NotNull
|
||||
public Collection<? extends DeclarationDescriptor> lookupDescriptorsForSimpleNameReference(@NotNull JetSimpleNameExpression referenceExpression,
|
||||
@NotNull JetScope outerScope, @NotNull JetScope scopeToCheckVisibility, @NotNull BindingTrace trace, @NotNull LookupMode lookupMode, boolean namespaceLevel, boolean storeResult) {
|
||||
@NotNull JetScope outerScope, @NotNull JetScope scopeToCheckVisibility, @NotNull BindingTrace trace, @NotNull LookupMode lookupMode, boolean packageLevel, boolean storeResult) {
|
||||
|
||||
LookupResult lookupResult = lookupSimpleNameReference(referenceExpression, outerScope, lookupMode, namespaceLevel);
|
||||
LookupResult lookupResult = lookupSimpleNameReference(referenceExpression, outerScope, lookupMode, packageLevel);
|
||||
if (lookupResult == LookupResult.EMPTY) return Collections.emptyList();
|
||||
return filterAndStoreResolutionResult(Collections.singletonList((SuccessfulLookupResult)lookupResult), referenceExpression, trace, scopeToCheckVisibility,
|
||||
lookupMode, storeResult);
|
||||
@@ -251,7 +251,7 @@ public class QualifiedExpressionResolver {
|
||||
|
||||
@NotNull
|
||||
private LookupResult lookupSimpleNameReference(@NotNull JetSimpleNameExpression referenceExpression,
|
||||
@NotNull JetScope outerScope, @NotNull LookupMode lookupMode, boolean namespaceLevel) {
|
||||
@NotNull JetScope outerScope, @NotNull LookupMode lookupMode, boolean packageLevel) {
|
||||
|
||||
Name referencedName = referenceExpression.getReferencedNameAsName();
|
||||
|
||||
@@ -275,7 +275,7 @@ public class QualifiedExpressionResolver {
|
||||
descriptors.add(localVariable);
|
||||
}
|
||||
}
|
||||
return new SuccessfulLookupResult(descriptors, outerScope, namespaceLevel);
|
||||
return new SuccessfulLookupResult(descriptors, outerScope, packageLevel);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -305,17 +305,17 @@ public class QualifiedExpressionResolver {
|
||||
|
||||
Collection<DeclarationDescriptor> filteredDescriptors;
|
||||
if (lookupMode == LookupMode.ONLY_CLASSES) {
|
||||
filteredDescriptors = Collections2.filter(descriptors, CLASSIFIERS_AND_NAMESPACES);
|
||||
filteredDescriptors = Collections2.filter(descriptors, CLASSIFIERS_AND_PACKAGE_VIEWS);
|
||||
}
|
||||
else {
|
||||
filteredDescriptors = Sets.newLinkedHashSet();
|
||||
//functions and properties can be imported if lookupResult.namespaceLevel == true
|
||||
//functions and properties can be imported if lookupResult.packageLevel == true
|
||||
for (SuccessfulLookupResult lookupResult : lookupResults) {
|
||||
if (lookupResult.namespaceLevel) {
|
||||
if (lookupResult.packageLevel) {
|
||||
filteredDescriptors.addAll(lookupResult.descriptors);
|
||||
continue;
|
||||
}
|
||||
filteredDescriptors.addAll(Collections2.filter(lookupResult.descriptors, CLASSIFIERS_AND_NAMESPACES));
|
||||
filteredDescriptors.addAll(Collections2.filter(lookupResult.descriptors, CLASSIFIERS_AND_PACKAGE_VIEWS));
|
||||
}
|
||||
}
|
||||
if (storeResult) {
|
||||
@@ -338,7 +338,7 @@ public class QualifiedExpressionResolver {
|
||||
JetScope resolutionScope = possibleResolutionScopes.iterator().next();
|
||||
|
||||
// A special case - will fill all trace information
|
||||
if (resolveClassNamespaceAmbiguity(canBeImportedDescriptors, referenceExpression, resolutionScope, trace, scopeToCheckVisibility)) {
|
||||
if (resolveClassPackageAmbiguity(canBeImportedDescriptors, referenceExpression, resolutionScope, trace, scopeToCheckVisibility)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -379,14 +379,18 @@ public class QualifiedExpressionResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tries to resolve descriptors ambiguity between class descriptor and namespace descriptor for the same class.
|
||||
* This method tries to resolve descriptors ambiguity between class descriptor and package descriptor for the same class.
|
||||
* It's ok choose class for expression reference resolution.
|
||||
*
|
||||
* @return <code>true</code> if method has successfully resolved ambiguity
|
||||
*/
|
||||
private boolean resolveClassNamespaceAmbiguity(@NotNull Collection<? extends DeclarationDescriptor> filteredDescriptors,
|
||||
@NotNull JetSimpleNameExpression referenceExpression, @NotNull JetScope resolutionScope, @NotNull BindingTrace trace,
|
||||
@NotNull JetScope scopeToCheckVisibility) {
|
||||
private boolean resolveClassPackageAmbiguity(
|
||||
@NotNull Collection<? extends DeclarationDescriptor> filteredDescriptors,
|
||||
@NotNull JetSimpleNameExpression referenceExpression,
|
||||
@NotNull JetScope resolutionScope,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope scopeToCheckVisibility
|
||||
) {
|
||||
|
||||
if (filteredDescriptors.size() == 2) {
|
||||
PackageViewDescriptor packageView = null;
|
||||
@@ -430,14 +434,15 @@ public class QualifiedExpressionResolver {
|
||||
private static class SuccessfulLookupResult implements LookupResult {
|
||||
final Collection<? extends DeclarationDescriptor> descriptors;
|
||||
final JetScope resolutionScope;
|
||||
final boolean namespaceLevel;
|
||||
final boolean packageLevel;
|
||||
|
||||
private SuccessfulLookupResult(Collection<? extends DeclarationDescriptor> descriptors,
|
||||
JetScope resolutionScope,
|
||||
boolean namespaceLevel) {
|
||||
boolean packageLevel
|
||||
) {
|
||||
this.descriptors = descriptors;
|
||||
this.resolutionScope = resolutionScope;
|
||||
this.namespaceLevel = namespaceLevel;
|
||||
this.packageLevel = packageLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
private Map<JetDeclaration, CallableMemberDescriptor> members = null;
|
||||
|
||||
// File scopes - package scope extended with imports
|
||||
protected final Map<JetFile, WritableScope> namespaceScopes = Maps.newHashMap();
|
||||
protected final Map<JetFile, WritableScope> fileScopes = Maps.newHashMap();
|
||||
|
||||
public final Map<JetDeclarationContainer, DeclarationDescriptor> forDeferredResolver = Maps.newHashMap();
|
||||
|
||||
@@ -110,8 +110,8 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
return classes;
|
||||
}
|
||||
|
||||
public Map<JetFile, WritableScope> getNamespaceScopes() {
|
||||
return namespaceScopes;
|
||||
public Map<JetFile, WritableScope> getFileScopes() {
|
||||
return fileScopes;
|
||||
}
|
||||
|
||||
public Map<JetFile, MutablePackageFragmentDescriptor> getPackageFragments() {
|
||||
|
||||
@@ -143,7 +143,7 @@ public class TopDownAnalyzer {
|
||||
mutableClassDescriptor.lockScopes();
|
||||
}
|
||||
Set<FqName> scriptFqNames = Sets.newHashSet();
|
||||
for (JetFile file : context.getNamespaceScopes().keySet()) {
|
||||
for (JetFile file : context.getFileScopes().keySet()) {
|
||||
if (file.isScript()) {
|
||||
scriptFqNames.add(JetPsiUtil.getFQName(file));
|
||||
}
|
||||
@@ -213,13 +213,13 @@ public class TopDownAnalyzer {
|
||||
// "depend on" builtins module
|
||||
((ModuleDescriptorImpl) moduleDescriptor).addFragmentProvider(KotlinBuiltIns.getInstance().getBuiltInsModule().getPackageFragmentProvider());
|
||||
|
||||
// Import a scope that contains all top-level namespaces that come from dependencies
|
||||
// This makes the namespaces visible at all, does not import themselves
|
||||
// Import a scope that contains all top-level packages that come from dependencies
|
||||
// This makes the package visible at all, does not import themselves
|
||||
PackageViewDescriptor rootPackage = moduleDescriptor.getPackage(FqName.ROOT);
|
||||
assert rootPackage != null : "Coulnd't find root package for " + moduleDescriptor;
|
||||
|
||||
// dummy builder is used because "root" is module descriptor,
|
||||
// namespaces added to module explicitly in
|
||||
// packages added to module explicitly in
|
||||
doProcess(rootPackage.getMemberScope(), new PackageLikeBuilderDummy(), files);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ public class TypeHierarchyResolver {
|
||||
) {
|
||||
|
||||
{
|
||||
// TODO: Very temp code - main goal is to remove recursion from collectNamespacesAndClassifiers
|
||||
// TODO: Very temp code - main goal is to remove recursion from collectPackageFragmentsAndClassifiers
|
||||
Queue<JetDeclarationContainer> forDeferredResolve = new LinkedList<JetDeclarationContainer>();
|
||||
forDeferredResolve.addAll(collectNamespacesAndClassifiers(outerScope, owner, declarations));
|
||||
forDeferredResolve.addAll(collectPackageFragmentsAndClassifiers(outerScope, owner, declarations));
|
||||
|
||||
while (!forDeferredResolve.isEmpty()) {
|
||||
JetDeclarationContainer declarationContainer = forDeferredResolve.poll();
|
||||
@@ -110,14 +110,14 @@ public class TypeHierarchyResolver {
|
||||
// Even more temp code
|
||||
if (descriptorForDeferredResolve instanceof MutableClassDescriptorLite) {
|
||||
forDeferredResolve.addAll(
|
||||
collectNamespacesAndClassifiers(
|
||||
collectPackageFragmentsAndClassifiers(
|
||||
scope,
|
||||
((MutableClassDescriptorLite) descriptorForDeferredResolve).getBuilder(),
|
||||
declarationContainer.getDeclarations()));
|
||||
}
|
||||
else if (descriptorForDeferredResolve instanceof MutablePackageFragmentDescriptor) {
|
||||
forDeferredResolve.addAll(
|
||||
collectNamespacesAndClassifiers(
|
||||
collectPackageFragmentsAndClassifiers(
|
||||
scope,
|
||||
((MutablePackageFragmentDescriptor) descriptorForDeferredResolve).getBuilder(),
|
||||
declarationContainer.getDeclarations()));
|
||||
@@ -147,7 +147,7 @@ public class TypeHierarchyResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<JetDeclarationContainer> collectNamespacesAndClassifiers(
|
||||
private Collection<JetDeclarationContainer> collectPackageFragmentsAndClassifiers(
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull PackageLikeBuilder owner,
|
||||
@NotNull Iterable<? extends PsiElement> declarations
|
||||
@@ -465,7 +465,7 @@ public class TypeHierarchyResolver {
|
||||
WriteThroughScope packageScope = new WriteThroughScope(rootPlusPackageScope, packageFragment.getMemberScope(),
|
||||
new TraceBasedRedeclarationHandler(trace), "package in file " + file.getName());
|
||||
packageScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
context.getNamespaceScopes().put(file, packageScope);
|
||||
context.getFileScopes().put(file, packageScope);
|
||||
|
||||
if (file.isScript()) {
|
||||
scriptHeaderResolver.processScriptHierarchy(file.getScript(), packageScope);
|
||||
@@ -560,7 +560,7 @@ public class TypeHierarchyResolver {
|
||||
|
||||
trace.record(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file, fragment);
|
||||
|
||||
// Register files corresponding to this namespace
|
||||
// Register files corresponding to this package
|
||||
// The trace currently does not support bi-di multimaps that would handle this task nicer
|
||||
FqName fqName = fragment.getFqName();
|
||||
Collection<JetFile> files = trace.get(PACKAGE_TO_FILES, fqName);
|
||||
|
||||
+10
-10
@@ -77,7 +77,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JetType lookupNamespaceOrClassObject(@NotNull JetSimpleNameExpression expression, @NotNull ExpressionTypingContext context) {
|
||||
private JetType lookupPackageOrClassObject(@NotNull JetSimpleNameExpression expression, @NotNull ExpressionTypingContext context) {
|
||||
Name referencedName = expression.getReferencedNameAsName();
|
||||
final ClassifierDescriptor classifier = context.scope.getClassifier(referencedName);
|
||||
if (classifier != null) {
|
||||
@@ -91,12 +91,12 @@ public class CallExpressionResolver {
|
||||
}
|
||||
JetType[] result = new JetType[1];
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||
context.trace, "trace for namespace/class object lookup of name", referencedName);
|
||||
context.trace, "trace for package/class object lookup of name", referencedName);
|
||||
if (furtherNameLookup(expression, result, context.replaceBindingTrace(temporaryTrace))) {
|
||||
temporaryTrace.commit();
|
||||
return DataFlowUtils.checkType(result[0], expression, context);
|
||||
}
|
||||
// To report NO_CLASS_OBJECT when no namespace found
|
||||
// To report NO_CLASS_OBJECT when no package found
|
||||
if (classifier != null) {
|
||||
if (classifier instanceof TypeParameterDescriptor) {
|
||||
if (isLHSOfDot(expression)) {
|
||||
@@ -172,10 +172,10 @@ public class CallExpressionResolver {
|
||||
scopes.add(getStaticNestedClassesScope(classDescriptor));
|
||||
|
||||
Name referencedName = expression.getReferencedNameAsName();
|
||||
PackageViewDescriptor namespace = context.scope.getPackage(referencedName);
|
||||
if (namespace != null) {
|
||||
PackageViewDescriptor packageView = context.scope.getPackage(referencedName);
|
||||
if (packageView != null) {
|
||||
//for enums loaded from java binaries
|
||||
scopes.add(namespace.getMemberScope());
|
||||
scopes.add(packageView.getMemberScope());
|
||||
}
|
||||
|
||||
JetScope scope = new ChainedScope(
|
||||
@@ -265,11 +265,11 @@ public class CallExpressionResolver {
|
||||
ExpressionTypingContext newContext = receiver.exists()
|
||||
? context.replaceScope(receiver.getType().getMemberScope())
|
||||
: context;
|
||||
TemporaryTraceAndCache temporaryForNamespaceOrClassObject = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as namespace or class object", nameExpression);
|
||||
JetType jetType = lookupNamespaceOrClassObject(nameExpression, newContext.replaceTraceAndCache(temporaryForNamespaceOrClassObject));
|
||||
TemporaryTraceAndCache temporaryForPackageOrClassObject = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as package or class object", nameExpression);
|
||||
JetType jetType = lookupPackageOrClassObject(nameExpression, newContext.replaceTraceAndCache(temporaryForPackageOrClassObject));
|
||||
if (jetType != null) {
|
||||
temporaryForNamespaceOrClassObject.commit();
|
||||
temporaryForPackageOrClassObject.commit();
|
||||
|
||||
// Uncommitted changes in temp context
|
||||
context.trace.record(RESOLUTION_SCOPE, nameExpression, context.scope);
|
||||
|
||||
+4
-4
@@ -89,12 +89,12 @@ public class DataFlowValueFactory {
|
||||
private static class IdentifierInfo {
|
||||
public final Object id;
|
||||
public final boolean isStable;
|
||||
public final boolean isNamespace;
|
||||
public final boolean isPackage;
|
||||
|
||||
private IdentifierInfo(Object id, boolean isStable, boolean isNamespace) {
|
||||
private IdentifierInfo(Object id, boolean isStable, boolean isPackage) {
|
||||
this.id = id;
|
||||
this.isStable = isStable;
|
||||
this.isNamespace = isNamespace;
|
||||
this.isPackage = isPackage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class DataFlowValueFactory {
|
||||
if (selectorInfo.id == null) {
|
||||
return NO_IDENTIFIER_INFO;
|
||||
}
|
||||
if (receiverInfo == null || receiverInfo == NO_IDENTIFIER_INFO || receiverInfo.isNamespace) {
|
||||
if (receiverInfo == null || receiverInfo == NO_IDENTIFIER_INFO || receiverInfo.isPackage) {
|
||||
return selectorInfo;
|
||||
}
|
||||
return createInfo(Pair.create(receiverInfo.id, selectorInfo.id), receiverInfo.isStable && selectorInfo.isStable);
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class FileBasedPackageMemberDeclarationProvider extends AbstractPsiBasedD
|
||||
protected void doCreateIndex(@NotNull Index index) {
|
||||
for (JetFile file : packageFiles) {
|
||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||
assert fqName.asString().equals(file.getPackageName()) : "Files declaration utils contains file with invalid namespace";
|
||||
assert fqName.asString().equals(file.getPackageName()) : "Files declaration utils contains file with invalid package";
|
||||
index.putToIndex(declaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class StubClassBuilder extends ClassBuilder {
|
||||
private final StubElement parent;
|
||||
private StubBuildingVisitor v;
|
||||
private final Stack<StubElement> parentStack;
|
||||
private boolean isNamespace = false;
|
||||
private boolean isPackageClass = false;
|
||||
|
||||
public StubClassBuilder(@NotNull Stack<StubElement> parentStack) {
|
||||
this.parentStack = parentStack;
|
||||
@@ -85,11 +85,11 @@ public class StubClassBuilder extends ClassBuilder {
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(packageName);
|
||||
|
||||
if (name.equals(packageClassName) || name.endsWith("/" + packageClassName)) {
|
||||
isNamespace = true;
|
||||
isPackageClass = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isNamespace) {
|
||||
if (!isPackageClass) {
|
||||
parentStack.push(v.getResult());
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class StubClassBuilder extends ClassBuilder {
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
if (!isNamespace) {
|
||||
if (!isPackageClass) {
|
||||
StubElement pop = parentStack.pop();
|
||||
assert pop == v.getResult();
|
||||
}
|
||||
|
||||
@@ -220,8 +220,8 @@ public class JetTestUtils {
|
||||
private JetTestUtils() {
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace) {
|
||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile file) {
|
||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -47,8 +47,8 @@ public class JUnitUsageGenTest extends CodegenTestCase {
|
||||
|
||||
public void testKt1592() throws Exception {
|
||||
loadFile("junit/kt1592.kt");
|
||||
Class<?> namespaceClass = generatePackageClass();
|
||||
Method method = namespaceClass.getMethod("foo", Method.class);
|
||||
Class<?> packageClass = generatePackageClass();
|
||||
Method method = packageClass.getMethod("foo", Method.class);
|
||||
method.setAccessible(true);
|
||||
Annotation annotation = method.getAnnotation(getCorrespondingAnnotationClass(Test.class));
|
||||
assertEquals(ClassLoaderIsolationUtil.getAnnotationAttribute(annotation, "timeout"), 0l);
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
import static org.jetbrains.jet.codegen.KotlinPackageAnnotationTest.collectCallableNames;
|
||||
|
||||
public class KotlinClassAnnotationTest extends CodegenTestCase {
|
||||
public static final FqName NAMESPACE_NAME = new FqName("test");
|
||||
public static final FqName PACKAGE_NAME = new FqName("test");
|
||||
public static final FqNameUnsafe CLASS_NAME = new FqNameUnsafe("A");
|
||||
|
||||
@Override
|
||||
@@ -40,13 +40,13 @@ public class KotlinClassAnnotationTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testClassKotlinInfo() throws Exception {
|
||||
loadText("package " + NAMESPACE_NAME + "\n" +
|
||||
loadText("package " + PACKAGE_NAME + "\n" +
|
||||
"\n" +
|
||||
"class " + CLASS_NAME + " {\n" +
|
||||
" fun foo() {}\n" +
|
||||
" fun bar() = 42\n" +
|
||||
"}\n");
|
||||
Class aClass = generateClass(NAMESPACE_NAME + "." + CLASS_NAME);
|
||||
Class aClass = generateClass(PACKAGE_NAME + "." + CLASS_NAME);
|
||||
|
||||
Class<? extends Annotation> annotationClass = getCorrespondingAnnotationClass(KotlinClass.class);
|
||||
assertTrue(aClass.isAnnotationPresent(annotationClass));
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class KotlinPackageAnnotationTest extends CodegenTestCase {
|
||||
public static final FqName NAMESPACE_NAME = new FqName("test");
|
||||
public static final FqName PACKAGE_NAME = new FqName("test");
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -42,7 +42,7 @@ public class KotlinPackageAnnotationTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testPackageKotlinInfo() throws Exception {
|
||||
loadText("package " + NAMESPACE_NAME + "\n" +
|
||||
loadText("package " + PACKAGE_NAME + "\n" +
|
||||
"\n" +
|
||||
"fun foo() = 42\n" +
|
||||
"val bar = 239\n" +
|
||||
@@ -50,7 +50,7 @@ public class KotlinPackageAnnotationTest extends CodegenTestCase {
|
||||
"class A\n" +
|
||||
"class B\n" +
|
||||
"object C\n");
|
||||
Class aClass = generateClass(PackageClassUtils.getPackageClassFqName(NAMESPACE_NAME).asString());
|
||||
Class aClass = generateClass(PackageClassUtils.getPackageClassFqName(PACKAGE_NAME).asString());
|
||||
|
||||
Class<? extends Annotation> annotationClass = getCorrespondingAnnotationClass(KotlinPackage.class);
|
||||
assertTrue(aClass.isAnnotationPresent(annotationClass));
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class KotlinPackageFragmentAnnotationTest extends CodegenTestCase {
|
||||
public static final FqName NAMESPACE_NAME = new FqName("test");
|
||||
public static final FqName PACKAGE_NAME = new FqName("test");
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -37,8 +37,8 @@ public class KotlinPackageFragmentAnnotationTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testKotlinPackageFragmentIsWritten() throws Exception {
|
||||
loadText("package " + NAMESPACE_NAME + "\n\nfun foo() = 42\n");
|
||||
String facadeFileName = JvmClassName.byFqNameWithoutInnerClasses(PackageClassUtils.getPackageClassFqName(NAMESPACE_NAME)).getInternalName() + ".class";
|
||||
loadText("package " + PACKAGE_NAME + "\n\nfun foo() = 42\n");
|
||||
String facadeFileName = JvmClassName.byFqNameWithoutInnerClasses(PackageClassUtils.getPackageClassFqName(PACKAGE_NAME)).getInternalName() + ".class";
|
||||
|
||||
OutputFileCollection outputFiles = generateClassesInFile();
|
||||
for (OutputFile outputFile : outputFiles.asList()) {
|
||||
|
||||
@@ -333,7 +333,7 @@ public class LineNumberTest extends TestCaseWithTmpdir {
|
||||
assertNotNull(file);
|
||||
ClassReader reader = new ClassReader(file.asByteArray());
|
||||
|
||||
// There must be exactly one line number attribute for each static delegate in namespace.class, and it should point to the first
|
||||
// There must be exactly one line number attribute for each static delegate in package facade class, and it should point to the first
|
||||
// line. There are two static delegates in this test, hence the [1, 1]
|
||||
List<Integer> expectedLineNumbers = Arrays.asList(1, 1);
|
||||
List<Integer> actualLineNumbers = readAllLineNumbers(reader);
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import jet.IntRange;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -27,7 +26,7 @@ import java.util.Arrays;
|
||||
|
||||
import static org.jetbrains.jet.codegen.CodegenTestUtil.assertIsCurrentTime;
|
||||
|
||||
public class NamespaceGenTest extends CodegenTestCase {
|
||||
public class PackageGenTest extends CodegenTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -74,7 +74,7 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
assertNotNull(findDeclaredMethodByName(aClass, "setFoo"));
|
||||
}
|
||||
|
||||
public void testPrivatePropertyInNamespace() throws Exception {
|
||||
public void testPrivatePropertyInPackage() throws Exception {
|
||||
loadText("private val x = 239");
|
||||
Class nsClass = generatePackagePartClass();
|
||||
Field[] fields = nsClass.getDeclaredFields();
|
||||
@@ -135,7 +135,7 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
assertEquals(610, getFoo.invoke(instance));
|
||||
}
|
||||
|
||||
public void testInitializersForNamespaceProperties() throws Exception {
|
||||
public void testInitializersForTopLevelProperties() throws Exception {
|
||||
loadText("val x = System.currentTimeMillis()");
|
||||
Method method = generateFunction("getX");
|
||||
method.setAccessible(true);
|
||||
|
||||
@@ -28,13 +28,13 @@ public class SourceInfoGenTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
}
|
||||
|
||||
public void testSingleFileNamespace() {
|
||||
public void testSingleFilePackage() {
|
||||
String producer = "sourceInfo/foo1.kt";
|
||||
loadFiles(producer);
|
||||
assertEquals(producer, getProducerInfo("foo/FooPackage.class"));
|
||||
}
|
||||
|
||||
public void testMultiFileNamespace() {
|
||||
public void testMultiFilePackage() {
|
||||
loadFiles("sourceInfo/foo1.kt", "sourceInfo/foo2.kt");
|
||||
assertEquals(null, getProducerInfo("foo/FooPackage.class"));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ import static org.jetbrains.jet.test.util.DescriptorValidator.ValidationVisitor.
|
||||
import static org.jetbrains.jet.test.util.RecursiveDescriptorComparator.*;
|
||||
|
||||
/*
|
||||
The generated test compares namespace descriptors loaded from kotlin sources and read from compiled java.
|
||||
The generated test compares package descriptors loaded from kotlin sources and read from compiled java.
|
||||
*/
|
||||
public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
protected void doTestCompiledJava(@NotNull String javaFileName) throws Exception {
|
||||
@@ -153,7 +153,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
injectorForAnalyzer.getTopDownAnalyzer().analyzeFiles(environment.getSourceFiles(), Collections.<AnalyzerScriptParameter>emptyList());
|
||||
|
||||
PackageViewDescriptor packageView = module.getPackage(TEST_PACKAGE_FQNAME);
|
||||
assert packageView != null : "Test namespace not found";
|
||||
assert packageView != null : "Test package not found";
|
||||
|
||||
checkJavaPackage(expectedFile, packageView, trace.getBindingContext(), DONT_INCLUDE_METHODS_OF_OBJECT);
|
||||
}
|
||||
@@ -166,10 +166,10 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
assertTrue(testPackageDir.mkdir());
|
||||
FileUtil.copy(originalJavaFile, new File(testPackageDir, originalJavaFile.getName()));
|
||||
|
||||
Pair<PackageViewDescriptor, BindingContext> javaNamespaceAndContext = loadTestPackageAndBindingContextFromJavaRoot(
|
||||
Pair<PackageViewDescriptor, BindingContext> javaPackageAndContext = loadTestPackageAndBindingContextFromJavaRoot(
|
||||
tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||
|
||||
checkJavaPackage(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second,
|
||||
checkJavaPackage(expectedFile, javaPackageAndContext.first, javaPackageAndContext.second,
|
||||
DONT_INCLUDE_METHODS_OF_OBJECT.withValidationStrategy(ALLOW_ERROR_TYPES));
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
private static void checkForLoadErrorsAndCompare(
|
||||
@NotNull PackageViewDescriptor javaPackage,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull Runnable compareNamespacesRunnable
|
||||
@NotNull Runnable comparePackagesRunnable
|
||||
) {
|
||||
boolean fail = false;
|
||||
try {
|
||||
@@ -225,7 +225,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
fail = true;
|
||||
}
|
||||
|
||||
compareNamespacesRunnable.run();
|
||||
comparePackagesRunnable.run();
|
||||
if (fail) {
|
||||
fail("See error above");
|
||||
}
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
);
|
||||
|
||||
PackageViewDescriptor packageView = exhaust.getModuleDescriptor().getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME);
|
||||
assertNotNull("Failed to find namespace: " + LoadDescriptorUtil.TEST_PACKAGE_FQNAME, packageView);
|
||||
assertNotNull("Failed to find package: " + LoadDescriptorUtil.TEST_PACKAGE_FQNAME, packageView);
|
||||
return packageView;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public abstract class AbstractLazyResolveDiagnosticsTest extends BaseDiagnostics
|
||||
String txtFileRelativePath = path.replaceAll("\\.kt$|\\.ktscript", ".txt");
|
||||
File txtFile = new File("compiler/testData/lazyResolve/diagnostics/" + txtFileRelativePath);
|
||||
|
||||
// Only recurse into those namespaces mentioned in the files
|
||||
// Only recurse into those packages mentioned in the files
|
||||
// Otherwise we'll be examining the whole JDK
|
||||
final Set<Name> names = LazyResolveTestUtil.getTopLevelPackagesFromFileList(jetFiles);
|
||||
validateAndCompareDescriptors(
|
||||
|
||||
+2
-2
@@ -46,12 +46,12 @@ public class LazyResolveStdlibLoadingTest extends KotlinTestWithEnvironmentManag
|
||||
protected void doTestForGivenFiles(
|
||||
List<JetFile> files
|
||||
) {
|
||||
Set<Name> namespaceShortNames = LazyResolveTestUtil.getTopLevelPackagesFromFileList(files);
|
||||
Set<Name> packageShortNames = LazyResolveTestUtil.getTopLevelPackagesFromFileList(files);
|
||||
|
||||
ModuleDescriptor module = LazyResolveTestUtil.resolveEagerly(files, stdlibEnvironment);
|
||||
ModuleDescriptor lazyModule = LazyResolveTestUtil.resolveLazily(files, stdlibEnvironment);
|
||||
|
||||
for (Name name : namespaceShortNames) {
|
||||
for (Name name : packageShortNames) {
|
||||
PackageViewDescriptor eager = module.getPackage(FqName.topLevel(name));
|
||||
PackageViewDescriptor lazy = lazyModule.getPackage(FqName.topLevel(name));
|
||||
RecursiveDescriptorComparator.validateAndCompareDescriptors(eager, lazy, RecursiveDescriptorComparator.RECURSIVE, null);
|
||||
|
||||
+1
-1
@@ -269,7 +269,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
context = analyzeExhaust.getBindingContext();
|
||||
|
||||
PackageViewDescriptor packageView = analyzeExhaust.getModuleDescriptor().getPackage(PACKAGE);
|
||||
assertNotNull("Failed to find namespace: " + PACKAGE, packageView);
|
||||
assertNotNull("Failed to find package: " + PACKAGE, packageView);
|
||||
return packageView;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user