本文整理汇总了Java中com.puppycrawl.tools.checkstyle.ConfigurationLoader类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationLoader类的具体用法?Java ConfigurationLoader怎么用?Java ConfigurationLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationLoader类属于com.puppycrawl.tools.checkstyle包,在下文中一共展示了ConfigurationLoader类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: CheckstyleRunner
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
public CheckstyleRunner(String configLocation, String suppressionLocation) {
try {
// create a configuration
DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader
.loadConfiguration(configLocation, new PropertiesExpander(System.getProperties()));
// add the suppression file to the configuration
DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
suppressions.addAttribute("file", suppressionLocation);
config.addChild(suppressions);
this.config = config;
} catch (CheckstyleException e) {
throw new RuntimeException(e);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:17,代码来源:CheckstyleRunner.java
示例2: CheckstyleRunner
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
public CheckstyleRunner(String configLocation, String suppressionLocation)
throws CheckstyleException {
// create a configuration
DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
configLocation, new PropertiesExpander(System.getProperties()));
// add the suppression file to the configuration
DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
suppressions.addAttribute("file", suppressionLocation);
config.addChild(suppressions);
this.config = config;
}
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:CheckstyleRunner.java
示例3: getConfiguration
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
/**
* Returns {@link Configuration} based on Google's checks xml-configuration (google_checks.xml).
* This implementation uses {@link ConfigurationLoader} in order to load configuration
* from xml-file.
* @return {@link Configuration} based on Google's checks xml-configuration (google_checks.xml).
* @throws CheckstyleException if exception occurs during configuration loading.
*/
protected static Configuration getConfiguration() throws CheckstyleException {
if (configuration == null) {
configuration = ConfigurationLoader.loadConfiguration(XML_NAME, new PropertiesExpander(
System.getProperties()));
}
return configuration;
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:AbstractModuleTestSupport.java
示例4: isValidCheckstyleXml
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
private static boolean isValidCheckstyleXml(String fileName, String code,
String unserializedSource)
throws IOException, CheckstyleException {
// can't process non-existent examples, or out of context snippets
if (!code.contains("com.mycompany") && !code.contains("checkstyle-packages")
&& !code.contains("MethodLimit") && !code.contains("<suppress ")
&& !code.contains("<suppress-xpath ")
&& !code.contains("<import-control ")
&& !unserializedSource.startsWith("<property ")
&& !unserializedSource.startsWith("<taskdef ")) {
// validate checkstyle structure and contents
try {
final Properties properties = new Properties();
properties.setProperty("checkstyle.header.file",
new File("config/java.header").getCanonicalPath());
final PropertiesExpander expander = new PropertiesExpander(properties);
final Configuration config = ConfigurationLoader.loadConfiguration(new InputSource(
new StringReader(code)), expander, false);
final Checker checker = new Checker();
try {
final ClassLoader moduleClassLoader = Checker.class.getClassLoader();
checker.setModuleClassLoader(moduleClassLoader);
checker.configure(config);
}
finally {
checker.destroy();
}
}
catch (CheckstyleException ex) {
throw new CheckstyleException(fileName + " has invalid Checkstyle xml ("
+ ex.getMessage() + "): " + unserializedSource, ex);
}
}
return true;
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:39,代码来源:XdocsPagesTest.java
示例5: setup
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
@Before
public void setup() throws CheckstyleException {
baos = new ByteArrayOutputStream();
final AuditListener listener = new DefaultLogger(baos, OutputStreamOptions.NONE);
final InputSource inputSource = new InputSource(CheckstyleTest.class.getClassLoader().getResourceAsStream(
"checkstyle-logging.xml"));
final Configuration configuration = ConfigurationLoader.loadConfiguration(inputSource,
new PropertiesExpander(System.getProperties()), IgnoredModulesOptions.EXECUTE);
checker = new Checker();
checker.setModuleClassLoader(Checker.class.getClassLoader());
checker.configure(configuration);
checker.addListener(listener);
}
开发者ID:opendaylight,项目名称:yangtools,代码行数:16,代码来源:CheckstyleTest.java
示例6: createChecker
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
@NotNull
private Checker createChecker(@NotNull AuditListener auditListener) {
try {
Checker checker = new Checker();
ClassLoader moduleClassLoader = Checker.class.getClassLoader();
String configurationFile = getConfigurationFilename();
Properties properties = System.getProperties();// loadProperties(new File(System.getProperty(CHECKSTYLE_PROPERTIES_FILE)));
checker.setModuleClassLoader(moduleClassLoader);
checker.configure(ConfigurationLoader.loadConfiguration(configurationFile, new PropertiesExpander(properties)));
checker.addListener(auditListener);
return checker;
} catch (CheckstyleException e) {
throw new ReviewException("Unable to create Checkstyle checker", e);
}
}
开发者ID:TouK,项目名称:sputnik,代码行数:16,代码来源:CheckstyleProcessor.java
示例7: execute
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
public Map<String, List<StyleProblem>> execute() throws CheckstyleException {
Properties properties;
if (propertiesFile == null) {
properties = System.getProperties();
} else {
properties = loadProperties(new File(propertiesFile));
}
if (configFile == null) {
configFile = "/google_checks.xml";
}
// create configurations
Configuration config = ConfigurationLoader.loadConfiguration(configFile, new PropertiesExpander(properties));
// create our custom audit listener
RepositoryMinerAudit listener = new RepositoryMinerAudit();
listener.setRepositoryPathLength(repository.length());
ClassLoader moduleClassLoader = Checker.class.getClassLoader();
RootModule rootModule = getRootModule(config.getName(), moduleClassLoader);
rootModule.setModuleClassLoader(moduleClassLoader);
rootModule.configure(config);
rootModule.addListener(listener);
// executes checkstyle
rootModule.process((List<File>) FileUtils.listFiles(new File(repository), EXTENSION_FILE_FILTER, true));
rootModule.destroy();
return listener.getFileErrors();
}
开发者ID:visminer,项目名称:repositoryminer,代码行数:33,代码来源:CheckStyleExecutor.java
示例8: configuration
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
/**
* Load checkstyle configuration.
* @param env The environment
* @return The configuration just loaded
* @see #validate()
*/
private Configuration configuration(final Environment env) {
final File cache =
new File(env.tempdir(), "checkstyle/checkstyle.cache");
final File parent = cache.getParentFile();
if (!parent.exists() && !parent.mkdirs()) {
throw new IllegalStateException(
String.format(
"Unable to create directories needed for %s",
cache.getPath()
)
);
}
final Properties props = new Properties();
props.setProperty("cache.file", cache.getPath());
props.setProperty("header", this.header(env));
final InputSource src = new InputSource(
this.getClass().getResourceAsStream("checks.xml")
);
final Configuration config;
try {
config = ConfigurationLoader.loadConfiguration(
src,
new PropertiesExpander(props),
true
);
} catch (final CheckstyleException ex) {
throw new IllegalStateException("Failed to load config", ex);
}
return config;
}
开发者ID:teamed,项目名称:qulice,代码行数:37,代码来源:CheckstyleValidator.java
示例9: check
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
/**
* Check one file.
* @param name The name of the check
* @param listener The listener
* @throws Exception If something goes wrong inside
*/
private void check(final String name, final AuditListener listener)
throws Exception {
final Checker checker = new Checker();
final InputSource src = new InputSource(
this.getClass().getResourceAsStream(
String.format("%s/config.xml", this.dir)
)
);
checker.setClassLoader(Thread.currentThread().getContextClassLoader());
checker.setModuleClassLoader(
Thread.currentThread().getContextClassLoader()
);
checker.configure(
ConfigurationLoader.loadConfiguration(
src,
new PropertiesExpander(new Properties()),
true
)
);
final List<File> files = new ArrayList<>(0);
files.add(
new File(
this.getClass().getResource(
String.format("%s%s", this.dir, name)
).getFile()
)
);
checker.addListener(listener);
checker.process(files);
checker.destroy();
}
开发者ID:teamed,项目名称:qulice,代码行数:38,代码来源:ChecksTest.java
示例10: toCheckstyleConfiguration
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
@VisibleForTesting
static Configuration toCheckstyleConfiguration(File xmlConfig) throws CheckstyleException {
return ConfigurationLoader.loadConfiguration(xmlConfig.getAbsolutePath(),
new PropertiesExpander(new Properties()));
}
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:6,代码来源:CheckstyleConfiguration.java
示例11: loadConfiguration
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
public static Configuration loadConfiguration(String path, Properties props)
throws CheckstyleException {
return ConfigurationLoader.loadConfiguration(path, new PropertiesExpander(props));
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:5,代码来源:ConfigurationUtil.java
示例12: getConfigurationFromStream
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; //导入依赖的package包/类
private Configuration getConfigurationFromStream(InputStream in) throws CheckstyleException {
return ConfigurationLoader.loadConfiguration(
new InputSource(in),
new CheckstylePropertiesResolver(new Properties()), // TODO: pass real properties
true);
}
开发者ID:reflectoring,项目名称:coderadar,代码行数:7,代码来源:CheckstyleSourceCodeFileAnalyzerPlugin.java
注:本文中的com.puppycrawl.tools.checkstyle.ConfigurationLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论