use of org.jetbrains.kotlin.psi.KtDeclarationContainer in project intellij by bazelbuild.
the class BlazeKotlinRunConfigurationProducer method getTargetIdeInfo.
@Nullable
private static TargetIdeInfo getTargetIdeInfo(ConfigurationContext context) {
Location<?> location = context.getLocation();
if (location == null) {
return null;
}
VirtualFile virtualFile = location.getVirtualFile();
if (virtualFile == null) {
return null;
}
KtDeclarationContainer entryPointContainer = KotlinRunConfigurationProducer.Companion.getEntryPointContainer(location.getPsiElement());
if (entryPointContainer == null) {
return null;
}
String startClassFqName = KotlinRunConfigurationProducer.Companion.getStartClassFqName(entryPointContainer);
if (startClassFqName == null) {
return null;
}
Collection<TargetIdeInfo> kotlinBinaryTargets = findKotlinBinaryTargets(context.getProject(), VfsUtil.virtualToIoFile(virtualFile));
// first look for a matching main_class
TargetIdeInfo match = kotlinBinaryTargets.stream().filter(target -> target.javaIdeInfo != null && startClassFqName.equals(target.javaIdeInfo.javaBinaryMainClass)).findFirst().orElse(null);
if (match != null) {
return match;
}
match = kotlinBinaryTargets.stream().filter(target -> startClassFqName.equals(target.key.label.targetName().toString())).findFirst().orElse(null);
if (match != null) {
return match;
}
return Iterables.getFirst(kotlinBinaryTargets, null);
}
use of org.jetbrains.kotlin.psi.KtDeclarationContainer in project kotlin by JetBrains.
the class JetRunConfiguration method updateMainClassName.
private void updateMainClassName(PsiElement element) {
KtDeclarationContainer container = KotlinRunConfigurationProducer.Companion.getEntryPointContainer(element);
String name = KotlinRunConfigurationProducer.Companion.getStartClassFqName(container);
if (name != null) {
MAIN_CLASS_NAME = name;
}
}
Aggregations