diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-28 13:17:57 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-28 13:18:46 +0100 |
commit | b8eecc041ad4aa23a3bf5cf7c8847573b125d187 (patch) | |
tree | d0b719f881f8f324d574fa699bd6befb7608c058 /sonar-java-api/src | |
parent | 220dd330306d76b7ff13baa07abf461688c92fc1 (diff) | |
download | sonarqube-b8eecc041ad4aa23a3bf5cf7c8847573b125d187.tar.gz sonarqube-b8eecc041ad4aa23a3bf5cf7c8847573b125d187.zip |
SONAR-2149 Resource filters are ignored in complexity distributions of Java projects
This issue implies SONAR-2153 : API: A decorator should override formulas
Diffstat (limited to 'sonar-java-api/src')
4 files changed, 26 insertions, 35 deletions
diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java index 563879e23bb..d482c3d8bb2 100644 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java +++ b/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java @@ -109,11 +109,11 @@ public final class JavaClass extends Resource { return getName(); } - public static JavaClass createRef(String name) { + public static JavaClass create(String name) { return new JavaClass(name); } - public static JavaClass createRef(String packageName, String className) { + public static JavaClass create(String packageName, String className) { if (StringUtils.isBlank(packageName)) { return new JavaClass(className); } diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java index 743b3fa4069..ce7eb14fe8b 100644 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java +++ b/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java @@ -25,9 +25,8 @@ import org.sonar.api.resources.*; /** * @since 2.6 */ -public final class JavaMethod extends Resource { +public final class JavaMethod extends BlockUnit { - public static final String SCOPE = Scopes.BLOCK_UNIT; public static final String QUALIFIER = Qualifiers.METHOD; public static final int UNKNOWN_LINE = -1; @@ -37,17 +36,19 @@ public final class JavaMethod extends Resource { private String className; private int fromLine; private int toLine; + private boolean isAccessor = false; private JavaMethod(String className, String signature) { - setKey(toKey(className, signature)); + super(toKey(className, signature), QUALIFIER, Java.INSTANCE); this.className = className; this.signature = signature; } - private JavaMethod(String className, String signature, int fromLine, int toLine) { + private JavaMethod(String className, String signature, int fromLine, int toLine, boolean isAccessor) { this(className, signature); this.fromLine = fromLine; this.toLine = toLine; + this.isAccessor = isAccessor; } public int getFromLine() { @@ -66,6 +67,10 @@ public final class JavaMethod extends Resource { return className; } + public boolean isAccessor() { + return isAccessor; + } + @Override public String getName() { return signature; @@ -82,31 +87,11 @@ public final class JavaMethod extends Resource { } @Override - public Language getLanguage() { - return Java.INSTANCE; - } - - @Override - public String getScope() { - return SCOPE; - } - - @Override - public String getQualifier() { - return QUALIFIER; - } - - @Override public Resource getParent() { return null; } @Override - public boolean matchFilePattern(String antPattern) { - return false; - } - - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @@ -155,6 +140,7 @@ public final class JavaMethod extends Resource { private String signature; private int fromLine = UNKNOWN_LINE; private int toLine = UNKNOWN_LINE; + private boolean isAccessor = false; public Builder setKey(String key) { String[] parts = splitClassAndMethodFromKey(key); @@ -188,8 +174,13 @@ public final class JavaMethod extends Resource { return this; } + public Builder setAccessor(boolean accessor) { + isAccessor = accessor; + return this; + } + public JavaMethod create() { - return new JavaMethod(className, signature, fromLine, toLine); + return new JavaMethod(className, signature, fromLine, toLine, isAccessor); } } } diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java index 869f60b3be5..92eba48740a 100644 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java @@ -30,7 +30,7 @@ public class JavaClassTest { @Test public void shouldCreateReferenceFromName() { - JavaClass javaClass = JavaClass.createRef("org.foo.Bar"); + JavaClass javaClass = JavaClass.create("org.foo.Bar"); assertThat(javaClass.getClassName(), is("Bar")); assertThat(javaClass.getKey(), is("org.foo.Bar")); assertThat(javaClass.getLanguage(), is((Language)Java.INSTANCE)); @@ -40,7 +40,7 @@ public class JavaClassTest { @Test public void shouldCreateReferenceFromPackageAndClassname() { - JavaClass javaClass = JavaClass.createRef("org.foo", "Bar"); + JavaClass javaClass = JavaClass.create("org.foo", "Bar"); assertThat(javaClass.getClassName(), is("Bar")); assertThat(javaClass.getKey(), is("org.foo.Bar")); assertThat(javaClass.getLanguage(), is((Language)Java.INSTANCE)); @@ -50,25 +50,25 @@ public class JavaClassTest { @Test public void shouldGetPackageName() { - JavaClass javaClass = JavaClass.createRef("org.foo.Bar"); + JavaClass javaClass = JavaClass.create("org.foo.Bar"); assertThat(javaClass.getPackageName(), is("org.foo")); - javaClass = JavaClass.createRef("Bar"); + javaClass = JavaClass.create("Bar"); assertThat(javaClass.getPackageName(), is("")); } @Test public void shouldGetClassName() { - JavaClass javaClass = JavaClass.createRef("org.foo.Bar"); + JavaClass javaClass = JavaClass.create("org.foo.Bar"); assertThat(javaClass.getClassName(), is("Bar")); - javaClass = JavaClass.createRef("Bar"); + javaClass = JavaClass.create("Bar"); assertThat(javaClass.getClassName(), is("Bar")); } @Test public void shouldOverrideToString() { - JavaClass javaClass = JavaClass.createRef("org.foo.Bar"); + JavaClass javaClass = JavaClass.create("org.foo.Bar"); assertThat(javaClass.toString(), is("org.foo.Bar")); } diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java index bc6976aca25..fad1e992dfe 100644 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java @@ -40,7 +40,7 @@ public class JavaMethodTest { public void shouldCreateReferenceFromClassAndSignature() { String className = "org.foo.Bar"; String signature = "hello(LString;)V"; - JavaMethod method = JavaMethod.createRef(JavaClass.createRef(className), signature); + JavaMethod method = JavaMethod.createRef(JavaClass.create(className), signature); assertThat(method.getKey(), is(className + "#" + signature)); assertThat(method.getClassName(), is(className)); assertThat(method.getName(), is(signature)); |