本文整理汇总了Java中lombok.ast.Identifier类的典型用法代码示例。如果您正苦于以下问题:Java Identifier类的具体用法?Java Identifier怎么用?Java Identifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Identifier类属于lombok.ast包,在下文中一共展示了Identifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: detectR2
import lombok.ast.Identifier; //导入依赖的package包/类
private static boolean detectR2(JavaContext context, Node node, Identifier identifier) {
boolean isR2 = node.getParent() != null
&& (identifier.toString().equals(R2) || identifier.toString().contains(".R2."))
&& node.getParent() instanceof Select
&& SUPPORTED_TYPES.contains(((Select) node.getParent()).astIdentifier().toString());
if (isR2 && !context.isSuppressedWithComment(node, ISSUE)) {
context.report(ISSUE, node, context.getLocation(identifier), LINT_ERROR_BODY);
}
return isR2;
}
示例3: visitIdentifier
import lombok.ast.Identifier; //导入依赖的package包/类
@Override
public boolean visitIdentifier(Identifier node) {
List<VisitingDetector> list = mNodeTypeDetectors.get(Identifier.class);
if (list != null) {
for (VisitingDetector v : list) {
v.getVisitor().visitIdentifier(node);
}
}
return false;
}
示例4: getNode
import lombok.ast.Identifier; //导入依赖的package包/类
@NonNull
public TypeReference getNode() {
TypeReference typeReference = new TypeReference();
StrictListAccessor<TypeReferencePart, TypeReference> parts = typeReference.astParts();
for (String part : Splitter.on('.').split(getName())) {
Identifier identifier = Identifier.of(part);
parts.addToEnd(new TypeReferencePart().astIdentifier(identifier));
}
return typeReference;
}
示例5: createPrimary
import lombok.ast.Identifier; //导入依赖的package包/类
public Node createPrimary(Node identifier, Node methodArguments) {
Identifier id = createIdentifierIfNeeded(identifier, currentPos());
if (methodArguments instanceof TemporaryNode.MethodArguments) {
MethodInvocation invoke = new MethodInvocation().astName(id);
for (Node arg : ((TemporaryNode.MethodArguments)methodArguments).arguments) {
invoke.rawArguments().addToEnd(arg);
}
return posify(invoke);
} else {
VariableReference ref = new VariableReference().astIdentifier(id);
DanglingNodes.addDanglingNode(ref, methodArguments);
return posify(ref);
}
}
示例6: createIdentifierIfNeeded
import lombok.ast.Identifier; //导入依赖的package包/类
Identifier createIdentifierIfNeeded(Node identifier, int pos) {
if (identifier instanceof Identifier) return (Identifier)identifier;
Identifier i = new Identifier();
i.setPosition(new Position(pos, pos));
DanglingNodes.addDanglingNode(i, identifier);
return i;
}
示例7: 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;
}
示例8: fillIdentifiers
import lombok.ast.Identifier; //导入依赖的package包/类
private void fillIdentifiers(char[][] tokens, long[] positions, StrictListAccessor<Identifier, ?> list) {
if (tokens == null) return;
if (positions.length != tokens.length) throw new IllegalStateException("bug");
for (int i = 0; i < positions.length; i++) {
list.addToEnd(toIdentifier(tokens[i], positions[i]));
}
}
示例9: plainTypeReference
import lombok.ast.Identifier; //导入依赖的package包/类
private JCExpression plainTypeReference(TypeReference node) {
if (node.isPrimitive() || node.isVoid() || node.astParts().size() == 1) {
int end = node.getPosition().getEnd();
if (node.astArrayDimensions() > 0) {
end = node.astParts().last().getPosition().getEnd();
}
if (end == node.getPosition().getStart()) end = node.getPosition().getEnd();
Identifier identifier = node.astParts().first().astIdentifier();
int typeTag = primitiveTypeTag(identifier.astValue());
if (typeTag > 0) return setPos(node.getPosition().getStart(), end, treeMaker.TypeIdent(typeTag));
}
JCExpression current = null;
for (TypeReferencePart part : node.astParts()) {
JCExpression expr = (JCExpression) toTree(part);
if (current == null) {
current = expr;
continue;
}
if (expr instanceof JCIdent) {
current = treeMaker.Select(current, ((JCIdent)expr).name);
setPos(posOfStructure(part, ".", true), part.getPosition().getEnd(), current);
} else if (expr instanceof JCTypeApply) {
JCTypeApply apply = (JCTypeApply)expr;
apply.clazz = treeMaker.Select(current, ((JCIdent)apply.clazz).name);
setPos(posOfStructure(part, ".", true), part.astIdentifier().getPosition().getEnd(), apply.clazz);
current = apply;
} else {
throw new IllegalStateException("Didn't expect a " + expr.getClass().getName() + " in " + node);
}
}
//TODO add a lot more tests involving 'void', apparently we're missing a bunch.
return current;
}
示例10: chain
import lombok.ast.Identifier; //导入依赖的package包/类
private JCExpression chain(Iterable<Identifier> parts) {
JCExpression previous = null;
for (Identifier part : parts) {
Name next = toName(part);
if (previous == null) {
previous = setPos(part, treeMaker.Ident(next));
} else {
previous = setPos(posOfStructure(part, ".", true), part.getPosition().getEnd(), treeMaker.Select(previous, next));
}
}
return previous;
}
示例11: fillWithIdentifiers
import lombok.ast.Identifier; //导入依赖的package包/类
private void fillWithIdentifiers(JCTree node, StrictListAccessor<Identifier, ?> list) {
if (node instanceof JCIdent) {
JCIdent id = (JCIdent) node;
list.addToEnd(setPos(node, new Identifier().astValue(id.name.toString())));
} else if (node instanceof JCFieldAccess) {
JCFieldAccess sel = (JCFieldAccess) node;
fillWithIdentifiers(sel.selected, list);
list.addToEnd(setPos(node, new Identifier().astValue(sel.name.toString())));
}
}
示例12: visitImport
import lombok.ast.Identifier; //导入依赖的package包/类
@Override public void visitImport(JCImport node) {
ImportDeclaration imp = new ImportDeclaration();
fillWithIdentifiers(node.getQualifiedIdentifier(), imp.astParts());
Identifier last = imp.astParts().last();
if (last != null && "*".equals(last.astValue())) {
imp.astParts().remove(last);
imp.astStarImport(true);
setConversionPositionInfo(imp, ".*", last.getPosition());
}
imp.astStaticImport(node.isStatic());
set(node, imp);
}
示例13: visitIdent
import lombok.ast.Identifier; //导入依赖的package包/类
@Override public void visitIdent(JCIdent node) {
String name = node.getName().toString();
if ("this".equals(name)) {
This t = new This();
set(node, t);
setConversionPositionInfo(t, "this", getPosition(node));
return;
}
if ("super".equals(name)) {
Super s = new Super();
set(node, s);
setConversionPositionInfo(s, "super", getPosition(node));
return;
}
Identifier id = setPos(node, new Identifier().astValue(name));
if (hasFlag(FlagKey.TYPE_REFERENCE)) {
TypeReferencePart part = setPos(node, new TypeReferencePart().astIdentifier(id));
set(node, new TypeReference().astParts().addToEnd(part));
return;
}
set(node, new VariableReference().astIdentifier(id));
}
示例14: visitSelect
import lombok.ast.Identifier; //导入依赖的package包/类
@Override public void visitSelect(JCFieldAccess node) {
String name = node.getIdentifier().toString();
Identifier id = setPos(node, new Identifier().astValue(name));
Node selected = toTree(node.selected, params);
if (hasFlag(FlagKey.TYPE_REFERENCE)) {
TypeReference parent = (TypeReference) selected;
parent.astParts().addToEnd(setPos(node, new TypeReferencePart().astIdentifier(id)));
set(node, parent);
return;
}
if ("this".equals(name)) {
This t = new This();
setConversionPositionInfo(t, "this", getPosition(node));
set(node, t.rawQualifier(toTree(node.getExpression(), FlagKey.TYPE_REFERENCE)));
return;
}
if ("super".equals(name)) {
Super s = new Super();
setConversionPositionInfo(s, "super", getPosition(node));
set(node, s.rawQualifier(toTree(node.getExpression(), FlagKey.TYPE_REFERENCE)));
return;
}
if ("class".equals(name)) {
ClassLiteral c = new ClassLiteral();
setConversionPositionInfo(c, "class", getPosition(node));
set(node, c.rawTypeReference(toTree(node.getExpression(), FlagKey.TYPE_REFERENCE)));
return;
}
set(node, new Select().astIdentifier(id).rawOperand(toTree(node.getExpression())));
}
示例15: visitContinue
import lombok.ast.Identifier; //导入依赖的package包/类
@Override public void visitContinue(JCContinue node) {
Continue c = new Continue();
if (node.getLabel() != null) {
c.astLabel(new Identifier().astValue(node.getLabel().toString()));
}
set(node, c);
}