diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java new file mode 100644 index 000000000000..c6d79ff881d2 --- /dev/null +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java @@ -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); + } +} diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XNumericValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XNumericValuePresentation.java new file mode 100644 index 000000000000..ee8c0ed53846 --- /dev/null +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XNumericValuePresentation.java @@ -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); + } +} diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java index 0d2ede493740..0fbc9c713f15 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java @@ -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 diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java index 8406271716ba..63ac338674e9 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java @@ -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)); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index 4a1e416a6ab5..f1a9463c87c6 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -141,23 +141,23 @@ public class XValueNodeImpl extends XValueContainerNode 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() { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java index 5420e8656769..aaad5a9827c2 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java @@ -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); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java new file mode 100644 index 000000000000..9fb0aa2d394d --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java @@ -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); +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java index 5badfdc300c6..06669bb71fdd 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java @@ -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);