001 /* 002 * Copyright 2010-2015 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.kotlin.asJava; 018 019 import com.intellij.openapi.components.ServiceManager; 020 import com.intellij.openapi.project.Project; 021 import com.intellij.psi.PsiClass; 022 import com.intellij.psi.search.GlobalSearchScope; 023 import org.jetbrains.annotations.NotNull; 024 import org.jetbrains.annotations.Nullable; 025 import org.jetbrains.kotlin.descriptors.ClassDescriptor; 026 import org.jetbrains.kotlin.name.FqName; 027 import org.jetbrains.kotlin.psi.JetClassOrObject; 028 import org.jetbrains.kotlin.psi.JetFile; 029 030 import java.util.Collection; 031 032 public abstract class LightClassGenerationSupport { 033 034 @NotNull 035 public static LightClassGenerationSupport getInstance(@NotNull Project project) { 036 return ServiceManager.getService(project, LightClassGenerationSupport.class); 037 } 038 039 @NotNull 040 public abstract LightClassConstructionContext getContextForPackage(@NotNull Collection<JetFile> files); 041 042 @NotNull 043 public abstract LightClassConstructionContext getContextForClassOrObject(@NotNull JetClassOrObject classOrObject); 044 045 @NotNull 046 public abstract Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope); 047 048 /* 049 * Finds files whose package declaration is exactly {@code fqName}. For example, if a file declares 050 * package a.b.c 051 * it will not be returned for fqName "a.b" 052 * 053 * If the resulting collection is empty, it means that this package has not other declarations than sub-packages 054 */ 055 @NotNull 056 public abstract Collection<JetFile> findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope); 057 058 // Returns only immediately declared classes/objects, package classes are not included (they have no declarations) 059 @NotNull 060 public abstract Collection<JetClassOrObject> findClassOrObjectDeclarationsInPackage( 061 @NotNull FqName packageFqName, 062 @NotNull GlobalSearchScope searchScope 063 ); 064 065 public abstract boolean packageExists(@NotNull FqName fqName, @NotNull GlobalSearchScope scope); 066 067 @NotNull 068 public abstract Collection<FqName> getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope); 069 070 @Nullable 071 public abstract PsiClass getPsiClass(@NotNull JetClassOrObject classOrObject); 072 073 @NotNull 074 public abstract Collection<PsiClass> getPackageClasses(@NotNull FqName packageFqName, @NotNull GlobalSearchScope scope); 075 076 @Nullable 077 public abstract ClassDescriptor resolveClassToDescriptor(@NotNull JetClassOrObject classOrObject); 078 079 @NotNull 080 public abstract Collection<PsiClass> getFacadeClasses(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope); 081 082 @NotNull 083 public abstract Collection<PsiClass> getFacadeClassesInPackage(@NotNull FqName packageFqName, @NotNull GlobalSearchScope scope); 084 085 @NotNull 086 public abstract Collection<String> getFacadeNames(@NotNull FqName packageFqName, @NotNull GlobalSearchScope scope); 087 088 @NotNull 089 public abstract Collection<JetFile> findFilesForFacade(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope); 090 091 @NotNull 092 public abstract LightClassConstructionContext getContextForFacade(@NotNull Collection<JetFile> files); 093 094 }