Skip to content

Commit 77fd2b3

Browse files
cmagliefacchinm
authored andcommitted
Increase debugging info in json parsing from autocomplete
1 parent 4664178 commit 77fd2b3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

app/src/cc/arduino/autocomplete/ClangCompletionProvider.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.fife.ui.autocomplete.ParameterizedCompletion.Parameter;
4444
import org.fife.ui.autocomplete.TemplateCompletion;
4545

46+
import com.fasterxml.jackson.core.JsonParseException;
4647
import com.fasterxml.jackson.databind.ObjectMapper;
4748

4849
import processing.app.Editor;
@@ -95,7 +96,25 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
9596
// Parse engine output and build code completions
9697
ObjectMapper mapper = new ObjectMapper();
9798
ArduinoCompletionsList allCc;
98-
allCc = mapper.readValue(out, ArduinoCompletionsList.class);
99+
try {
100+
allCc = mapper.readValue(out, ArduinoCompletionsList.class);
101+
} catch (JsonParseException e) {
102+
System.err.println("Error parsing autocomplete output:");
103+
System.err.println();
104+
int begin = (int) e.getLocation().getCharOffset() - 100;
105+
if (begin < 0) {
106+
begin = 0;
107+
}
108+
int end = begin + 100;
109+
if (end >= out.length()) {
110+
System.err.println(out.substring(begin));
111+
} else {
112+
System.err.println(out.substring(begin, end));
113+
}
114+
System.err.println();
115+
e.printStackTrace();
116+
return res;
117+
}
99118
for (ArduinoCompletion cc : allCc) {
100119

101120
if (cc.type.equals("Function") || cc.type.equals("Macro")) {

0 commit comments

Comments
 (0)