Skip to content

Commit e9ed6a1

Browse files
authored
1. add user error in DebugException (#208)
1. add user error in DebugException 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
1 parent 46828dc commit e9ed6a1

File tree

24 files changed

+569
-512
lines changed

24 files changed

+569
-512
lines changed

.project

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<projectDescription>
3-
<name>java-debug-parent</name>
4-
<comment></comment>
5-
<projects>
6-
</projects>
7-
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.m2e.core.maven2Builder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
13-
</buildSpec>
14-
<natures>
15-
<nature>org.eclipse.m2e.core.maven2Nature</nature>
16-
</natures>
17-
</projectDescription>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>java-debug-parent</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.m2e.core.maven2Builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
16+
</natures>
17+
</projectDescription>

LICENSE.txt

Lines changed: 108 additions & 108 deletions
Large diffs are not rendered by default.

check_style.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
<module name="ModifierOrder"/>
135135
<module name="EmptyLineSeparator">
136136
<property name="allowNoEmptyLineBetweenFields" value="true"/>
137+
<property name="allowMultipleEmptyLines" value="false"/>
138+
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
137139
</module>
138140
<module name="SeparatorWrap">
139141
<property name="id" value="SeparatorWrapDot"/>
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" output="target/classes" path="src/main/java">
4-
<attributes>
5-
<attribute name="optional" value="true"/>
6-
<attribute name="maven.pomderived" value="true"/>
7-
</attributes>
8-
</classpathentry>
9-
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10-
<attributes>
11-
<attribute name="optional" value="true"/>
12-
<attribute name="maven.pomderived" value="true"/>
13-
<attribute name="test" value="true"/>
14-
</attributes>
15-
</classpathentry>
16-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
17-
<attributes>
18-
<attribute name="maven.pomderived" value="true"/>
19-
</attributes>
20-
</classpathentry>
21-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22-
<attributes>
23-
<attribute name="maven.pomderived" value="true"/>
24-
</attributes>
25-
</classpathentry>
26-
<classpathentry kind="src" path="target/generated-sources/annotations">
27-
<attributes>
28-
<attribute name="optional" value="true"/>
29-
<attribute name="maven.pomderived" value="true"/>
30-
<attribute name="ignore_optional_problems" value="true"/>
31-
<attribute name="m2e-apt" value="true"/>
32-
</attributes>
33-
</classpathentry>
34-
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
35-
<attributes>
36-
<attribute name="optional" value="true"/>
37-
<attribute name="maven.pomderived" value="true"/>
38-
<attribute name="ignore_optional_problems" value="true"/>
39-
<attribute name="m2e-apt" value="true"/>
40-
<attribute name="test" value="true"/>
41-
</attributes>
42-
</classpathentry>
43-
<classpathentry kind="output" path="target/classes"/>
44-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="src" path="target/generated-sources/annotations">
27+
<attributes>
28+
<attribute name="optional" value="true"/>
29+
<attribute name="maven.pomderived" value="true"/>
30+
<attribute name="ignore_optional_problems" value="true"/>
31+
<attribute name="m2e-apt" value="true"/>
32+
</attributes>
33+
</classpathentry>
34+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
35+
<attributes>
36+
<attribute name="optional" value="true"/>
37+
<attribute name="maven.pomderived" value="true"/>
38+
<attribute name="ignore_optional_problems" value="true"/>
39+
<attribute name="m2e-apt" value="true"/>
40+
<attribute name="test" value="true"/>
41+
</attributes>
42+
</classpathentry>
43+
<classpathentry kind="output" path="target/classes"/>
44+
</classpath>
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<projectDescription>
3-
<name>com.microsoft.java.debug.core</name>
4-
<comment></comment>
5-
<projects>
6-
</projects>
7-
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
13-
<buildCommand>
14-
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
15-
<arguments>
16-
</arguments>
17-
</buildCommand>
18-
<buildCommand>
19-
<name>org.eclipse.m2e.core.maven2Builder</name>
20-
<arguments>
21-
</arguments>
22-
</buildCommand>
23-
</buildSpec>
24-
<natures>
25-
<nature>org.eclipse.jdt.core.javanature</nature>
26-
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
27-
<nature>org.eclipse.m2e.core.maven2Nature</nature>
28-
</natures>
29-
</projectDescription>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.microsoft.java.debug.core</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.m2e.core.maven2Builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.jdt.core.javanature</nature>
26+
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
27+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
28+
</natures>
29+
</projectDescription>

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugException.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class DebugException extends Exception {
1515
private static final long serialVersionUID = 1L;
1616
private int errorCode;
1717

18+
private boolean userError = false;
19+
1820
public DebugException() {
1921
super();
2022
}
@@ -36,6 +38,18 @@ public DebugException(String message, int errorCode) {
3638
this.errorCode = errorCode;
3739
}
3840

41+
/**
42+
* Create a debug exception with userError flag.
43+
* @param message the error message
44+
* @param errorCode the error code
45+
* @param userError the boolean value indicating whether this exception is caused by a known user error
46+
*/
47+
public DebugException(String message, int errorCode, boolean userError) {
48+
super(message);
49+
this.errorCode = errorCode;
50+
this.userError = userError;
51+
}
52+
3953
public DebugException(String message, Throwable cause, int errorCode) {
4054
super(message, cause);
4155
this.errorCode = errorCode;
@@ -49,4 +63,12 @@ public DebugException(Throwable cause, int errorCode) {
4963
public int getErrorCode() {
5064
return this.errorCode;
5165
}
66+
67+
public void setUserError(boolean userError) {
68+
this.userError = userError;
69+
}
70+
71+
public boolean isUserError() {
72+
return this.userError;
73+
}
5274
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public IBreakpoint createBreakpoint(String className, int lineNumber, int hitCou
8181
return new EvaluatableBreakpoint(vm, this.getEventHub(), className, lineNumber, hitCount, condition, logMessage);
8282
}
8383

84-
8584
@Override
8685
public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught) {
8786
EventRequestManager manager = vm.eventRequestManager();

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/UsageDataSession.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.google.gson.JsonElement;
2323
import com.microsoft.java.debug.core.adapter.AdapterUtils;
24+
import com.microsoft.java.debug.core.adapter.ErrorCode;
2425
import com.microsoft.java.debug.core.protocol.JsonUtils;
2526
import com.microsoft.java.debug.core.protocol.Messages.Request;
2627
import com.microsoft.java.debug.core.protocol.Messages.Response;
@@ -39,6 +40,7 @@ public class UsageDataSession {
3940
private Map<String, Integer> commandCountMap = new HashMap<>();
4041
private Map<String, Integer> breakpointCountMap = new HashMap<>();
4142
private Map<Integer, RequestEvent> requestEventMap = new HashMap<>();
43+
private Map<String, Integer> userErrorCount = new HashMap<>();
4244
private List<String> eventList = new ArrayList<>();
4345

4446
public static String getSessionGuid() {
@@ -136,6 +138,7 @@ public void submitUsageData() {
136138
props.put("sessionStopAt", String.valueOf(stopAt));
137139
props.put("commandCount", JsonUtils.toJson(commandCountMap));
138140
props.put("breakpointCount", JsonUtils.toJson(breakpointCountMap));
141+
props.put("userErrorCount", JsonUtils.toJson(userErrorCount));
139142
if (jdiEventSequenceEnabled) {
140143
synchronized (eventList) {
141144
props.put("jdiEventSequence", JsonUtils.toJson(eventList));
@@ -163,6 +166,18 @@ public static void recordEvent(Event event) {
163166
}
164167
}
165168

169+
/**
170+
* Record counts for each user errors encountered.
171+
*/
172+
public void recordUserError(ErrorCode errorCode) {
173+
try {
174+
String errorCodeStr = errorCode.name();
175+
userErrorCount.put(errorCodeStr, userErrorCount.getOrDefault(errorCodeStr, 0) + 1);
176+
} catch (Exception e) {
177+
logger.log(Level.SEVERE, String.format("Exception on recording user error: %s.", e.toString()), e);
178+
}
179+
}
180+
166181
/**
167182
* Enable JDI event sequence track in current session.
168183
*/

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ public static CompletionException createCompletionException(String message, Erro
231231
return new CompletionException(new DebugException(message, errorCode.getId()));
232232
}
233233

234+
public static DebugException createUserErrorDebugException(String message, ErrorCode errorCode) {
235+
return new DebugException(message, errorCode.getId(), true);
236+
}
237+
238+
234239
/**
235240
* Calculate SHA-256 Digest of given string.
236241
* @param content

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public enum ErrorCode {
3131
LAUNCH_IN_TERMINAL_FAILURE(1014),
3232
STEP_FAILURE(1015),
3333
RESTARTFRAME_FAILURE(1016),
34-
COMPLETIONS_FAILURE(1017);
34+
COMPLETIONS_FAILURE(1017),
35+
EVALUATION_COMPILE_ERROR(2001),
36+
EVALUATE_NOT_SUSPENDED_THREAD(2002);
3537

3638
private int id;
3739

0 commit comments

Comments
 (0)