本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression类的典型用法代码示例。如果您正苦于以下问题:Java ArrayAllocationExpression类的具体用法?Java ArrayAllocationExpression怎么用?Java ArrayAllocationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayAllocationExpression类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了ArrayAllocationExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLockField
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public char[] createLockField(AnnotationValues<Synchronized> annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) {
char[] lockName = annotation.getInstance().value().toCharArray();
Annotation source = (Annotation) annotationNode.get();
boolean autoMake = false;
if (lockName.length == 0) {
autoMake = true;
lockName = isStatic ? STATIC_LOCK_NAME : INSTANCE_LOCK_NAME;
}
if (fieldExists(new String(lockName), annotationNode) == MemberExistsResult.NOT_EXISTS) {
if (!autoMake) {
if (reportErrors) annotationNode.addError(String.format("The field %s does not exist.", new String(lockName)));
return null;
}
FieldDeclaration fieldDecl = new FieldDeclaration(lockName, 0, -1);
setGeneratedBy(fieldDecl, source);
fieldDecl.declarationSourceEnd = -1;
fieldDecl.modifiers = (isStatic ? Modifier.STATIC : 0) | Modifier.FINAL | Modifier.PRIVATE;
//We use 'new Object[0];' because unlike 'new Object();', empty arrays *ARE* serializable!
ArrayAllocationExpression arrayAlloc = new ArrayAllocationExpression();
setGeneratedBy(arrayAlloc, source);
arrayAlloc.dimensions = new Expression[] { makeIntLiteral("0".toCharArray(), source) };
arrayAlloc.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
setGeneratedBy(arrayAlloc.type, source);
fieldDecl.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
setGeneratedBy(fieldDecl.type, source);
fieldDecl.initialization = arrayAlloc;
// TODO temporary workaround for issue 217. http://code.google.com/p/projectlombok/issues/detail?id=217
// injectFieldSuppressWarnings(annotationNode.up().up(), fieldDecl);
injectField(annotationNode.up().up(), fieldDecl);
}
return lockName;
}
示例2: consumeArrayCreationExpressionWithoutInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
protected void consumeArrayCreationExpressionWithoutInitializer() {
// ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
// ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
super.consumeArrayCreationExpressionWithoutInitializer();
ArrayAllocationExpression alloc = (ArrayAllocationExpression)this.expressionStack[this.expressionPtr];
if (alloc.type == this.assistNode){
if (!this.diet){
this.restartRecovery = true; // force to restart in recovery mode
this.lastIgnoredToken = -1;
}
this.isOrphanCompletionNode = true;
}
}
示例3: consumeArrayCreationExpressionWithInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
protected void consumeArrayCreationExpressionWithInitializer() {
// ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
super.consumeArrayCreationExpressionWithInitializer();
ArrayAllocationExpression alloc = (ArrayAllocationExpression)this.expressionStack[this.expressionPtr];
if (alloc.type == this.assistNode){
if (!this.diet){
this.restartRecovery = true; // force to restart in recovery mode
this.lastIgnoredToken = -1;
}
this.isOrphanCompletionNode = true;
}
}
示例4: consumeArrayCreationExpressionWithInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
protected void consumeArrayCreationExpressionWithInitializer() {
// ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
// ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
int length;
ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
this.expressionLengthPtr -- ;
arrayAllocation.initializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
length = (this.expressionLengthStack[this.expressionLengthPtr--]);
this.expressionPtr -= length ;
System.arraycopy(
this.expressionStack,
this.expressionPtr+1,
arrayAllocation.dimensions = new Expression[length],
0,
length);
Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
arrayAllocation.type = getTypeReference(0);
arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
if (annotationsOnDimensions != null) {
arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
}
arrayAllocation.sourceStart = this.intStack[this.intPtr--];
if (arrayAllocation.initializer == null) {
arrayAllocation.sourceEnd = this.endStatementPosition;
} else {
arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
}
pushOnExpressionStack(arrayAllocation);
}
示例5: consumeArrayCreationExpressionWithoutInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
protected void consumeArrayCreationExpressionWithoutInitializer() {
// ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
// ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
int length;
ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
length = (this.expressionLengthStack[this.expressionLengthPtr--]);
this.expressionPtr -= length ;
System.arraycopy(
this.expressionStack,
this.expressionPtr+1,
arrayAllocation.dimensions = new Expression[length],
0,
length);
Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
arrayAllocation.type = getTypeReference(0);
arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
if (annotationsOnDimensions != null) {
arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
}
arrayAllocation.sourceStart = this.intStack[this.intPtr--];
if (arrayAllocation.initializer == null) {
arrayAllocation.sourceEnd = this.endStatementPosition;
} else {
arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
}
pushOnExpressionStack(arrayAllocation);
}
示例6: cannotDefineDimensionsAndInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
this.handle(
IProblem.CannotDefineDimensionExpressionsWithInit,
NoArgument,
NoArgument,
expresssion.sourceStart,
expresssion.sourceEnd);
}
示例7: incorrectLocationForNonEmptyDimension
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
this.handle(
IProblem.IllegalDimension,
NoArgument,
NoArgument,
expression.dimensions[index].sourceStart,
expression.dimensions[index].sourceEnd);
}
示例8: mustDefineDimensionsOrInitializer
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
this.handle(
IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
NoArgument,
NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
示例9: multianewarray
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void multianewarray(
TypeReference typeReference,
TypeBinding typeBinding,
int dimensions,
ArrayAllocationExpression allocationExpression) {
if (typeReference != null && (typeReference.bits & ASTNode.HasTypeAnnotations) != 0) {
addAnnotationContext(typeReference, this.position, AnnotationTargetTypeConstants.NEW, allocationExpression);
}
super.multianewarray(typeReference, typeBinding, dimensions, allocationExpression);
}
示例10: multianewarray
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void multianewarray(
TypeReference typeReference,
TypeBinding typeBinding,
int dimensions,
ArrayAllocationExpression allocationExpression) {
this.countLabels = 0;
this.stackDepth += (1 - dimensions);
if (this.classFileOffset + 3 >= this.bCodeStream.length) {
resizeByteArray();
}
this.position += 2;
this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_multianewarray;
writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
this.bCodeStream[this.classFileOffset++] = (byte) dimensions;
}
示例11: newArray
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void newArray(TypeReference typeReference, ArrayAllocationExpression allocationExpression, ArrayBinding arrayBinding) {
TypeBinding component = arrayBinding.elementsType();
switch (component.id) {
case TypeIds.T_int :
newarray(ClassFileConstants.INT_ARRAY);
break;
case TypeIds.T_byte :
newarray(ClassFileConstants.BYTE_ARRAY);
break;
case TypeIds.T_boolean :
newarray(ClassFileConstants.BOOLEAN_ARRAY);
break;
case TypeIds.T_short :
newarray(ClassFileConstants.SHORT_ARRAY);
break;
case TypeIds.T_char :
newarray(ClassFileConstants.CHAR_ARRAY);
break;
case TypeIds.T_long :
newarray(ClassFileConstants.LONG_ARRAY);
break;
case TypeIds.T_float :
newarray(ClassFileConstants.FLOAT_ARRAY);
break;
case TypeIds.T_double :
newarray(ClassFileConstants.DOUBLE_ARRAY);
break;
default :
anewarray(component);
}
}
示例12: visit
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public boolean visit(
ArrayAllocationExpression arrayAllocationExpression,
BlockScope scope) {
final int numberOfParens = (arrayAllocationExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens > 0) {
manageOpeningParenthesizedExpression(arrayAllocationExpression, numberOfParens);
}
this.scribe.printNextToken(TerminalTokens.TokenNamenew);
this.scribe.space();
arrayAllocationExpression.type.traverse(this, scope);
final Expression[] dimensions = arrayAllocationExpression.dimensions;
int dimensionsLength = dimensions.length;
for (int i = 0; i < dimensionsLength; i++) {
if (this.preferences.insert_space_before_opening_bracket_in_array_allocation_expression) {
this.scribe.space();
}
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET, false);
if (dimensions[i] != null) {
if (this.preferences.insert_space_after_opening_bracket_in_array_allocation_expression) {
this.scribe.space();
}
dimensions[i].traverse(this, scope);
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_before_closing_bracket_in_array_allocation_expression);
} else {
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_between_empty_brackets_in_array_allocation_expression);
}
}
final ArrayInitializer initializer = arrayAllocationExpression.initializer;
if (initializer != null) {
initializer.traverse(this, scope);
}
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(arrayAllocationExpression, numberOfParens);
}
return false;
}
示例13: endVisit
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
@Override
public void endVisit(ArrayAllocationExpression x, BlockScope scope) {
try {
SourceInfo info = makeSourceInfo(x);
JArrayType type = (JArrayType) typeMap.get(x.resolvedType);
if (x.initializer != null) {
// handled by ArrayInitializer.
} else {
// Annoyingly, JDT only visits non-null dims, so we can't popList().
List<JExpression> dims = new ArrayList<JExpression>();
for (int i = x.dimensions.length - 1; i >= 0; --i) {
JExpression dimension = pop(x.dimensions[i]);
// can be null if index expression was empty
if (dimension == null) {
dimension = JAbsentArrayDimension.INSTANCE;
}
dims.add(dimension);
}
// Undo the stack reversal.
Collections.reverse(dims);
push(JNewArray.createDims(info, type, dims));
}
} catch (Throwable e) {
throw translateException(x, e);
}
}
示例14: createLockField
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
private char[] createLockField(AnnotationValues<Synchronized> annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) {
char[] lockName = annotation.getInstance().value().toCharArray();
Annotation source = (Annotation) annotationNode.get();
boolean autoMake = false;
if (lockName.length == 0) {
autoMake = true;
lockName = isStatic ? STATIC_LOCK_NAME : INSTANCE_LOCK_NAME;
}
if (fieldExists(new String(lockName), annotationNode) == MemberExistsResult.NOT_EXISTS) {
if (!autoMake) {
if (reportErrors) annotationNode.addError(String.format("The field %s does not exist.", new String(lockName)));
return null;
}
FieldDeclaration fieldDecl = new FieldDeclaration(lockName, 0, -1);
setGeneratedBy(fieldDecl, source);
fieldDecl.declarationSourceEnd = -1;
fieldDecl.modifiers = (isStatic ? Modifier.STATIC : 0) | Modifier.FINAL | Modifier.PRIVATE;
//We use 'new Object[0];' because unlike 'new Object();', empty arrays *ARE* serializable!
ArrayAllocationExpression arrayAlloc = new ArrayAllocationExpression();
setGeneratedBy(arrayAlloc, source);
arrayAlloc.dimensions = new Expression[] { makeIntLiteral("0".toCharArray(), source) };
arrayAlloc.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
setGeneratedBy(arrayAlloc.type, source);
fieldDecl.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
setGeneratedBy(fieldDecl.type, source);
fieldDecl.initialization = arrayAlloc;
// TODO temporary workaround for issue 217. http://code.google.com/p/projectlombok/issues/detail?id=217
// injectFieldSuppressWarnings(annotationNode.up().up(), fieldDecl);
injectField(annotationNode.up().up(), fieldDecl);
}
return lockName;
}
示例15: visit
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
@Override public boolean visit(ArrayAllocationExpression node, BlockScope scope) {
fixPositions(setGeneratedBy(node, source));
return super.visit(node, scope);
}