forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArmccCompilerParser.java
47 lines (38 loc) · 1.43 KB
/
ArmccCompilerParser.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package edu.hm.hafner.analysis.parser;
import java.util.Optional;
import java.util.regex.Matcher;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.RegexpLineParser;
import static edu.hm.hafner.util.IntegerParser.parseInt;
/**
* A parser for armcc compiler warnings.
*
* @author Emanuele Zattin
*/
public class ArmccCompilerParser extends RegexpLineParser {
private static final long serialVersionUID = -2677728927938443703L;
private static final String ARMCC_WARNING_PATTERN = "^\"(.+)\", line (\\d+): ([A-Z][a-z]+):\\D*(\\d+)\\D*?:\\s+(.+)$";
/**
* Creates a new instance of {@link ArmccCompilerParser}.
*/
public ArmccCompilerParser() {
super(ARMCC_WARNING_PATTERN);
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
String type = matcher.group(3);
int errorCode = parseInt(matcher.group(4));
Severity priority;
if ("error".equalsIgnoreCase(type)) {
priority = Severity.WARNING_HIGH;
}
else {
priority = Severity.WARNING_NORMAL;
}
String message = matcher.group(5);
return builder.setFileName(matcher.group(1)).setLineStart(matcher.group(2)).setMessage(errorCode + " - " + message)
.setSeverity(priority).buildOptional();
}
}