private static PsiClass getPiClass(FqName packageFQN, JavaSemanticServices semanticServices) { // TODO: move this check outside // If this package is actually a Kotlin namespace, then we access it through a namespace // descriptor, and // Kotlin functions are already there NamespaceDescriptor kotlinNamespaceDescriptor = semanticServices.getKotlinNamespaceDescriptor(packageFQN); if (kotlinNamespaceDescriptor != null) { return null; } else { // TODO: what is GlobalSearchScope return semanticServices .getDescriptorResolver() .javaFacade .findClass(getQualifiedName(packageFQN, JvmAbi.PACKAGE_CLASS).getFqName()); } }
public JetTypeJetSignatureReader( JavaSemanticServices javaSemanticServices, JetStandardLibrary jetStandardLibrary, TypeVariableResolver typeVariableResolver) { this.javaSemanticServices = javaSemanticServices; this.javaDescriptorResolver = javaSemanticServices.getDescriptorResolver(); this.jetStandardLibrary = jetStandardLibrary; this.typeVariableResolver = typeVariableResolver; }
@Override public void extendNamespaceScope( @NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope) { namespaceMemberScope.importScope( javaSemanticServices .getDescriptorResolver() .createJavaPackageScope( DescriptorUtils.getFQName(namespaceDescriptor).toSafe(), namespaceDescriptor)); delegateConfiguration.extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope); }
@Override public void visitClassType(String name, boolean nullable, boolean forceReal) { FqName ourName = new FqName( name.replace('/', '.').replace('$', '.') // TODO: not sure ); this.classDescriptor = null; if (!forceReal) { classDescriptor = javaSemanticServices .getTypeTransformer() .getKotlinAnalog(ourName, JavaTypeTransformer.TypeUsage.MEMBER_SIGNATURE_INVARIANT); } if (classDescriptor == null) { // TODO: this is the worst code in Kotlin project Matcher matcher = Pattern.compile("jet\\.Function(\\d+)").matcher(ourName.getFqName()); if (matcher.matches()) { classDescriptor = JetStandardClasses.getFunction(Integer.parseInt(matcher.group(1))); } } if (classDescriptor == null) { Matcher matcher = Pattern.compile("jet\\.Tuple(\\d+)").matcher(ourName.getFqName()); if (matcher.matches()) { classDescriptor = JetStandardClasses.getTuple(Integer.parseInt(matcher.group(1))); } } if (this.classDescriptor == null) { this.classDescriptor = javaDescriptorResolver.resolveClass(ourName, DescriptorSearchRule.INCLUDE_KOTLIN); } if (this.classDescriptor == null) { // TODO: report in to trace this.errorType = ErrorUtils.createErrorType("class not found by name: " + ourName); } this.nullable = nullable; this.typeArguments = new ArrayList<TypeProjection>(); }