本文整理汇总了Java中lombok.ast.Identifier.astValue方法的典型用法代码示例。如果您正苦于以下问题:Java Identifier.astValue方法的具体用法?Java Identifier.astValue怎么用?Java Identifier.astValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lombok.ast.Identifier
的用法示例。
在下文中一共展示了Identifier.astValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNameOfIdentifier
import lombok.ast.Identifier; //导入方法依赖的package包/类
public void checkNameOfIdentifier(Identifier identifier) {
String n = identifier.astValue();
if (n.length() == 0) {
identifier.addMessage(error(IDENTIFIER_EMPTY, "Empty Identifier"));
return;
}
if (!Character.isJavaIdentifierStart(n.charAt(0))) {
identifier.addMessage(error(IDENTIFIER_INVALID, "Not a legal start character for a java identifier: " + n.charAt(0)));
return;
}
for (int i = 1; i < n.length(); i++) {
if (!Character.isJavaIdentifierPart(n.charAt(i))) {
identifier.addMessage(error(IDENTIFIER_INVALID, "Not a legal character in a java identifier: " + n.charAt(i)));
return;
}
}
}
示例2: createIdentifier
import lombok.ast.Identifier; //导入方法依赖的package包/类
public Node createIdentifier(String text, org.parboiled.Node<Node> rawIdentifier) {
Identifier id = new Identifier();
if (text != null) id.astValue(text);
int start = rawIdentifier.getStartIndex();
int end = Math.max(start, rawIdentifier.getEndIndex());
id.setPosition(new Position(start, end));
return id;
}
示例3: visitIdentifier
import lombok.ast.Identifier; //导入方法依赖的package包/类
@Override
public boolean visitIdentifier(Identifier node) {
String name = node.astValue();
if (name == null) name = FAIL + "NULL_IDENTIFIER" + FAIL;
else if (name.isEmpty()) name = FAIL + "EMPTY_IDENTIFIER" + FAIL;
else if (!isValidJavaIdentifier(name)) name = FAIL + "INVALID_IDENTIFIER: " + name + FAIL;
formatter.buildInline(node);
formatter.property("name", name);
formatter.append(name);
formatter.closeInline();
return true;
}
示例4: visitIdentifier
import lombok.ast.Identifier; //导入方法依赖的package包/类
@Override
public boolean visitIdentifier(Identifier node) {
String identifier = node.astValue();
boolean isLeft = LEFT_FIELD.equals(identifier);
boolean isRight = RIGHT_FIELD.equals(identifier);
if (!isLeft && !isRight) {
return false;
}
Node parent = node.getParent();
if (parent instanceof ImportDeclaration || parent instanceof EnumConstant
|| parent instanceof VariableDefinitionEntry) {
return false;
}
JavaParser.ResolvedNode resolved = mContext.resolve(node);
if (resolved != null) {
if (!(resolved instanceof JavaParser.ResolvedField)) {
return false;
} else {
JavaParser.ResolvedField field = (JavaParser.ResolvedField) resolved;
if (!field.getContainingClass().matches(FQCN_GRAVITY)) {
return false;
}
}
} else {
// Can't resolve types (for example while editing code with errors):
// rely on heuristics like import statements and class qualifiers
if (parent instanceof Select &&
!(GRAVITY_CLASS.equals(((Select) parent).astOperand().toString()))) {
return false;
}
if (parent instanceof VariableReference) {
// No operand: make sure it's statically imported
if (!LintUtils.isImported(mContext.getCompilationUnit(),
FQCN_GRAVITY_PREFIX + identifier)) {
return false;
}
}
}
String message = String.format(
"Use \"`Gravity.%1$s`\" instead of \"`Gravity.%2$s`\" to ensure correct "
+ "behavior in right-to-left locales",
(isLeft ? GRAVITY_VALUE_START : GRAVITY_VALUE_END).toUpperCase(Locale.US),
(isLeft ? GRAVITY_VALUE_LEFT : GRAVITY_VALUE_RIGHT).toUpperCase(Locale.US));
Location location = mContext.getLocation(node);
mContext.report(USE_START, node, location, message);
return true;
}
示例5: namesMatch
import lombok.ast.Identifier; //导入方法依赖的package包/类
private boolean namesMatch(String name, Identifier astName) {
return name == null ? astName.astValue() == null : name.equals(astName.astValue());
}