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

Java AbstractCheck类代码示例

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

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



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

示例1: notifyBegin

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Notify checks that we are about to begin walking a tree.
 * @param rootAST the root of the tree.
 * @param contents the contents of the file the AST was generated from.
 * @param astState state of AST.
 */
private void notifyBegin(DetailAST rootAST, FileContents contents,
        AstState astState) {
    final Set<AbstractCheck> checks;

    if (astState == AstState.WITH_COMMENTS) {
        checks = commentChecks;
    }
    else {
        checks = ordinaryChecks;
    }

    for (AbstractCheck check : checks) {
        check.setFileContents(contents);
        check.clearMessages();
        check.beginTree(rootAST);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:TreeWalker.java


示例2: notifyEnd

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Notify checks that we have finished walking a tree.
 * @param rootAST the root of the tree.
 * @param astState state of AST.
 */
private void notifyEnd(DetailAST rootAST, AstState astState) {
    final Set<AbstractCheck> checks;

    if (astState == AstState.WITH_COMMENTS) {
        checks = commentChecks;
    }
    else {
        checks = ordinaryChecks;
    }

    for (AbstractCheck check : checks) {
        check.finishTree(rootAST);
        messages.addAll(check.getMessages());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:TreeWalker.java


示例3: getListOfChecks

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Method returns list of checks.
 *
 * @param ast
 *            the node to notify for
 * @param astState
 *            state of AST.
 * @return list of visitors
 */
private Collection<AbstractCheck> getListOfChecks(DetailAST ast, AstState astState) {
    Collection<AbstractCheck> visitors = null;
    final String tokenType = TokenUtils.getTokenName(ast.getType());

    if (astState == AstState.WITH_COMMENTS) {
        if (tokenToCommentChecks.containsKey(tokenType)) {
            visitors = tokenToCommentChecks.get(tokenType);
        }
    }
    else {
        if (tokenToOrdinaryChecks.containsKey(tokenType)) {
            visitors = tokenToOrdinaryChecks.get(tokenType);
        }
    }
    return visitors;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:TreeWalker.java


示例4: testDefaultTokensAreSubsetOfAcceptableTokens

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
@Test
public void testDefaultTokensAreSubsetOfAcceptableTokens() throws Exception {
    for (Class<?> check : CheckUtil.getCheckstyleChecks()) {
        if (AbstractCheck.class.isAssignableFrom(check)) {
            final AbstractCheck testedCheck = (AbstractCheck) check.getDeclaredConstructor()
                    .newInstance();
            final int[] defaultTokens = testedCheck.getDefaultTokens();
            final int[] acceptableTokens = testedCheck.getAcceptableTokens();

            if (!isSubset(defaultTokens, acceptableTokens)) {
                final String errorMessage = String.format(Locale.ROOT,
                        "%s's default tokens must be a subset"
                        + " of acceptable tokens.", check.getName());
                Assert.fail(errorMessage);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:AllChecksTest.java


示例5: testRequiredTokensAreSubsetOfAcceptableTokens

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
@Test
public void testRequiredTokensAreSubsetOfAcceptableTokens() throws Exception {
    for (Class<?> check : CheckUtil.getCheckstyleChecks()) {
        if (AbstractCheck.class.isAssignableFrom(check)) {
            final AbstractCheck testedCheck = (AbstractCheck) check.getDeclaredConstructor()
                    .newInstance();
            final int[] requiredTokens = testedCheck.getRequiredTokens();
            final int[] acceptableTokens = testedCheck.getAcceptableTokens();

            if (!isSubset(requiredTokens, acceptableTokens)) {
                final String errorMessage = String.format(Locale.ROOT,
                        "%s's required tokens must be a subset"
                        + " of acceptable tokens.", check.getName());
                Assert.fail(errorMessage);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:AllChecksTest.java


示例6: testRequiredTokensAreSubsetOfDefaultTokens

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
@Test
public void testRequiredTokensAreSubsetOfDefaultTokens() throws Exception {
    for (Class<?> check : CheckUtil.getCheckstyleChecks()) {
        if (AbstractCheck.class.isAssignableFrom(check)) {
            final AbstractCheck testedCheck = (AbstractCheck) check.getDeclaredConstructor()
                    .newInstance();
            final int[] defaultTokens = testedCheck.getDefaultTokens();
            final int[] requiredTokens = testedCheck.getRequiredTokens();

            if (!isSubset(requiredTokens, defaultTokens)) {
                final String errorMessage = String.format(Locale.ROOT,
                        "%s's required tokens must be a subset"
                        + " of default tokens.", check.getName());
                Assert.fail(errorMessage);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:AllChecksTest.java


示例7: validatePropertySectionPropertyTokens

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
private static void validatePropertySectionPropertyTokens(String fileName, String sectionName,
        AbstractCheck check, List<Node> columns) {
    Assert.assertEquals(fileName + " section '" + sectionName
            + "' should have the basic token description", "tokens to check", columns.get(1)
            .getTextContent());
    Assert.assertEquals(
            fileName + " section '" + sectionName + "' should have all the acceptable tokens",
            "subset of tokens "
                    + CheckUtil.getTokenText(check.getAcceptableTokens(),
                            check.getRequiredTokens()), columns.get(2).getTextContent()
                    .replaceAll("\\s+", " ").trim());
    Assert.assertEquals(fileName + " section '" + sectionName
            + "' should have all the default tokens",
            CheckUtil.getTokenText(check.getDefaultTokens(), check.getRequiredTokens()),
            columns.get(3).getTextContent().replaceAll("\\s+", " ").trim());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:XdocsPagesTest.java


示例8: setupChild

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * {@inheritDoc} Creates child module.
 * @noinspection ChainOfInstanceofChecks
 */
@Override
public void setupChild(Configuration childConf)
        throws CheckstyleException {
    final String name = childConf.getName();
    final Object module = moduleFactory.createModule(name);
    if (module instanceof AutomaticBean) {
        final AutomaticBean bean = (AutomaticBean) module;
        bean.contextualize(childContext);
        bean.configure(childConf);
    }
    if (module instanceof AbstractCheck) {
        final AbstractCheck check = (AbstractCheck) module;
        check.init();
        registerCheck(check);
    }
    else if (module instanceof TreeWalkerFilter) {
        final TreeWalkerFilter filter = (TreeWalkerFilter) module;
        filters.add(filter);
    }
    else {
        throw new CheckstyleException(
            "TreeWalker is not allowed as a parent of " + name
                    + " Please review 'Parent Module' section for this Check in web"
                    + " documentation if Check is standard.");
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:31,代码来源:TreeWalker.java


示例9: registerCheck

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Register a check for a given configuration.
 * @param check the check to register
 * @throws CheckstyleException if an error occurs
 */
private void registerCheck(AbstractCheck check)
        throws CheckstyleException {
    validateDefaultTokens(check);
    final int[] tokens;
    final Set<String> checkTokens = check.getTokenNames();
    if (checkTokens.isEmpty()) {
        tokens = check.getDefaultTokens();
    }
    else {
        tokens = check.getRequiredTokens();

        //register configured tokens
        final int[] acceptableTokens = check.getAcceptableTokens();
        Arrays.sort(acceptableTokens);
        for (String token : checkTokens) {
            final int tokenId = TokenUtils.getTokenId(token);
            if (Arrays.binarySearch(acceptableTokens, tokenId) >= 0) {
                registerCheck(token, check);
            }
            else {
                final String message = String.format(Locale.ROOT, "Token \"%s\" was "
                        + "not found in Acceptable tokens list in check %s",
                        token, check.getClass().getName());
                throw new CheckstyleException(message);
            }
        }
    }
    for (int element : tokens) {
        registerCheck(element, check);
    }
    if (check.isCommentNodesRequired()) {
        commentChecks.add(check);
    }
    else {
        ordinaryChecks.add(check);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:43,代码来源:TreeWalker.java


示例10: validateDefaultTokens

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Validates that check's required tokens are subset of default tokens.
 * @param check to validate
 * @throws CheckstyleException when validation of default tokens fails
 */
private static void validateDefaultTokens(AbstractCheck check) throws CheckstyleException {
    if (check.getRequiredTokens().length != 0) {
        final int[] defaultTokens = check.getDefaultTokens();
        Arrays.sort(defaultTokens);
        for (final int token : check.getRequiredTokens()) {
            if (Arrays.binarySearch(defaultTokens, token) < 0) {
                final String message = String.format(Locale.ROOT, "Token \"%s\" from required "
                        + "tokens was not found in default tokens list in check %s",
                        token, check.getClass().getName());
                throw new CheckstyleException(message);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:TreeWalker.java


示例11: notifyVisit

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Notify checks that visiting a node.
 * @param ast the node to notify for.
 * @param astState state of AST.
 */
private void notifyVisit(DetailAST ast, AstState astState) {
    final Collection<AbstractCheck> visitors = getListOfChecks(ast, astState);

    if (visitors != null) {
        for (AbstractCheck check : visitors) {
            check.visitToken(ast);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:TreeWalker.java


示例12: notifyLeave

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Notify checks that leaving a node.
 * @param ast
 *        the node to notify for
 * @param astState state of AST.
 */
private void notifyLeave(DetailAST ast, AstState astState) {
    final Collection<AbstractCheck> visitors = getListOfChecks(ast, astState);

    if (visitors != null) {
        for (AbstractCheck check : visitors) {
            check.leaveToken(ast);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:TreeWalker.java


示例13: getExternalResourceLocationsOfChecks

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Returns a set of external configuration resource locations which are used by the checks set.
 * @param checks a set of checks.
 * @return a set of external configuration resource locations which are used by the checks set.
 */
private static Set<String> getExternalResourceLocationsOfChecks(Set<AbstractCheck> checks) {
    final Set<String> externalConfigurationResources = new HashSet<String>();
    for (AbstractCheck check : checks) {
        if (check instanceof ExternalResourceHolder) {
            final Set<String> checkExternalResources =
                ((ExternalResourceHolder) check).getExternalResourceLocations();
            externalConfigurationResources.addAll(checkExternalResources);
        }
    }
    return externalConfigurationResources;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:TreeWalker.java


示例14: getExternalResourceLocationsOfChecks

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Returns a set of external configuration resource locations which are used by the checks set.
 * @param checks a set of checks.
 * @return a set of external configuration resource locations which are used by the checks set.
 */
private static Set<String> getExternalResourceLocationsOfChecks(Set<AbstractCheck> checks) {
    final Set<String> externalConfigurationResources = new HashSet<>();
    checks.stream().filter(check -> check instanceof ExternalResourceHolder).forEach(check -> {
        final Set<String> checkExternalResources =
            ((ExternalResourceHolder) check).getExternalResourceLocations();
        externalConfigurationResources.addAll(checkExternalResources);
    });
    return externalConfigurationResources;
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:15,代码来源:TreeWalker.java


示例15: destroy

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
@Override
public void destroy() {
    ordinaryChecks.forEach(AbstractCheck::destroy);
    commentChecks.forEach(AbstractCheck::destroy);
    super.destroy();
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:7,代码来源:TreeWalker.java


示例16: isStatefulFieldClearedDuringBeginTree

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Checks if stateful field is cleared during {@link AbstractCheck#beginTree} in check.
 *
 * @param check      check object which field is to be verified
 * @param astToVisit ast to pass into check methods
 * @param fieldName  name of the field to be checked
 * @param isClear    function for checking field state
 * @return {@code true} if state of the field is cleared
 * @throws NoSuchFieldException   if there is no field with the
 *                                {@code fieldName} in the {@code check}
 * @throws IllegalAccessException if the field is inaccessible
 */
public static boolean isStatefulFieldClearedDuringBeginTree(AbstractCheck check,
                                                            DetailAST astToVisit,
                                                            String fieldName,
                                                            Predicate<Object> isClear)
        throws NoSuchFieldException, IllegalAccessException {
    check.beginTree(astToVisit);
    check.visitToken(astToVisit);
    check.beginTree(null);
    final Field resultField = getClassDeclaredField(check.getClass(), fieldName);
    return isClear.test(resultField.get(check));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:TestUtil.java


示例17: isCheckstyleCheck

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Checks whether a class may be considered as the checkstyle check.
 * Checkstyle's checks are classes which implement 'AbstractCheck' interface.
 * @param loadedClass class to check.
 * @return true if a class may be considered as the checkstyle check.
 */
public static boolean isCheckstyleCheck(Class<?> loadedClass) {
    return AbstractCheck.class.isAssignableFrom(loadedClass);
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:10,代码来源:CheckUtil.java


示例18: isCheckstyleTreeWalkerCheck

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Checks whether a class may be considered as the checkstyle check
 * which has TreeWalker as a parent.
 * Checkstyle's checks are classes which implement 'AbstractCheck' interface.
 * @param clazz class to check.
 * @return true if a class may be considered as the checkstyle check.
 */
public static boolean isCheckstyleTreeWalkerCheck(Class<?> clazz) {
    return AbstractCheck.class.isAssignableFrom(clazz);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:ModuleReflectionUtils.java


示例19: CheckstyleApiFixer

import com.puppycrawl.tools.checkstyle.api.AbstractCheck; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param pCheck the check for which this instance of the API fixer shall run
 */
public CheckstyleApiFixer(@Nonnull final AbstractCheck pCheck)
{
    this(pCheck, null);
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:10,代码来源:CheckstyleApiFixer.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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