本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.Assignment类的典型用法代码示例。如果您正苦于以下问题:Java Assignment类的具体用法?Java Assignment怎么用?Java Assignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assignment类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了Assignment类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateCleanMethod
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
List<Statement> statements = new ArrayList<Statement>();
for (BuilderFieldData bfd : builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
}
}
FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
thisUnclean.receiver = new ThisReference(0, 0);
statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
decl.selector = CLEAN_METHOD_NAME;
decl.modifiers = ClassFileConstants.AccPrivate;
decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
decl.statements = statements.toArray(new Statement[0]);
decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return decl;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:HandleBuilder.java
示例2: doAssignmentCheck0
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
private void doAssignmentCheck0(EclipseNode node, Statement statement, char[] varName) {
if (statement instanceof Assignment)
doAssignmentCheck0(node, ((Assignment)statement).expression, varName);
else if (statement instanceof LocalDeclaration)
doAssignmentCheck0(node, ((LocalDeclaration)statement).initialization, varName);
else if (statement instanceof CastExpression)
doAssignmentCheck0(node, ((CastExpression)statement).expression, varName);
else if (statement instanceof SingleNameReference) {
if (Arrays.equals(((SingleNameReference)statement).token, varName)) {
EclipseNode problemNode = node.getNodeFor(statement);
if (problemNode != null) problemNode.addWarning(
"You're assigning an auto-cleanup variable to something else. This is a bad idea.");
}
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:16,代码来源:HandleCleanup.java
示例3: generateClearMethod
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
void generateClearMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
Assignment a = new Assignment(thisDotField, new NullLiteral(0, 0), 0);
md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
md.statements = returnStatement != null ? new Statement[] {a, returnStatement} : new Statement[] {a};
md.returnType = returnType;
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:EclipseGuavaSingularizer.java
示例4: createConstructBuilderVarIfNeeded
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
protected Statement createConstructBuilderVarIfNeeded(SingularData data, EclipseNode builderType) {
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
thisDotField2.receiver = new ThisReference(0, 0);
Expression cond = new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL);
MessageSend createBuilderInvoke = new MessageSend();
char[][] tokenizedName = makeGuavaTypeName(getSimpleTargetTypeName(data), false);
createBuilderInvoke.receiver = new QualifiedNameReference(tokenizedName, NULL_POSS, 0, 0);
createBuilderInvoke.selector = getBuilderMethodName(data);
return new IfStatement(cond, new Assignment(thisDotField2, createBuilderInvoke, 0), 0, 0);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:EclipseGuavaSingularizer.java
示例5: visit
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.Assignment, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public boolean visit(Assignment assignment, BlockScope scope) {
final int numberOfParens = (assignment.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens > 0) {
manageOpeningParenthesizedExpression(assignment, numberOfParens);
}
assignment.lhs.traverse(this, scope);
this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
if (this.preferences.insert_space_after_assignment_operator) {
this.scribe.space();
}
Alignment assignmentAlignment = this.scribe.createAlignment(
Alignment.ASSIGNMENT,
this.preferences.alignment_for_assignment,
Alignment.R_OUTERMOST,
1,
this.scribe.scanner.currentPosition);
this.scribe.enterAlignment(assignmentAlignment);
boolean ok = false;
do {
try {
this.scribe.alignFragment(assignmentAlignment, 0);
assignment.expression.traverse(this, scope);
ok = true;
} catch(AlignmentException e){
this.scribe.redoAlignment(e);
}
} while (!ok);
this.scribe.exitAlignment(assignmentAlignment, true);
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(assignment, numberOfParens);
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:CodeFormatterVisitor.java
示例6: generateAssignment
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
FieldBinding codegenBinding = this.binding.original();
if (codegenBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) {
this.receiver.generateCode(currentScope, codeStream, !codegenBinding.isStatic());
assignment.expression.generateCode(currentScope, codeStream, true);
fieldStore(currentScope, codeStream, codegenBinding, null, this.actualReceiverType, this.receiver.isImplicitThis(), valueRequired);
} else {
codeStream.generateEmulationForField(codegenBinding);
this.receiver.generateCode(currentScope, codeStream, !codegenBinding.isStatic());
if (codegenBinding.isStatic()) { // need a receiver?
codeStream.aconst_null();
}
assignment.expression.generateCode(currentScope, codeStream, true);
if (valueRequired) {
switch (codegenBinding.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2_x2();
break;
default :
codeStream.dup_x2();
break;
}
}
codeStream.generateEmulatedWriteAccessForField(codegenBinding);
}
if (valueRequired){
codeStream.generateImplicitConversion(assignment.implicitConversion);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:CodeSnippetFieldReference.java
示例7: generateAssignment
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
super.generateAssignment(currentScope, codeStream, assignment, valueRequired);
return;
}
lastFieldBinding = generateReadSequence(currentScope, codeStream);
codeStream.generateEmulationForField(lastFieldBinding);
codeStream.swap();
assignment.expression.generateCode(currentScope, codeStream, true);
if (valueRequired) {
switch (lastFieldBinding.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2_x2();
break;
default :
codeStream.dup_x2();
break;
}
}
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding);
if (valueRequired) {
codeStream.generateImplicitConversion(assignment.implicitConversion);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CodeSnippetQualifiedNameReference.java
示例8: consumeAssignment
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
protected void consumeAssignment() {
// Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
//optimize the push/pop
int op = this.intStack[this.intPtr--] ; //<--the encoded operator
this.expressionPtr -- ; this.expressionLengthPtr -- ;
Expression expression = this.expressionStack[this.expressionPtr+1];
this.expressionStack[this.expressionPtr] =
(op != EQUAL ) ?
new CompoundAssignment(
this.expressionStack[this.expressionPtr] ,
expression,
op,
expression.sourceEnd):
new Assignment(
this.expressionStack[this.expressionPtr] ,
expression,
expression.sourceEnd);
if (this.pendingRecoveredType != null) {
// Used only in statements recovery.
// This is not a real assignment but a placeholder for an existing anonymous type.
// The assignment must be replace by the anonymous type.
if (this.pendingRecoveredType.allocation != null &&
this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation;
this.pendingRecoveredType = null;
return;
}
this.pendingRecoveredType = null;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:Parser.java
示例9: assignmentHasNoEffect
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
public void assignmentHasNoEffect(Assignment location, char[] name){
int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
if (severity == ProblemSeverities.Ignore) return;
String[] arguments = new String[] { new String(name) };
this.handle(
IProblem.AssignmentHasNoEffect,
arguments,
arguments,
severity,
location.sourceStart,
location.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:ProblemReporter.java
示例10: possibleAccidentalBooleanAssignment
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
public void possibleAccidentalBooleanAssignment(Assignment assignment) {
this.handle(
IProblem.PossibleAccidentalBooleanAssignment,
NoArgument,
NoArgument,
assignment.sourceStart,
assignment.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java
示例11: createSetter
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
static MethodDeclaration createSetter(TypeDeclaration parent, EclipseNode fieldNode, String name, boolean shouldReturnThis, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam) {
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
ASTNode source = sourceNode.get();
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
MethodDeclaration method = new MethodDeclaration(parent.compilationResult);
method.modifiers = modifier;
if (shouldReturnThis) {
method.returnType = cloneSelfType(fieldNode, source);
}
if (method.returnType == null) {
method.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
shouldReturnThis = false;
}
Annotation[] deprecated = null;
if (isFieldDeprecated(fieldNode)) {
deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
}
method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
Argument param = new Argument(field.name, p, copyType(field.type, source), Modifier.FINAL);
param.sourceStart = pS; param.sourceEnd = pE;
method.arguments = new Argument[] { param };
method.selector = name.toCharArray();
method.binding = null;
method.thrownExceptions = null;
method.typeParameters = null;
method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
Expression fieldRef = createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source);
NameReference fieldNameRef = new SingleNameReference(field.name, p);
Assignment assignment = new Assignment(fieldRef, fieldNameRef, (int)p);
assignment.sourceStart = pS; assignment.sourceEnd = assignment.statementEnd = pE;
method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
List<Statement> statements = new ArrayList<Statement>(5);
if (nonNulls.length == 0) {
statements.add(assignment);
} else {
Statement nullCheck = generateNullCheck(field, sourceNode);
if (nullCheck != null) statements.add(nullCheck);
statements.add(assignment);
}
if (shouldReturnThis) {
ThisReference thisRef = new ThisReference(pS, pE);
ReturnStatement returnThis = new ReturnStatement(thisRef, pS, pE);
statements.add(returnThis);
}
method.statements = statements.toArray(new Statement[0]);
param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:59,代码来源:HandleSetter.java
示例12: visit
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
@Override public boolean visit(Assignment node, BlockScope scope) {
fixPositions(setGeneratedBy(node, source));
return super.visit(node, scope);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java
示例13: createConstructor
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
public static ConstructorDeclaration createConstructor(
AccessLevel level, EclipseNode type, Collection<EclipseNode> fields,
Boolean suppressConstructorProperties, EclipseNode sourceNode, List<Annotation> onConstructor) {
ASTNode source = sourceNode.get();
TypeDeclaration typeDeclaration = ((TypeDeclaration)type.get());
long p = (long)source.sourceStart << 32 | source.sourceEnd;
boolean isEnum = (((TypeDeclaration)type.get()).modifiers & ClassFileConstants.AccEnum) != 0;
if (isEnum) level = AccessLevel.PRIVATE;
if (suppressConstructorProperties == null) {
if (fields.isEmpty()) {
suppressConstructorProperties = false;
} else {
suppressConstructorProperties = Boolean.TRUE.equals(type.getAst().readConfiguration(ConfigurationKeys.ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES));
}
}
ConstructorDeclaration constructor = new ConstructorDeclaration(
((CompilationUnitDeclaration) type.top().get()).compilationResult);
constructor.modifiers = toEclipseModifier(level);
constructor.selector = typeDeclaration.name;
constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
constructor.constructorCall.sourceStart = source.sourceStart;
constructor.constructorCall.sourceEnd = source.sourceEnd;
constructor.thrownExceptions = null;
constructor.typeParameters = null;
constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = source.sourceStart;
constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = source.sourceEnd;
constructor.arguments = null;
List<Argument> params = new ArrayList<Argument>();
List<Statement> assigns = new ArrayList<Statement>();
List<Statement> nullChecks = new ArrayList<Statement>();
for (EclipseNode fieldNode : fields) {
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
char[] rawName = field.name;
char[] fieldName = removePrefixFromField(fieldNode);
FieldReference thisX = new FieldReference(rawName, p);
thisX.receiver = new ThisReference((int)(p >> 32), (int)p);
SingleNameReference assignmentNameRef = new SingleNameReference(fieldName, p);
Assignment assignment = new Assignment(thisX, assignmentNameRef, (int)p);
assignment.sourceStart = (int)(p >> 32); assignment.sourceEnd = assignment.statementEnd = (int)(p >> 32);
assigns.add(assignment);
long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd;
Argument parameter = new Argument(fieldName, fieldPos, copyType(field.type, source), Modifier.FINAL);
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
if (nonNulls.length != 0) {
Statement nullCheck = generateNullCheck(field, sourceNode);
if (nullCheck != null) nullChecks.add(nullCheck);
}
parameter.annotations = copyAnnotations(source, nonNulls, nullables);
params.add(parameter);
}
nullChecks.addAll(assigns);
constructor.statements = nullChecks.isEmpty() ? null : nullChecks.toArray(new Statement[nullChecks.size()]);
constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[params.size()]);
/* Generate annotations that must be put on the generated method, and attach them. */ {
Annotation[] constructorProperties = null;
if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && level != AccessLevel.PACKAGE && !isLocalType(type)) {
constructorProperties = createConstructorProperties(source, fields);
}
constructor.annotations = copyAnnotations(source,
onConstructor.toArray(new Annotation[0]),
constructorProperties);
}
constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
return constructor;
}
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:81,代码来源:HandleConstructor.java
示例14: visit
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
public boolean visit(Assignment assignment, BlockScope scope) {
addRealFragment(assignment);
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:BinaryExpressionFragmentBuilder.java
示例15: endVisit
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
@Override
public void endVisit(Assignment x, BlockScope scope) {
pushBinaryOp(x, JBinaryOperator.ASG);
}
开发者ID:WeTheInternet,项目名称:xapi,代码行数:5,代码来源:GwtAstBuilder.java
示例16: pushBinaryOp
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
protected void pushBinaryOp(Assignment x, JBinaryOperator op) {
pushBinaryOp(x, op, x.lhs, x.expression);
}
开发者ID:WeTheInternet,项目名称:xapi,代码行数:4,代码来源:GwtAstBuilder.java
示例17: visit
import org.eclipse.jdt.internal.compiler.ast.Assignment; //导入依赖的package包/类
@Override public boolean visit(Assignment 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.Assignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论