• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParameterizedSingleTypeReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedSingleTypeReference类的具体用法?Java ParameterizedSingleTypeReference怎么用?Java ParameterizedSingleTypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParameterizedSingleTypeReference类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了ParameterizedSingleTypeReference类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: namePlusTypeParamsToTypeReference

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
	if (params != null && params.length > 0) {
		TypeReference[] refs = new TypeReference[params.length];
		int idx = 0;
		for (TypeParameter param : params) {
			TypeReference typeRef = new SingleTypeReference(param.name, p);
			refs[idx++] = typeRef;
		}
		return new ParameterizedSingleTypeReference(typeName, refs, 0, p);
	}
	
	return new SingleTypeReference(typeName, p);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:EclipseHandlerUtil.java


示例2: visit

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
public boolean visit(
		ParameterizedSingleTypeReference parameterizedSingleTypeReference,
		BlockScope scope) {
	final int numberOfParens = (parameterizedSingleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
	if (numberOfParens > 0) {
		manageOpeningParenthesizedExpression(parameterizedSingleTypeReference, numberOfParens);
	}
	if (parameterizedSingleTypeReference.annotations != null) {
		formatInlineAnnotations(parameterizedSingleTypeReference.annotations[0], false);
	}
	this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);

	TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments;
	int typeArgumentsLength = typeArguments.length;
	if (typeArgumentsLength > 0) {
		this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_parameterized_type_reference);
		if (this.preferences.insert_space_after_opening_angle_bracket_in_parameterized_type_reference) {
			this.scribe.space();
		}
		for (int i = 0; i < typeArgumentsLength - 1; i++) {
			typeArguments[i].traverse(this, scope);
			this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_parameterized_type_reference);
			if (this.preferences.insert_space_after_comma_in_parameterized_type_reference) {
				this.scribe.space();
			}
		}
		typeArguments[typeArgumentsLength - 1].traverse(this, scope);
		if (isClosingGenericToken()) {
			this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_parameterized_type_reference);
		}
	} else {
		this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_parameterized_type_reference);
		this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS);
	}
	formatLeadingDimensions(parameterizedSingleTypeReference);
	if (numberOfParens > 0) {
		manageClosingParenthesizedExpression(parameterizedSingleTypeReference, numberOfParens);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:CodeFormatterVisitor.java


示例3: getSingularData

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
/**
 * Returns the explicitly requested singular annotation on this node (field
 * or parameter), or null if there's no {@code @Singular} annotation on it.
 * 
 * @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation.
 */
private SingularData getSingularData(EclipseNode node, ASTNode source) {
	for (EclipseNode child : node.down()) {
		if (!annotationTypeMatches(Singular.class, child)) continue;
		char[] pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((AbstractVariableDeclaration) node.get()).name;
		AnnotationValues<Singular> ann = createAnnotation(Singular.class, child);
		String explicitSingular = ann.getInstance().value();
		if (explicitSingular.isEmpty()) {
			if (Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.SINGULAR_AUTO))) {
				node.addError("The singular must be specified explicitly (e.g. @Singular(\"task\")) because auto singularization is disabled.");
				explicitSingular = new String(pluralName);
			} else {
				explicitSingular = autoSingularize(new String(pluralName));
				if (explicitSingular == null) {
					node.addError("Can't singularize this name; please specify the singular explicitly (i.e. @Singular(\"sheep\"))");
					explicitSingular = new String(pluralName);
				}
			}
		}
		char[] singularName = explicitSingular.toCharArray();
		
		TypeReference type = ((AbstractVariableDeclaration) node.get()).type;
		TypeReference[] typeArgs = null;
		String typeName;
		if (type instanceof ParameterizedSingleTypeReference) {
			typeArgs = ((ParameterizedSingleTypeReference) type).typeArguments;
			typeName = new String(((ParameterizedSingleTypeReference) type).token);
		} else if (type instanceof ParameterizedQualifiedTypeReference) {
			TypeReference[][] tr = ((ParameterizedQualifiedTypeReference) type).typeArguments;
			if (tr != null) typeArgs = tr[tr.length - 1];
			char[][] tokens = ((ParameterizedQualifiedTypeReference) type).tokens;
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < tokens.length; i++) {
				if (i > 0) sb.append(".");
				sb.append(tokens[i]);
			}
			typeName = sb.toString();
		} else {
			typeName = type.toString();
		}
		
		String targetFqn = EclipseSingularsRecipes.get().toQualified(typeName);
		EclipseSingularizer singularizer = EclipseSingularsRecipes.get().getSingularizer(targetFqn);
		if (singularizer == null) {
			node.addError("Lombok does not know how to create the singular-form builder methods for type '" + typeName + "'; they won't be generated.");
			return null;
		}
		
		return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.<TypeReference>emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source);
	}
	
	return null;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:59,代码来源:HandleBuilder.java


