com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck Java Examples

The following examples show how to use com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetadataFactory.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a set of generic metadata for a module that has no metadata delivered with the plugin.
 *
 * @param module
 *          the module
 * @return the generic metadata built
 */
public static RuleMetadata createGenericMetadata(Module module) {

  String parent = null;
  try {

    Class<?> checkClass = CheckstylePlugin.getDefault().getAddonExtensionClassLoader()
            .loadClass(module.getName());

    Object moduleInstance = checkClass.newInstance();

    if (moduleInstance instanceof AbstractFileSetCheck) {
      parent = XMLTags.CHECKER_MODULE;
    } else {
      parent = XMLTags.TREEWALKER_MODULE;
    }
  } catch (Exception e) {
    // Ok we tried... default to TreeWalker
    parent = XMLTags.TREEWALKER_MODULE;
  }

  RuleGroupMetadata otherGroup = getRuleGroupMetadata(XMLTags.OTHER_GROUP);
  RuleMetadata ruleMeta = new RuleMetadata(module.getName(), module.getName(), parent,
          MetadataFactory.getDefaultSeverity(), false, true, true, false, otherGroup);
  module.setMetaData(ruleMeta);
  sRuleMetadata.put(ruleMeta.getInternalName(), ruleMeta);

  List<ConfigProperty> properties = module.getProperties();
  int size = properties != null ? properties.size() : 0;
  for (int i = 0; i < size; i++) {

    ConfigProperty property = properties.get(i);
    ConfigPropertyMetadata meta = new ConfigPropertyMetadata(ConfigPropertyType.String,
            property.getName(), null, null);
    property.setMetaData(meta);
  }
  return ruleMeta;
}
 
Example #2
Source File: CheckUtil.java    From sonar-checkstyle with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Checks whether a class may be considered as the checkstyle file set.
 * Checkstyle's file sets are classes which implement 'AbstractFileSetCheck' interface.
 * @param loadedClass class to check.
 * @return true if a class may be considered as the checkstyle file set.
 */
public static boolean isFileSetModule(Class<?> loadedClass) {
    return AbstractFileSetCheck.class.isAssignableFrom(loadedClass);
}