mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
xdebugger: restored custom presentation for keywords and numbers, changed values are highlighted by coloring their names
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.xdebugger.frame.presentation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XKeywordValuePresentation extends XValuePresentation {
|
||||
private final String myValue;
|
||||
|
||||
public XKeywordValuePresentation(String value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderValue(@NotNull XValueTextRenderer renderer) {
|
||||
renderer.renderKeywordValue(myValue);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.xdebugger.frame.presentation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XNumericValuePresentation extends XValuePresentation {
|
||||
private final String myValue;
|
||||
|
||||
public XNumericValuePresentation(String value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderValue(@NotNull XValueTextRenderer renderer) {
|
||||
renderer.renderNumericValue(myValue);
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -19,7 +19,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Determines how a value is shown in debugger trees. Use one of the standard implementations (for {@link com.intellij.xdebugger.frame.presentation.XStringValuePresentation strings}
|
||||
* Determines how a value is shown in debugger trees. Use one of the standard implementations (for {@link com.intellij.xdebugger.frame.presentation.XStringValuePresentation strings},
|
||||
* {@link com.intellij.xdebugger.frame.presentation.XNumericValuePresentation numbers}, {@link com.intellij.xdebugger.frame.presentation.XKeywordValuePresentation keywords}
|
||||
* and for {@link com.intellij.xdebugger.frame.presentation.XRegularValuePresentation other values}) or override this class if you need something special
|
||||
*
|
||||
* @see com.intellij.xdebugger.frame.XValueNode#setPresentation(javax.swing.Icon, XValuePresentation, boolean)
|
||||
@@ -60,6 +61,16 @@ public abstract class XValuePresentation {
|
||||
*/
|
||||
void renderStringValue(@NotNull String value);
|
||||
|
||||
/**
|
||||
* Appends {@code value} highlighted as a number
|
||||
*/
|
||||
void renderNumericValue(@NotNull String value);
|
||||
|
||||
/**
|
||||
* Appends {@code value} highlighted as a keyword
|
||||
*/
|
||||
void renderKeywordValue(@NotNull String value);
|
||||
|
||||
/**
|
||||
* Appends {@code value} surrounded by quotes to the node text colored as a string
|
||||
* @param value value to be shown
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class XValueHint extends AbstractValueHint {
|
||||
|
||||
SimpleColoredText text = new SimpleColoredText();
|
||||
text.append(myExpression, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
|
||||
XValueNodeImpl.buildText(valuePresenter, text, false);
|
||||
XValueNodeImpl.buildText(valuePresenter, text);
|
||||
if (!hasChildren) {
|
||||
showHint(HintUtil.createInformationLabel(text));
|
||||
}
|
||||
|
||||
+5
-5
@@ -141,23 +141,23 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
|
||||
}
|
||||
}
|
||||
appendName();
|
||||
buildText(myValuePresentation, myText, myChanged);
|
||||
buildText(myValuePresentation, myText);
|
||||
}
|
||||
|
||||
private void appendName() {
|
||||
if (!StringUtil.isEmpty(myName)) {
|
||||
XValuePresentationUtil.renderValue(myName, myText, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES, MAX_VALUE_LENGTH, null);
|
||||
SimpleTextAttributes attributes = myChanged ? XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES : XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES;
|
||||
XValuePresentationUtil.renderValue(myName, myText, attributes, MAX_VALUE_LENGTH, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void buildText(@NotNull XValuePresentation valuePresenter, @NotNull final ColoredTextContainer text,
|
||||
final boolean changed) {
|
||||
public static void buildText(@NotNull XValuePresentation valuePresenter, @NotNull final ColoredTextContainer text) {
|
||||
XValuePresentationUtil.appendSeparator(text, valuePresenter.getSeparator());
|
||||
String type = valuePresenter.getType();
|
||||
if (type != null) {
|
||||
text.append("{" + type + "} ", XDebuggerUIConstants.TYPE_ATTRIBUTES);
|
||||
}
|
||||
valuePresenter.renderValue(new XValueTextRendererImpl(text, changed));
|
||||
valuePresenter.renderValue(new XValueTextRendererImpl(text));
|
||||
}
|
||||
|
||||
public void markChanged() {
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ package com.intellij.xdebugger.impl.ui.tree.nodes;
|
||||
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.ui.ColoredTextContainer;
|
||||
import com.intellij.ui.JBColor;
|
||||
@@ -91,7 +92,7 @@ public class XValuePresentationUtil {
|
||||
return extractor.getText();
|
||||
}
|
||||
|
||||
private static class XValuePresentationTextExtractor implements XValuePresentation.XValueTextRenderer {
|
||||
private static class XValuePresentationTextExtractor extends XValueTextRendererBase {
|
||||
private final StringBuilder myBuilder;
|
||||
|
||||
public XValuePresentationTextExtractor() {
|
||||
@@ -104,7 +105,7 @@ public class XValuePresentationUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStringValue(@NotNull String value) {
|
||||
protected void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key) {
|
||||
myBuilder.append(value);
|
||||
}
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.ui.tree.nodes;
|
||||
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class XValueTextRendererBase implements XValuePresentation.XValueTextRenderer {
|
||||
@Override
|
||||
public void renderStringValue(@NotNull String value) {
|
||||
renderStringValue(value, null, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderNumericValue(@NotNull String value) {
|
||||
renderRawValue(value, DefaultLanguageHighlighterColors.NUMBER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderKeywordValue(@NotNull String value) {
|
||||
renderRawValue(value, DefaultLanguageHighlighterColors.KEYWORD);
|
||||
}
|
||||
|
||||
protected abstract void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key);
|
||||
}
|
||||
+11
-17
@@ -17,45 +17,39 @@ package com.intellij.xdebugger.impl.ui.tree.nodes;
|
||||
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.ui.ColoredTextContainer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class XValueTextRendererImpl implements XValuePresentation.XValueTextRenderer {
|
||||
class XValueTextRendererImpl extends XValueTextRendererBase {
|
||||
private final ColoredTextContainer myText;
|
||||
private final boolean myChanged;
|
||||
|
||||
public XValueTextRendererImpl(ColoredTextContainer text, boolean changed) {
|
||||
public XValueTextRendererImpl(ColoredTextContainer text) {
|
||||
myText = text;
|
||||
myChanged = changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderValue(@NotNull String value) {
|
||||
SimpleTextAttributes attributes = myChanged ? XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
XValuePresentationUtil.renderValue(value, myText, attributes, -1, null);
|
||||
XValuePresentationUtil.renderValue(value, myText, SimpleTextAttributes.REGULAR_ATTRIBUTES, -1, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStringValue(@NotNull String value) {
|
||||
renderStringValue(value, null, -1);
|
||||
protected void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key) {
|
||||
TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
|
||||
SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
|
||||
myText.append(value, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStringValue(@NotNull String value, @Nullable String additionalSpecialCharsToHighlight, int maxLength) {
|
||||
SimpleTextAttributes attributes;
|
||||
if (myChanged) {
|
||||
attributes = XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES;
|
||||
}
|
||||
else {
|
||||
attributes = SimpleTextAttributes.fromTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DefaultLanguageHighlighterColors.STRING));
|
||||
}
|
||||
TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DefaultLanguageHighlighterColors.STRING);
|
||||
SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
|
||||
myText.append("\"", attributes);
|
||||
XValuePresentationUtil.renderValue(value, myText, attributes, maxLength, additionalSpecialCharsToHighlight);
|
||||
myText.append("\"", attributes);
|
||||
|
||||
Reference in New Issue
Block a user