diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-08-03 13:15:32 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2017-09-07 08:33:31 +0200 |
commit | e992c54eda36632088c2da41174f703a49282c35 (patch) | |
tree | 4791869dd29898fa48b3bea26944884197502346 /sonar-plugin-api | |
parent | 24afdb04fb172ef2ff3fe23760513fc16e42e42a (diff) | |
download | sonarqube-e992c54eda36632088c2da41174f703a49282c35.tar.gz sonarqube-e992c54eda36632088c2da41174f703a49282c35.zip |
SONAR-9672 Store the link between a rule and the plugin declaring it
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 0e9b90fbc3c..c9690b1536c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -385,6 +385,7 @@ public interface RulesDefinition { */ class Context { private final Map<String, Repository> repositoriesByKey = new HashMap<>(); + private String currentPluginKey; /** * New builder for {@link org.sonar.api.server.rule.RulesDefinition.Repository}. @@ -442,6 +443,10 @@ public interface RulesDefinition { } repositoriesByKey.put(newRepository.key, new RepositoryImpl(newRepository, existing)); } + + public void setCurrentPluginKey(@Nullable String pluginKey) { + this.currentPluginKey = pluginKey; + } } interface NewExtendedRepository { @@ -496,7 +501,7 @@ public interface RulesDefinition { @Override public NewRule createRule(String ruleKey) { checkArgument(!newRules.containsKey(ruleKey), "The rule '%s' of repository '%s' is declared several times", ruleKey, key); - NewRule newRule = new NewRule(key, ruleKey); + NewRule newRule = new NewRule(context.currentPluginKey, key, ruleKey); newRules.put(ruleKey, newRule); return newRule; } @@ -671,6 +676,7 @@ public interface RulesDefinition { } class NewRule { + private final String pluginKey; private final String repoKey; private final String key; private RuleType type; @@ -688,7 +694,8 @@ public interface RulesDefinition { private final DebtRemediationFunctions functions; private boolean activatedByDefault; - private NewRule(String repoKey, String key) { + private NewRule(@Nullable String pluginKey, String repoKey, String key) { + this.pluginKey = pluginKey; this.repoKey = repoKey; this.key = key; this.functions = new DefaultDebtRemediationFunctions(repoKey, key); @@ -926,6 +933,7 @@ public interface RulesDefinition { @Immutable class Rule { + private final String pluginKey; private final Repository repository; private final String repoKey; private final String key; @@ -944,6 +952,7 @@ public interface RulesDefinition { private final boolean activatedByDefault; private Rule(Repository repository, NewRule newRule) { + this.pluginKey = newRule.pluginKey; this.repository = repository; this.repoKey = newRule.repoKey; this.key = newRule.key; @@ -970,6 +979,14 @@ public interface RulesDefinition { return repository; } + /** + * @since 6.6 the plugin the rule was declared in + */ + @CheckForNull + public String pluginKey() { + return pluginKey; + } + public String key() { return key; } |