use of org.jetbrains.kotlin.psi.KtProperty 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.KtProperty 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.KtProperty in project kotlin by JetBrains.
the class AddFieldBreakpointDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
updateUI();
}
});
myClassChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassChooser.setText(selectedClass.getQualifiedName());
}
}
});
myFieldChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
PsiClass selectedClass = getSelectedClass();
DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<DescriptorMemberChooserObject>(properties, false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
chooser.setCopyJavadocVisible(false);
chooser.show();
List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
KtProperty field = (KtProperty) selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
}
});
myFieldChooser.setEnabled(false);
return myPanel;
}
Aggregations