Skip to content

Commit 98c78a5

Browse files
authored
Merge pull request #8019 from lahodaj/inline-values
Inlining values inside debugger
2 parents 46c42e4 + a7da46c commit 98c78a5

File tree

29 files changed

+1253
-50
lines changed

29 files changed

+1253
-50
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,8 +1563,8 @@ jobs:
15631563
# - name: debugger.jpda.truffle
15641564
# run: ant $OPTS -f java/debugger.jpda.truffle test
15651565

1566-
# - name: debugger.jpda.ui
1567-
# run: ant $OPTS -f java/debugger.jpda.ui test
1566+
- name: debugger.jpda.ui
1567+
run: ant $OPTS -f java/debugger.jpda.ui test-unit
15681568

15691569
- name: Create Test Summary
15701570
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4

ide/api.lsp/apichanges.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@
5151
<!-- ACTUAL CHANGES BEGIN HERE: -->
5252

5353
<changes>
54+
<change id="InlineValuesProvider">
55+
<api name="LSP_API"/>
56+
<summary>Adding InlineValue and InlineValuesProvider</summary>
57+
<version major="1" minor="35"/>
58+
<date day="23" month="4" year="2025"/>
59+
<author login="jlahoda"/>
60+
<compatibility binary="compatible" source="compatible" addition="yes" deletion="no" />
61+
<description>
62+
The <code>InlineValuesProvider</code> is introduced to provide debugger
63+
inline values in the the LSP protocol.
64+
</description>
65+
<class package="org.netbeans.spi.lsp" name="InlineValuesProvider"/>
66+
</change>
5467
<change id="InlayHintsProvider">
5568
<api name="LSP_API"/>
5669
<summary>Adding InlayHintsProvider</summary>

ide/api.lsp/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.netbeans.api.lsp/1
33
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/lsp/Bundle.properties
4-
OpenIDE-Module-Specification-Version: 1.34
4+
OpenIDE-Module-Specification-Version: 1.35
55
AutoUpdate-Show-In-Client: false

