This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
/
ClangParser.java
64 lines (55 loc) · 1.93 KB
/
ClangParser.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package hudson.plugins.warnings.parser;
import java.util.regex.Matcher;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
/**
* A parser for the Clang compiler warnings.
*
* @author Neil Davis
*/
@Extension
public class ClangParser extends RegexpLineParser {
private static final long serialVersionUID = -3015592762345283182L;
private static final String CLANG_WARNING_PATTERN = "^\\s*(?:\\d+%)?([^%]*?):(\\d+):(?:(\\d+):)?(?:(?:\\{\\d+:\\d+-\\d+:\\d+\\})+:)?\\s*(warning|[^\\[\\]]*error):\\s*(.*?)(?:\\[(.*)\\])?$";
/**
* Creates a new instance of {@link ClangParser}.
*/
public ClangParser() {
super(Messages._Warnings_AppleLLVMClang_ParserName(),
Messages._Warnings_AppleLLVMClang_LinkName(),
Messages._Warnings_AppleLLVMClang_TrendName(),
CLANG_WARNING_PATTERN);
}
@Override
protected Warning createWarning(final Matcher matcher) {
String message = matcher.group(5);
if (message.matches("^-\\[.*\\].*$")) {
return FALSE_POSITIVE;
}
String filename = matcher.group(1);
int lineNumber = getLineNumber(matcher.group(2));
int column = getLineNumber(matcher.group(3));
String type = matcher.group(4);
String category = matcher.group(6);
Priority priority;
if (type.contains("error")) {
priority = Priority.HIGH;
}
else {
priority = Priority.NORMAL;
}
Warning warning;
if (category == null) {
warning = createWarning(filename, lineNumber, message, priority);
}
else {
warning = createWarning(filename, lineNumber, category, message, priority);
}
warning.setColumnPosition(column);
return warning;
}
@Override
protected String getId() {
return "Apple LLVM Compiler (Clang)"; // old ID in serialization
}
}