use of org.jetbrains.kotlin.psi.KtNamedFunction 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();
}
use of org.jetbrains.kotlin.psi.KtNamedFunction in project kotlin by JetBrains.
the class KotlinOverridingTest method makeFunction.
private FunctionDescriptor makeFunction(String funDecl) {
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(module);
return functionDescriptorResolver.resolveFunctionDescriptor(module, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
}
Aggregations