1. add user error in DebugException #208
Merged
Conversation
Collaborator
andxu
commented
Aug 20, 2018
|
2. add user error logic in evaluation since a lot of them are reported in evaluation which is caused by known reasons(eg: compilation error). 3. enable evaluation on hover
|
How about CompletionsProvider? It has similar user errors. |
...lugin/src/main/java/com/microsoft/java/debug/plugin/internal/eval/JdtEvaluationProvider.java
Outdated
| @@ -135,6 +137,13 @@ public void initialize(IDebugAdapterContext context, Map<String, Object> props) | |||
| compiledExpression = engine.getCompiledExpression(expression, stackframe); | |||
| } | |||
|
|
|||
| if (compiledExpression.hasErrors()) { | |||
| completableFuture.completeExceptionally(AdapterUtils.createUserErrorDebugException( | |||
| String.format("Cannot evalution expression because of compilation error(s): %s.", | |||
| @@ -53,6 +53,7 @@ | |||
| caps.supportsCompletionsRequest = true; | |||
| caps.supportsRestartFrame = true; | |||
| caps.supportsLogPoints = true; | |||
| caps.supportsEvaluateForHovers = true; | |||
testforstephen
Aug 20, 2018
Contributor
By mistake? or Do you want to support EvaluateForHovers in this PR?
...core/src/main/java/com/microsoft/java/debug/core/adapter/handler/EvaluateRequestHandler.java
Outdated
| throw AdapterUtils.createCompletionException( | ||
| String.format("Cannot evalution expression because of %s.", cause.toString()), | ||
| String.format("Cannot evaluation expression because of %s.", cause.toString()), |
com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugException.java
Outdated
| * Create a debug exception with userError flag. | ||
| * @param message the error message | ||
| * @param errorCode the error code | ||
| * @param userError the boolean value of whether this exception is caused by a known user error |
...core/src/main/java/com/microsoft/java/debug/core/adapter/handler/EvaluateRequestHandler.java
Outdated
| ErrorCode.EVALUATE_FAILURE); | ||
| // stackFrameReference is null means the given thread is running | ||
| throw new CompletionException(AdapterUtils.createUserErrorDebugException( | ||
| "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed.", |
testforstephen
Aug 20, 2018
Contributor
=> Failed to evaluate. Reason: Cannot evaluate because the thread is not suspended.
| @@ -15,6 +15,8 @@ | |||
| private static final long serialVersionUID = 1L; | |||
| private int errorCode; | |||
|
|
|||
| private boolean userError = false; | |||
andxu
Aug 21, 2018
Author
Collaborator
No better name, I think the java doc may eliminate the confusion
com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugException.java
Outdated
| public DebugException(String message, Throwable cause, int errorCode) { | ||
| super(message, cause); | ||
| this.errorCode = errorCode; | ||
| } | ||
|
|
||
|
|
com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/UsageDataSession.java
Outdated
| @@ -39,6 +40,7 @@ | |||
| private Map<String, Integer> commandCountMap = new HashMap<>(); | |||
| private Map<String, Integer> breakpointCountMap = new HashMap<>(); | |||
| private Map<Integer, RequestEvent> requestEventMap = new HashMap<>(); | |||
| private Map<String, Integer> userErrorCount = new HashMap<>(); | |||
…debug into andy_user_error2
| @@ -134,6 +134,8 @@ | |||
| <module name="ModifierOrder"/> | |||
| <module name="EmptyLineSeparator"> | |||
| <property name="allowNoEmptyLineBetweenFields" value="true"/> | |||
| <property name="allowMultipleEmptyLines" value="false"/> | |||
andxu
Aug 21, 2018
Author
Collaborator
Some bad styles are founded by yanzh but not by checkstyle, so I enhanced the rules
...microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java
Outdated
| COMPLETIONS_FAILURE(1017); | ||
| COMPLETIONS_FAILURE(1017), | ||
| EVALUATION_COMPILE_ERROR(2001), | ||
| EVALUATE_NOT_SUSPEND(2002); |
testforstephen
Aug 21, 2018
Contributor
Cannot get the failure reason from the name. -> EVALUATE_NOT_SUSPENDED_THREAD
|
This pr looks good to me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.