use of org.jetbrains.kotlin.idea.MainFunctionDetector in project kotlin by JetBrains.
the class JetRunConfiguration method findMainFun.
@Nullable
private static KtNamedFunction findMainFun(@NotNull PsiClass psiClass) {
for (KtNamedFunction function : getMainFunCandidates(psiClass)) {
BindingContext bindingContext = ResolutionUtils.analyze(function, BodyResolveMode.FULL);
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext);
if (mainFunctionDetector.isMain(function))
return function;
}
return null;
}
use of org.jetbrains.kotlin.idea.MainFunctionDetector in project kotlin by JetBrains.
the class Translation method generateCallToMain.
//TODO: determine whether should throw exception
@Nullable
private static JsStatement generateCallToMain(@NotNull TranslationContext context, @NotNull Collection<KtFile> files, @NotNull List<String> arguments) {
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(context.bindingContext());
KtNamedFunction mainFunction = mainFunctionDetector.getMainFunction(files);
if (mainFunction == null) {
return null;
}
FunctionDescriptor functionDescriptor = getFunctionDescriptor(context.bindingContext(), mainFunction);
JsArrayLiteral argument = new JsArrayLiteral(toStringLiteralList(arguments, context.program()));
return CallTranslator.INSTANCE.buildCall(context, functionDescriptor, Collections.singletonList(argument), null).makeStmt();
}
Aggregations