-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser for CCES (CrossCore Embedded Studio from Analog Devices)
- Loading branch information
1 parent
533ac7e
commit bb0f6f4
Showing
6 changed files
with
176 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/edu/hm/hafner/analysis/parser/CrossCoreEmbeddedStudioParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package edu.hm.hafner.analysis.parser; | ||
|
||
|
||
import java.io.UncheckedIOException; | ||
import java.util.Iterator; | ||
import java.util.Optional; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Stream; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import edu.hm.hafner.analysis.Issue; | ||
import edu.hm.hafner.analysis.IssueBuilder; | ||
import edu.hm.hafner.analysis.IssueParser; | ||
import edu.hm.hafner.analysis.LookaheadParser; | ||
import edu.hm.hafner.analysis.ParsingException; | ||
import edu.hm.hafner.analysis.ReaderFactory; | ||
import edu.hm.hafner.analysis.Report; | ||
import edu.hm.hafner.analysis.Severity; | ||
import edu.hm.hafner.util.LookaheadStream; | ||
|
||
/** | ||
* A parser for the CrossCoreEmbeddedStudio (CCES) log files. | ||
*/ | ||
public class CrossCoreEmbeddedStudioParser extends LookaheadParser { | ||
private static final long serialVersionUID = 5490211629355204910L; | ||
|
||
/* Regex to match the CCES warnings. | ||
* | ||
* Details: | ||
* - See below the MATCHER_* ids to ease their retrieval. | ||
* - Potential columns are ignored | ||
* - Assume warnings description are always spread over two lines (what was observed so far) | ||
* - Errors are not parsed, only warnings | ||
*/ | ||
private static final String CCES_WARNING_PATTERN = | ||
"^\"(.+?)\", line (\\d+).*(cc\\d+).*warning:(.*)"; | ||
|
||
private static final Integer MATCHER_FILE = 1; | ||
private static final Integer MATCHER_LINE = 2; | ||
private static final Integer MATCHER_CATEGORY = 3; | ||
private static final Integer MATCHER_MESSAGE_BEGIN = 4; | ||
|
||
public CrossCoreEmbeddedStudioParser() { | ||
super(CCES_WARNING_PATTERN); | ||
} | ||
|
||
CrossCoreEmbeddedStudioParser(final String pattern) { | ||
super(pattern); | ||
} | ||
|
||
@Override | ||
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead, | ||
final IssueBuilder builder) { | ||
|
||
StringBuilder message = new StringBuilder(matcher.group(MATCHER_MESSAGE_BEGIN).trim()); | ||
|
||
// always grab the second line | ||
if (lookahead.hasNext()) { | ||
message.append(" "); | ||
message.append(lookahead.next().trim()); | ||
} | ||
|
||
return builder.setFileName(matcher.group(MATCHER_FILE)) | ||
.setLineStart(matcher.group(MATCHER_LINE)) | ||
.setSeverity(Severity.WARNING_NORMAL) | ||
.setCategory(matcher.group(MATCHER_CATEGORY)) | ||
.setMessage(message.toString()) | ||
.buildOptional(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/edu/hm/hafner/analysis/registry/CrossCoreEmbeddedStudioDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package edu.hm.hafner.analysis.registry; | ||
|
||
import edu.hm.hafner.analysis.IssueParser; | ||
import edu.hm.hafner.analysis.parser.CrossCoreEmbeddedStudioParser; | ||
|
||
/** | ||
* A descriptor for CrossCore Embedded Studio from Analog Devices | ||
*/ | ||
public class CrossCoreEmbeddedStudioDescriptor extends ParserDescriptor { | ||
private static final String ID = "crosscore-embedded-studio"; | ||
private static final String NAME = "CrossCore Embedded Studio (CCES)"; | ||
|
||
CrossCoreEmbeddedStudioDescriptor() { | ||
super(ID, NAME); | ||
} | ||
|
||
@Override | ||
public IssueParser createParser(final Option... options) { | ||
return new CrossCoreEmbeddedStudioParser(); | ||
} | ||
|
||
@Override | ||
public String getUrl() { | ||
return "https://www.analog.com/en/design-center/evaluation-hardware-and-software/software/adswt-cces.html"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/edu/hm/hafner/analysis/parser/CrossCoreEmbeddedStudioParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.hm.hafner.analysis.parser; | ||
|
||
import edu.hm.hafner.analysis.AbstractParserTest; | ||
import edu.hm.hafner.analysis.Report; | ||
import edu.hm.hafner.analysis.Severity; | ||
import edu.hm.hafner.analysis.assertions.SoftAssertions; | ||
|
||
/** | ||
* Tests the class {@link CrossCoreEmbeddedStudioParser}. | ||
*/ | ||
class CrossCoreEmbeddedStudioParserTest extends AbstractParserTest { | ||
CrossCoreEmbeddedStudioParserTest() { | ||
super("cces.log"); | ||
} | ||
|
||
@Override | ||
protected CrossCoreEmbeddedStudioParser createParser() { | ||
return new CrossCoreEmbeddedStudioParser(); | ||
} | ||
|
||
@Override | ||
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) { | ||
// check all warnings were caught | ||
softly.assertThat(report).hasSize(6); | ||
|
||
|
||
// test in details the first warning | ||
softly.assertThat(report.get(0)) | ||
.hasFileName("src/dummy_1.c") | ||
.hasLineStart(333) | ||
.hasSeverity(Severity.WARNING_NORMAL) | ||
.hasCategory("cc0188") | ||
.hasMessage("enumerated type mixed with another type"); | ||
|
||
// test in details the last warning, that has column (but not parsed) | ||
softly.assertThat(report.get(5)) | ||
.hasFileName("src/dummy_5.c") | ||
.hasLineStart(125) | ||
.hasSeverity(Severity.WARNING_NORMAL) | ||
.hasCategory("cc1462") | ||
.hasMessage("call to dummy_btc has not been inlined"); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Building libdummy for toolchain sharc_21565... | ||
CC src/dummy_1.c | ||
"src/dummy_1.c", line 333: cc0188: {D} warning: | ||
enumerated type mixed with another type | ||
dummy_get(); | ||
^ | ||
|
||
"src/dummy_2.c", line 36: cc0188: {D} warning: enumerated type | ||
mixed with another type | ||
dummy_get(); | ||
^ | ||
|
||
CC src/dummy_3.c | ||
"src/dummy_3.c", line 149: cc0111: {D} warning: statement is | ||
unreachable | ||
break; | ||
^ | ||
|
||
CC src/dummy_4.c | ||
"src/dummy_4.c", line 85: cc0188: {D} warning: enumerated type | ||
mixed with another type | ||
dummy_get(); | ||
^ | ||
|
||
"src/dummy_4.c", line 295: cc0111: {D} warning: statement is | ||
unreachable | ||
break; | ||
^ | ||
|
||
CC src/dummy_5.c | ||
"src/dummy_5.c", line 125 (col. 22): cc1462: {D} warning: call to | ||
dummy_btc has not been inlined | ||
|