public InjectorForReplWithJava(
      @NotNull ModuleContext moduleContext,
      @NotNull BindingTrace bindingTrace,
      @NotNull DeclarationProviderFactory declarationProviderFactory,
      @NotNull GlobalSearchScope moduleContentScope,
      @NotNull AdditionalFileScopeProvider additionalFileScopeProvider) {
    this.moduleContext = moduleContext;
    this.kotlinBuiltIns = moduleContext.getBuiltIns();
    this.moduleDescriptor = moduleContext.getModule();
    this.platformToKotlinClassMap = moduleContext.getPlatformToKotlinClassMap();
    this.project = moduleContext.getProject();
    this.storageManager = moduleContext.getStorageManager();
    this.bindingTrace = bindingTrace;
    this.declarationProviderFactory = declarationProviderFactory;
    this.resolveSession =
        new ResolveSession(
            project,
            getModuleContext(),
            moduleDescriptor,
            declarationProviderFactory,
            bindingTrace);
    this.scopeProvider = new ScopeProvider(getResolveSession());
    this.moduleContentScope = moduleContentScope;
    this.lazyTopDownAnalyzer = new LazyTopDownAnalyzer();
    this.lazyTopDownAnalyzerForTopLevel = new LazyTopDownAnalyzerForTopLevel();
    this.javaClassFinder = new JavaClassFinderImpl();
    this.jvmVirtualFileFinder =
        org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory.SERVICE
            .getInstance(project)
            .create(moduleContentScope);
    this.traceBasedErrorReporter = new TraceBasedErrorReporter();
    this.deserializedDescriptorResolver =
        new DeserializedDescriptorResolver(traceBasedErrorReporter);
    this.psiBasedExternalAnnotationResolver = new PsiBasedExternalAnnotationResolver();
    this.traceBasedExternalSignatureResolver = new TraceBasedExternalSignatureResolver();
    this.lazyResolveBasedCache = new LazyResolveBasedCache();
    this.javaPropertyInitializerEvaluator = new JavaPropertyInitializerEvaluatorImpl();
    this.samConversionResolver = SamConversionResolverImpl.INSTANCE$;
    this.javaSourceElementFactory = new JavaSourceElementFactoryImpl();
    this.singleModuleClassResolver = new SingleModuleClassResolver();
    this.globalJavaResolverContext =
        new GlobalJavaResolverContext(
            storageManager,
            javaClassFinder,
            jvmVirtualFileFinder,
            deserializedDescriptorResolver,
            psiBasedExternalAnnotationResolver,
            traceBasedExternalSignatureResolver,
            traceBasedErrorReporter,
            lazyResolveBasedCache,
            javaPropertyInitializerEvaluator,
            samConversionResolver,
            javaSourceElementFactory,
            singleModuleClassResolver);
    this.reflectionTypes = new ReflectionTypes(moduleDescriptor);
    this.lazyJavaPackageFragmentProvider =
        new LazyJavaPackageFragmentProvider(
            globalJavaResolverContext, moduleDescriptor, reflectionTypes);
    this.javaDescriptorResolver =
        new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, moduleDescriptor);
    this.javaClassDataFinder =
        new JavaClassDataFinder(jvmVirtualFileFinder, deserializedDescriptorResolver);
    this.binaryClassAnnotationAndConstantLoader =
        new BinaryClassAnnotationAndConstantLoaderImpl(
            moduleDescriptor, storageManager, jvmVirtualFileFinder, traceBasedErrorReporter);
    this.deserializationComponentsForJava =
        new DeserializationComponentsForJava(
            storageManager,
            moduleDescriptor,
            javaClassDataFinder,
            binaryClassAnnotationAndConstantLoader,
            lazyJavaPackageFragmentProvider);
    this.javaLazyAnalyzerPostConstruct = new JavaLazyAnalyzerPostConstruct();
    this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
    this.kotlinJvmCheckerProvider = KotlinJvmCheckerProvider.INSTANCE$;
    this.symbolUsageValidator = kotlinJvmCheckerProvider.getSymbolUsageValidator();
    this.additionalFileScopeProvider = additionalFileScopeProvider;
    this.annotationResolver = new AnnotationResolver();
    this.callResolver = new CallResolver();
    this.argumentTypeResolver = new ArgumentTypeResolver();
    this.expressionTypingComponents = new ExpressionTypingComponents();
    this.expressionTypingServices = new ExpressionTypingServices(expressionTypingComponents);
    this.callExpressionResolver = new CallExpressionResolver(callResolver, kotlinBuiltIns);
    this.controlStructureTypingUtils = new ControlStructureTypingUtils(callResolver);
    this.descriptorResolver = new DescriptorResolver();
    this.delegatedPropertyResolver = new DelegatedPropertyResolver();
    this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
    this.typeLazinessToken = new TypeLazinessToken();
    this.dynamicTypesSettings = new DynamicTypesSettings();
    this.typeResolver =
        new TypeResolver(
            annotationResolver,
            qualifiedExpressionResolver,
            moduleDescriptor,
            javaFlexibleTypeCapabilitiesProvider,
            storageManager,
            typeLazinessToken,
            dynamicTypesSettings);
    this.forLoopConventionsChecker = new ForLoopConventionsChecker();
    this.fakeCallResolver = new FakeCallResolver(project, callResolver);
    this.functionDescriptorResolver =
        new FunctionDescriptorResolver(
            typeResolver,
            descriptorResolver,
            annotationResolver,
            storageManager,
            expressionTypingServices,
            kotlinBuiltIns);
    this.localClassifierAnalyzer =
        new LocalClassifierAnalyzer(
            descriptorResolver, functionDescriptorResolver, typeResolver, annotationResolver);
    this.multiDeclarationResolver =
        new MultiDeclarationResolver(
            fakeCallResolver, descriptorResolver, typeResolver, symbolUsageValidator);
    this.valueParameterResolver =
        new ValueParameterResolver(kotlinJvmCheckerProvider, expressionTypingServices);
    this.statementFilter = new StatementFilter();
    this.candidateResolver = new CandidateResolver();
    this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
    this.taskPrioritizer = new TaskPrioritizer(storageManager);
    this.jetImportsFactory = new JetImportsFactory();
    this.lazyDeclarationResolver = new LazyDeclarationResolver(getModuleContext(), bindingTrace);
    this.declarationScopeProvider = new DeclarationScopeProviderImpl(lazyDeclarationResolver);
    this.scriptBodyResolver = new ScriptBodyResolver();
    this.bodyResolver = new BodyResolver();
    this.controlFlowAnalyzer = new ControlFlowAnalyzer();
    this.declarationsChecker = new DeclarationsChecker();
    this.modifiersChecker = new ModifiersChecker(bindingTrace, kotlinJvmCheckerProvider);
    this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
    this.declarationResolver = new DeclarationResolver();
    this.overloadResolver = new OverloadResolver();
    this.overrideResolver = new OverrideResolver();
    this.varianceChecker = new VarianceChecker(bindingTrace);

    this.resolveSession.setAnnotationResolve(annotationResolver);
    this.resolveSession.setDescriptorResolver(descriptorResolver);
    this.resolveSession.setFunctionDescriptorResolver(functionDescriptorResolver);
    this.resolveSession.setJetImportFactory(jetImportsFactory);
    this.resolveSession.setLazyDeclarationResolver(lazyDeclarationResolver);
    this.resolveSession.setQualifiedExpressionResolver(qualifiedExpressionResolver);
    this.resolveSession.setScopeProvider(scopeProvider);
    this.resolveSession.setScriptBodyResolver(scriptBodyResolver);
    this.resolveSession.setTypeResolver(typeResolver);

    scopeProvider.setAdditionalFileScopesProvider(additionalFileScopeProvider);
    scopeProvider.setDeclarationScopeProvider(declarationScopeProvider);

    this.lazyTopDownAnalyzer.setBodyResolver(bodyResolver);
    this.lazyTopDownAnalyzer.setDeclarationResolver(declarationResolver);
    this.lazyTopDownAnalyzer.setDeclarationScopeProvider(declarationScopeProvider);
    this.lazyTopDownAnalyzer.setFileScopeProvider(scopeProvider);
    this.lazyTopDownAnalyzer.setLazyDeclarationResolver(lazyDeclarationResolver);
    this.lazyTopDownAnalyzer.setModuleDescriptor(moduleDescriptor);
    this.lazyTopDownAnalyzer.setOverloadResolver(overloadResolver);
    this.lazyTopDownAnalyzer.setOverrideResolver(overrideResolver);
    this.lazyTopDownAnalyzer.setTopLevelDescriptorProvider(resolveSession);
    this.lazyTopDownAnalyzer.setTrace(bindingTrace);
    this.lazyTopDownAnalyzer.setVarianceChecker(varianceChecker);

    this.lazyTopDownAnalyzerForTopLevel.setKotlinCodeAnalyzer(resolveSession);
    this.lazyTopDownAnalyzerForTopLevel.setLazyTopDownAnalyzer(lazyTopDownAnalyzer);

    javaClassFinder.setComponentPostConstruct(javaLazyAnalyzerPostConstruct);
    javaClassFinder.setProject(project);
    javaClassFinder.setScope(moduleContentScope);

    traceBasedExternalSignatureResolver.setExternalAnnotationResolver(
        psiBasedExternalAnnotationResolver);
    traceBasedExternalSignatureResolver.setProject(project);
    traceBasedExternalSignatureResolver.setTrace(bindingTrace);

    lazyResolveBasedCache.setSession(resolveSession);

    traceBasedErrorReporter.setTrace(bindingTrace);

    singleModuleClassResolver.setResolver(javaDescriptorResolver);

    javaLazyAnalyzerPostConstruct.setCodeAnalyzer(resolveSession);
    javaLazyAnalyzerPostConstruct.setProject(project);
    javaLazyAnalyzerPostConstruct.setTrace(bindingTrace);

    annotationResolver.setCallResolver(callResolver);
    annotationResolver.setStorageManager(storageManager);
    annotationResolver.setTypeResolver(typeResolver);

    callResolver.setAdditionalCheckerProvider(kotlinJvmCheckerProvider);
    callResolver.setArgumentTypeResolver(argumentTypeResolver);
    callResolver.setCallCompleter(callCompleter);
    callResolver.setCandidateResolver(candidateResolver);
    callResolver.setExpressionTypingServices(expressionTypingServices);
    callResolver.setTaskPrioritizer(taskPrioritizer);
    callResolver.setTypeResolver(typeResolver);

    argumentTypeResolver.setBuiltIns(kotlinBuiltIns);
    argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
    argumentTypeResolver.setTypeResolver(typeResolver);

    expressionTypingServices.setStatementFilter(statementFilter);

    expressionTypingComponents.setAdditionalCheckerProvider(kotlinJvmCheckerProvider);
    expressionTypingComponents.setAnnotationResolver(annotationResolver);
    expressionTypingComponents.setBuiltIns(kotlinBuiltIns);
    expressionTypingComponents.setCallExpressionResolver(callExpressionResolver);
    expressionTypingComponents.setCallResolver(callResolver);
    expressionTypingComponents.setControlStructureTypingUtils(controlStructureTypingUtils);
    expressionTypingComponents.setDescriptorResolver(descriptorResolver);
    expressionTypingComponents.setDynamicTypesSettings(dynamicTypesSettings);
    expressionTypingComponents.setExpressionTypingServices(expressionTypingServices);
    expressionTypingComponents.setForLoopConventionsChecker(forLoopConventionsChecker);
    expressionTypingComponents.setFunctionDescriptorResolver(functionDescriptorResolver);
    expressionTypingComponents.setGlobalContext(moduleContext);
    expressionTypingComponents.setLocalClassifierAnalyzer(localClassifierAnalyzer);
    expressionTypingComponents.setMultiDeclarationResolver(multiDeclarationResolver);
    expressionTypingComponents.setPlatformToKotlinClassMap(platformToKotlinClassMap);
    expressionTypingComponents.setReflectionTypes(reflectionTypes);
    expressionTypingComponents.setSymbolUsageValidator(symbolUsageValidator);
    expressionTypingComponents.setTypeResolver(typeResolver);
    expressionTypingComponents.setValueParameterResolver(valueParameterResolver);

    callExpressionResolver.setExpressionTypingServices(expressionTypingServices);

    descriptorResolver.setAnnotationResolver(annotationResolver);
    descriptorResolver.setBuiltIns(kotlinBuiltIns);
    descriptorResolver.setDelegatedPropertyResolver(delegatedPropertyResolver);
    descriptorResolver.setExpressionTypingServices(expressionTypingServices);
    descriptorResolver.setStorageManager(storageManager);
    descriptorResolver.setTypeResolver(typeResolver);

    delegatedPropertyResolver.setAdditionalCheckerProvider(kotlinJvmCheckerProvider);
    delegatedPropertyResolver.setBuiltIns(kotlinBuiltIns);
    delegatedPropertyResolver.setCallResolver(callResolver);
    delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);

    qualifiedExpressionResolver.setSymbolUsageValidator(symbolUsageValidator);

    forLoopConventionsChecker.setBuiltIns(kotlinBuiltIns);
    forLoopConventionsChecker.setFakeCallResolver(fakeCallResolver);
    forLoopConventionsChecker.setSymbolUsageValidator(symbolUsageValidator);

    candidateResolver.setArgumentTypeResolver(argumentTypeResolver);

    jetImportsFactory.setProject(project);

    lazyDeclarationResolver.setDeclarationScopeProvider(declarationScopeProvider);
    lazyDeclarationResolver.setTopLevelDescriptorProvider(resolveSession);

    declarationScopeProvider.setFileScopeProvider(scopeProvider);

    scriptBodyResolver.setAdditionalCheckerProvider(kotlinJvmCheckerProvider);
    scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);

    bodyResolver.setAdditionalCheckerProvider(kotlinJvmCheckerProvider);
    bodyResolver.setAnnotationResolver(annotationResolver);
    bodyResolver.setCallResolver(callResolver);
    bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
    bodyResolver.setDeclarationsChecker(declarationsChecker);
    bodyResolver.setDelegatedPropertyResolver(delegatedPropertyResolver);
    bodyResolver.setExpressionTypingServices(expressionTypingServices);
    bodyResolver.setFunctionAnalyzerExtension(functionAnalyzerExtension);
    bodyResolver.setScriptBodyResolverResolver(scriptBodyResolver);
    bodyResolver.setTrace(bindingTrace);
    bodyResolver.setValueParameterResolver(valueParameterResolver);

    controlFlowAnalyzer.setTrace(bindingTrace);

    declarationsChecker.setDescriptorResolver(descriptorResolver);
    declarationsChecker.setModifiersChecker(modifiersChecker);
    declarationsChecker.setTrace(bindingTrace);

    functionAnalyzerExtension.setTrace(bindingTrace);

    declarationResolver.setAnnotationResolver(annotationResolver);
    declarationResolver.setTrace(bindingTrace);

    overloadResolver.setTrace(bindingTrace);

    overrideResolver.setTrace(bindingTrace);

    deserializedDescriptorResolver.setComponents(deserializationComponentsForJava);

    javaClassFinder.initialize();

    javaLazyAnalyzerPostConstruct.postCreate();
  }
Esempio n. 2
0
 public void resolveBodies(@NotNull BodiesResolveContext c) {
   resolveBehaviorDeclarationBodies(c);
   controlFlowAnalyzer.process(c);
   declarationsChecker.process(c);
   functionAnalyzerExtension.process(c);
 }