本文整理汇总了Java中com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck类的典型用法代码示例。如果您正苦于以下问题:Java RegexpSinglelineCheck类的具体用法?Java RegexpSinglelineCheck怎么用?Java RegexpSinglelineCheck使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegexpSinglelineCheck类属于com.puppycrawl.tools.checkstyle.checks.regexp包,在下文中一共展示了RegexpSinglelineCheck类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSuppressionCommentsInJavaScriptFile
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
@Test
public void testSuppressionCommentsInJavaScriptFile() throws Exception {
final DefaultConfiguration filterCfg =
createModuleConfig(SuppressWithPlainTextCommentFilter.class);
filterCfg.addAttribute("offCommentFormat", "// CS-OFF");
filterCfg.addAttribute("onCommentFormat", "// CS-ON");
final DefaultConfiguration checkCfg = createModuleConfig(RegexpSinglelineCheck.class);
checkCfg.addAttribute("format", ".*===.*");
final String[] suppressed = {
"2: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*===.*"),
};
final String[] violationMessages = {
"2: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*===.*"),
"5: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*===.*"),
};
verifySuppressed(
"InputSuppressWithPlainTextCommentFilter.js",
removeSuppressed(violationMessages, suppressed),
filterCfg, checkCfg
);
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:SuppressWithPlainTextCommentFilterTest.java
示例2: getCheckMessages
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
/**
* Get's the check's messages.
* @param module class to examine.
* @return a set of checkstyle's module message fields.
* @throws ClassNotFoundException if the attempt to read a protected class fails.
*/
public static Set<Field> getCheckMessages(Class<?> module) throws ClassNotFoundException {
final Set<Field> checkstyleMessages = new HashSet<Field>();
// get all fields from current class
final Field[] fields = module.getDeclaredFields();
for (Field field : fields) {
if (field.getName().startsWith("MSG_")) {
checkstyleMessages.add(field);
}
}
// deep scan class through hierarchy
final Class<?> superModule = module.getSuperclass();
if (superModule != null) {
checkstyleMessages.addAll(getCheckMessages(superModule));
}
// special cases that require additional classes
if (module == RegexpMultilineCheck.class) {
checkstyleMessages.addAll(getCheckMessages(Class
.forName("com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector")));
}
else if (module == RegexpSinglelineCheck.class
|| module == RegexpSinglelineJavaCheck.class) {
checkstyleMessages.addAll(getCheckMessages(Class
.forName("com.puppycrawl.tools.checkstyle.checks.regexp.SinglelineDetector")));
}
return checkstyleMessages;
}
示例3: getCheckMessages
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
/**
* Get's the check's messages.
* @param module class to examine.
* @return a set of checkstyle's module message fields.
* @throws ClassNotFoundException if the attempt to read a protected class fails.
*/
public static Set<Field> getCheckMessages(Class<?> module) throws ClassNotFoundException {
final Set<Field> checkstyleMessages = new HashSet<>();
// get all fields from current class
final Field[] fields = module.getDeclaredFields();
for (Field field : fields) {
if (field.getName().startsWith("MSG_")) {
checkstyleMessages.add(field);
}
}
// deep scan class through hierarchy
final Class<?> superModule = module.getSuperclass();
if (superModule != null) {
checkstyleMessages.addAll(getCheckMessages(superModule));
}
// special cases that require additional classes
if (module == RegexpMultilineCheck.class) {
checkstyleMessages.addAll(getCheckMessages(Class
.forName("com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector")));
}
else if (module == RegexpSinglelineCheck.class
|| module == RegexpSinglelineJavaCheck.class) {
checkstyleMessages.addAll(getCheckMessages(Class
.forName("com.puppycrawl.tools.checkstyle.checks.regexp.SinglelineDetector")));
}
return checkstyleMessages;
}
示例4: testSuppressionCommentsInPropertiesFile
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
@Test
public void testSuppressionCommentsInPropertiesFile() throws Exception {
final DefaultConfiguration filterCfg =
createModuleConfig(SuppressWithPlainTextCommentFilter.class);
filterCfg.addAttribute("offCommentFormat", "# CHECKSTYLE:OFF");
filterCfg.addAttribute("onCommentFormat", "# CHECKSTYLE:ON");
final DefaultConfiguration checkCfg = createModuleConfig(RegexpSinglelineCheck.class);
checkCfg.addAttribute("format", "^key[0-9]=$");
final String[] suppressed = {
"2: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
"^key[0-9]=$"),
};
final String[] violationMessages = {
"2: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
"^key[0-9]=$"),
"4: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
"^key[0-9]=$"),
};
verifySuppressed(
"InputSuppressWithPlainTextCommentFilter.properties",
removeSuppressed(violationMessages, suppressed),
filterCfg, checkCfg
);
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:29,代码来源:SuppressWithPlainTextCommentFilterTest.java
示例5: testFilterWithCustomMessageFormat
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
@Test
public void testFilterWithCustomMessageFormat() throws Exception {
final DefaultConfiguration filterCfg =
createModuleConfig(SuppressWithPlainTextCommentFilter.class);
final String messageFormat =
".*" + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB) + ".*";
// [email protected][CheckstyleTestMakeup] need to test dynamic property
filterCfg.addAttribute("messageFormat", messageFormat);
final DefaultConfiguration fileTabCheckCfg =
createModuleConfig(FileTabCharacterCheck.class);
fileTabCheckCfg.addAttribute("eachLine", "true");
final DefaultConfiguration regexpCheckCfg = createModuleConfig(RegexpSinglelineCheck.class);
regexpCheckCfg.addAttribute("id", "ignore");
regexpCheckCfg.addAttribute("format", ".*[a-zA-Z][0-9].*");
final String[] suppressed = {
"8:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB),
};
final String[] violationMessages = {
"6: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"8:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB),
"8: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"10: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"13: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
};
verifySuppressed(
"InputSuppressWithPlainTextCommentFilterCustomMessageFormat.java",
removeSuppressed(violationMessages, suppressed),
filterCfg, fileTabCheckCfg, regexpCheckCfg
);
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:40,代码来源:SuppressWithPlainTextCommentFilterTest.java
示例6: testSuppressByModuleId
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
@Test
public void testSuppressByModuleId() throws Exception {
final DefaultConfiguration filterCfg =
createModuleConfig(SuppressWithPlainTextCommentFilter.class);
filterCfg.addAttribute("offCommentFormat", "CSOFF (\\w+) \\(\\w+\\)");
filterCfg.addAttribute("onCommentFormat", "CSON (\\w+)");
filterCfg.addAttribute("checkFormat", "$1");
final DefaultConfiguration regexpCheckCfg = createModuleConfig(RegexpSinglelineCheck.class);
regexpCheckCfg.addAttribute("id", "ignore");
regexpCheckCfg.addAttribute("format", ".*[a-zA-Z][0-9].*");
final DefaultConfiguration fileTabCheckCfg =
createModuleConfig(FileTabCharacterCheck.class);
fileTabCheckCfg.addAttribute("eachLine", "true");
fileTabCheckCfg.addAttribute("id", "foo");
final String[] suppressedViolationMessages = {
"6: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"9: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"11: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
};
final String[] expectedViolationMessages = {
"6: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"9:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB),
"9: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"11: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"14: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
};
verifySuppressed(
"InputSuppressWithPlainTextCommentFilterSuppressById.java",
removeSuppressed(expectedViolationMessages, suppressedViolationMessages),
filterCfg, regexpCheckCfg, fileTabCheckCfg
);
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:45,代码来源:SuppressWithPlainTextCommentFilterTest.java
示例7: testSuppressByModuleIdWithNullModuleId
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; //导入依赖的package包/类
@Test
public void testSuppressByModuleIdWithNullModuleId() throws Exception {
final DefaultConfiguration filterCfg =
createModuleConfig(SuppressWithPlainTextCommentFilter.class);
filterCfg.addAttribute("offCommentFormat", "CSOFF (\\w+) \\(\\w+\\)");
filterCfg.addAttribute("onCommentFormat", "CSON (\\w+)");
filterCfg.addAttribute("checkFormat", "$1");
final DefaultConfiguration regexpCheckCfg = createModuleConfig(RegexpSinglelineCheck.class);
regexpCheckCfg.addAttribute("id", "ignore");
regexpCheckCfg.addAttribute("format", ".*[a-zA-Z][0-9].*");
final DefaultConfiguration fileTabCheckCfg =
createModuleConfig(FileTabCharacterCheck.class);
fileTabCheckCfg.addAttribute("eachLine", "true");
fileTabCheckCfg.addAttribute("id", null);
final String[] suppressedViolationMessages = {
"6: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"9: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"11: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
};
final String[] expectedViolationMessages = {
"6: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"9:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB),
"9: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"11: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
"14: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED,
".*[a-zA-Z][0-9].*"),
};
verifySuppressed(
"InputSuppressWithPlainTextCommentFilterSuppressById.java",
removeSuppressed(expectedViolationMessages, suppressedViolationMessages),
filterCfg, regexpCheckCfg, fileTabCheckCfg
);
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:45,代码来源:SuppressWithPlainTextCommentFilterTest.java