code cleanup: frontend module

This commit is contained in:
Dmitry Jemerov
2015-07-21 15:12:54 +02:00
parent e6776ebd8e
commit 6bf934b472
41 changed files with 58 additions and 65 deletions
@@ -31,17 +31,15 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import org.jetbrains.kotlin.storage.StorageManager
import java.util.ArrayList import java.util.ArrayList
import java.util.HashMap import java.util.HashMap
import kotlin.properties.Delegates
public trait ResolverForModule { public interface ResolverForModule {
public val lazyResolveSession: ResolveSession public val lazyResolveSession: ResolveSession
public val packageFragmentProvider: PackageFragmentProvider public val packageFragmentProvider: PackageFragmentProvider
} }
public trait ResolverForProject<M : ModuleInfo,out R : ResolverForModule> { public interface ResolverForProject<M : ModuleInfo,out R : ResolverForModule> {
public fun resolverForModule(moduleInfo: M): R = resolverForModuleDescriptor(descriptorForModule(moduleInfo)) public fun resolverForModule(moduleInfo: M): R = resolverForModuleDescriptor(descriptorForModule(moduleInfo))
public fun descriptorForModule(moduleInfo: M): ModuleDescriptor public fun descriptorForModule(moduleInfo: M): ModuleDescriptor
public fun resolverForModuleDescriptor(descriptor: ModuleDescriptor): R public fun resolverForModuleDescriptor(descriptor: ModuleDescriptor): R
@@ -61,7 +59,7 @@ public class ResolverForProjectImpl<M : ModuleInfo, R : ResolverForModule>(
) : ResolverForProject<M, R> { ) : ResolverForProject<M, R> {
val resolverByModuleDescriptor: MutableMap<ModuleDescriptor, () -> R> = HashMap() val resolverByModuleDescriptor: MutableMap<ModuleDescriptor, () -> R> = HashMap()
override val allModules: Collection<M> by Delegates.lazy { override val allModules: Collection<M> by lazy {
(descriptorByModule.keySet() + delegateResolver.allModules).toSet() (descriptorByModule.keySet() + delegateResolver.allModules).toSet()
} }
@@ -87,9 +85,9 @@ public data class ModuleContent(
public val moduleContentScope: GlobalSearchScope public val moduleContentScope: GlobalSearchScope
) )
public trait PlatformAnalysisParameters public interface PlatformAnalysisParameters
public trait ModuleInfo { public interface ModuleInfo {
public val isLibrary: Boolean public val isLibrary: Boolean
get() = false get() = false
public val name: Name public val name: Name
@@ -98,7 +96,7 @@ public trait ModuleInfo {
public fun dependencyOnBuiltins(): DependencyOnBuiltins = DependenciesOnBuiltins.LAST public fun dependencyOnBuiltins(): DependencyOnBuiltins = DependenciesOnBuiltins.LAST
//TODO: (module refactoring) provide dependency on builtins after runtime in IDEA //TODO: (module refactoring) provide dependency on builtins after runtime in IDEA
public trait DependencyOnBuiltins { public interface DependencyOnBuiltins {
public fun adjustDependencies(builtinsModule: ModuleDescriptorImpl, dependencies: MutableList<ModuleDescriptorImpl>) public fun adjustDependencies(builtinsModule: ModuleDescriptorImpl, dependencies: MutableList<ModuleDescriptorImpl>)
} }
@@ -122,7 +120,7 @@ public trait ModuleInfo {
} }
} }
public trait AnalyzerFacade<A : ResolverForModule, in P : PlatformAnalysisParameters> { public interface AnalyzerFacade<A : ResolverForModule, in P : PlatformAnalysisParameters> {
public fun <M : ModuleInfo> setupResolverForProject( public fun <M : ModuleInfo> setupResolverForProject(
projectContext: ProjectContext, projectContext: ProjectContext,
modules: Collection<M>, modules: Collection<M>,
@@ -97,10 +97,10 @@ public class PseudocodeVariableDataCollector(
} }
//todo may be a type alias //todo may be a type alias
trait InstructionDataMergeStrategy<D> : interface InstructionDataMergeStrategy<D> :
(Instruction, Collection<MutableMap<VariableDescriptor, D>>) -> Edges<MutableMap<VariableDescriptor, D>> (Instruction, Collection<MutableMap<VariableDescriptor, D>>) -> Edges<MutableMap<VariableDescriptor, D>>
public trait LexicalScopeVariableInfo { public interface LexicalScopeVariableInfo {
val declaredIn : Map<VariableDescriptor, LexicalScope> val declaredIn : Map<VariableDescriptor, LexicalScope>
val scopeVariables : Map<LexicalScope, Collection<VariableDescriptor>> val scopeVariables : Map<LexicalScope, Collection<VariableDescriptor>>
} }
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.PsiComment import com.intellij.psi.PsiComment
trait UnreachableCode { interface UnreachableCode {
val elements: Set<JetElement> val elements: Set<JetElement>
fun getUnreachableTextRanges(element: JetElement): List<TextRange> fun getUnreachableTextRanges(element: JetElement): List<TextRange>
} }
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.cfg.pseudocode
import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue
public trait PseudoValue { public interface PseudoValue {
public val debugName: String public val debugName: String
public val element: JetElement? public val element: JetElement?
public val createdAt: InstructionWithValue? public val createdAt: InstructionWithValue?
} }
public trait PseudoValueFactory { public interface PseudoValueFactory {
public fun newValue(element: JetElement?, instruction: InstructionWithValue?): PseudoValue public fun newValue(element: JetElement?, instruction: InstructionWithValue?): PseudoValue
} }
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.checker.JetTypeChecker
public trait TypePredicate: (JetType) -> Boolean { public interface TypePredicate: (JetType) -> Boolean {
override fun invoke(typeToCheck: JetType): Boolean override fun invoke(typeToCheck: JetType): Boolean
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
public trait Instruction { public interface Instruction {
public var owner: Pseudocode public var owner: Pseudocode
public val previousInstructions: Collection<Instruction> public val previousInstructions: Collection<Instruction>
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions
import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.psi.JetElement
public trait JetElementInstruction : Instruction { public interface JetElementInstruction : Instruction {
public val element: JetElement public val element: JetElement
} }
@@ -16,23 +16,22 @@
package org.jetbrains.kotlin.cfg.pseudocode.instructions package org.jetbrains.kotlin.cfg.pseudocode.instructions
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.JetDeclaration import org.jetbrains.kotlin.psi.JetDeclaration
import kotlin.properties.Delegates import org.jetbrains.kotlin.psi.JetElement
public class LexicalScope(val parentScope: LexicalScope?, val element: JetElement) { public class LexicalScope(val parentScope: LexicalScope?, val element: JetElement) {
//todo remove after KT-4126 //todo remove after KT-4126
private val d = (parentScope?.depth ?: 0) + 1 private val d = (parentScope?.depth ?: 0) + 1
val depth: Int get() = d val depth: Int get() = d
val lexicalScopeForContainingDeclaration: LexicalScope? by Delegates.lazy { computeLexicalScopeForContainingDeclaration() } val lexicalScopeForContainingDeclaration: LexicalScope? by lazy { computeLexicalScopeForContainingDeclaration() }
private fun computeLexicalScopeForContainingDeclaration(): LexicalScope? { private fun computeLexicalScopeForContainingDeclaration(): LexicalScope? {
var scope: LexicalScope? = this var scope: LexicalScope? = this
while (scope != null) { while (scope != null) {
if (scope?.element is JetDeclaration) { if (scope.element is JetDeclaration) {
return scope return scope
} }
scope = scope?.parentScope scope = scope.parentScope
} }
return null return null
} }
@@ -20,6 +20,6 @@ import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
public trait InstructionWithReceivers: Instruction { public interface InstructionWithReceivers: Instruction {
public val receiverValues: Map<PseudoValue, ReceiverValue> public val receiverValues: Map<PseudoValue, ReceiverValue>
} }
@@ -19,6 +19,6 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions.eval
import org.jetbrains.kotlin.cfg.pseudocode.instructions.JetElementInstruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.JetElementInstruction
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
public trait InstructionWithValue : JetElementInstruction { public interface InstructionWithValue : JetElementInstruction {
public val outputValue: PseudoValue? public val outputValue: PseudoValue?
} }
@@ -18,4 +18,4 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction
public trait JumpInstruction : Instruction public interface JumpInstruction : Instruction
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.config
import java.io.File import java.io.File
public trait ContentRoot public interface ContentRoot
public data class KotlinSourceRoot(public val path: String): ContentRoot public data class KotlinSourceRoot(public val path: String): ContentRoot
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.psi.JetFile
public trait ExternalDeclarationsProvider { public interface ExternalDeclarationsProvider {
companion object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>( companion object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
"org.jetbrains.kotlin.externalDeclarationsProvider", "org.jetbrains.kotlin.externalDeclarationsProvider",
javaClass<ExternalDeclarationsProvider>() javaClass<ExternalDeclarationsProvider>()
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
// Don't implement JetElement (or it will be treated as statement) // Don't implement JetElement (or it will be treated as statement)
public trait KDoc : PsiComment { public interface KDoc : PsiComment {
public fun getOwner(): JetDeclaration? public fun getOwner(): JetDeclaration?
public fun getDefaultSection(): KDocSection public fun getDefaultSection(): KDocSection
public fun findSectionByName(name: String): KDocSection? public fun findSectionByName(name: String): KDocSection?
@@ -33,7 +33,7 @@ object JetQualifiedExpressionImpl {
} }
private fun JetQualifiedExpression.getExpression(afterOperation: Boolean): JetExpression? { private fun JetQualifiedExpression.getExpression(afterOperation: Boolean): JetExpression? {
return getOperationTokenNode()?.getPsi()?.siblings(afterOperation, false)?.firstOrNull { it is JetExpression } as? JetExpression return getOperationTokenNode().getPsi()?.siblings(afterOperation, false)?.firstOrNull { it is JetExpression } as? JetExpression
} }
public fun JetQualifiedExpression.getReceiverExpression(): JetExpression { public fun JetQualifiedExpression.getReceiverExpression(): JetExpression {
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.psi
import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait ValueArgument { public interface ValueArgument {
IfNotParsed IfNotParsed
public fun getArgumentExpression(): JetExpression? public fun getArgumentExpression(): JetExpression?
@@ -36,7 +36,7 @@ public trait ValueArgument {
public fun isExternal(): Boolean public fun isExternal(): Boolean
} }
public trait FunctionLiteralArgument : ValueArgument { public interface FunctionLiteralArgument : ValueArgument {
public fun getFunctionLiteral(): JetFunctionLiteralExpression public fun getFunctionLiteral(): JetFunctionLiteralExpression
override fun getArgumentExpression(): JetExpression override fun getArgumentExpression(): JetExpression
@@ -50,7 +50,7 @@ private fun CallableDescriptor.isPlatformStaticIn(predicate: (DeclarationDescrip
when (this) { when (this) {
is PropertyAccessorDescriptor -> { is PropertyAccessorDescriptor -> {
val propertyDescriptor = getCorrespondingProperty() val propertyDescriptor = getCorrespondingProperty()
predicate(propertyDescriptor.getContainingDeclaration()!!) && predicate(propertyDescriptor.getContainingDeclaration()) &&
(hasPlatformStaticAnnotation() || propertyDescriptor.hasPlatformStaticAnnotation()) (hasPlatformStaticAnnotation() || propertyDescriptor.hasPlatformStaticAnnotation())
} }
else -> predicate(getContainingDeclaration()) && hasPlatformStaticAnnotation() else -> predicate(getContainingDeclaration()) && hasPlatformStaticAnnotation()
@@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.ServiceManager
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
public trait CodeAnalyzerInitializer { public interface CodeAnalyzerInitializer {
public fun initialize(trace: BindingTrace, module: ModuleDescriptor, codeAnalyzer: KotlinCodeAnalyzer?) public fun initialize(trace: BindingTrace, module: ModuleDescriptor, codeAnalyzer: KotlinCodeAnalyzer?)
public fun createTrace(): BindingTrace public fun createTrace(): BindingTrace
@@ -83,8 +83,8 @@ public object DescriptorToSourceUtils {
if (declarationDescriptor is PropertyAccessorDescriptor) { if (declarationDescriptor is PropertyAccessorDescriptor) {
descriptor = (descriptor as PropertyAccessorDescriptor).getCorrespondingProperty() descriptor = (descriptor as PropertyAccessorDescriptor).getCorrespondingProperty()
} }
while (!(descriptor == null || DescriptorUtils.isTopLevelDeclaration(descriptor!!))) { while (!(descriptor == null || DescriptorUtils.isTopLevelDeclaration(descriptor))) {
descriptor = descriptor!!.getContainingDeclaration() descriptor = descriptor.getContainingDeclaration()
} }
return descriptor return descriptor
} }
@@ -28,13 +28,13 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.TypeProjectionImpl
trait TypeBinding<out P : PsiElement> { interface TypeBinding<out P : PsiElement> {
val psiElement: P val psiElement: P
val jetType: JetType val jetType: JetType
fun getArgumentBindings(): List<TypeArgumentBinding<P>?> fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
} }
trait TypeArgumentBinding<out P: PsiElement> { interface TypeArgumentBinding<out P: PsiElement> {
val typeProjection: TypeProjection val typeProjection: TypeProjection
val typeParameterDescriptor: TypeParameterDescriptor? val typeParameterDescriptor: TypeParameterDescriptor?
val typeBinding: TypeBinding<P> val typeBinding: TypeBinding<P>
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
public trait AdditionalTypeChecker { public interface AdditionalTypeChecker {
public class Composite(val checkers: List<AdditionalTypeChecker>): AdditionalTypeChecker { public class Composite(val checkers: List<AdditionalTypeChecker>): AdditionalTypeChecker {
override fun checkType(expression: JetExpression, expressionType: JetType, c: ResolutionContext<*>) { override fun checkType(expression: JetExpression, expressionType: JetType, c: ResolutionContext<*>) {
@@ -33,14 +33,12 @@ public class InlineCheckerWrapper : CallChecker {
var parentDescriptor: DeclarationDescriptor? = context.scope.getContainingDeclaration() var parentDescriptor: DeclarationDescriptor? = context.scope.getContainingDeclaration()
while (parentDescriptor != null) { while (parentDescriptor != null) {
val descriptor = parentDescriptor!! if (InlineUtil.isInline(parentDescriptor)) {
val checker = getChecker(parentDescriptor as SimpleFunctionDescriptor)
if (InlineUtil.isInline(descriptor)) {
val checker = getChecker(descriptor as SimpleFunctionDescriptor)
checker.check(resolvedCall, context) checker.check(resolvedCall, context)
} }
parentDescriptor = parentDescriptor?.getContainingDeclaration() parentDescriptor = parentDescriptor.getContainingDeclaration()
} }
} }
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
import org.jetbrains.kotlin.resolve.calls.context.ResolutionResultsCache.CachedData import org.jetbrains.kotlin.resolve.calls.context.ResolutionResultsCache.CachedData
public trait ResolutionResultsCache { public interface ResolutionResultsCache {
public data class CachedData( public data class CachedData(
val resolutionResults: OverloadResolutionResultsImpl<*>, val resolutionResults: OverloadResolutionResultsImpl<*>,
val deferredComputation: BasicCallResolutionContext, val deferredComputation: BasicCallResolutionContext,
@@ -38,7 +38,7 @@ public enum class ArgumentMatchStatus(val isError: Boolean = true) {
UNKNOWN() UNKNOWN()
} }
public trait ArgumentMatch : ArgumentMapping { public interface ArgumentMatch : ArgumentMapping {
public val valueParameter: ValueParameterDescriptor public val valueParameter: ValueParameterDescriptor
public val status: ArgumentMatchStatus public val status: ArgumentMatchStatus
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
public trait VariableAsFunctionResolvedCall { public interface VariableAsFunctionResolvedCall {
public val functionCall: ResolvedCall<FunctionDescriptor> public val functionCall: ResolvedCall<FunctionDescriptor>
public val variableCall: ResolvedCall<VariableDescriptor> public val variableCall: ResolvedCall<VariableDescriptor>
} }
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.types.expressions.OperatorConventions
public trait CallableDescriptorCollector<D : CallableDescriptor> { public interface CallableDescriptorCollector<D : CallableDescriptor> {
public fun getNonExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection<D> public fun getNonExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection<D>
@@ -67,7 +67,7 @@ public class ResolutionTaskHolder<D : CallableDescriptor, F : D>(
return internalTasks!! return internalTasks!!
} }
public trait PriorityProvider<D> { public interface PriorityProvider<D> {
public fun getPriority(candidate: D): Int public fun getPriority(candidate: D): Int
public fun getMaxPriority(): Int public fun getMaxPriority(): Int
@@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Diagnostic
import com.intellij.openapi.util.ModificationTracker import com.intellij.openapi.util.ModificationTracker
public trait Diagnostics : Iterable<Diagnostic> { public interface Diagnostics : Iterable<Diagnostic> {
//should not be called on readonly views //should not be called on readonly views
//any Diagnostics object returned by BindingContext#getDiagnostics() should implement this property //any Diagnostics object returned by BindingContext#getDiagnostics() should implement this property
public val modificationTracker: ModificationTracker public val modificationTracker: ModificationTracker
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.StorageManager
public trait LazyClassContext { public interface LazyClassContext {
val declarationScopeProvider: DeclarationScopeProvider val declarationScopeProvider: DeclarationScopeProvider
val storageManager: StorageManager val storageManager: StorageManager
@@ -35,9 +35,8 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.util.collectionUtils.concat
import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.Printer
import java.util.LinkedHashSet import java.util.LinkedHashSet
import kotlin.properties.Delegates
trait IndexedImports { interface IndexedImports {
val imports: List<JetImportDirective> val imports: List<JetImportDirective>
fun importsForName(name: Name): Collection<JetImportDirective> fun importsForName(name: Name): Collection<JetImportDirective>
} }
@@ -50,7 +49,7 @@ class AllUnderImportsIndexed(allImports: Collection<JetImportDirective>) : Index
class AliasImportsIndexed(allImports: Collection<JetImportDirective>) : IndexedImports { class AliasImportsIndexed(allImports: Collection<JetImportDirective>) : IndexedImports {
override val imports = allImports.filter { !it.isAllUnder() } override val imports = allImports.filter { !it.isAllUnder() }
private val nameToDirectives: ListMultimap<Name, JetImportDirective> by Delegates.lazy { private val nameToDirectives: ListMultimap<Name, JetImportDirective> by lazy {
val builder = ImmutableListMultimap.builder<Name, JetImportDirective>() val builder = ImmutableListMultimap.builder<Name, JetImportDirective>()
for (directive in imports) { for (directive in imports) {
@@ -144,6 +144,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
this.packages = this.packages =
storageManager.createMemoizedFunctionWithNullableValues(new Function1<FqName, LazyPackageDescriptor>() { storageManager.createMemoizedFunctionWithNullableValues(new Function1<FqName, LazyPackageDescriptor>() {
@Override
@Nullable @Nullable
public LazyPackageDescriptor invoke(FqName fqName) { public LazyPackageDescriptor invoke(FqName fqName) {
return createPackage(fqName); return createPackage(fqName);
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetScript import org.jetbrains.kotlin.psi.JetScript
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor
public trait TopLevelDescriptorProvider { public interface TopLevelDescriptorProvider {
fun getPackageFragment(fqName: FqName): LazyPackageDescriptor? fun getPackageFragment(fqName: FqName): LazyPackageDescriptor?
fun getScriptDescriptor(script: JetScript): ScriptDescriptor fun getScriptDescriptor(script: JetScript): ScriptDescriptor
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.resolve.lazy.declarations
import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo
public trait ClassMemberDeclarationProvider : DeclarationProvider { public interface ClassMemberDeclarationProvider : DeclarationProvider {
public fun getOwnerInfo(): JetClassLikeInfo public fun getOwnerInfo(): JetClassLikeInfo
} }
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
public trait DeclarationProvider { public interface DeclarationProvider {
public fun getDeclarations(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<JetDeclaration> public fun getDeclarations(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<JetDeclaration>
public fun getFunctionDeclarations(name: Name): Collection<JetNamedFunction> public fun getFunctionDeclarations(name: Name): Collection<JetNamedFunction>
@@ -21,10 +21,7 @@ import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait PackageMemberDeclarationProvider : DeclarationProvider { public interface PackageMemberDeclarationProvider : DeclarationProvider {
/**
* Implementation of this method are not obliged to use the filters but may do so when it gives any performance advantage
*/
public fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection<FqName> public fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection<FqName>
public fun getPackageFiles(): Collection<JetFile> public fun getPackageFiles(): Collection<JetFile>
@@ -83,7 +83,7 @@ public open class LazyClassMemberScope(
return result return result
} }
private trait MemberExtractor<T : CallableMemberDescriptor> { private interface MemberExtractor<T : CallableMemberDescriptor> {
public fun extract(extractFrom: JetType, name: Name): Collection<T> public fun extract(extractFrom: JetType, name: Name): Collection<T>
} }
@@ -20,7 +20,7 @@ import com.google.common.collect.Multimap
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait WritableScope : JetScope { public interface WritableScope : JetScope {
public enum class LockLevel { public enum class LockLevel {
WRITING, WRITING,
BOTH, BOTH,
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
import java.util.ArrayList import java.util.ArrayList
import kotlin.properties.Delegates import kotlin.properties.Delegates
public trait Qualifier: ReceiverValue { public interface Qualifier: ReceiverValue {
public val expression: JetExpression public val expression: JetExpression
@@ -19,6 +19,6 @@ package org.jetbrains.kotlin.resolve.source
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceElement
public trait PsiSourceElement : SourceElement { public interface PsiSourceElement : SourceElement {
public val psi: PsiElement? public val psi: PsiElement?
} }
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.BindingTrace
import kotlin.platform.platformStatic import kotlin.platform.platformStatic
public trait SymbolUsageValidator { public interface SymbolUsageValidator {
public fun validateTypeUsage(targetDescriptor: ClassifierDescriptor, trace: BindingTrace, element: PsiElement) { } public fun validateTypeUsage(targetDescriptor: ClassifierDescriptor, trace: BindingTrace, element: PsiElement) { }
@@ -307,6 +307,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
@Override
public JetTypeInfo visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, ExpressionTypingContext data) { public JetTypeInfo visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, ExpressionTypingContext data) {
return basic.visitSimpleNameExpression(expression, data); return basic.visitSimpleNameExpression(expression, data);
} }