forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCadenceIncisiveParser.java
106 lines (95 loc) · 3.78 KB
/
CadenceIncisiveParser.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.hm.hafner.analysis.parser;
import java.util.Optional;
import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.Severity;
import static edu.hm.hafner.util.IntegerParser.*;
/**
* A parser for Cadence Incisive Enterprise Simulator.
*
* @author Andrew 'Necromant' Andrianov
*/
public class CadenceIncisiveParser extends RegexpLineParser {
private static final long serialVersionUID = -3251791089328958452L;
private static final String SLASH = "/";
private static final String CADENCE_MESSAGE_PATTERN = "(" + "(^[a-zA-Z]+): \\*([a-zA-Z]),([a-zA-Z]+): (.*) "
+ "\\[File:(.*), Line:(.*)\\]." //ncelab vhdl warning
+ ")|(" + "(^[a-zA-Z]+): \\*([a-zA-Z]),([a-zA-Z]+) \\((.*),([0-9]+)\\|([0-9]+)\\): (.*)$" //Warning/error with filename
+ ")|(" + "(^g?make\\[.*\\]: Entering directory)\\s*(['`]((.*))\\')" // make: entering directory
+ ")|(" + "(^[a-zA-Z]+): \\*([a-zA-Z]),([a-zA-Z]+): (.*)$" //Single generic warning
+ ")";
/**
* Creates a new instance of {@link CadenceIncisiveParser}.
*/
public CadenceIncisiveParser() {
super(CADENCE_MESSAGE_PATTERN);
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
String tool;
String type;
String category;
String message;
String fileName;
int lineNumber = 0;
Severity priority;
if (matcher.group(1) != null) {
/* vhdl warning from ncelab */
tool = matcher.group(2);
type = matcher.group(3);
category = matcher.group(4);
fileName = matcher.group(6);
lineNumber = parseInt(matcher.group(7));
message = matcher.group(5);
priority = Severity.WARNING_NORMAL;
}
else if (matcher.group(16) != null) {
return Optional.empty();
}
else if (matcher.group(8) != null) {
tool = matcher.group(9);
type = matcher.group(10);
category = matcher.group(11);
fileName = matcher.group(12);
lineNumber = parseInt(matcher.group(13));
message = matcher.group(15);
priority = Severity.WARNING_NORMAL;
}
else if (matcher.group(21) != null) {
tool = matcher.group(22);
type = matcher.group(23);
category = matcher.group(24);
fileName = StringUtils.EMPTY;
message = matcher.group(25);
priority = Severity.WARNING_LOW;
}
else {
return Optional.empty(); /* Should never happen! */
}
if ("E".equalsIgnoreCase(type)) {
priority = Severity.WARNING_HIGH;
category = "Error (" + tool + "): " + category;
}
else {
category = "Warning (" + tool + "): " + category;
}
// Filename should never be null here, unless someone updates from the code above fail
if (fileName == null) {
return Optional.empty();
}
if (fileName.startsWith(SLASH)) {
return builder.setFileName(fileName).setLineStart(lineNumber).setCategory(category)
.setMessage(message).setSeverity(priority).buildOptional();
}
return builder.setFileName(fileName).setLineStart(lineNumber).setCategory(category)
.setMessage(message).setSeverity(priority).buildOptional();
}
}