code: private static Set<Language> getApplicableLanguages(PMDConfiguration configuration, RuleSets ruleSets) {
          Set<Language> languages = new HashSet<>();
          LanguageVersionDiscoverer discoverer = configuration.getLanguageVersionDiscoverer();
  
          for (Rule rule : ruleSets.getAllRules()) {
              Language language = rule.getLanguage();
              if (languages.contains(language))
                  continue;
              LanguageVersion version = discoverer.getDefaultLanguageVersion(language);
              if (RuleSet.applies(rule, version)) {
                  languages.add(language);
                  log.debug("Using {} version: {}", language.getShortName(), version.getShortName());
              }
          }
          return languages;
      }
docs: Paste from PMD