@Override public void addDefaultImports(@NotNull Collection<JetImportDirective> directives) { for (ImportPath importPath : DEFAULT_JAVA_IMPORTS) { directives.add(JetPsiFactory.createImportDirective(project, importPath)); } delegateConfiguration.addDefaultImports(directives); }
@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); }
@NotNull public Collection<? extends DeclarationDescriptor> processImportReference( @NotNull JetImportDirective importDirective, @NotNull JetScope scope, @NotNull JetScope scopeToCheckVisibility, @NotNull Importer importer, @NotNull BindingTrace trace, @NotNull ModuleConfiguration moduleConfiguration, @NotNull LookupMode lookupMode) { if (importDirective.isAbsoluteInRootNamespace()) { trace.report(UNSUPPORTED.on(importDirective, "TypeHierarchyResolver")); // TODO return Collections.emptyList(); } JetExpression importedReference = importDirective.getImportedReference(); if (importedReference == null) { return Collections.emptyList(); } Collection<? extends DeclarationDescriptor> descriptors; if (importedReference instanceof JetQualifiedExpression) { // store result only when we find all descriptors, not only classes on the second phase descriptors = lookupDescriptorsForQualifiedExpression( (JetQualifiedExpression) importedReference, scope, scopeToCheckVisibility, trace, lookupMode, lookupMode == LookupMode.EVERYTHING); } else { assert importedReference instanceof JetSimpleNameExpression; descriptors = lookupDescriptorsForSimpleNameReference( (JetSimpleNameExpression) importedReference, scope, scopeToCheckVisibility, trace, lookupMode, true, lookupMode == LookupMode.EVERYTHING); } JetSimpleNameExpression referenceExpression = JetPsiUtil.getLastReference(importedReference); if (importDirective.isAllUnder()) { if (referenceExpression == null || !canImportMembersFrom(descriptors, referenceExpression, trace, lookupMode)) { return Collections.emptyList(); } for (DeclarationDescriptor descriptor : descriptors) { importer.addAllUnderImport(descriptor, moduleConfiguration.getPlatformToKotlinClassMap()); } return Collections.emptyList(); } Name aliasName = JetPsiUtil.getAliasName(importDirective); if (aliasName == null) { return Collections.emptyList(); } for (DeclarationDescriptor descriptor : descriptors) { importer.addAliasImport(descriptor, aliasName); } return descriptors; }