Skip to content

Commit 00887a7

Browse files
committed
created provider for VariableUtils
1 parent 14854c6 commit 00887a7

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/VariablesRequestHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.microsoft.java.debug.core.adapter.IEvaluationProvider;
3434
import com.microsoft.java.debug.core.adapter.IStackFrameManager;
3535
import com.microsoft.java.debug.core.adapter.variables.IVariableFormatter;
36+
import com.microsoft.java.debug.core.adapter.variables.IVariableProvider;
3637
import com.microsoft.java.debug.core.adapter.variables.JavaLogicalStructure;
3738
import com.microsoft.java.debug.core.adapter.variables.JavaLogicalStructure.LogicalStructureExpression;
3839
import com.microsoft.java.debug.core.adapter.variables.JavaLogicalStructure.LogicalVariable;
@@ -78,6 +79,7 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
7879
boolean showStaticVariables = DebugSettings.getCurrent().showStaticVariables;
7980

8081
Map<String, Object> options = variableFormatter.getDefaultOptions();
82+
IVariableProvider evaluateNameUtils = context.getProvider(IVariableProvider.class);
8183
VariableUtils.applyFormatterOptions(options, varArgs.format != null && varArgs.format.hex);
8284
IEvaluationProvider evaluationEngine = context.getProvider(IEvaluationProvider.class);
8385

@@ -260,12 +262,12 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
260262
String typeName = ((ObjectReference) containerNode.getProxiedVariable()).referenceType().name();
261263
// TODO: This replacement will possibly change the $ in the class name itself.
262264
typeName = typeName.replaceAll("\\$", ".");
263-
evaluateName = VariableUtils.getEvaluateName(javaVariable.evaluateName, "((" + typeName + ")" + containerEvaluateName + ")", false);
265+
evaluateName = evaluateNameUtils.getEvaluateName(javaVariable.evaluateName, "((" + typeName + ")" + containerEvaluateName + ")", false);
264266
} else {
265267
if (containerEvaluateName != null && containerEvaluateName.contains("%s")) {
266268
evaluateName = String.format(containerEvaluateName, javaVariable.evaluateName);
267269
} else {
268-
evaluateName = VariableUtils.getEvaluateName(javaVariable.evaluateName, containerEvaluateName, containerNode.isIndexedVariable());
270+
evaluateName = evaluateNameUtils.getEvaluateName(javaVariable.evaluateName, containerEvaluateName, containerNode.isIndexedVariable());
269271
}
270272
}
271273

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.microsoft.java.debug.core.adapter.variables;
2+
3+
import com.microsoft.java.debug.core.adapter.IProvider;
4+
5+
public interface IVariableProvider extends IProvider {
6+
/**
7+
* Get the name for evaluation of variable.
8+
*
9+
* @param name the variable name, if any
10+
* @param containerName the container name, if any
11+
* @param isArrayElement is the variable an array element?
12+
*/
13+
public String getEvaluateName(String name, String containerName, boolean isArrayElement);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.microsoft.java.debug.core.adapter.variables;
2+
3+
public class VariableProvider implements IVariableProvider {
4+
@Override
5+
public String getEvaluateName(String name, String containerName, boolean isArrayElement) {
6+
return VariableUtils.getEvaluateName(name, containerName, isArrayElement);
7+
}
8+
}

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtProviderContextFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static IProviderContext createProviderContext() {
3838
context.registerProvider(IEvaluationProvider.class, new JdtEvaluationProvider());
3939
context.registerProvider(ICompletionsProvider.class, new CompletionsProvider());
4040
context.registerProvider(IStepFilterProvider.class, new StepFilterProvider());
41+
context.registerProvider(IVariableProvider.class, new VariableProvider());
4142

4243
return context;
4344
}

0 commit comments

Comments
 (0)