use of org.jetbrains.kotlin.psi.KtClassOrObject in project kotlin by JetBrains.
the class JavaElementFinder method getClasses.
@NotNull
@Override
public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
List<PsiClass> answer = new SmartList<PsiClass>();
FqName packageFQN = new FqName(psiPackage.getQualifiedName());
answer.addAll(lightClassGenerationSupport.getFacadeClassesInPackage(packageFQN, scope));
Collection<KtClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
for (KtClassOrObject declaration : declarations) {
PsiClass aClass = toLightClass(declaration);
if (aClass != null) {
answer.add(aClass);
}
}
return sortByClasspath(answer, scope).toArray(new PsiClass[answer.size()]);
}
use of org.jetbrains.kotlin.psi.KtClassOrObject in project kotlin by JetBrains.
the class JavaElementFinder method getClassNames.
@NotNull
@Override
public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
FqName packageFQN = new FqName(psiPackage.getQualifiedName());
Collection<KtClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
Set<String> answer = Sets.newHashSet();
answer.addAll(lightClassGenerationSupport.getFacadeNames(packageFQN, scope));
for (KtClassOrObject declaration : declarations) {
String name = declaration.getName();
if (name != null) {
answer.add(name);
}
}
return answer;
}
use of org.jetbrains.kotlin.psi.KtClassOrObject in project kotlin by JetBrains.
the class JavaElementFinder method findClassesAndObjects.
// Finds explicitly declared classes and objects, not package classes
// Also DefaultImpls classes of interfaces
private void findClassesAndObjects(FqName qualifiedName, GlobalSearchScope scope, List<PsiClass> answer) {
findInterfaceDefaultImpls(qualifiedName, scope, answer);
Collection<KtClassOrObject> classOrObjectDeclarations = lightClassGenerationSupport.findClassOrObjectDeclarations(qualifiedName, scope);
for (KtClassOrObject declaration : classOrObjectDeclarations) {
if (!(declaration instanceof KtEnumEntry)) {
PsiClass lightClass = toLightClass(declaration);
if (lightClass != null) {
answer.add(lightClass);
}
}
}
}
use of org.jetbrains.kotlin.psi.KtClassOrObject in project kotlin by JetBrains.
the class KotlinBytecodeToolWindow method compileSingleFile.
@NotNull
public static GenerationState compileSingleFile(@NotNull final KtFile ktFile, @NotNull CompilerConfiguration configuration) {
ResolutionFacade resolutionFacade = ResolutionUtils.getResolutionFacade(ktFile);
BindingContext bindingContextForFile = resolutionFacade.analyzeFullyAndGetResult(Collections.singletonList(ktFile)).getBindingContext();
kotlin.Pair<BindingContext, List<KtFile>> result = DebuggerUtils.INSTANCE.analyzeInlinedFunctions(resolutionFacade, ktFile, configuration.getBoolean(CommonConfigurationKeys.DISABLE_INLINE), bindingContextForFile);
BindingContext bindingContext = result.getFirst();
List<KtFile> toProcess = result.getSecond();
GenerationState.GenerateClassFilter generateClassFilter = new GenerationState.GenerateClassFilter() {
@Override
public boolean shouldGeneratePackagePart(@NotNull KtFile file) {
return file == ktFile;
}
@Override
public boolean shouldAnnotateClass(@NotNull KtClassOrObject processingClassOrObject) {
return true;
}
@Override
public boolean shouldGenerateClass(@NotNull KtClassOrObject processingClassOrObject) {
return processingClassOrObject.getContainingKtFile() == ktFile;
}
@Override
public boolean shouldGenerateScript(@NotNull KtScript script) {
return script.getContainingKtFile() == ktFile;
}
};
GenerationState state = new GenerationState(ktFile.getProject(), ClassBuilderFactories.TEST, resolutionFacade.getModuleDescriptor(), bindingContext, toProcess, configuration, generateClassFilter);
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
return state;
}
use of org.jetbrains.kotlin.psi.KtClassOrObject in project kotlin by JetBrains.
the class KtFileTreeNode method getChildrenImpl.
@Override
public Collection<AbstractTreeNode> getChildrenImpl() {
KtFile file = (KtFile) getValue();
if (file == null)
return Collections.emptyList();
ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
if (getSettings().isShowMembers()) {
List<KtDeclaration> declarations = file.getDeclarations();
for (KtDeclaration declaration : declarations) {
if (declaration instanceof KtClassOrObject) {
result.add(new KtClassOrObjectTreeNode(file.getProject(), (KtClassOrObject) declaration, getSettings()));
} else if (getSettings().isShowMembers()) {
result.add(new KtDeclarationTreeNode(getProject(), declaration, getSettings()));
}
}
}
return result;
}
Aggregations