Java 类org.eclipse.jdt.internal.compiler.ast.Assignment 实例源码

项目:lombok-ianchiu    文件:HandleBuilder.java   
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;
}
项目:EasyMPermission    文件:HandleBuilder.java   
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;
}
项目:lombok-ianchiu    文件:HandleCleanup.java   
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.");
        }
    }
}
项目:lombok-ianchiu    文件:EclipseGuavaSingularizer.java   
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);
}
项目:lombok-ianchiu    文件:EclipseGuavaSingularizer.java   
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);
}
项目:EasyMPermission    文件:HandleCleanup.java   
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.");
        }
    }
}
项目:EasyMPermission    文件:EclipseGuavaSingularizer.java   
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);
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @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;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeSnippetFieldReference.java   
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);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeSnippetQualifiedNameReference.java   
/**
 * 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);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
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;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
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);
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void possibleAccidentalBooleanAssignment(Assignment assignment) {
    this.handle(
        IProblem.PossibleAccidentalBooleanAssignment,
        NoArgument,
        NoArgument,
        assignment.sourceStart,
        assignment.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeSnippetFieldReference.java   
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);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeSnippetQualifiedNameReference.java   
/**
 * 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);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void possibleAccidentalBooleanAssignment(Assignment assignment) {
    this.handle(
        IProblem.PossibleAccidentalBooleanAssignment,
        NoArgument,
        NoArgument,
        assignment.sourceStart,
        assignment.sourceEnd);
}
项目:lombok    文件:HandleCleanup.java   
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.");
        }
    }
}
项目:lombok-ianchiu    文件:HandleSetter.java   
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;
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(Assignment node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:HandleConstructor.java   
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;
}
项目:EasyMPermission    文件:HandleSetter.java   
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;
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(Assignment node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(Assignment assignment, BlockScope scope) {
    addRealFragment(assignment);
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(Assignment assignment, BlockScope scope) {
    addRealFragment(assignment);
    return false;
}
项目:xapi    文件:GwtAstBuilder.java   
@Override
public void endVisit(Assignment x, BlockScope scope) {
  pushBinaryOp(x, JBinaryOperator.ASG);
}
项目:xapi    文件:GwtAstBuilder.java   
protected void pushBinaryOp(Assignment x, JBinaryOperator op) {
  pushBinaryOp(x, op, x.lhs, x.expression);
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(Assignment node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetExpression(node);
    return super.visit(node, scope);
}