示例4: visit

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
@Override public boolean visit(ParameterizedSingleTypeReference node, BlockScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java


示例5: getSingularData

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
/**
 * Returns the explicitly requested singular annotation on this node (field
 * or parameter), or null if there's no {@code @Singular} annotation on it.
 * 
 * @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation.
 */
private SingularData getSingularData(EclipseNode node, ASTNode source) {
	for (EclipseNode child : node.down()) {
		if (child.getKind() == Kind.ANNOTATION && annotationTypeMatches(Singular.class, child)) {
			char[] pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((AbstractVariableDeclaration) node.get()).name;
			AnnotationValues<Singular> ann = createAnnotation(Singular.class, child);
			String explicitSingular = ann.getInstance().value();
			if (explicitSingular.isEmpty()) {
				if (Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.SINGULAR_AUTO))) {
					node.addError("The singular must be specified explicitly (e.g. @Singular(\"task\")) because auto singularization is disabled.");
					explicitSingular = new String(pluralName);
				} else {
					explicitSingular = autoSingularize(node.getName());
					if (explicitSingular == null) {
						node.addError("Can't singularize this name; please specify the singular explicitly (i.e. @Singular(\"sheep\"))");
						explicitSingular = new String(pluralName);
					}
				}
			}
			char[] singularName = explicitSingular.toCharArray();
			
			TypeReference type = ((AbstractVariableDeclaration) node.get()).type;
			TypeReference[] typeArgs = null;
			String typeName;
			if (type instanceof ParameterizedSingleTypeReference) {
				typeArgs = ((ParameterizedSingleTypeReference) type).typeArguments;
				typeName = new String(((ParameterizedSingleTypeReference) type).token);
			} else if (type instanceof ParameterizedQualifiedTypeReference) {
				TypeReference[][] tr = ((ParameterizedQualifiedTypeReference) type).typeArguments;
				if (tr != null) typeArgs = tr[tr.length - 1];
				char[][] tokens = ((ParameterizedQualifiedTypeReference) type).tokens;
				StringBuilder sb = new StringBuilder();
				for (int i = 0; i < tokens.length; i++) {
					if (i > 0) sb.append(".");
					sb.append(tokens[i]);
				}
				typeName = sb.toString();
			} else {
				typeName = type.toString();
			}
			
			String targetFqn = EclipseSingularsRecipes.get().toQualified(typeName);
			EclipseSingularizer singularizer = EclipseSingularsRecipes.get().getSingularizer(targetFqn);
			if (singularizer == null) {
				node.addError("Lombok does not know how to create the singular-form builder methods for type '" + typeName + "'; they won't be generated.");
				return null;
			}
			
			return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.<TypeReference>emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source);
		}
	}
	
	return null;
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:60,代码来源:HandleBuilder.java


