本文整理汇总了Java中lombok.core.AST.Kind.TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java Kind.TYPE属性的具体用法?Java Kind.TYPE怎么用?Java Kind.TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类lombok.core.AST.Kind
的用法示例。
在下文中一共展示了Kind.TYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTypeReference
public TypeReference createTypeReference(EclipseNode type, long p) {
List<String> list = new ArrayList<String>();
list.add(type.getName());
EclipseNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
if (list.size() == 1) return new SingleTypeReference(list.get(0).toCharArray(), p);
long[] ps = new long[list.size()];
char[][] tokens = new char[list.size()][];
for (int i = 0; i < list.size(); i++) {
ps[i] = p;
tokens[i] = list.get(i).toCharArray();
}
return new QualifiedTypeReference(tokens, ps);
}
示例2: cloneSelfType
public static JCExpression cloneSelfType(JavacNode childOfType) {
JavacNode typeNode = childOfType;
JavacTreeMaker maker = childOfType.getTreeMaker();
while (typeNode != null && typeNode.getKind() != Kind.TYPE) typeNode = typeNode.up();
if (typeNode != null && typeNode.get() instanceof JCClassDecl) {
JCClassDecl type = (JCClassDecl) typeNode.get();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
if (!type.typarams.isEmpty()) {
for (JCTypeParameter tp : type.typarams) {
typeArgs.append(maker.Ident(tp.name));
}
return maker.TypeApply(maker.Ident(type.name), typeArgs.toList());
} else {
return maker.Ident(type.name);
}
} else {
return null;
}
}
示例3: createTypeReference
public JCExpression createTypeReference(JavacNode type) {
java.util.List<String> list = new ArrayList<String>();
list.add(type.getName());
JavacNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
JavacTreeMaker maker = type.getTreeMaker();
JCExpression chain = maker.Ident(type.toName(list.get(0)));
for (int i = 1; i < list.size(); i++) {
chain = maker.Select(chain, type.toName(list.get(i)));
}
return chain;
}
示例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: createTypeReference
private TypeReference createTypeReference(EclipseNode type, long p) {
List<String> list = new ArrayList<String>();
list.add(type.getName());
EclipseNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
if (list.size() == 1) return new SingleTypeReference(list.get(0).toCharArray(), p);
long[] ps = new long[list.size()];
char[][] tokens = new char[list.size()][];
for (int i = 0; i < list.size(); i++) {
ps[i] = p;
tokens[i] = list.get(i).toCharArray();
}
return new QualifiedTypeReference(tokens, ps);
}
示例6: cloneSelfType
public static JCExpression cloneSelfType(JavacNode field) {
JavacNode typeNode = field;
TreeMaker maker = field.getTreeMaker();
while (typeNode != null && typeNode.getKind() != Kind.TYPE) typeNode = typeNode.up();
if (typeNode != null && typeNode.get() instanceof JCClassDecl) {
JCClassDecl type = (JCClassDecl) typeNode.get();
ListBuffer<JCExpression> typeArgs = ListBuffer.lb();
if (!type.typarams.isEmpty()) {
for (JCTypeParameter tp : type.typarams) {
typeArgs.append(maker.Ident(tp.name));
}
return maker.TypeApply(maker.Ident(type.name), typeArgs.toList());
} else {
return maker.Ident(type.name);
}
} else {
return null;
}
}
示例7: createTypeReference
private JCExpression createTypeReference(JavacNode type) {
java.util.List<String> list = new ArrayList<String>();
list.add(type.getName());
JavacNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
TreeMaker maker = type.getTreeMaker();
JCExpression chain = maker.Ident(type.toName(list.get(0)));
for (int i = 1; i < list.size(); i++) {
chain = maker.Select(chain, type.toName(list.get(i)));
}
return chain;
}
示例8: upToType
static EclipseNode upToType(EclipseNode typeNode) {
EclipseNode node = typeNode;
do {
node = node.up();
} while ((node != null) && (node.getKind() != Kind.TYPE));
return node;
}
示例9: getTypeName
public static String getTypeName(EclipseNode type) {
String typeName = getSingleTypeName(type);
EclipseNode upType = type.up();
while (upType.getKind() == Kind.TYPE) {
typeName = getSingleTypeName(upType) + "." + typeName;
upType = upType.up();
}
return typeName;
}
示例10: findInnerClass
public EclipseNode findInnerClass(EclipseNode parent, String name) {
char[] c = name.toCharArray();
for (EclipseNode child : parent.down()) {
if (child.getKind() != Kind.TYPE) continue;
TypeDeclaration td = (TypeDeclaration) child.get();
if (Arrays.equals(td.name, c)) return child;
}
return null;
}
示例11: changeModifiersAndGenerateConstructor
private void changeModifiersAndGenerateConstructor(JavacNode typeNode, JavacNode errorNode) {
JCClassDecl classDecl = (JCClassDecl) typeNode.get();
boolean makeConstructor = true;
classDecl.mods.flags |= Flags.FINAL;
boolean markStatic = true;
if (typeNode.up().getKind() == Kind.COMPILATION_UNIT) markStatic = false;
if (markStatic && typeNode.up().getKind() == Kind.TYPE) {
JCClassDecl typeDecl = (JCClassDecl) typeNode.up().get();
if ((typeDecl.mods.flags & Flags.INTERFACE) != 0) markStatic = false;
}
if (markStatic) classDecl.mods.flags |= Flags.STATIC;
for (JavacNode element : typeNode.down()) {
if (element.getKind() == Kind.FIELD) {
JCVariableDecl fieldDecl = (JCVariableDecl) element.get();
fieldDecl.mods.flags |= Flags.STATIC;
} else if (element.getKind() == Kind.METHOD) {
JCMethodDecl methodDecl = (JCMethodDecl) element.get();
if (methodDecl.name.contentEquals("<init>")) {
if (getGeneratedBy(methodDecl) == null && (methodDecl.mods.flags & Flags.GENERATEDCONSTR) == 0) {
element.addError("@UtilityClasses cannot have declared constructors.");
makeConstructor = false;
continue;
}
}
methodDecl.mods.flags |= Flags.STATIC;
} else if (element.getKind() == Kind.TYPE) {
JCClassDecl innerClassDecl = (JCClassDecl) element.get();
innerClassDecl.mods.flags |= Flags.STATIC;
}
}
if (makeConstructor) createPrivateDefaultConstructor(typeNode);
}
示例12: getTypeName
public static String getTypeName(JavacNode typeNode) {
String typeName = ((JCClassDecl) typeNode.get()).name.toString();
JavacNode upType = typeNode.up();
while (upType.getKind() == Kind.TYPE) {
typeName = ((JCClassDecl) upType.get()).name.toString() + "." + typeName;
upType = upType.up();
}
return typeName;
}
示例13: findInnerClass
public JavacNode findInnerClass(JavacNode parent, String name) {
for (JavacNode child : parent.down()) {
if (child.getKind() != Kind.TYPE) continue;
JCClassDecl td = (JCClassDecl) child.get();
if (td.name.contentEquals(name)) return child;
}
return null;
}
示例14: getTypeName
private String getTypeName(EclipseNode type) {
String typeName = getSingleTypeName(type);
EclipseNode upType = type.up();
while (upType.getKind() == Kind.TYPE) {
typeName = getSingleTypeName(upType) + "." + typeName;
upType = upType.up();
}
return typeName;
}
示例15: getTypeName
private String getTypeName(JavacNode typeNode) {
String typeName = ((JCClassDecl) typeNode.get()).name.toString();
JavacNode upType = typeNode.up();
while (upType.getKind() == Kind.TYPE) {
typeName = ((JCClassDecl) upType.get()).name.toString() + "." + typeName;
upType = upType.up();
}
return typeName;
}