From c97c954dc12a5e978371a0deb19734121c1fcc2a Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 7 Feb 2011 22:32:45 +0100 Subject: Rename Scopes.TYPE to Scopes.PROGRAM_UNIT --- .../main/java/org/sonar/api/resources/Scopes.java | 23 ++++++++++++++-------- .../org/sonar/api/resources/ResourceUtilsTest.java | 2 +- .../java/org/sonar/api/resources/ScopesTest.java | 8 ++++---- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'sonar-plugin-api') 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". - * + *

* Scopes are generally used in UI to display/hide some services or in web services. - * + *

* 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