use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.
the class XValueNodeImpl method updateText.
private void updateText() {
myText.clear();
XValueMarkers<?, ?> markers = myTree.getValueMarkers();
if (markers != null) {
ValueMarkup markup = markers.getMarkup(getValueContainer());
if (markup != null) {
myText.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
}
}
appendName();
buildText(myValuePresentation, myText);
}
use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.
the class CodeFragmentFactoryContextWrapper method wrapContext.
private PsiElement wrapContext(Project project, final PsiElement originalContext) {
if (project.isDefault())
return originalContext;
//TODO [egor] : does not work for anything other than java anyway, see IDEA-132677
if (!(myDelegate instanceof DefaultCodeFragmentFactory)) {
return originalContext;
}
PsiElement context = originalContext;
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session != null) {
XValueMarkers<?, ?> markers = ((XDebugSessionImpl) session).getValueMarkers();
Map<?, ValueMarkup> markupMap = markers != null ? markers.getAllMarkers() : null;
//final Map<ObjectReference, ValueMarkup> markupMap = ValueDescriptorImpl.getMarkupMap(process);
if (!ContainerUtil.isEmpty(markupMap)) {
final Pair<String, Map<String, ObjectReference>> markupVariables = createMarkupVariablesText(markupMap);
int offset = markupVariables.getFirst().length() - 1;
final TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.CODE_BLOCK, markupVariables.getFirst(), "", myDelegate.getFileType());
final JavaCodeFragment codeFragment = myDelegate.createCodeFragment(textWithImports, context, project);
codeFragment.accept(new JavaRecursiveElementVisitor() {
public void visitLocalVariable(PsiLocalVariable variable) {
final String name = variable.getName();
variable.putUserData(LABEL_VARIABLE_VALUE_KEY, markupVariables.getSecond().get(name));
}
});
final PsiElement newContext = codeFragment.findElementAt(offset);
if (newContext != null) {
context = newContext;
}
}
}
return context;
}
use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.
the class CodeFragmentFactoryContextWrapper method createMarkupVariablesText.
private static Pair<String, Map<String, ObjectReference>> createMarkupVariablesText(Map<?, ValueMarkup> markupMap) {
final Map<String, ObjectReference> reverseMap = new HashMap<>();
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
try {
for (Map.Entry<?, ValueMarkup> entry : markupMap.entrySet()) {
ObjectReference objectRef = (ObjectReference) entry.getKey();
final ValueMarkup markup = entry.getValue();
String labelName = markup.getText();
if (!StringUtil.isJavaIdentifier(labelName)) {
continue;
}
try {
final String typeName = objectRef.type().name();
labelName += DEBUG_LABEL_SUFFIX;
if (buffer.length() > 0) {
buffer.append("\n");
}
buffer.append(typeName).append(" ").append(labelName).append(";");
reverseMap.put(labelName, objectRef);
} catch (ObjectCollectedException e) {
//it.remove();
}
}
buffer.append(" ");
return Pair.create(buffer.toString(), reverseMap);
} finally {
StringBuilderSpinAllocator.dispose(buffer);
}
}
use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.
the class JavaFramesListRenderer method customizePresentation.
public void customizePresentation(StackFrameDescriptorImpl descriptor, @NotNull ColoredTextContainer component, StackFrameDescriptorImpl selectedDescriptor) {
component.setIcon(descriptor.getIcon());
//final Object selectedValue = list.getSelectedValue();
final boolean shouldHighlightAsRecursive = isOccurrenceOfSelectedFrame(selectedDescriptor, descriptor);
final ValueMarkup markup = descriptor.getValueMarkup();
if (markup != null) {
component.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
}
boolean needSeparator = false;
//if (index > 0) {
// final int currentFrameIndex = descriptor.getUiIndex();
// final Object elementAt = list.getModel().getElementAt(index - 1);
// if (elementAt instanceof StackFrameDescriptorImpl) {
// StackFrameDescriptorImpl previousDescriptor = (StackFrameDescriptorImpl)elementAt;
// final int previousFrameIndex = previousDescriptor.getUiIndex();
// needSeparator = (currentFrameIndex - previousFrameIndex != 1);
// }
//}
//if (selected) {
// setBackground(UIUtil.getListSelectionBackground());
//}
//else {
// Color bg = descriptor.getBackgroundColor();
// if (bg == null) bg = UIUtil.getListBackground();
// if (shouldHighlightAsRecursive) bg = myColorScheme.getColor(DebuggerColors.RECURSIVE_CALL_ATTRIBUTES);
// setBackground(bg);
//}
//
//if (needSeparator) {
// final MatteBorder border = BorderFactory.createMatteBorder(1, 0, 0, 0, JBColor.GRAY);
// setBorder(border);
//}
//else {
// setBorder(null);
//}
final String label = descriptor.getLabel();
final int openingBrace = label.indexOf("{");
final int closingBrace = (openingBrace < 0) ? -1 : label.indexOf("}");
final SimpleTextAttributes attributes = getAttributes(descriptor);
if (openingBrace < 0 || closingBrace < 0) {
component.append(label, attributes);
} else {
component.append(label.substring(0, openingBrace - 1), attributes);
component.append(" (" + label.substring(openingBrace + 1, closingBrace) + ")", SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
component.append(label.substring(closingBrace + 1, label.length()), attributes);
if (shouldHighlightAsRecursive && descriptor.isRecursiveCall()) {
component.append(" [" + descriptor.getOccurrenceIndex() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
}
}
Aggregations