ide/api.lsp/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
is.autoload=true
18-
javac.release=11
18+
javac.release=17
1919
javac.compilerargs=-Xlint -Xlint:-serial
2020
javadoc.name=LSP APIs
2121
javadoc.title=LSP APIs
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.api.lsp;
20+
21+
/**
22+
* An expression whose value may be shown inline while debugging.
23+
*
24+
* @since 1.35
25+
*/
26+
public final class InlineValue {
27+
private final Range range;
28+
private final String expression;
29+
30+
private InlineValue(Range range, String expression) {
31+
this.range = range;
32+
this.expression = expression;
33+
}
34+
35+
/**
36+
* {@return Range to which the inline value applies}
37+
*/
38+
public Range getRange() {
39+
return range;
40+
}
41+
42+
/**
43+
* {@return The expression of that should be evaluated for the inline value.}
44+
*/
45+
public String getExpression() {
46+
return expression;
47+
}
48+
49+
/**
50+
* {@return a new instance of {@code InlineValue}, based on the provided information.}
51+
*
52+
* @param range range to which the inline value should apply
53+
* @param expression expression that should be evaluted
54+
*/
55+
public static InlineValue createInlineVariable(Range range, String expression) {
56+
return new InlineValue(range, expression);
57+
}
58+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.spi.lsp;
20+
21+
import java.util.List;
22+
import java.util.concurrent.CompletableFuture;
23+
import org.netbeans.api.annotations.common.NonNull;
24+
import org.netbeans.api.lsp.InlineValue;
25+
import org.openide.filesystems.FileObject;
26+
27+
/**
28+
* Compute {@link InlineValue}s for the given file and offset.
29+
*
30+
* @since 1.35
31+
*/
32+
public interface InlineValuesProvider {
33+
34+
/**
35+
* Compute {@linkplain InlineValue}s for the given file and location.
36+
*
37+
* @param file file for which the inline values should be computed
38+
* @param currentExecutionPosition position for which the inline values should be computed
39+
* @return the computed inline values
40+
*/
41+
public CompletableFuture<List<? extends InlineValue>> inlineValues(@NonNull FileObject file, int currentExecutionPosition);
42+
}

ide/editor.actions/src/org/netbeans/modules/editor/actions/ShowInlineHintsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@EditorActionRegistration(name="toggle-inline-hints",
2626
menuPath="View",
27-
menuPosition=899,
27+
menuPosition=897,
2828
preferencesKey=ShowInlineHintsAction.KEY_LINES,
2929
preferencesDefault=ShowInlineHintsAction.DEF_LINES)
3030
public class ShowInlineHintsAction extends AbstractAction {

ide/editor.actions/src/org/netbeans/modules/editor/actions/ShowLinesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@EditorActionRegistration(name="toggle-lines-view",
2626
menuPath="View",
27-
menuPosition=898,
27+
menuPosition=895,
2828
preferencesKey=ShowLinesAction.KEY_LINES,
2929
preferencesDefault=ShowLinesAction.DEF_LINES)
3030
public class ShowLinesAction extends AbstractAction {

ide/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/HighlightsList.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void add(HighlightItem item) {
121121
* @param usePrependText reflect the prepended text setting.
122122
* @return either simple or compound attribute set.
123123
*/
124-
public AttributeSet cutSameFont(Font defaultFont, int maxEndOffset, int wsEndOffset, CharSequence docText, boolean usePrependText) {
124+
public AttributeSet cutSameFont(Font defaultFont, int maxEndOffset, int wsEndOffset, CharSequence docText) {
125125
assert (maxEndOffset <= endOffset()) :
126126
"maxEndOffset=" + maxEndOffset + " > endOffset()=" + endOffset() + ", " + this; // NOI18N
127127
HighlightItem item = get(0);
@@ -159,13 +159,13 @@ public AttributeSet cutSameFont(Font defaultFont, int maxEndOffset, int wsEndOff
159159

160160
// Extends beyond first highlight
161161
Font firstFont = ViewUtils.getFont(firstAttrs, defaultFont);
162-
Object firstPrependText = usePrependText && firstAttrs != null ? firstAttrs.getAttribute(ViewUtils.KEY_VIRTUAL_TEXT_PREPEND) : null;
162+
Object firstPrependText = firstAttrs != null ? firstAttrs.getAttribute(ViewUtils.KEY_VIRTUAL_TEXT_PREPEND) : null;
163163
int index = 1;
164164
while (true) {
165165
item = get(index);
166166
AttributeSet attrs = item.getAttributes();
167167
Font font = ViewUtils.getFont(attrs, defaultFont);
168-
Object prependText = usePrependText && attrs != null ? attrs.getAttribute(ViewUtils.KEY_VIRTUAL_TEXT_PREPEND) : null;
168+
Object prependText = attrs != null ? attrs.getAttribute(ViewUtils.KEY_VIRTUAL_TEXT_PREPEND) : null;
169169
if (!font.equals(firstFont) || !Objects.equals(firstPrependText, prependText)) { // Stop at itemEndOffset
170170
if (index == 1) { // Just single attribute set
171171
cutStartItems(1);

ide/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ public final class DocumentViewOp
317317
boolean asTextField;
318318

319319
private boolean guideLinesEnable;
320-
private boolean inlineHintsEnable;
321320

322321
private int indentLevelSize;
323322

@@ -924,13 +923,10 @@ public void run() {
924923
// Line height correction
925924
float lineHeightCorrectionOrig = rowHeightCorrection;
926925
rowHeightCorrection = prefs.getFloat(SimpleValueNames.LINE_HEIGHT_CORRECTION, 1.0f);
927-
boolean inlineHintsEnableOrig = inlineHintsEnable;
928-
inlineHintsEnable = prefs.getBoolean("enable.inline.hints", false); // NOI18N
929926
boolean updateMetrics = (rowHeightCorrection != lineHeightCorrectionOrig);
930927
boolean releaseChildren = nonInitialUpdate &&
931928
((nonPrintableCharactersVisible != nonPrintableCharactersVisibleOrig) ||
932-
(rowHeightCorrection != lineHeightCorrectionOrig) ||
933-
(inlineHintsEnable != inlineHintsEnableOrig));
929+
(rowHeightCorrection != lineHeightCorrectionOrig));
934930
indentLevelSize = getIndentSize();
935931
tabSize = prefs.getInt(SimpleValueNames.TAB_SIZE, EditorPreferencesDefaults.defaultTabSize);
936932
if (updateMetrics) {
@@ -1172,10 +1168,6 @@ public boolean isGuideLinesEnable() {
11721168
return guideLinesEnable && !asTextField;
11731169
}
11741170

1175-
public boolean isInlineHintsEnable() {
1176-
return inlineHintsEnable;
1177-
}
1178-
11791171
public int getIndentLevelSize() {
11801172
return indentLevelSize;
11811173
}

0 commit comments

Comments
 (0)