本文整理汇总了Java中lombok.core.AST.Kind.FIELD属性的典型用法代码示例。如果您正苦于以下问题:Java Kind.FIELD属性的具体用法?Java Kind.FIELD怎么用?Java Kind.FIELD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类lombok.core.AST.Kind
的用法示例。
在下文中一共展示了Kind.FIELD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createListOfNonExistentFields
/**
* Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type.
*/
public static List<Integer> createListOfNonExistentFields(List<String> list, EclipseNode type, boolean excludeStandard, boolean excludeTransient) {
boolean[] matched = new boolean[list.size()];
for (EclipseNode child : type.down()) {
if (list.isEmpty()) break;
if (child.getKind() != Kind.FIELD) continue;
if (excludeStandard) {
if ((((FieldDeclaration)child.get()).modifiers & ClassFileConstants.AccStatic) != 0) continue;
if (child.getName().startsWith("$")) continue;
}
if (excludeTransient && (((FieldDeclaration)child.get()).modifiers & ClassFileConstants.AccTransient) != 0) continue;
int idx = list.indexOf(child.getName());
if (idx > -1) matched[idx] = true;
}
List<Integer> problematic = new ArrayList<Integer>();
for (int i = 0 ; i < list.size() ; i++) {
if (!matched[i]) problematic.add(i);
}
return problematic;
}
示例2: createListOfNonExistentFields
/**
* Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type.
*/
public static List<Integer> createListOfNonExistentFields(List<String> list, JavacNode type, boolean excludeStandard, boolean excludeTransient) {
boolean[] matched = new boolean[list.size()];
for (JavacNode child : type.down()) {
if (list.isEmpty()) break;
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl field = (JCVariableDecl)child.get();
if (excludeStandard) {
if ((field.mods.flags & Flags.STATIC) != 0) continue;
if (field.name.toString().startsWith("$")) continue;
}
if (excludeTransient && (field.mods.flags & Flags.TRANSIENT) != 0) continue;
int idx = list.indexOf(child.getName());
if (idx > -1) matched[idx] = true;
}
ListBuffer<Integer> problematic = new ListBuffer<Integer>();
for (int i = 0 ; i < list.size() ; i++) {
if (!matched[i]) problematic.append(i);
}
return problematic.toList();
}
示例3: createJavadocComment
private static Comment createJavadocComment(final String text, final JavacNode field) {
return new Comment() {
@Override public String getText() {
return text;
}
@Override public int getSourcePos(int index) {
return -1;
}
@Override public CommentStyle getStyle() {
return CommentStyle.JAVADOC;
}
@Override public boolean isDeprecated() {
return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field);
}
};
}
示例4: upFromAnnotationToFields
/**
* {@code @Foo int x, y;} is stored in both javac and ecj as 2 FieldDeclarations, both with the same annotation as child.
* The normal {@code up()} method can't handle having multiple parents, but this one can.
*/
public Collection<L> upFromAnnotationToFields() {
if (getKind() != Kind.ANNOTATION) return Collections.emptyList();
L field = up();
if (field == null || field.getKind() != Kind.FIELD) return Collections.emptyList();
L type = field.up();
if (type == null || type.getKind() != Kind.TYPE) return Collections.emptyList();
List<L> fields = new ArrayList<L>();
for (L potentialField : type.down()) {
if (potentialField.getKind() != Kind.FIELD) continue;
if (fieldContainsAnnotation(potentialField.get(), get())) fields.add(potentialField);
}
return fields;
}
示例5: findRequiredFields
public static List<JavacNode> findRequiredFields(JavacNode typeNode) {
ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>();
for (JavacNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) continue;
long fieldFlags = fieldDecl.mods.flags;
//Skip static fields.
if ((fieldFlags & Flags.STATIC) != 0) continue;
boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
boolean isNonNull = !findAnnotations(child, NON_NULL_PATTERN).isEmpty();
if ((isFinal || isNonNull) && fieldDecl.init == null) fields.append(child);
}
return fields.toList();
}
示例6: handle
private static void handle(AnnotationValues<?> annotation, JCAnnotation ast, JavacNode annotationNode) {
if (inNetbeansEditor(annotationNode)) return;
Object anno = annotation.getInstance();
JavacNode fieldNode = annotationNode.up();
if (fieldNode == null || fieldNode.getKind() != Kind.FIELD || !(fieldNode.get() instanceof JCVariableDecl)) {
annotationNode.addError("@OneToOne is legal only on fields.");
return;
}
JCVariableDecl field = (JCVariableDecl)fieldNode.get();
if ((field.mods.flags & Flags.STATIC) != 0) {
annotationNode.addError("@OneToOne is not legal on static fields.");
return;
}
if (fieldExists(toUpperCase(field.name.toString()), fieldNode) == MemberExistsResult.NOT_EXISTS) {
JCVariableDecl fieldDecl = createField(anno, fieldNode);
injectFieldSuppressWarnings(fieldNode.up(), fieldDecl);
}
}
示例7: handle
private static void handle(AnnotationValues<?> annotation, Annotation ast, EclipseNode annotationNode) {
Object anno = annotation.getInstance();
EclipseNode fieldNode = annotationNode.up();
EclipseNode typeNode = fieldNode.up();
if (fieldNode.getKind() != Kind.FIELD) {
annotationNode.addError("@" + anno.getClass().getSimpleName() + " is only supported on a field.");
return;
}
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
if (field.isStatic()) {
annotationNode.addError("@" + anno.getClass().getSimpleName() + " is not legal on static fields.");
return;
}
if (fieldExists(toProperCase(new String(field.name)), fieldNode) == MemberExistsResult.NOT_EXISTS) {
FieldDeclaration fieldDecl = createField(anno, fieldNode, ast);
injectFieldSuppressWarnings(typeNode, fieldDecl);
typeNode.rebuild();
}
}
示例8: findRequiredFields
private static List<JavacNode> findRequiredFields(JavacNode typeNode) {
ListBuffer<JavacNode> fields = ListBuffer.lb();
for (JavacNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) continue;
long fieldFlags = fieldDecl.mods.flags;
//Skip static fields.
if ((fieldFlags & Flags.STATIC) != 0) continue;
boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
boolean isNonNull = !findAnnotations(child, TransformationsUtil.NON_NULL_PATTERN).isEmpty();
if ((isFinal || isNonNull) && fieldDecl.init == null) fields.append(child);
}
return fields.toList();
}
示例9: findAllFields
private static List<JavacNode> findAllFields(JavacNode typeNode) {
ListBuffer<JavacNode> fields = ListBuffer.lb();
for (JavacNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) continue;
long fieldFlags = fieldDecl.mods.flags;
//Skip static fields.
if ((fieldFlags & Flags.STATIC) != 0) continue;
//Skip initialized final fields
boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
if (!isFinal || fieldDecl.init == null) fields.append(child);
}
return fields.toList();
}
示例10: createListOfNonExistentFields
/**
* Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type.
*/
public static List<Integer> createListOfNonExistentFields(List<String> list, JavacNode type, boolean excludeStandard, boolean excludeTransient) {
boolean[] matched = new boolean[list.size()];
for (JavacNode child : type.down()) {
if (list.isEmpty()) break;
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl field = (JCVariableDecl)child.get();
if (excludeStandard) {
if ((field.mods.flags & Flags.STATIC) != 0) continue;
if (field.name.toString().startsWith("$")) continue;
}
if (excludeTransient && (field.mods.flags & Flags.TRANSIENT) != 0) continue;
int idx = list.indexOf(child.getName());
if (idx > -1) matched[idx] = true;
}
ListBuffer<Integer> problematic = ListBuffer.lb();
for (int i = 0 ; i < list.size() ; i++) {
if (!matched[i]) problematic.append(i);
}
return problematic.toList();
}
示例11: findFields
private static List<EclipseNode> findFields(EclipseNode typeNode, boolean nullMarked) {
List<EclipseNode> fields = new ArrayList<EclipseNode>();
for (EclipseNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
FieldDeclaration fieldDecl = (FieldDeclaration) child.get();
if (!filterField(fieldDecl)) continue;
boolean isFinal = (fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0;
boolean isNonNull = nullMarked && findAnnotations(fieldDecl, NON_NULL_PATTERN).length != 0;
if ((isFinal || isNonNull) && fieldDecl.initialization == null) fields.add(child);
}
return fields;
}
示例12: findAllFields
static List<EclipseNode> findAllFields(EclipseNode typeNode) {
List<EclipseNode> fields = new ArrayList<EclipseNode>();
for (EclipseNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
FieldDeclaration fieldDecl = (FieldDeclaration) child.get();
if (!filterField(fieldDecl)) continue;
// Skip initialized final fields.
if (((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) && fieldDecl.initialization != null) continue;
fields.add(child);
}
return fields;
}
示例13: generateBuilderFields
public void generateBuilderFields(EclipseNode builderType, List<BuilderFieldData> builderFields, ASTNode source) {
List<EclipseNode> existing = new ArrayList<EclipseNode>();
for (EclipseNode child : builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
top:
for (BuilderFieldData bfd : builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType));
} else {
for (EclipseNode exists : existing) {
char[] n = ((FieldDeclaration) exists.get()).name;
if (Arrays.equals(n, bfd.name)) {
bfd.createdFields.add(exists);
continue top;
}
}
FieldDeclaration fd = new FieldDeclaration(bfd.name, 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
bfd.createdFields.add(injectFieldAndMarkGenerated(builderType, fd));
}
}
}
示例14: generateBuilderFields
public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
int len = builderFields.size();
java.util.List<JavacNode> existing = new ArrayList<JavacNode>();
for (JavacNode child : builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
top:
for (int i = len - 1; i >= 0; i--) {
BuilderFieldData bfd = builderFields.get(i);
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source));
} else {
for (JavacNode exists : existing) {
Name n = ((JCVariableDecl) exists.get()).name;
if (n.equals(bfd.name)) {
bfd.createdFields.add(exists);
continue top;
}
}
JavacTreeMaker maker = builderType.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
JCVariableDecl newField = maker.VarDef(mods, bfd.name, cloneType(maker, bfd.type, source, builderType.getContext()), null);
bfd.createdFields.add(injectFieldAndMarkGenerated(builderType, newField));
}
}
}
示例15: fieldQualifiesForGetterGeneration
public boolean fieldQualifiesForGetterGeneration(JavacNode field) {
if (field.getKind() != Kind.FIELD) return false;
JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) return false;
//Skip static fields.
if ((fieldDecl.mods.flags & Flags.STATIC) != 0) return false;
return true;
}