当前位置: 首页>>代码示例>>Java>>正文


Java Kind.TYPE属性代码示例

本文整理汇总了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);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:HandleEqualsAndHashCode.java

示例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;
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:JavacHandlerUtil.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:HandleEqualsAndHashCode.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:LombokNode.java

示例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);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:20,代码来源:HandleEqualsAndHashCode.java

示例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;
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:19,代码来源:JavacHandlerUtil.java

示例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;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:19,代码来源:HandleEqualsAndHashCode.java

示例8: upToType

static EclipseNode upToType(EclipseNode typeNode) {
	EclipseNode node = typeNode;
	do {
		node = node.up();
	} while ((node != null) && (node.getKind() != Kind.TYPE));
	return node;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:7,代码来源:PatchExtensionMethod.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:HandleToString.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:HandleBuilder.java

示例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);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:40,代码来源:HandleUtilityClass.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:HandleToString.java

示例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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:8,代码来源:HandleBuilder.java

示例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;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:9,代码来源:HandleToString.java

示例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;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:9,代码来源:HandleToString.java


注:本文中的lombok.core.AST.Kind.TYPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。