Skip to content

Commit

Permalink
remove error recovery and align with upstream/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk committed Dec 23, 2013
1 parent 1539b95 commit a758ac8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 62 deletions.
3 changes: 0 additions & 3 deletions cxx-squid/src/main/java/org/sonar/cxx/api/CxxGrammar.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class CxxGrammar extends Grammar {
public Rule labeledStatement;
public Rule expressionStatement;
public Rule compoundStatement;
public Rule errorInCompoundStatement;
public Rule statementSeq;
public Rule selectionStatement;
public Rule condition;
Expand All @@ -89,7 +88,6 @@ public class CxxGrammar extends Grammar {
public Rule forRangeDeclaration;
public Rule forRangeInitializer;
public Rule jumpStatement;
public Rule errorInJumpStatement;
public Rule declarationStatement;

// Declarations
Expand All @@ -98,7 +96,6 @@ public class CxxGrammar extends Grammar {
public Rule blockDeclaration;
public Rule aliasDeclaration;
public Rule simpleDeclaration;
public Rule errorInSimpleDeclaration;
public Rule staticAssertDeclaration;
public Rule emptyDeclaration;
public Rule attributeDeclaration;
Expand Down
14 changes: 0 additions & 14 deletions cxx-squid/src/test/java/org/sonar/cxx/parser/StatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ public void labeledStatement() {
assertThat(p).matches("attributeSpecifierSeq default : statement");
}

@Test
public void compountStatement_errorRecovery() {
p.setRootRule(g.compoundStatement);

assertThat(p, parse("{ <trash> jjj <<<<]]]] }"));
}

@Test
public void statementSeq() {
p.setRootRule(g.rule(CxxGrammarImpl.statementSeq));
Expand Down Expand Up @@ -236,11 +229,4 @@ public void jumpStatement_reallife() {

assertThat(p).matches("return foo()->i;");
}

// @Test
// public void jumpStatement_errorRecovery() {
// p.setRootRule(g.jumpStatement);

// assertThat(p, parse("return boom bamm boo;"));
// }
}
19 changes: 0 additions & 19 deletions cxx-squid/src/test/resources/parser/own/error_recovery.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -149,43 +149,40 @@ protected void saveViolation(Project project, SensorContext context, String rule
.withKey(ruleId);
Rule rule = ruleFinder.find(ruleQuery);
if (rule != null) {
Violation violation = null;
if ((file != null) && (file.length() > 0)){
org.sonar.api.resources.File resource =
org.sonar.api.resources.File.fromIOFile(new File(file), project);
if (context.getResource(resource) != null) {
// file level violation
violation = Violation.create(rule, resource);

// considering the line information for file level violations only
if (line != null){
try{
int linenr = Integer.parseInt(line);
violation.setLineId(linenr);
} catch(java.lang.NumberFormatException nfe){
CxxUtils.LOG.warn("Skipping invalid line number: {}", line);
}
Violation violation = null;
if ((file != null) && (file.length() > 0)){
org.sonar.api.resources.File resource =
org.sonar.api.resources.File.fromIOFile(new File(file), project);
if (context.getResource(resource) != null) {
// file level violation
violation = Violation.create(rule, resource);

// considering the line information for file level violations only
if (line != null){
try{
int linenr = Integer.parseInt(line);
violation.setLineId(linenr);
} catch(java.lang.NumberFormatException nfe){
CxxUtils.LOG.warn("Skipping invalid line number: {}", line);
}
} else {
CxxUtils.LOG.warn("Cannot find the file '{}', skipping violation '{}'", file, msg);
}
// file level violation
violation.setMessage(msg);
context.saveViolation(violation);
} else {
// project level violation
violation = Violation.create(rule, project);
CxxUtils.LOG.warn("Cannot find the file '{}', skipping violation '{}'", file, msg);
}
} else {
// project level violation
violation = Violation.create(rule, project);
}

if (violation != null){
if (violation != null){
violation.setMessage(msg);
context.saveViolation(violation);
context.saveViolation(violation);
}
} else {
CxxUtils.LOG.warn("Cannot find the rule {}, skipping violation", ruleId);
}
}

protected void processReport(Project project, SensorContext context, File report)
throws Exception
{
Expand Down

0 comments on commit a758ac8

Please sign in to comment.