• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TreeWalker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.TreeWalker的典型用法代码示例。如果您正苦于以下问题:Java TreeWalker类的具体用法?Java TreeWalker怎么用?Java TreeWalker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TreeWalker类属于com.puppycrawl.tools.checkstyle包,在下文中一共展示了TreeWalker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: dependencyCycle

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
/**
 * Read a file with a cycle in the dependency definition.
 * 
 * @throws Exception
 *             in case of an unexpected test execution
 */
@Test
public void dependencyCycle() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotypeCycle.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	try {
		verify(main, getPath(SampleIs.class), expected);
		fail("IllegalArgumentException should have been thrown");
	} catch (IllegalArgumentException ex) {
		assertThat(ex).hasMessageContaining("There is a cycle in dependency-configuration:")
				.hasMessageContaining("dto").hasMessageContaining("view").hasMessageContaining("transformer");

	}
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:23,代码来源:StereotypeCheckConfigurationReaderTest.java


示例2: fileStereotypeXmlNotExist

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
/**
 * Checks if the configuration file exists.
 * 
 * @throws Exception
 *             in case of an unexpected test execution
 */
@Test
public void fileStereotypeXmlNotExist() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotypeNotExist.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	try {
		verify(main, getPath(SampleIs.class), expected);
		fail("IllegalArgumentException");
	} catch (IllegalArgumentException ex) {
		assertThat(ex)
				.hasMessageStartingWith(
						"File defined in property 'file' of Check info.novatec.ita.check.StereotypeCheck does not exist")
				.hasMessageEndingWith("src/test/resources/stereotypeNotExist.xml");
	}
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:24,代码来源:StereotypeCheckConfigurationReaderTest.java


示例3: testCacheWhenFileExternalResourceContentDoesNotChange

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class);
    checkConfig.addAttribute("file", getPath("InputImportControlOneRegExp.xml"));

    final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class);
    treeWalkerConfig.addChild(checkConfig);

    final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig);
    final File cacheFile = temporaryFolder.newFile();
    checkerConfig.addAttribute("cacheFile", cacheFile.getPath());

    final String filePath = temporaryFolder.newFile("EmptyFile.java").getPath();
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

    verify(checkerConfig, filePath, expected);
    // One more time to use cache.
    verify(checkerConfig, filePath, expected);

    assertTrue("External resource is not present in cache",
            new String(Files7.readAllBytes(new Path(cacheFile)),
                    StandardCharsets.UTF_8).contains("InputImportControlOneRegExp.xml"));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:ImportControlCheckTest.java


示例4: verifySuppressed

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private void verifySuppressed(Configuration moduleConfig, String fileName,
        String[] expectedViolations, String... suppressedViolations) throws Exception {
    final DefaultConfiguration memberNameCheckConfig =
            createModuleConfig(MemberNameCheck.class);
    memberNameCheckConfig.addAttribute("id", "ignore");

    final DefaultConfiguration constantNameCheckConfig =
        createModuleConfig(ConstantNameCheck.class);
    constantNameCheckConfig.addAttribute("id", null);

    final DefaultConfiguration treewalkerConfig = createModuleConfig(TreeWalker.class);
    treewalkerConfig.addChild(memberNameCheckConfig);
    treewalkerConfig.addChild(constantNameCheckConfig);
    treewalkerConfig.addChild(createModuleConfig(IllegalCatchCheck.class));

    if (moduleConfig != null) {
        treewalkerConfig.addChild(moduleConfig);
    }

    final DefaultConfiguration checkerConfig = createRootConfig(treewalkerConfig);

    verify(checkerConfig, fileName,
            removeSuppressed(expectedViolations, suppressedViolations));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:SuppressionCommentFilterTest.java


示例5: verifySuppressed

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private void verifySuppressed(Configuration moduleConfig, String fileName,
        String[] expectedViolations, String... suppressedViolations) throws Exception {
    final DefaultConfiguration memberNameCheckConfig =
            createModuleConfig(MemberNameCheck.class);
    memberNameCheckConfig.addAttribute("id", "ignore");

    final DefaultConfiguration constantNameCheckConfig =
        createModuleConfig(ConstantNameCheck.class);
    constantNameCheckConfig.addAttribute("id", null);

    final DefaultConfiguration treewalkerConfig = createModuleConfig(TreeWalker.class);
    treewalkerConfig.addChild(memberNameCheckConfig);
    treewalkerConfig.addChild(constantNameCheckConfig);
    treewalkerConfig.addChild(createModuleConfig(IllegalCatchCheck.class));

    if (moduleConfig != null) {
        treewalkerConfig.addChild(moduleConfig);
    }

    final DefaultConfiguration checkerConfig = createRootConfig(treewalkerConfig);

    verify(checkerConfig,
            fileName,
            removeSuppressed(expectedViolations, suppressedViolations));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:SuppressWithNearbyCommentFilterTest.java


示例6: testCacheWhenFileExternalResourceContentDoesNotChange

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class);
    checkConfig.addAttribute("file", getPath("InputImportControlOneRegExp.xml"));

    final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class);
    treeWalkerConfig.addChild(checkConfig);

    final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig);
    final File cacheFile = temporaryFolder.newFile();
    checkerConfig.addAttribute("cacheFile", cacheFile.getPath());

    final String filePath = temporaryFolder.newFile("EmptyFile.java").getPath();
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

    verify(checkerConfig, filePath, expected);
    // One more time to use cache.
    verify(checkerConfig, filePath, expected);

    assertTrue("External resource is not present in cache",
            new String(Files.readAllBytes(cacheFile.toPath()),
                    StandardCharsets.UTF_8).contains("InputImportControlOneRegExp.xml"));
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:24,代码来源:ImportControlCheckTest.java


