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 com.intellij.psi.PsiClass;
020 import com.intellij.psi.PsiPackage;
021 import org.jetbrains.annotations.NotNull;
022 import org.jetbrains.annotations.Nullable;
023 import org.jetbrains.jet.lang.resolve.java.structure.JavaClass;
024 import org.jetbrains.jet.lang.resolve.java.structure.JavaPackage;
025 import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl;
026 import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPackageImpl;
027 import org.jetbrains.jet.lang.resolve.name.FqName;
028
029 import javax.inject.Inject;
030
031 public class JavaClassFinderImpl implements JavaClassFinder {
032 private PsiClassFinder psiClassFinder;
033
034 @Inject
035 public void setPsiClassFinder(@NotNull PsiClassFinder psiClassFinder) {
036 this.psiClassFinder = psiClassFinder;
037 }
038
039 @Nullable
040 @Override
041 public JavaClass findClass(@NotNull FqName fqName) {
042 PsiClass psiClass = psiClassFinder.findPsiClass(fqName);
043 return psiClass == null ? null : new JavaClassImpl(psiClass);
044 }
045
046 @Nullable
047 @Override
048 public JavaPackage findPackage(@NotNull FqName fqName) {
049 PsiPackage psiPackage = psiClassFinder.findPsiPackage(fqName);
050 return psiPackage == null ? null : new JavaPackageImpl(psiPackage);
051 }
052 }