001 /* 002 * Copyright 2010-2013 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jetbrains.jet.lang.resolve.java; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.jet.lang.DefaultModuleConfiguration; 021 import org.jetbrains.jet.lang.ModuleConfiguration; 022 import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; 023 import org.jetbrains.jet.lang.resolve.ImportPath; 024 import org.jetbrains.jet.lang.resolve.scopes.JetScope; 025 import org.jetbrains.jet.lang.resolve.scopes.WritableScope; 026 027 import javax.inject.Inject; 028 import java.util.ArrayList; 029 import java.util.Arrays; 030 import java.util.Collections; 031 import java.util.List; 032 033 public class JavaBridgeConfiguration implements ModuleConfiguration { 034 035 public static final List<ImportPath> DEFAULT_JAVA_IMPORTS = Collections.unmodifiableList(Arrays.asList(new ImportPath("java.lang.*"))); 036 public static final List<ImportPath> ALL_JAVA_IMPORTS; 037 038 static { 039 List<ImportPath> allJavaImports = new ArrayList<ImportPath>(); 040 allJavaImports.addAll(DEFAULT_JAVA_IMPORTS); 041 allJavaImports.addAll(DefaultModuleConfiguration.DEFAULT_JET_IMPORTS); 042 ALL_JAVA_IMPORTS = Collections.unmodifiableList(allJavaImports); 043 } 044 045 private JavaDescriptorResolver javaDescriptorResolver; 046 047 @Inject 048 public void setJavaDescriptorResolver(@NotNull JavaDescriptorResolver javaDescriptorResolver) { 049 this.javaDescriptorResolver = javaDescriptorResolver; 050 } 051 052 @Override 053 public void extendNamespaceScope(@NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope) { 054 JetScope javaPackageScope = javaDescriptorResolver.getJavaPackageScope(namespaceDescriptor); 055 if (javaPackageScope != null) { 056 namespaceMemberScope.importScope(javaPackageScope); 057 } 058 DefaultModuleConfiguration.INSTANCE.extendNamespaceScope(namespaceDescriptor, namespaceMemberScope); 059 } 060 }