本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression类的典型用法代码示例。如果您正苦于以下问题:Java ArrayAllocationExpression类的具体用法?Java ArrayAllocationExpression怎么用?Java ArrayAllocationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayAllocationExpression类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了ArrayAllocationExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:37,代码来源:HandleSynchronized.java
示例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;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:SelectionParser.java
示例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;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:SelectionParser.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:Parser.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:Parser.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:TypeAnnotationCodeStream.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:CodeStream.java
示例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);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:CodeStream.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:43,代码来源:CodeFormatterVisitor.java
示例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);
}
}
开发者ID:WeTheInternet,项目名称:xapi,代码行数:28,代码来源:GwtAstBuilder.java
示例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;
}
开发者ID:redundent,项目名称:lombok,代码行数:37,代码来源:HandleSynchronized.java
示例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);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java
示例16: visit
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public boolean visit(
ArrayAllocationExpression arrayAllocationExpression,
BlockScope scope) {
addRealFragment(arrayAllocationExpression);
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:BinaryExpressionFragmentBuilder.java
示例17: 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 (arrayAllocationExpression.annotationsOnDimensions != null) {
formatInlineAnnotations(arrayAllocationExpression.annotationsOnDimensions[i], true);
}
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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:46,代码来源:CodeFormatterVisitor.java
示例18: addAnnotationContext
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
private void addAnnotationContext(TypeReference typeReference, int info, int targetType, ArrayAllocationExpression allocationExpression) {
allocationExpression.getAllAnnotationContexts(targetType, info, this.allTypeAnnotationContexts);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:TypeAnnotationCodeStream.java
示例19: newArray
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
public void newArray(TypeReference typeReference, ArrayAllocationExpression allocationExpression, ArrayBinding arrayBinding) {
if (typeReference != null && (typeReference.bits & ASTNode.HasTypeAnnotations) != 0) {
addAnnotationContext(typeReference, this.position, AnnotationTargetTypeConstants.NEW, allocationExpression);
}
super.newArray(typeReference, allocationExpression, arrayBinding);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:TypeAnnotationCodeStream.java
示例20: visit
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; //导入依赖的package包/类
@Override public boolean visit(ArrayAllocationExpression node, BlockScope scope) {
setGeneratedBy(node, source);
applyOffsetExpression(node);
return super.visit(node, scope);
}
开发者ID:redundent,项目名称:lombok,代码行数:6,代码来源:SetGeneratedByVisitor.java
注:本文中的org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论