Class CheckRegistrar.RegistrarContext

java.lang.Object
org.sonar.plugins.java.api.CheckRegistrar.RegistrarContext
Direct Known Subclasses:
SonarComponents
Enclosing interface:
CheckRegistrar

public static class CheckRegistrar.RegistrarContext extends Object
Context for checks registration.
  • Constructor Details

    • RegistrarContext

      public RegistrarContext()
  • Method Details

    • registerClassesForRepository

      public void registerClassesForRepository(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses, Iterable<Class<? extends JavaCheck>> testCheckClasses)
      Registers java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      checkClasses - classes of checks for main sources
      testCheckClasses - classes of checks for test sources
    • repositoryKey

      @Deprecated(since="7.25", forRemoval=true) public String repositoryKey()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      getter for repository key.
      Returns:
      the repository key.
    • checkClasses

      @Deprecated(since="7.25", forRemoval=true) public Iterable<Class<? extends JavaCheck>> checkClasses()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      get main source check classes
      Returns:
      iterable of main checks classes
    • testCheckClasses

      @Deprecated(since="7.25", forRemoval=true) public Iterable<Class<? extends JavaCheck>> testCheckClasses()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      get test source check classes
      Returns:
      iterable of test checks classes
    • registerMainChecks

      public void registerMainChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances)
      Registers main code java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      javaCheckClassesAndInstances - a collection of Classinvalid input: '<'? extends JavaCheck> and JavaCheck> instances
    • registerTestChecks

      public void registerTestChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances)
      Registers test code java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      javaCheckClassesAndInstances - a collection of Classinvalid input: '<'? extends JavaCheck> and JavaCheck> instances
    • registerMainSharedCheck

      public void registerMainSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Registers one main code check related to not one but a list of rules. The check will be active if at least one of the given rule key is active. In this context injection of @RuleProperty and auto instantiation of rules defined as template in RulesDefinition will not work. And the reportIssue mechanism will not be able to find the RuleKey automatically.
    • registerTestSharedCheck

      public void registerTestSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Registers one test code check related to not one but a list of rules. The check will be active if at least one of the given rule key is active. In this context injection of @RuleProperty and auto instantiation of rules defined as template in RulesDefinition will not work.
    • registerAutoScanCompatibleRules

      public void registerAutoScanCompatibleRules(Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Cannot be used outside of Sonar Products. Registers rules compatible with the autoscan context. Note: It's possible to convert checkClass to RuleKey using:
         RuleKey.of(repositoryKey, RuleAnnotationUtils.getRuleKey(checkClass))