本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.FullIdent类的典型用法代码示例。如果您正苦于以下问题:Java FullIdent类的具体用法?Java FullIdent怎么用?Java FullIdent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FullIdent类属于com.puppycrawl.tools.checkstyle.api包,在下文中一共展示了FullIdent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
defined = true;
if (matchDirectoryStructure) {
final DetailAST packageNameAst = ast.getLastChild().getPreviousSibling();
final FullIdent fullIdent = FullIdent.createFullIdent(packageNameAst);
final String packageName = fullIdent.getText().replace('.', File.separatorChar);
final String directoryName = getDirectoryName();
if (!directoryName.endsWith(packageName)) {
log(fullIdent.getLineNo(), MSG_KEY_MISMATCH, packageName);
}
}
}
示例2: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST detailAST) {
final DetailAST parameterDef =
detailAST.findFirstToken(TokenTypes.PARAMETER_DEF);
final DetailAST excTypeParent =
parameterDef.findFirstToken(TokenTypes.TYPE);
final List<DetailAST> excTypes = getAllExceptionTypes(excTypeParent);
for (DetailAST excType : excTypes) {
final FullIdent ident = FullIdent.createFullIdent(excType);
if (illegalClassNames.contains(ident.getText())) {
log(detailAST, MSG_KEY, ident.getText());
}
}
}
示例3: postProcessLiteralNew
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Processes one of the collected "new" tokens when walking tree
* has finished.
* @param newTokenAst the "new" token.
*/
private void postProcessLiteralNew(DetailAST newTokenAst) {
final DetailAST typeNameAst = newTokenAst.getFirstChild();
final AST nameSibling = typeNameAst.getNextSibling();
if (nameSibling.getType() != TokenTypes.ARRAY_DECLARATOR) {
// ast != "new Boolean[]"
final FullIdent typeIdent = FullIdent.createFullIdent(typeNameAst);
final String typeName = typeIdent.getText();
final String fqClassName = getIllegalInstantiation(typeName);
if (fqClassName != null) {
final int lineNo = newTokenAst.getLineNo();
final int colNo = newTokenAst.getColumnNo();
log(lineNo, colNo, MSG_KEY, fqClassName);
}
}
}
示例4: checkImportStatements
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Check import statements.
* @param className name of the class
* @return value of illegal instantiated type
*/
private String checkImportStatements(String className) {
String illegalType = null;
// import statements
for (FullIdent importLineText : imports) {
String importArg = importLineText.getText();
if (importArg.endsWith(".*")) {
importArg = importArg.substring(0, importArg.length() - 1)
+ className;
}
if (CommonUtils.baseClassName(importArg).equals(className)
&& illegalClasses.contains(importArg)) {
illegalType = importArg;
break;
}
}
return illegalType;
}
示例5: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST detailAST) {
final DetailAST methodDef = detailAST.getParent();
// Check if the method with the given name should be ignored.
if (!isIgnorableMethod(methodDef)) {
DetailAST token = detailAST.getFirstChild();
while (token != null) {
if (token.getType() != TokenTypes.COMMA) {
final FullIdent ident = FullIdent.createFullIdent(token);
if (illegalClassNames.contains(ident.getText())) {
log(token, MSG_KEY, ident.getText());
}
}
token = token.getNextSibling();
}
}
}
示例6: getThrows
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Computes the exception nodes for a method.
*
* @param ast the method node.
* @return the list of exception nodes for ast.
*/
private List<ExceptionInfo> getThrows(DetailAST ast) {
final List<ExceptionInfo> returnValue = new ArrayList<ExceptionInfo>();
final DetailAST throwsAST = ast
.findFirstToken(TokenTypes.LITERAL_THROWS);
if (throwsAST != null) {
DetailAST child = throwsAST.getFirstChild();
while (child != null) {
if (child.getType() == TokenTypes.IDENT
|| child.getType() == TokenTypes.DOT) {
final FullIdent ident = FullIdent.createFullIdent(child);
final ExceptionInfo exceptionInfo = new ExceptionInfo(
createClassInfo(new Token(ident), getCurrentClassName()));
returnValue.add(exceptionInfo);
}
child = child.getNextSibling();
}
}
return returnValue;
}
示例7: doVisitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Shares processing...
*
* @param ident the import to process.
* @param isStatic whether the token is static or not.
* @param previous previous non-static but current is static (above), or
* previous static but current is non-static (under).
*/
private void doVisitToken(FullIdent ident, boolean isStatic,
boolean previous) {
final String name = ident.getText();
final int groupIdx = getGroupNumber(name);
final int line = ident.getLineNo();
if (groupIdx > lastGroup) {
if (!beforeFirstImport && separated && line - lastImportLine < 2
&& !isInSameGroup(groupIdx, isStatic)) {
log(line, MSG_SEPARATION, name);
}
}
else if (isInSameGroup(groupIdx, isStatic)) {
doVisitTokenInSameGroup(isStatic, previous, name, line);
}
else {
log(line, MSG_ORDERING, name);
}
if (isSeparatorInGroup(groupIdx, isStatic, line)) {
log(line, MSG_SEPARATED_IN_GROUP, name);
}
lastGroup = groupIdx;
lastImport = name;
}
示例8: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
final FullIdent imp;
if (ast.getType() == TokenTypes.IMPORT) {
imp = FullIdent.createFullIdentBelow(ast);
}
else {
imp = FullIdent.createFullIdent(
ast.getFirstChild().getNextSibling());
}
if (isIllegalImport(imp.getText())) {
log(ast.getLineNo(),
ast.getColumnNo(),
MSG_KEY,
imp.getText());
}
}
示例9: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST aAST) {
final FullIdent imp;
if ( aAST.getType() == TokenTypes.IMPORT ) {
imp = FullIdent.createFullIdentBelow( aAST );
}
else {
// handle case of static imports of method names
imp = FullIdent.createFullIdent( aAST.getFirstChild().getNextSibling() );
}
final String text = imp.getText();
if ( isIllegalImport( text ) ) {
final String message = buildError( text );
log( aAST.getLineNo(), aAST.getColumnNo(), message, text );
}
}
示例10: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
defined = true;
if (matchDirectoryStructure) {
final DetailAST packageNameAst = ast.getLastChild().getPreviousSibling();
final FullIdent fullIdent = FullIdent.createFullIdent(packageNameAst);
final String packageName = fullIdent.getText().replace('.', File.separatorChar);
final String directoryName = getDirectoryName();
if (!directoryName.endsWith(packageName)) {
log(fullIdent.getLineNo(), MSG_KEY_MISMATCH, packageName);
}
}
}
示例11: checkImportStatements
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Check import statements.
* @param className name of the class
* @return value of illegal instantiated type
*/
private String checkImportStatements(String className) {
String illegalType = null;
// import statements
for (FullIdent importLineText : imports) {
String importArg = importLineText.getText();
if (importArg.endsWith(".*")) {
importArg = importArg.substring(0, importArg.length() - 1)
+ className;
}
if (CommonUtils.baseClassName(importArg).equals(className)
&& classes.contains(importArg)) {
illegalType = importArg;
break;
}
}
return illegalType;
}
示例12: getThrows
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
/**
* Computes the exception nodes for a method.
*
* @param ast the method node.
* @return the list of exception nodes for ast.
*/
private List<ExceptionInfo> getThrows(DetailAST ast) {
final List<ExceptionInfo> returnValue = new ArrayList<>();
final DetailAST throwsAST = ast
.findFirstToken(TokenTypes.LITERAL_THROWS);
if (throwsAST != null) {
DetailAST child = throwsAST.getFirstChild();
while (child != null) {
if (child.getType() == TokenTypes.IDENT
|| child.getType() == TokenTypes.DOT) {
final FullIdent ident = FullIdent.createFullIdent(child);
final ExceptionInfo exceptionInfo = new ExceptionInfo(
createClassInfo(new Token(ident), getCurrentClassName()));
returnValue.add(exceptionInfo);
}
child = child.getNextSibling();
}
}
return returnValue;
}
示例13: addImportFromFullQualifiedType
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
private void addImportFromFullQualifiedType(DetailAST ast) {
if (isClassType(ast)) {
String typeName = FullIdent.createFullIdent(ast.getLastChild()).getText();
if (typeName.indexOf(".") == -1) {
if (!this.currentClass.hasImport(typeName)) {
String currentImport = this.currentClass.getPackageName() + "." + typeName;
this.currentClass.addImport(currentImport, ast);
logger.fine("import: " + currentImport);
}
} else {
this.currentClass.addImport(typeName, ast);
logger.fine("import: " + typeName);
}
}
}
示例14: addImport
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
private void addImport(DetailAST ast) {
DetailAST nameAST;
FullIdent full;
nameAST = ast.getLastChild().getPreviousSibling();
full = FullIdent.createFullIdent(nameAST);
String currentImport = full.getText();
this.currentClass.addImport(currentImport, ast);
logger.fine("import: " + currentImport);
}
示例15: addPackagename
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入依赖的package包/类
private void addPackagename(DetailAST ast) {
DetailAST nameAST;
FullIdent full;
nameAST = ast.getLastChild().getPreviousSibling();
full = FullIdent.createFullIdent(nameAST);
String packageName = full.getText();
this.currentClass.setPackageName(packageName);
logger.fine("package name: " + packageName);
}