use of org.jetbrains.kotlin.psi.KtNamedFunction in project kotlin by JetBrains.
the class AnalyzerExtensions method process.
public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
for (Map.Entry<KtNamedFunction, SimpleFunctionDescriptor> entry : bodiesResolveContext.getFunctions().entrySet()) {
KtNamedFunction function = entry.getKey();
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
for (AnalyzerExtension extension : getFunctionExtensions(functionDescriptor)) {
extension.process(functionDescriptor, function, trace);
}
}
for (Map.Entry<KtProperty, PropertyDescriptor> entry : bodiesResolveContext.getProperties().entrySet()) {
KtProperty function = entry.getKey();
PropertyDescriptor propertyDescriptor = entry.getValue();
for (AnalyzerExtension extension : getPropertyExtensions(propertyDescriptor)) {
extension.process(propertyDescriptor, function, trace);
}
}
}
use of org.jetbrains.kotlin.psi.KtNamedFunction 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.psi.KtNamedFunction in project kotlin by JetBrains.
the class KotlinOverridingDialog method formatElement.
private static String formatElement(PsiElement element) {
element = KtPsiUtil.ascendIfPropertyAccessor(element);
if (element instanceof KtNamedFunction || element instanceof KtProperty) {
BindingContext bindingContext = ResolutionUtils.analyze((KtElement) element, BodyResolveMode.FULL);
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
if (declarationDescriptor instanceof CallableMemberDescriptor) {
DeclarationDescriptor containingDescriptor = declarationDescriptor.getContainingDeclaration();
if (containingDescriptor instanceof ClassDescriptor) {
return KotlinBundle.message("x.in.y", DescriptorRenderer.COMPACT.render(declarationDescriptor), IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor));
}
}
}
assert element instanceof PsiMethod : "Method accepts only kotlin functions/properties and java methods, but '" + element.getText() + "' was found";
return RenderingUtilsKt.formatPsiMethod((PsiMethod) element, true, false);
}
use of org.jetbrains.kotlin.psi.KtNamedFunction in project kotlin by JetBrains.
the class KotlinOverloadTest 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);
}
use of org.jetbrains.kotlin.psi.KtNamedFunction in project kotlin by JetBrains.
the class KtFunctionPsiElementCellRenderer method getElementText.
@Override
public String getElementText(PsiElement element) {
if (element instanceof KtNamedFunction) {
KtNamedFunction function = (KtNamedFunction) element;
DeclarationDescriptor descriptor = ResolutionUtils.resolveToDescriptor(function, BodyResolveMode.PARTIAL);
return DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(descriptor);
}
return super.getElementText(element);
}
Aggregations