Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1034084 // parseECJOutputForErrors [OK]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5231L/30K).

1  
/*
2  
Example:
3  
4  
----------
5  
1. ERROR in /home/stefan/JavaX-Caches/Temp/1642773472353/UserCode_1642773470538.java (at line 26)
6  
  xg.fillRect(10, 10, 10, 10);
7  
  ^^
8  
xg cannot be resolved
9  
----------
10  
*/
11  
12  
sclass ECJError {
13  
  S file, error;
14  
  int lineNr;
15  
  S codeLine;
16  
  IntRange colRange;
17  
  
18  
  toString { ret "Error on line " + lineNr + ": " + error; }
19  
}
20  
21  
static L<ECJError> parseECJOutputForErrors(S text) {
22  
  new L<ECJError> errors;
23  
  LS lines = lines(text);
24  
  for i over lines: {
25  
    if (startsWith(lines.get(i), "---")) {
26  
      S line = get(lines, i+1);
27  
      //print(line);
28  
      LS groups = regexpFirstGroups("^\\d+\\. ERROR in (.*?) \\(at line (\\d+)\\)$", line);
29  
      if (groups != null) {
30  
        //print(+groups);
31  
        S codeLine = get(lines, i+2);
32  
        S markLine = get(lines, i+3);
33  
        S errorLine = get(lines, i+4);
34  
        //print(+markLine);
35  
        LS markGroups = regexpFirstGroups("^( *)(\\^+)", markLine);
36  
        //print(+markGroups);
37  
        new ECJError e;
38  
        e.file = groups.get(0);
39  
        e.error = errorLine;
40  
        e.lineNr = parseInt(groups.get(1));
41  
        e.codeLine = codeLine;
42  
        int col1 = l(first(markGroups));
43  
        int cols = l(second(markGroups));
44  
        e.colRange = intRangeWithLength(col1+1, cols);
45  
        errors.add(e);
46  
      }
47  
    }
48  
  }
49  
  ret errors;
50  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034084
Snippet name: parseECJOutputForErrors [OK]
Eternal ID of this version: #1034084/17
Text MD5: 7518cf3ea97b971486d29b71ce1d44b7
Transpilation MD5: 0a2b8194545b956e9a20a3eea00b9172
Author: stefan
Category: javax / compiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-21 16:47:16
Source code size: 1361 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 100 / 153
Version history: 16 change(s)
Referenced in: [show references]