示例6: visit

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
public boolean visit(
		ParameterizedSingleTypeReference parameterizedSingleTypeReference,
		BlockScope scope) {
	final int numberOfParens = (parameterizedSingleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
	if (numberOfParens > 0) {
		manageOpeningParenthesizedExpression(parameterizedSingleTypeReference, numberOfParens);
	}
	this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);

	TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments;
	int typeArgumentsLength = typeArguments.length;
	if (typeArgumentsLength > 0) {
		this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_parameterized_type_reference);
		if (this.preferences.insert_space_after_opening_angle_bracket_in_parameterized_type_reference) {
			this.scribe.space();
		}
		for (int i = 0; i < typeArgumentsLength - 1; i++) {
			typeArguments[i].traverse(this, scope);
			this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_parameterized_type_reference);
			if (this.preferences.insert_space_after_comma_in_parameterized_type_reference) {
				this.scribe.space();
			}
		}
		typeArguments[typeArgumentsLength - 1].traverse(this, scope);
		if (isClosingGenericToken()) {
			this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_parameterized_type_reference);
		}
	} else {
		this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_parameterized_type_reference);
		this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS);
	}

	int dimensions = getDimensions();
	if (dimensions != 0 && dimensions <= parameterizedSingleTypeReference.dimensions()) {
		if (this.preferences.insert_space_before_opening_bracket_in_array_type_reference) {
			this.scribe.space();
		}
		for (int i = 0; i < dimensions; i++) {
			this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
			if (this.preferences.insert_space_between_brackets_in_array_type_reference) {
				this.scribe.space();
			}
			this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
		}
	}
	if (numberOfParens > 0) {
		manageClosingParenthesizedExpression(parameterizedSingleTypeReference, numberOfParens);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:51,代码来源:CodeFormatterVisitor.java


示例7: createStaticConstructor

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
private MethodDeclaration createStaticConstructor(AccessLevel level, String name, EclipseNode type, Collection<EclipseNode> fields, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;
	
	MethodDeclaration constructor = new MethodDeclaration(
			((CompilationUnitDeclaration) type.top().get()).compilationResult);
	
	constructor.modifiers = toEclipseModifier(level) | Modifier.STATIC;
	TypeDeclaration typeDecl = (TypeDeclaration) type.get();
	if (typeDecl.typeParameters != null && typeDecl.typeParameters.length > 0) {
		TypeReference[] refs = new TypeReference[typeDecl.typeParameters.length];
		int idx = 0;
		for (TypeParameter param : typeDecl.typeParameters) {
			TypeReference typeRef = new SingleTypeReference(param.name, (long)param.sourceStart << 32 | param.sourceEnd);
			setGeneratedBy(typeRef, source);
			refs[idx++] = typeRef;
		}
		constructor.returnType = new ParameterizedSingleTypeReference(typeDecl.name, refs, 0, p);
	} else constructor.returnType = new SingleTypeReference(((TypeDeclaration)type.get()).name, p);
	constructor.annotations = null;
	constructor.selector = name.toCharArray();
	constructor.thrownExceptions = null;
	constructor.typeParameters = copyTypeParams(((TypeDeclaration)type.get()).typeParameters, source);
	constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = source.sourceStart;
	constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = source.sourceEnd;
	
	List<Argument> params = new ArrayList<Argument>();
	List<Expression> assigns = new ArrayList<Expression>();
	AllocationExpression statement = new AllocationExpression();
	statement.sourceStart = pS; statement.sourceEnd = pE;
	statement.type = copyType(constructor.returnType, source);
	
	for (EclipseNode fieldNode : fields) {
		FieldDeclaration field = (FieldDeclaration) fieldNode.get();
		long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd;
		SingleNameReference nameRef = new SingleNameReference(field.name, fieldPos);
		assigns.add(nameRef);
		
		Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);

		Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN));
		if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
		params.add(parameter);
	}
	
	statement.arguments = assigns.isEmpty() ? null : assigns.toArray(new Expression[assigns.size()]);
	constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[params.size()]);
	constructor.statements = new Statement[] { new ReturnStatement(statement, (int)(p >> 32), (int)p) };
	
	constructor.traverse(new SetGeneratedByVisitor(source), typeDecl.scope);
	return constructor;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:54,代码来源:HandleConstructor.java


示例8: visit

import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; //导入依赖的package包/类
@Override public boolean visit(ParameterizedSingleTypeReference node, BlockScope scope) {
	setGeneratedBy(node, source);
	applyOffset(node);
	return super.visit(node, scope);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:6,代码来源:SetGeneratedByVisitor.java



注:本文中的org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InspectionProfile类代码示例发布时间:2022-05-22
下一篇:
Java IndexIterator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap