diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-07 22:32:45 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-07 22:32:45 +0100 |
commit | c97c954dc12a5e978371a0deb19734121c1fcc2a (patch) | |
tree | acf028c15d68838abc09393a915f206027f32239 /sonar-plugin-api | |
parent | a34a3671bd0c8427ae3cdf165f7a2136713e875e (diff) | |
download | sonarqube-c97c954dc12a5e978371a0deb19734121c1fcc2a.tar.gz sonarqube-c97c954dc12a5e978371a0deb19734121c1fcc2a.zip |
Rename Scopes.TYPE to Scopes.PROGRAM_UNIT
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 20 insertions, 13 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Scopes.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Scopes.java index 2f4677ed366..c992cb36e1f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Scopes.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Scopes.java @@ -25,9 +25,9 @@ import org.apache.commons.lang.StringUtils; /** * Resource scopes are used to group some types of resources. For example Java methods, Flex methods, C functions * and Cobol paragraphs are grouped in the scope "block unit". - * + * <p/> * Scopes are generally used in UI to display/hide some services or in web services. - * + * <p/> * Scopes are not extensible by plugins. * * @since 2.6 @@ -37,6 +37,7 @@ public final class Scopes { private Scopes() { // only static methods } + /** * For example view, subview, project, module or library. Persisted in database. */ @@ -57,14 +58,14 @@ public final class Scopes { /** * Types like Java classes/interfaces. Not persisted in database. */ - public static final String TYPE = "TYP"; + public static final String PROGRAM_UNIT = "PGU"; /** * Block units like methods, functions or Cobol paragraphs. */ public static final String BLOCK_UNIT = "BLU"; - public static final String[] SORTED_SCOPES = {PROJECT, DIRECTORY, FILE, TYPE, BLOCK_UNIT}; + public static final String[] SORTED_SCOPES = {PROJECT, DIRECTORY, FILE, PROGRAM_UNIT, BLOCK_UNIT}; public static boolean isProject(final Resource resource) { @@ -75,12 +76,18 @@ public final class Scopes { return StringUtils.equals(DIRECTORY, resource.getScope()); } + /** + * This scope is sometimes called a "compilation unit". + */ public static boolean isFile(final Resource resource) { return StringUtils.equals(FILE, resource.getScope()); } - public static boolean isType(final Resource resource) { - return StringUtils.equals(TYPE, resource.getScope()); + /** + * A program unit can be a Java class. + */ + public static boolean isProgramUnit(final Resource resource) { + return StringUtils.equals(PROGRAM_UNIT, resource.getScope()); } public static boolean isBlockUnit(final Resource resource) { @@ -94,7 +101,7 @@ public final class Scopes { public static boolean isHigherThan(final String scope, final String than) { int index = ArrayUtils.indexOf(SORTED_SCOPES, scope); int thanIndex = ArrayUtils.indexOf(SORTED_SCOPES, than); - return index<thanIndex; + return index < thanIndex; } public static boolean isHigherThanOrEquals(final Resource resource, final String than) { @@ -104,6 +111,6 @@ public final class Scopes { public static boolean isHigherThanOrEquals(final String scope, final String than) { int index = ArrayUtils.indexOf(SORTED_SCOPES, scope); int thanIndex = ArrayUtils.indexOf(SORTED_SCOPES, than); - return index<=thanIndex; + return index <= thanIndex; } }
\ No newline at end of file diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceUtilsTest.java index a5240345f6d..f6cad4d31de 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceUtilsTest.java @@ -78,7 +78,7 @@ public class ResourceUtilsTest { @Test public void shouldNotBePersistable() { Resource javaClass = mock(Resource.class); - when(javaClass.getScope()).thenReturn(Scopes.TYPE); + when(javaClass.getScope()).thenReturn(Scopes.PROGRAM_UNIT); Resource javaMethod = mock(Resource.class); when(javaMethod.getScope()).thenReturn(Scopes.BLOCK_UNIT); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java index 1cd288c5543..5674f5dd8f4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java @@ -33,7 +33,7 @@ public class ScopesTest { assertThat(Scopes.isDirectory(resource), is(false)); assertThat(Scopes.isFile(resource), is(false)); assertThat(Scopes.isBlockUnit(resource), is(false)); - assertThat(Scopes.isType(resource), is(false)); + assertThat(Scopes.isProgramUnit(resource), is(false)); } @Test @@ -43,7 +43,7 @@ public class ScopesTest { assertThat(Scopes.isDirectory(resource), is(false)); assertThat(Scopes.isFile(resource), is(false)); assertThat(Scopes.isBlockUnit(resource), is(false)); - assertThat(Scopes.isType(resource), is(false)); + assertThat(Scopes.isProgramUnit(resource), is(false)); } @Test @@ -53,7 +53,7 @@ public class ScopesTest { assertThat(Scopes.isDirectory(resource), is(true)); assertThat(Scopes.isFile(resource), is(false)); assertThat(Scopes.isBlockUnit(resource), is(false)); - assertThat(Scopes.isType(resource), is(false)); + assertThat(Scopes.isProgramUnit(resource), is(false)); } @Test @@ -63,7 +63,7 @@ public class ScopesTest { assertThat(Scopes.isDirectory(resource), is(false)); assertThat(Scopes.isFile(resource), is(true)); assertThat(Scopes.isBlockUnit(resource), is(false)); - assertThat(Scopes.isType(resource), is(false)); + assertThat(Scopes.isProgramUnit(resource), is(false)); } @Test |