diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-01 10:57:21 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-01 10:57:28 +0100 |
commit | 936f7f5f75e4acd3a58e12f67e69d9e24290c91c (patch) | |
tree | 6abd75dd50384cd602994d04d48fc48aec87569c /sonar-squid/src/main | |
parent | ee6efa4035d4f956bec561b9680f10d35068ea46 (diff) | |
download | sonarqube-936f7f5f75e4acd3a58e12f67e69d9e24290c91c.tar.gz sonarqube-936f7f5f75e4acd3a58e12f67e69d9e24290c91c.zip |
SONAR-2159 The total classes used in complexity distribution is different than the number of classes
Diffstat (limited to 'sonar-squid/src/main')
-rw-r--r-- | sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java b/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java index a38d2613258..cbadf4d6a05 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java +++ b/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java @@ -20,16 +20,16 @@ package org.sonar.squid.api; -import java.util.HashSet; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - import org.sonar.squid.measures.Measurable; import org.sonar.squid.measures.Measures; import org.sonar.squid.measures.Metric; import org.sonar.squid.measures.MetricDef; +import java.util.HashSet; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + public abstract class SourceCode implements Measurable, Comparable<SourceCode> { private final String name; @@ -212,6 +212,17 @@ public abstract class SourceCode implements Measurable, Comparable<SourceCode> { return parent.getParent(sourceCode); } + public <SOURCECODE extends SourceCode> SOURCECODE getAncestor(Class<SOURCECODE> withClass) { + SOURCECODE ancestor = getParent(withClass); + if (ancestor!=null) { + SOURCECODE parentAncestor = ancestor.getAncestor(withClass); + if (parentAncestor!=null) { + ancestor = parentAncestor; + } + } + return ancestor; + } + public void log(CheckMessage message) { message.setSourceCode(this); getCheckMessages().add(message); |