Ejemplo n.º 1
0
 @NotNull
 public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) {
   final PsiAnnotation annotation =
       JavaAnnotationResolver.findAnnotationWithExternal(
           psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName());
   return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION;
 }
Ejemplo n.º 2
0
 @Nullable
 private CompileTimeConstant<?> getCompileTimeConstFromAnnotation(
     PsiAnnotation value, PostponedTasks taskList) {
   AnnotationDescriptor annotationDescriptor =
       annotationResolver.resolveAnnotation(value, taskList);
   if (annotationDescriptor != null) {
     return new AnnotationValue(annotationDescriptor);
   }
   return null;
 }
  public InjectorForJavaSemanticServices(@NotNull Project project) {
    this.javaSemanticServices = new JavaSemanticServices();
    this.javaDescriptorResolver = new JavaDescriptorResolver();
    this.bindingTrace = new org.jetbrains.jet.lang.resolve.BindingTraceContext();
    this.javaBridgeConfiguration = new JavaBridgeConfiguration();
    this.psiClassFinder = new PsiClassFinderImpl();
    this.moduleDescriptor =
        new org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl(
            org.jetbrains.jet.lang.resolve.name.Name.special("<dummy>"),
            org.jetbrains.jet.lang.resolve.java.JavaBridgeConfiguration.ALL_JAVA_IMPORTS,
            org.jetbrains.jet.lang.resolve.java.JavaToKotlinClassMap.getInstance());
    this.project = project;
    this.psiDeclarationProviderFactory = new PsiDeclarationProviderFactory(getPsiClassFinder());
    this.javaTypeTransformer = new JavaTypeTransformer();
    this.javaClassResolver = new JavaClassResolver();
    this.javaAnnotationResolver = new JavaAnnotationResolver();
    this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
    this.javaClassObjectResolver = new JavaClassObjectResolver();
    this.javaSupertypeResolver = new JavaSupertypeResolver();
    this.javaFunctionResolver = new JavaFunctionResolver();
    this.javaValueParameterResolver = new JavaValueParameterResolver();
    this.javaSignatureResolver = new JavaSignatureResolver();
    this.javaNamespaceResolver = new JavaNamespaceResolver();
    this.javaConstructorResolver = new JavaConstructorResolver();
    this.javaInnerClassResolver = new JavaInnerClassResolver();
    this.javaPropertyResolver = new JavaPropertyResolver();

    this.javaSemanticServices.setDescriptorResolver(javaDescriptorResolver);
    this.javaSemanticServices.setPsiClassFinder(psiClassFinder);
    this.javaSemanticServices.setPsiDeclarationProviderFactory(psiDeclarationProviderFactory);
    this.javaSemanticServices.setTrace(bindingTrace);
    this.javaSemanticServices.setTypeTransformer(javaTypeTransformer);

    this.javaDescriptorResolver.setClassResolver(javaClassResolver);
    this.javaDescriptorResolver.setConstructorResolver(javaConstructorResolver);
    this.javaDescriptorResolver.setFunctionResolver(javaFunctionResolver);
    this.javaDescriptorResolver.setInnerClassResolver(javaInnerClassResolver);
    this.javaDescriptorResolver.setNamespaceResolver(javaNamespaceResolver);
    this.javaDescriptorResolver.setPropertiesResolver(javaPropertyResolver);

    javaBridgeConfiguration.setJavaSemanticServices(javaSemanticServices);

    this.psiClassFinder.setProject(project);

    moduleDescriptor.setModuleConfiguration(javaBridgeConfiguration);

    javaTypeTransformer.setJavaSemanticServices(javaSemanticServices);
    javaTypeTransformer.setResolver(javaDescriptorResolver);

    javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
    javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
    javaClassResolver.setFunctionResolver(javaFunctionResolver);
    javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
    javaClassResolver.setPsiClassFinder(psiClassFinder);
    javaClassResolver.setSemanticServices(javaSemanticServices);
    javaClassResolver.setSignatureResolver(javaSignatureResolver);
    javaClassResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassResolver.setTrace(bindingTrace);

    javaAnnotationResolver.setClassResolver(javaClassResolver);
    javaAnnotationResolver.setCompileTimeConstResolver(javaCompileTimeConstResolver);

    javaCompileTimeConstResolver.setAnnotationResolver(javaAnnotationResolver);
    javaCompileTimeConstResolver.setClassResolver(javaClassResolver);

    javaClassObjectResolver.setSemanticServices(javaSemanticServices);
    javaClassObjectResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassObjectResolver.setTrace(bindingTrace);

    javaSupertypeResolver.setClassResolver(javaClassResolver);
    javaSupertypeResolver.setSemanticServices(javaSemanticServices);
    javaSupertypeResolver.setTrace(bindingTrace);
    javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);

    javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
    javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
    javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
    javaFunctionResolver.setTrace(bindingTrace);
    javaFunctionResolver.setTypeTransformer(javaTypeTransformer);

    javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);

    javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);

    javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
    javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
    javaNamespaceResolver.setTrace(bindingTrace);

    javaConstructorResolver.setTrace(bindingTrace);
    javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
    javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);

    javaInnerClassResolver.setClassResolver(javaClassResolver);

    javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
    javaPropertyResolver.setJavaSignatureResolver(javaSignatureResolver);
    javaPropertyResolver.setSemanticServices(javaSemanticServices);
    javaPropertyResolver.setTrace(bindingTrace);

    psiClassFinder.initialize();
  }
  public InjectorForTopDownAnalyzerForJvm(
      @NotNull Project project,
      @NotNull TopDownAnalysisParameters topDownAnalysisParameters,
      @NotNull BindingTrace bindingTrace,
      @NotNull ModuleDescriptorImpl moduleDescriptor) {
    this.topDownAnalyzer = new TopDownAnalyzer();
    this.topDownAnalysisContext = new TopDownAnalysisContext();
    this.bodyResolver = new BodyResolver();
    this.controlFlowAnalyzer = new ControlFlowAnalyzer();
    this.declarationsChecker = new DeclarationsChecker();
    this.descriptorResolver = new DescriptorResolver();
    this.project = project;
    this.topDownAnalysisParameters = topDownAnalysisParameters;
    this.bindingTrace = bindingTrace;
    this.moduleDescriptor = moduleDescriptor;
    this.javaBridgeConfiguration = new JavaBridgeConfiguration();
    this.javaDescriptorResolver = new JavaDescriptorResolver();
    this.psiClassFinder = new PsiClassFinderImpl();
    this.namespaceFactory = new NamespaceFactoryImpl();
    this.declarationResolver = new DeclarationResolver();
    this.annotationResolver = new AnnotationResolver();
    this.callResolver = new CallResolver();
    this.argumentTypeResolver = new ArgumentTypeResolver();
    this.expressionTypingServices = new ExpressionTypingServices();
    this.callExpressionResolver = new CallExpressionResolver();
    this.typeResolver = new TypeResolver();
    this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
    this.candidateResolver = new CandidateResolver();
    this.importsResolver = new ImportsResolver();
    this.jetImportsFactory = new JetImportsFactory();
    this.scriptHeaderResolver = new ScriptHeaderResolver();
    this.overloadResolver = new OverloadResolver();
    this.overrideResolver = new OverrideResolver();
    this.typeHierarchyResolver = new TypeHierarchyResolver();
    this.scriptBodyResolver = new ScriptBodyResolver();
    this.javaSemanticServices = new JavaSemanticServices();
    this.psiDeclarationProviderFactory = new PsiDeclarationProviderFactory(psiClassFinder);
    this.javaTypeTransformer = new JavaTypeTransformer();
    this.javaClassResolver = new JavaClassResolver();
    this.javaAnnotationResolver = new JavaAnnotationResolver();
    this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
    this.javaClassObjectResolver = new JavaClassObjectResolver();
    this.javaSupertypeResolver = new JavaSupertypeResolver();
    this.javaNamespaceResolver = new JavaNamespaceResolver();
    this.javaSignatureResolver = new JavaSignatureResolver();
    this.javaConstructorResolver = new JavaConstructorResolver();
    this.javaValueParameterResolver = new JavaValueParameterResolver();
    this.javaFunctionResolver = new JavaFunctionResolver();
    this.javaInnerClassResolver = new JavaInnerClassResolver();
    this.javaPropertyResolver = new JavaPropertyResolver();

    this.topDownAnalyzer.setBodyResolver(bodyResolver);
    this.topDownAnalyzer.setContext(topDownAnalysisContext);
    this.topDownAnalyzer.setDeclarationResolver(declarationResolver);
    this.topDownAnalyzer.setModuleDescriptor(moduleDescriptor);
    this.topDownAnalyzer.setNamespaceFactory(namespaceFactory);
    this.topDownAnalyzer.setOverloadResolver(overloadResolver);
    this.topDownAnalyzer.setOverrideResolver(overrideResolver);
    this.topDownAnalyzer.setTopDownAnalysisParameters(topDownAnalysisParameters);
    this.topDownAnalyzer.setTrace(bindingTrace);
    this.topDownAnalyzer.setTypeHierarchyResolver(typeHierarchyResolver);

    this.topDownAnalysisContext.setTopDownAnalysisParameters(topDownAnalysisParameters);

    this.bodyResolver.setCallResolver(callResolver);
    this.bodyResolver.setContext(topDownAnalysisContext);
    this.bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
    this.bodyResolver.setDeclarationsChecker(declarationsChecker);
    this.bodyResolver.setDescriptorResolver(descriptorResolver);
    this.bodyResolver.setExpressionTypingServices(expressionTypingServices);
    this.bodyResolver.setScriptBodyResolverResolver(scriptBodyResolver);
    this.bodyResolver.setTopDownAnalysisParameters(topDownAnalysisParameters);
    this.bodyResolver.setTrace(bindingTrace);

    this.controlFlowAnalyzer.setTopDownAnalysisParameters(topDownAnalysisParameters);
    this.controlFlowAnalyzer.setTrace(bindingTrace);

    this.declarationsChecker.setTrace(bindingTrace);

    this.descriptorResolver.setAnnotationResolver(annotationResolver);
    this.descriptorResolver.setExpressionTypingServices(expressionTypingServices);
    this.descriptorResolver.setTypeResolver(typeResolver);

    this.javaBridgeConfiguration.setJavaSemanticServices(javaSemanticServices);

    javaDescriptorResolver.setClassResolver(javaClassResolver);
    javaDescriptorResolver.setConstructorResolver(javaConstructorResolver);
    javaDescriptorResolver.setFunctionResolver(javaFunctionResolver);
    javaDescriptorResolver.setInnerClassResolver(javaInnerClassResolver);
    javaDescriptorResolver.setNamespaceResolver(javaNamespaceResolver);
    javaDescriptorResolver.setPropertiesResolver(javaPropertyResolver);

    psiClassFinder.setProject(project);

    this.namespaceFactory.setModuleDescriptor(moduleDescriptor);
    this.namespaceFactory.setTrace(bindingTrace);

    declarationResolver.setAnnotationResolver(annotationResolver);
    declarationResolver.setContext(topDownAnalysisContext);
    declarationResolver.setDescriptorResolver(descriptorResolver);
    declarationResolver.setImportsResolver(importsResolver);
    declarationResolver.setScriptHeaderResolver(scriptHeaderResolver);
    declarationResolver.setTrace(bindingTrace);

    annotationResolver.setCallResolver(callResolver);
    annotationResolver.setExpressionTypingServices(expressionTypingServices);

    callResolver.setArgumentTypeResolver(argumentTypeResolver);
    callResolver.setCandidateResolver(candidateResolver);
    callResolver.setExpressionTypingServices(expressionTypingServices);
    callResolver.setTypeResolver(typeResolver);

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

    expressionTypingServices.setCallExpressionResolver(callExpressionResolver);
    expressionTypingServices.setCallResolver(callResolver);
    expressionTypingServices.setDescriptorResolver(descriptorResolver);
    expressionTypingServices.setProject(project);
    expressionTypingServices.setTypeResolver(typeResolver);

    callExpressionResolver.setExpressionTypingServices(expressionTypingServices);

    typeResolver.setAnnotationResolver(annotationResolver);
    typeResolver.setDescriptorResolver(descriptorResolver);
    typeResolver.setModuleDescriptor(moduleDescriptor);
    typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);

    candidateResolver.setArgumentTypeResolver(argumentTypeResolver);

    importsResolver.setContext(topDownAnalysisContext);
    importsResolver.setImportsFactory(jetImportsFactory);
    importsResolver.setModuleDescriptor(moduleDescriptor);
    importsResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
    importsResolver.setTrace(bindingTrace);

    jetImportsFactory.setProject(project);

    scriptHeaderResolver.setContext(topDownAnalysisContext);
    scriptHeaderResolver.setDependencyClassByQualifiedNameResolver(javaDescriptorResolver);
    scriptHeaderResolver.setNamespaceFactory(namespaceFactory);
    scriptHeaderResolver.setTopDownAnalysisParameters(topDownAnalysisParameters);
    scriptHeaderResolver.setTrace(bindingTrace);

    overloadResolver.setContext(topDownAnalysisContext);
    overloadResolver.setTrace(bindingTrace);

    overrideResolver.setContext(topDownAnalysisContext);
    overrideResolver.setTopDownAnalysisParameters(topDownAnalysisParameters);
    overrideResolver.setTrace(bindingTrace);

    typeHierarchyResolver.setContext(topDownAnalysisContext);
    typeHierarchyResolver.setDescriptorResolver(descriptorResolver);
    typeHierarchyResolver.setImportsResolver(importsResolver);
    typeHierarchyResolver.setNamespaceFactory(namespaceFactory);
    typeHierarchyResolver.setScriptHeaderResolver(scriptHeaderResolver);
    typeHierarchyResolver.setTrace(bindingTrace);

    scriptBodyResolver.setContext(topDownAnalysisContext);
    scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);
    scriptBodyResolver.setTrace(bindingTrace);

    javaSemanticServices.setDescriptorResolver(javaDescriptorResolver);
    javaSemanticServices.setPsiClassFinder(psiClassFinder);
    javaSemanticServices.setPsiDeclarationProviderFactory(psiDeclarationProviderFactory);
    javaSemanticServices.setTrace(bindingTrace);
    javaSemanticServices.setTypeTransformer(javaTypeTransformer);

    javaTypeTransformer.setJavaSemanticServices(javaSemanticServices);
    javaTypeTransformer.setResolver(javaDescriptorResolver);

    javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
    javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
    javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
    javaClassResolver.setPsiClassFinder(psiClassFinder);
    javaClassResolver.setSemanticServices(javaSemanticServices);
    javaClassResolver.setSignatureResolver(javaSignatureResolver);
    javaClassResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassResolver.setTrace(bindingTrace);

    javaAnnotationResolver.setClassResolver(javaClassResolver);
    javaAnnotationResolver.setCompileTimeConstResolver(javaCompileTimeConstResolver);

    javaCompileTimeConstResolver.setAnnotationResolver(javaAnnotationResolver);
    javaCompileTimeConstResolver.setClassResolver(javaClassResolver);

    javaClassObjectResolver.setSemanticServices(javaSemanticServices);
    javaClassObjectResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassObjectResolver.setTrace(bindingTrace);

    javaSupertypeResolver.setClassResolver(javaClassResolver);
    javaSupertypeResolver.setSemanticServices(javaSemanticServices);
    javaSupertypeResolver.setTrace(bindingTrace);
    javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);

    javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
    javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
    javaNamespaceResolver.setTrace(bindingTrace);

    javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);

    javaConstructorResolver.setTrace(bindingTrace);
    javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
    javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);

    javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);

    javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
    javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
    javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
    javaFunctionResolver.setTrace(bindingTrace);
    javaFunctionResolver.setTypeTransformer(javaTypeTransformer);

    javaInnerClassResolver.setClassResolver(javaClassResolver);

    javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
    javaPropertyResolver.setJavaSignatureResolver(javaSignatureResolver);
    javaPropertyResolver.setSemanticServices(javaSemanticServices);
    javaPropertyResolver.setTrace(bindingTrace);

    psiClassFinder.initialize();
  }
  public InjectorForJavaDescriptorResolver(
      @NotNull Project project,
      @NotNull BindingTrace bindingTrace,
      @NotNull ModuleDescriptor moduleDescriptor) {
    this.project = project;
    this.bindingTrace = bindingTrace;
    this.moduleDescriptor = moduleDescriptor;
    this.javaBridgeConfiguration = new JavaBridgeConfiguration();
    this.javaSemanticServices = new JavaSemanticServices();
    this.javaDescriptorResolver = new JavaDescriptorResolver();
    this.psiClassFinder = new PsiClassFinderImpl();
    this.psiDeclarationProviderFactory = new PsiDeclarationProviderFactory(getPsiClassFinder());
    this.javaTypeTransformer = new JavaTypeTransformer();
    this.javaClassResolver = new JavaClassResolver();
    this.javaAnnotationResolver = new JavaAnnotationResolver();
    this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
    this.javaClassObjectResolver = new JavaClassObjectResolver();
    this.javaSupertypeResolver = new JavaSupertypeResolver();
    this.javaNamespaceResolver = new JavaNamespaceResolver();
    this.javaSignatureResolver = new JavaSignatureResolver();
    this.javaConstructorResolver = new JavaConstructorResolver();
    this.javaValueParameterResolver = new JavaValueParameterResolver();
    this.javaFunctionResolver = new JavaFunctionResolver();
    this.javaInnerClassResolver = new JavaInnerClassResolver();
    this.javaPropertyResolver = new JavaPropertyResolver();

    javaBridgeConfiguration.setJavaSemanticServices(javaSemanticServices);
    javaBridgeConfiguration.setProject(project);

    this.javaSemanticServices.setDescriptorResolver(javaDescriptorResolver);
    this.javaSemanticServices.setPsiClassFinder(psiClassFinder);
    this.javaSemanticServices.setPsiDeclarationProviderFactory(psiDeclarationProviderFactory);
    this.javaSemanticServices.setTrace(bindingTrace);
    this.javaSemanticServices.setTypeTransformer(javaTypeTransformer);

    this.javaDescriptorResolver.setClassResolver(javaClassResolver);
    this.javaDescriptorResolver.setConstructorResolver(javaConstructorResolver);
    this.javaDescriptorResolver.setFunctionResolver(javaFunctionResolver);
    this.javaDescriptorResolver.setInnerClassResolver(javaInnerClassResolver);
    this.javaDescriptorResolver.setNamespaceResolver(javaNamespaceResolver);
    this.javaDescriptorResolver.setPropertiesResolver(javaPropertyResolver);

    this.psiClassFinder.setProject(project);

    javaTypeTransformer.setJavaSemanticServices(javaSemanticServices);
    javaTypeTransformer.setResolver(javaDescriptorResolver);

    javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
    javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
    javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
    javaClassResolver.setPsiClassFinder(psiClassFinder);
    javaClassResolver.setSemanticServices(javaSemanticServices);
    javaClassResolver.setSignatureResolver(javaSignatureResolver);
    javaClassResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassResolver.setTrace(bindingTrace);

    javaAnnotationResolver.setClassResolver(javaClassResolver);
    javaAnnotationResolver.setCompileTimeConstResolver(javaCompileTimeConstResolver);

    javaCompileTimeConstResolver.setAnnotationResolver(javaAnnotationResolver);
    javaCompileTimeConstResolver.setClassResolver(javaClassResolver);

    javaClassObjectResolver.setSemanticServices(javaSemanticServices);
    javaClassObjectResolver.setSupertypesResolver(javaSupertypeResolver);
    javaClassObjectResolver.setTrace(bindingTrace);

    javaSupertypeResolver.setClassResolver(javaClassResolver);
    javaSupertypeResolver.setSemanticServices(javaSemanticServices);
    javaSupertypeResolver.setTrace(bindingTrace);
    javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);

    javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
    javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
    javaNamespaceResolver.setTrace(bindingTrace);

    javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);

    javaConstructorResolver.setTrace(bindingTrace);
    javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
    javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);

    javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);

    javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
    javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
    javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
    javaFunctionResolver.setTrace(bindingTrace);
    javaFunctionResolver.setTypeTransformer(javaTypeTransformer);

    javaInnerClassResolver.setClassResolver(javaClassResolver);

    javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
    javaPropertyResolver.setJavaSignatureResolver(javaSignatureResolver);
    javaPropertyResolver.setSemanticServices(javaSemanticServices);
    javaPropertyResolver.setTrace(bindingTrace);

    javaBridgeConfiguration.init();

    psiClassFinder.initialize();
  }