From a6000809a34735ffe1c40bf07a9e291d3c767eb9 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Sat, 12 Jul 2014 04:23:51 +0400 Subject: Store descriptors instead of resolution scopes, rename Model -> Module --- src/Model/Diagnostics.kt | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'src/Model/Diagnostics.kt') diff --git a/src/Model/Diagnostics.kt b/src/Model/Diagnostics.kt index 78d711a0..723bd59d 100644 --- a/src/Model/Diagnostics.kt +++ b/src/Model/Diagnostics.kt @@ -2,32 +2,31 @@ package org.jetbrains.dokka import org.jetbrains.jet.lang.descriptors.* import org.jetbrains.jet.lang.resolve.name.* +import org.jetbrains.jet.lang.resolve.BindingContext -fun DocumentationNode.checkResolve() { - val parentScope = scope +fun BindingContext.checkResolveChildren(node : DocumentationNode) { + if (node.kind != DocumentationNodeKind.Module && node.kind != DocumentationNodeKind.Package) { + // TODO: we don't resolve packages and modules for now - for (item in details + members) { - val symbolName = item.name - val symbol: DeclarationDescriptor? = when (item.kind) { - DocumentationNodeKind.Receiver -> (parentScope.getContainingDeclaration() as FunctionDescriptor).getReceiverParameter() - DocumentationNodeKind.Parameter -> parentScope.getLocalVariable(Name.guess(symbolName)) - DocumentationNodeKind.Function -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull() - DocumentationNodeKind.Property -> parentScope.getProperties(Name.guess(symbolName)).firstOrNull() - DocumentationNodeKind.Constructor -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull() - - DocumentationNodeKind.Package -> { - // TODO: do not resolve constructors and packages for now - item.scope.getContainingDeclaration() + val parentScope = getResolutionScope(node.descriptor) + for (item in node.details + node.members) { + val symbolName = item.name + val symbol: DeclarationDescriptor? = when (item.kind) { + DocumentationNodeKind.Receiver -> (parentScope.getContainingDeclaration() as FunctionDescriptor).getReceiverParameter() + DocumentationNodeKind.Parameter -> parentScope.getLocalVariable(Name.guess(symbolName)) + DocumentationNodeKind.Function -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull() + DocumentationNodeKind.Property -> parentScope.getProperties(Name.guess(symbolName)).firstOrNull() + DocumentationNodeKind.Constructor -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull() + else -> parentScope.getClassifier(Name.guess(symbolName)) } - else -> parentScope.getClassifier(Name.guess(symbolName)) - } - if (symbol == null) - println("WARNING: Cannot resolve $item in ${path(this)}") + if (symbol == null) + println("WARNING: Cannot resolve $item in ${path(node)}") + } } - for (reference in allReferences().filterNot { it.kind == DocumentationReferenceKind.Owner }) { - reference.to.checkResolve() + for (reference in node.allReferences().filterNot { it.kind == DocumentationReferenceKind.Owner }) { + checkResolveChildren(reference.to) } } -- cgit