本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}