示例7: readValidConfigurationFile

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
/**
 * Successfully read a valid configuration file.
 * 
 * @throws Exception
 *             in case of an unexpected test execution
 */
@Test
public void readValidConfigurationFile() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	verify(main, getPath(SampleIs.class), expected);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:16,代码来源:StereotypeCheckConfigurationReaderTest.java


示例8: noPropertyFileDefined

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
/**
 * A configuration file must be specified to execute the stereotype check.
 * 
 * @throws Exception
 *             in case of an unexpected test execution
 */
@Test
public void noPropertyFileDefined() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	main.addChild(checkConfig);
	final String[] expected = {};
	try {
		verify(main, getPath(SampleIs.class), expected);
		fail("IllegalArgumentException");
	} catch (IllegalArgumentException ex) {
		assertThat(ex).hasMessage("No Property 'file' defined for Check info.novatec.ita.check.StereotypeCheck");
	}
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:20,代码来源:StereotypeCheckConfigurationReaderTest.java


示例9: checkEntityOverrideOk

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkEntityOverrideOk() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	verify(main, getPath(AdditionalOperation.class), expected);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例10: checkEntityOverrideFail

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkEntityOverrideFail() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
	main.addChild(checkConfig);
	String expectedFail = "Stereotype entity: does not extend info.novatec.ita.check.testclasses.core.fwk.api.data.dto.Pojo";
	verify(main, getPath(AdditionalOperation.class), expectedFail);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例11: checkInterfaceOverrideOk

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkInterfaceOverrideOk() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	verify(main, getPath(SampleApiBs.class), expected);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例12: checkInterfaceOverrideFail

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkInterfaceOverrideFail() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
	main.addChild(checkConfig);
	final String expectedFail = "Stereotype businessservice: does not extend info.novatec.ita.check.testclasses.core.fwk.api.bl.bs.BusinessService";
	verify(main, getPath(SampleApiBs.class), expectedFail);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例13: checkAnnotationOverrideOk

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkAnnotationOverrideOk() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
	main.addChild(checkConfig);
	final String[] expected = {};
	verify(main, getPath(SampleApp1View.class), expected);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例14: checkAnnotationOverrideFail

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void checkAnnotationOverrideFail() throws Exception {
	DefaultConfiguration main = createCheckConfig(TreeWalker.class);
	final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
	checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
	main.addChild(checkConfig);
	final String expectedFail = "Stereotype view: missing annotation info.novatec.ita.check.testclasses.core.fwk.common.ul.ViewStereotype";
	verify(main, getPath(SampleApp1View.class), expectedFail);
}
 
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java


示例15: createTreeWalkerConfig

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
/**
 * Creates {@link DefaultConfiguration} or the {@link Checker}.
 * based on the given {@link Configuration}.
 * @param config {@link Configuration} instance.
 * @return {@link DefaultConfiguration} for the {@link Checker}.
 */
protected static DefaultConfiguration createTreeWalkerConfig(Configuration config) {
    final DefaultConfiguration dc =
            new DefaultConfiguration("configuration");
    final DefaultConfiguration twConf = createModuleConfig(TreeWalker.class);
    // make sure that the tests always run with this charset
    dc.addAttribute("charset", "iso-8859-1");
    dc.addChild(twConf);
    twConf.addChild(config);
    return dc;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:AbstractModuleTestSupport.java


示例16: testWithMultipleChecks

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
@Test
public void testWithMultipleChecks() throws Exception {
    final DefaultConfiguration checksConfig = createModuleConfig(TreeWalker.class);
    checksConfig.addChild(createModuleConfig(AtclauseOrderCheck.class));
    checksConfig.addChild(createModuleConfig(JavadocParagraphCheck.class));

    final DefaultConfiguration checkerConfig = createRootConfig(checksConfig);

    verify(checkerConfig, getPath("InputAbstractJavadocCorrectParagraph.java"));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:AbstractJavadocCheckTest.java


示例17: checkFile

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private static void checkFile(String filename) throws Exception {
    final FileText text = new FileText(new File(filename),
                       System.getProperty("file.encoding", StandardCharsets.UTF_8.name()));
    final FileContents contents = new FileContents(text);
    final DetailAST rootAST = TreeWalker.parse(contents);
    if (rootAST != null) {
        checkTree(filename, rootAST);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:10,代码来源:DetailASTTest.java


示例18: parseFile

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private static DetailAST parseFile(File file) throws Exception {
    final FileContents contents = new FileContents(
            new FileText(file.getAbsoluteFile(),
                    System.getProperty("file.encoding",
                    StandardCharsets.UTF_8.name())));
    return TreeWalker.parseWithComments(contents);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:8,代码来源:ParseTreeTablePresentationTest.java


示例19: verifySuppressed

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private void verifySuppressed(Configuration moduleConfig, String fileName,
        String[] expectedViolations, String... suppressedViolations) throws Exception {
    final DefaultConfiguration holderConfig =
        createModuleConfig(SuppressWarningsHolder.class);
    holderConfig.addAttribute("aliasList",
        "com.puppycrawl.tools.checkstyle.checks.sizes."
            + "ParameterNumberCheck=paramnum");

    final DefaultConfiguration memberNameCheckConfig =
            createModuleConfig(MemberNameCheck.class);
    memberNameCheckConfig.addAttribute("id", "ignore");

    final DefaultConfiguration constantNameCheckConfig =
        createModuleConfig(ConstantNameCheck.class);
    constantNameCheckConfig.addAttribute("id", "");

    final DefaultConfiguration uncommentedMainCheckConfig =
        createModuleConfig(UncommentedMainCheck.class);
    uncommentedMainCheckConfig.addAttribute("id", "ignore");

    final DefaultConfiguration treewalkerConfig =
            createModuleConfig(TreeWalker.class);
    treewalkerConfig.addChild(holderConfig);
    treewalkerConfig.addChild(memberNameCheckConfig);
    treewalkerConfig.addChild(constantNameCheckConfig);
    treewalkerConfig.addChild(createModuleConfig(ParameterNumberCheck.class));
    treewalkerConfig.addChild(createModuleConfig(IllegalCatchCheck.class));
    treewalkerConfig.addChild(uncommentedMainCheckConfig);
    treewalkerConfig.addChild(createModuleConfig(JavadocTypeCheck.class));

    final DefaultConfiguration checkerConfig =
            createRootConfig(treewalkerConfig);
    if (moduleConfig != null) {
        checkerConfig.addChild(moduleConfig);
    }

    verify(checkerConfig,
            fileName,
        removeSuppressed(expectedViolations, suppressedViolations));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:41,代码来源:SuppressWarningsFilterTest.java


示例20: createCheckerConfig

import com.puppycrawl.tools.checkstyle.TreeWalker; //导入依赖的package包/类
private DefaultConfiguration createCheckerConfig(Configuration config) {
  DefaultConfiguration result = new DefaultConfiguration("configuration");
  DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
  // make sure that the tests always run with this charset
  result.addAttribute("charset", "iso-8859-1");
  result.addChild(treeWalkerConfig);
  treeWalkerConfig.addChild(config);
  return result;
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:10,代码来源:BaseCheckTestSupport.java



注:本文中的com.puppycrawl.tools.checkstyle.TreeWalker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Property类代码示例发布时间:2022-05-22
下一篇:
Java PortProber类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap