diff options
Diffstat (limited to 'sonar-squid')
-rw-r--r-- | sonar-squid/src/main/java/org/sonar/squid/api/SourceFile.java | 15 | ||||
-rw-r--r-- | sonar-squid/src/main/java/org/sonar/squid/text/Source.java | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/sonar-squid/src/main/java/org/sonar/squid/api/SourceFile.java b/sonar-squid/src/main/java/org/sonar/squid/api/SourceFile.java index b9355b88a48..922c5ca26b1 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/api/SourceFile.java +++ b/sonar-squid/src/main/java/org/sonar/squid/api/SourceFile.java @@ -26,6 +26,7 @@ import java.util.Set; public class SourceFile extends SourceCode { private Set<Integer> noSonarTagLines = new HashSet<Integer>(); + private Set<Integer> commentedOutCodeLines = new HashSet<Integer>(); public SourceFile(String key) { super(key); @@ -52,4 +53,18 @@ public class SourceFile extends SourceCode { public void addNoSonarTagLine(int line) { noSonarTagLines.add(line); } + + /** + * @since 2.13 + */ + public Set<Integer> getCommentedOutCodeLines() { + return commentedOutCodeLines; + } + + /** + * @since 2.13 + */ + public void addCommentedOutCodeLines(Set<Integer> commentedOutCodeLines) { + this.commentedOutCodeLines.addAll(commentedOutCodeLines); + } } diff --git a/sonar-squid/src/main/java/org/sonar/squid/text/Source.java b/sonar-squid/src/main/java/org/sonar/squid/text/Source.java index 8e6b51b4714..7d4510f8db1 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/text/Source.java +++ b/sonar-squid/src/main/java/org/sonar/squid/text/Source.java @@ -33,6 +33,7 @@ public class Source { private List<Line> lines = new ArrayList<Line>(); private CodeRecognizer codeRecognizer; private Set<Integer> noSonarTagLines = new HashSet<Integer>(); + private Set<Integer> commentedOutCodeLines = new HashSet<Integer>(); public Source(Reader reader, CodeRecognizer codeRecognizer, String... additionalSingleLineCommentFlag) { this.codeRecognizer = codeRecognizer; @@ -87,6 +88,7 @@ public class Source { line.setMeasure(Metric.COMMENT_LINES, 1); } else { line.setMeasure(Metric.COMMENTED_OUT_CODE_LINES, 1); + commentedOutCodeLines.add(line.getLineIndex()); } } } @@ -125,4 +127,11 @@ public class Source { public Set<Integer> getNoSonarTagLines() { return noSonarTagLines; } + + /** + * @since 2.13 + */ + public Set<Integer> getCommentedOutCodeLines() { + return commentedOutCodeLines; + } } |