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

项目:lombok-ianchiu    文件:HandleLog.java   
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    MessageSend factoryParameterCall = new MessageSend();
    setGeneratedBy(factoryParameterCall, source);

    factoryParameterCall.receiver = super.createFactoryParameter(type, source);
    factoryParameterCall.selector = "getName".toCharArray();

    factoryParameterCall.nameSourcePosition = p;
    factoryParameterCall.sourceStart = pS;
    factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;

    return factoryParameterCall;
}
项目:lombok-ianchiu    文件:HandleEqualsAndHashCode.java   
public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    /* if (Float.compare(fieldName, other.fieldName) != 0) return false */
    MessageSend floatCompare = new MessageSend();
    floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
    setGeneratedBy(floatCompare, source);
    floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
    floatCompare.selector = "compare".toCharArray();
    floatCompare.arguments = new Expression[] {thisRef, otherRef};
    IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
    EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
    ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
    setGeneratedBy(ifFloatCompareIsNot0, source);
    FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
    setGeneratedBy(falseLiteral, source);
    ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
    setGeneratedBy(returnFalse, source);
    IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
    setGeneratedBy(ifStatement, source);
    return ifStatement;
}
项目:lombok-ianchiu    文件:EclipseSingularsRecipes.java   
/** Generates 'this.<em>name</em>.size()' as an expression; if nullGuard is true, it's this.name == null ? 0 : this.name.size(). */
protected Expression getSize(EclipseNode builderType, char[] name, boolean nullGuard) {
    MessageSend invoke = new MessageSend();
    ThisReference thisRef = new ThisReference(0, 0);
    FieldReference thisDotName = new FieldReference(name, 0L);
    thisDotName.receiver = thisRef;
    invoke.receiver = thisDotName;
    invoke.selector = SIZE_TEXT;
    if (!nullGuard) return invoke;

    ThisReference cdnThisRef = new ThisReference(0, 0);
    FieldReference cdnThisDotName = new FieldReference(name, 0L);
    cdnThisDotName.receiver = cdnThisRef;
    NullLiteral nullLiteral = new NullLiteral(0, 0);
    EqualExpression isNull = new EqualExpression(cdnThisDotName, nullLiteral, OperatorIds.EQUAL_EQUAL);
    IntLiteral zeroLiteral = makeIntLiteral(new char[] {'0'}, null);
    ConditionalExpression conditional = new ConditionalExpression(isNull, zeroLiteral, invoke);
    return conditional;
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
private 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);
    FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
    thisDotField2.receiver = new ThisReference(0, 0);
    md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
    MessageSend clearMsg = new MessageSend();
    clearMsg.receiver = thisDotField2;
    clearMsg.selector = "clear".toCharArray();
    Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
    md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
    md.returnType = returnType;
    injectMethod(builderType, md);
}
项目:EasyMPermission    文件:HandleLog.java   
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    MessageSend factoryParameterCall = new MessageSend();
    setGeneratedBy(factoryParameterCall, source);

    factoryParameterCall.receiver = super.createFactoryParameter(type, source);
    factoryParameterCall.selector = "getName".toCharArray();

    factoryParameterCall.nameSourcePosition = p;
    factoryParameterCall.sourceStart = pS;
    factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;

    return factoryParameterCall;
}
项目:EasyMPermission    文件:HandleEqualsAndHashCode.java   
public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    /* if (Float.compare(fieldName, other.fieldName) != 0) return false */
    MessageSend floatCompare = new MessageSend();
    floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
    setGeneratedBy(floatCompare, source);
    floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
    floatCompare.selector = "compare".toCharArray();
    floatCompare.arguments = new Expression[] {thisRef, otherRef};
    IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
    EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
    ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
    setGeneratedBy(ifFloatCompareIsNot0, source);
    FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
    setGeneratedBy(falseLiteral, source);
    ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
    setGeneratedBy(returnFalse, source);
    IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
    setGeneratedBy(ifStatement, source);
    return ifStatement;
}
项目:EasyMPermission    文件:EclipseSingularsRecipes.java   
/** Generates 'this.<em>name</em>.size()' as an expression; if nullGuard is true, it's this.name == null ? 0 : this.name.size(). */
protected Expression getSize(EclipseNode builderType, char[] name, boolean nullGuard) {
    MessageSend invoke = new MessageSend();
    ThisReference thisRef = new ThisReference(0, 0);
    FieldReference thisDotName = new FieldReference(name, 0L);
    thisDotName.receiver = thisRef;
    invoke.receiver = thisDotName;
    invoke.selector = SIZE_TEXT;
    if (!nullGuard) return invoke;

    ThisReference cdnThisRef = new ThisReference(0, 0);
    FieldReference cdnThisDotName = new FieldReference(name, 0L);
    cdnThisDotName.receiver = cdnThisRef;
    NullLiteral nullLiteral = new NullLiteral(0, 0);
    EqualExpression isNull = new EqualExpression(cdnThisDotName, nullLiteral, OperatorIds.EQUAL_EQUAL);
    IntLiteral zeroLiteral = makeIntLiteral(new char[] {'0'}, null);
    ConditionalExpression conditional = new ConditionalExpression(isNull, zeroLiteral, invoke);
    return conditional;
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
protected MessageSend newMessageSendWithTypeArguments() {
    char[] selector = this.identifierStack[this.identifierPtr];
    if (selector != assistIdentifier()){
        return super.newMessageSendWithTypeArguments();
    }
    MessageSend messageSend = new SelectionOnMessageSend();
    int length;
    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
        this.expressionPtr -= length;
        System.arraycopy(
            this.expressionStack,
            this.expressionPtr + 1,
            messageSend.arguments = new Expression[length],
            0,
            length);
    }
    this.assistNode = messageSend;
    if (!this.diet){
        this.restartRecovery    = true; // force to restart in recovery mode
        this.lastIgnoredToken = -1;
    }

    this.isOrphanCompletionNode = true;
    return messageSend;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeMethodInvocationNameWithTypeArguments() {
    // MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'

    // when the name is only an identifier...we have a message send to "this" (implicit)

    MessageSend m = newMessageSendWithTypeArguments();
    m.sourceEnd = this.rParenPos;
    m.sourceStart =
        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
    m.selector = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    // handle type arguments
    int length = this.genericsLengthStack[this.genericsLengthPtr--];
    this.genericsPtr -= length;
    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
    this.intPtr--;  // consume position of '<'

    m.receiver = getUnspecifiedReference();
    m.sourceStart = m.receiver.sourceStart;
    pushOnExpressionStack(m);
    consumeInvocationExpression();
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeMethodInvocationPrimaryWithTypeArguments() {
    //optimize the push/pop
    //MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'

    MessageSend m = newMessageSendWithTypeArguments();
    m.sourceStart =
        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
    m.selector = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    // handle type arguments
    int length = this.genericsLengthStack[this.genericsLengthPtr--];
    this.genericsPtr -= length;
    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
    this.intPtr--; // consume position of '<'

    m.receiver = this.expressionStack[this.expressionPtr];
    m.sourceStart = m.receiver.sourceStart;
    m.sourceEnd = this.rParenPos;
    this.expressionStack[this.expressionPtr] = m;
    consumeInvocationExpression();
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeMethodInvocationSuperWithTypeArguments() {
    // MethodInvocation ::= 'super' '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'

    MessageSend m = newMessageSendWithTypeArguments();
    this.intPtr--; // start position of the typeArguments
    m.sourceEnd = this.rParenPos;
    m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
    m.selector = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    // handle type arguments
    int length = this.genericsLengthStack[this.genericsLengthPtr--];
    this.genericsPtr -= length;
    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
    m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword

    m.receiver = new SuperReference(m.sourceStart, this.endPosition);
    pushOnExpressionStack(m);
    consumeInvocationExpression();
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected MessageSend newMessageSend() {
    // '(' ArgumentListopt ')'
    // the arguments are on the expression stack

    MessageSend m = new MessageSend();
    int length;
    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
        this.expressionPtr -= length;
        System.arraycopy(
            this.expressionStack,
            this.expressionPtr + 1,
            m.arguments = new Expression[length],
            0,
            length);
    }
    return m;
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
    StringBuffer buffer = new StringBuffer();
    StringBuffer shortBuffer = new StringBuffer();
    for (int i = 0, length = params.length; i < length; i++) {
        if (i != 0){
            buffer.append(", "); //$NON-NLS-1$
            shortBuffer.append(", "); //$NON-NLS-1$
        }
        buffer.append(new String(params[i].readableName()));
        shortBuffer.append(new String(params[i].shortReadableName()));
    }

    int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
    this.handle(
        id,
        new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
        new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
        messageSend.sourceStart,
        messageSend.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
    int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
    int severity = computeSeverity(id);
    if (severity == ProblemSeverities.Ignore) return;
    StringBuffer buffer = new StringBuffer();
    StringBuffer shortBuffer = new StringBuffer();
    for (int i = 0, length = params.length; i < length; i++) {
        if (i != 0){
            buffer.append(", "); //$NON-NLS-1$
            shortBuffer.append(", "); //$NON-NLS-1$
        }
        buffer.append(new String(params[i].readableName()));
        shortBuffer.append(new String(params[i].shortReadableName()));
    }
    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
        this.handle(
            id,
            new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
            new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
            severity,
            messageSend.sourceStart,
            messageSend.sourceEnd);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
    StringBuffer buffer = new StringBuffer();
    StringBuffer shortBuffer = new StringBuffer();
    for (int i = 0, length = params.length; i < length; i++) {
        if (i != 0){
            buffer.append(", "); //$NON-NLS-1$
            shortBuffer.append(", "); //$NON-NLS-1$
        }
        buffer.append(new String(params[i].readableName()));
        shortBuffer.append(new String(params[i].shortReadableName()));
    }

    int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
    this.handle(
        id,
        new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
        new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
        messageSend.sourceStart,
        messageSend.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
    int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
    int severity = computeSeverity(id);
    if (severity == ProblemSeverities.Ignore) return;
    StringBuffer buffer = new StringBuffer();
    StringBuffer shortBuffer = new StringBuffer();
    for (int i = 0, length = params.length; i < length; i++) {
        if (i != 0){
            buffer.append(", "); //$NON-NLS-1$
            shortBuffer.append(", "); //$NON-NLS-1$
        }
        buffer.append(new String(params[i].readableName()));
        shortBuffer.append(new String(params[i].shortReadableName()));
    }
    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
        this.handle(
            id,
            new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
            new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
            severity,
            messageSend.sourceStart,
            messageSend.sourceEnd);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void missingTypeInMethod(MessageSend messageSend, MethodBinding method) {
    List missingTypes = method.collectMissingTypes(null);
    if (missingTypes == null) {
        System.err.println("The method " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
        return;
    }
    TypeBinding missingType = (TypeBinding) missingTypes.get(0);
    this.handle(
            IProblem.MissingTypeInMethod,
            new String[] {
                    new String(method.declaringClass.readableName()),
                    new String(method.selector),
                    typesAsString(method, false),
                    new String(missingType.readableName()),
            },
            new String[] {
                    new String(method.declaringClass.shortReadableName()),
                    new String(method.selector),
                    typesAsString(method, true),
                    new String(missingType.shortReadableName()),
            },
            (int) (messageSend.nameSourcePosition >>> 32),
            (int) messageSend.nameSourcePosition);
}
项目:lombok    文件:HandleLog.java   
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    MessageSend factoryParameterCall = new MessageSend();
    setGeneratedBy(factoryParameterCall, source);

    factoryParameterCall.receiver = super.createFactoryParameter(type, source);
    factoryParameterCall.selector = "getName".toCharArray();

    factoryParameterCall.nameSourcePosition = p;
    factoryParameterCall.sourceStart = pS;
    factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;

    return factoryParameterCall;
}
项目:lombok    文件:HandleEqualsAndHashCode.java   
private IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    /* if (Float.compare(fieldName, other.fieldName) != 0) return false */
    MessageSend floatCompare = new MessageSend();
    floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
    setGeneratedBy(floatCompare, source);
    floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
    floatCompare.selector = "compare".toCharArray();
    floatCompare.arguments = new Expression[] {thisRef, otherRef};
    IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
    EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
    ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
    setGeneratedBy(ifFloatCompareIsNot0, source);
    FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
    setGeneratedBy(falseLiteral, source);
    ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
    setGeneratedBy(returnFalse, source);
    IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
    setGeneratedBy(ifStatement, source);
    return ifStatement;
}
项目:lombok-ianchiu    文件:PatchDelegate.java   
public Expression get(final ASTNode source, char[] name) {
    MessageSend call = new MessageSend();
    call.sourceStart = source.sourceStart; call.sourceEnd = source.sourceEnd;
    call.nameSourcePosition = pos(source);
    setGeneratedBy(call, source);
    call.selector = name;
    call.receiver = new ThisReference(source.sourceStart, source.sourceEnd);
    setGeneratedBy(call.receiver, source);
    return call;
}
项目:lombok-ianchiu    文件:EclipseHandlerUtil.java   
static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source) {
    int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
    long p = (long)pS << 32 | pE;

    boolean lookForGetter = lookForGetter(field, fieldAccess);

    GetterMethod getter = lookForGetter ? findGetter(field) : null;

    if (getter == null) {
        FieldDeclaration fieldDecl = (FieldDeclaration)field.get();
        FieldReference ref = new FieldReference(fieldDecl.name, p);
        if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) {
            EclipseNode containerNode = field.up();
            if (containerNode != null && containerNode.get() instanceof TypeDeclaration) {
                ref.receiver = new SingleNameReference(((TypeDeclaration)containerNode.get()).name, p);
            } else {
                Expression smallRef = new FieldReference(field.getName().toCharArray(), p);
                if (source != null) setGeneratedBy(smallRef, source);
                return smallRef;
            }
        } else {
            ref.receiver = new ThisReference(pS, pE);
        }

        if (source != null) {
            setGeneratedBy(ref, source);
            setGeneratedBy(ref.receiver, source);
        }
        return ref;
    }

    MessageSend call = new MessageSend();
    setGeneratedBy(call, source);
    call.sourceStart = pS; call.statementEnd = call.sourceEnd = pE;
    call.receiver = new ThisReference(pS, pE);
    setGeneratedBy(call.receiver, source);
    call.selector = getter.name;
    return call;
}
项目:lombok-ianchiu    文件:EclipseGuavaSingularizer.java   
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
    LombokImmutableList<String> suffixes = getArgumentSuffixes();
    char[][] names = new char[suffixes.size()][];
    for (int i = 0; i < suffixes.size(); i++) {
        String s = suffixes.get(i);
        char[] n = data.getSingularName();
        names[i] = s.isEmpty() ? n : s.toCharArray();
    }

    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    List<Statement> statements = new ArrayList<Statement>();
    statements.add(createConstructBuilderVarIfNeeded(data, builderType));

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    MessageSend thisDotFieldDotAdd = new MessageSend();
    thisDotFieldDotAdd.arguments = new Expression[suffixes.size()];
    for (int i = 0; i < suffixes.size(); i++) {
        thisDotFieldDotAdd.arguments[i] = new SingleNameReference(names[i], 0L);
    }
    thisDotFieldDotAdd.receiver = thisDotField;
    thisDotFieldDotAdd.selector = getAddMethodName().toCharArray();
    statements.add(thisDotFieldDotAdd);
    if (returnStatement != null) statements.add(returnStatement);
    md.statements = statements.toArray(new Statement[statements.size()]);
    md.arguments = new Argument[suffixes.size()];
    for (int i = 0; i < suffixes.size(); i++) {
        TypeReference tr = cloneParamType(i, data.getTypeArgs(), builderType);
        md.arguments[i] = new Argument(names[i], 0, tr, 0);
    }
    md.returnType = returnType;
    md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray();

    data.setGeneratedByRecursive(md);
    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);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    List<Statement> statements = new ArrayList<Statement>();
    statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    MessageSend thisDotFieldDotAdd = new MessageSend();
    thisDotFieldDotAdd.arguments = new Expression[] {new SingleNameReference(data.getSingularName(), 0L)};
    thisDotFieldDotAdd.receiver = thisDotField;
    thisDotFieldDotAdd.selector = "add".toCharArray();
    statements.add(thisDotFieldDotAdd);
    if (returnStatement != null) statements.add(returnStatement);

    md.statements = statements.toArray(new Statement[statements.size()]);
    TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType);
    Argument param = new Argument(data.getSingularName(), 0, paramType, 0);
    md.arguments = new Argument[] {param};
    md.returnType = returnType;
    md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();

    data.setGeneratedByRecursive(md);
    injectMethod(builderType, md);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
void generatePluralMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    List<Statement> statements = new ArrayList<Statement>();
    statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    MessageSend thisDotFieldDotAddAll = new MessageSend();
    thisDotFieldDotAddAll.arguments = new Expression[] {new SingleNameReference(data.getPluralName(), 0L)};
    thisDotFieldDotAddAll.receiver = thisDotField;
    thisDotFieldDotAddAll.selector = "addAll".toCharArray();
    statements.add(thisDotFieldDotAddAll);
    if (returnStatement != null) statements.add(returnStatement);

    md.statements = statements.toArray(new Statement[statements.size()]);

    TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS);
    paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs());
    Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
    md.arguments = new Argument[] {param};
    md.returnType = returnType;
    md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();

    data.setGeneratedByRecursive(md);
    injectMethod(builderType, md);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilMapSingularizer.java   
private 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;

    String pN = new String(data.getPluralName());
    char[] keyFieldName = (pN + "$key").toCharArray();
    char[] valueFieldName = (pN + "$value").toCharArray();

    FieldReference thisDotField = new FieldReference(keyFieldName, 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    FieldReference thisDotField2 = new FieldReference(keyFieldName, 0L);
    thisDotField2.receiver = new ThisReference(0, 0);
    FieldReference thisDotField3 = new FieldReference(valueFieldName, 0L);
    thisDotField3.receiver = new ThisReference(0, 0);
    md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
    MessageSend clearMsg1 = new MessageSend();
    clearMsg1.receiver = thisDotField2;
    clearMsg1.selector = "clear".toCharArray();
    MessageSend clearMsg2 = new MessageSend();
    clearMsg2.receiver = thisDotField3;
    clearMsg2.selector = "clear".toCharArray();
    Block clearMsgs = new Block(2);
    clearMsgs.statements = new Statement[] {clearMsg1, clearMsg2};
    Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsgs, 0, 0);
    md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
    md.returnType = returnType;
    injectMethod(builderType, md);
}
项目:intellij-ce-playground    文件:EcjParser.java   
@Override
@Nullable
public ResolvedNode resolve(@NonNull JavaContext context, @NonNull Node node) {
    Object nativeNode = getNativeNode(node);
    if (nativeNode == null) {
        return null;
    }

    if (nativeNode instanceof NameReference) {
        return resolve(((NameReference) nativeNode).binding);
    } else if (nativeNode instanceof TypeReference) {
        return resolve(((TypeReference) nativeNode).resolvedType);
    } else if (nativeNode instanceof MessageSend) {
        return resolve(((MessageSend) nativeNode).binding);
    } else if (nativeNode instanceof AllocationExpression) {
        return resolve(((AllocationExpression) nativeNode).binding);
    } else if (nativeNode instanceof TypeDeclaration) {
        return resolve(((TypeDeclaration) nativeNode).binding);
    } else if (nativeNode instanceof ExplicitConstructorCall) {
        return resolve(((ExplicitConstructorCall) nativeNode).binding);
    } else if (nativeNode instanceof Annotation) {
        return resolve(((Annotation) nativeNode).resolvedType);
    } else if (nativeNode instanceof AbstractMethodDeclaration) {
        return resolve(((AbstractMethodDeclaration) nativeNode).binding);
    } else if (nativeNode instanceof AbstractVariableDeclaration) {
        if (nativeNode instanceof LocalDeclaration) {
            return resolve(((LocalDeclaration) nativeNode).binding);
        } else if (nativeNode instanceof FieldDeclaration) {
            return resolve(((FieldDeclaration) nativeNode).binding);
        }
    }

    // TODO: Handle org.eclipse.jdt.internal.compiler.ast.SuperReference. It
    // doesn't contain an actual method binding; the parent node call should contain
    // it, but is missing a native node reference; investigate the ECJ bridge's super
    // handling.

    return null;
}
项目:EasyMPermission    文件:PatchDelegate.java   
public Expression get(final ASTNode source, char[] name) {
    MessageSend call = new MessageSend();
    call.sourceStart = source.sourceStart; call.sourceEnd = source.sourceEnd;
    call.nameSourcePosition = pos(source);
    setGeneratedBy(call, source);
    call.selector = name;
    call.receiver = new ThisReference(source.sourceStart, source.sourceEnd);
    setGeneratedBy(call.receiver, source);
    return call;
}
项目:EasyMPermission    文件:EclipseHandlerUtil.java   
static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source) {
    int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
    long p = (long)pS << 32 | pE;

    boolean lookForGetter = lookForGetter(field, fieldAccess);

    GetterMethod getter = lookForGetter ? findGetter(field) : null;

    if (getter == null) {
        FieldDeclaration fieldDecl = (FieldDeclaration)field.get();
        FieldReference ref = new FieldReference(fieldDecl.name, p);
        if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) {
            EclipseNode containerNode = field.up();
            if (containerNode != null && containerNode.get() instanceof TypeDeclaration) {
                ref.receiver = new SingleNameReference(((TypeDeclaration)containerNode.get()).name, p);
            } else {
                Expression smallRef = new FieldReference(field.getName().toCharArray(), p);
                if (source != null) setGeneratedBy(smallRef, source);
                return smallRef;
            }
        } else {
            ref.receiver = new ThisReference(pS, pE);
        }

        if (source != null) {
            setGeneratedBy(ref, source);
            setGeneratedBy(ref.receiver, source);
        }
        return ref;
    }

    MessageSend call = new MessageSend();
    setGeneratedBy(call, source);
    call.sourceStart = pS; call.statementEnd = call.sourceEnd = pE;
    call.receiver = new ThisReference(pS, pE);
    setGeneratedBy(call.receiver, source);
    call.selector = getter.name;
    return call;
}
项目: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);
}
项目:EasyMPermission    文件:EclipseJavaUtilListSetSingularizer.java   
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    List<Statement> statements = new ArrayList<Statement>();
    statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    MessageSend thisDotFieldDotAdd = new MessageSend();
    thisDotFieldDotAdd.arguments = new Expression[] {new SingleNameReference(data.getSingularName(), 0L)};
    thisDotFieldDotAdd.receiver = thisDotField;
    thisDotFieldDotAdd.selector = "add".toCharArray();
    statements.add(thisDotFieldDotAdd);
    if (returnStatement != null) statements.add(returnStatement);

    md.statements = statements.toArray(new Statement[statements.size()]);
    TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType);
    Argument param = new Argument(data.getSingularName(), 0, paramType, 0);
    md.arguments = new Argument[] {param};
    md.returnType = returnType;
    md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();

    data.setGeneratedByRecursive(md);
    injectMethod(builderType, md);
}
项目:EasyMPermission    文件:EclipseJavaUtilListSetSingularizer.java   
void generatePluralMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    List<Statement> statements = new ArrayList<Statement>();
    statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    MessageSend thisDotFieldDotAddAll = new MessageSend();
    thisDotFieldDotAddAll.arguments = new Expression[] {new SingleNameReference(data.getPluralName(), 0L)};
    thisDotFieldDotAddAll.receiver = thisDotField;
    thisDotFieldDotAddAll.selector = "addAll".toCharArray();
    statements.add(thisDotFieldDotAddAll);
    if (returnStatement != null) statements.add(returnStatement);

    md.statements = statements.toArray(new Statement[statements.size()]);

    TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS);
    paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs());
    Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
    md.arguments = new Argument[] {param};
    md.returnType = returnType;
    md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();

    data.setGeneratedByRecursive(md);
    injectMethod(builderType, md);
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
protected MessageSend newMessageSend() {
    // '(' ArgumentListopt ')'
    // the arguments are on the expression stack

    char[] selector = this.identifierStack[this.identifierPtr];
    if (selector != assistIdentifier()){
        return super.newMessageSend();
    }
    MessageSend messageSend = new SelectionOnMessageSend();
    int length;
    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
        this.expressionPtr -= length;
        System.arraycopy(
            this.expressionStack,
            this.expressionPtr + 1,
            messageSend.arguments = new Expression[length],
            0,
            length);
    }
    this.assistNode = messageSend;
    if (!this.diet){
        this.restartRecovery    = true; // force to restart in recovery mode
        this.lastIgnoredToken = -1;
    }

    this.isOrphanCompletionNode = true;
    return messageSend;
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationName() {
    super.consumeMethodInvocationName();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationNameWithTypeArguments() {
    super.consumeMethodInvocationNameWithTypeArguments();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationPrimary() {
    super.consumeMethodInvocationPrimary();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationPrimaryWithTypeArguments() {
    super.consumeMethodInvocationPrimaryWithTypeArguments();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationSuper() {
    super.consumeMethodInvocationSuper();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AssistParser.java   
protected void consumeMethodInvocationSuperWithTypeArguments() {
    super.consumeMethodInvocationSuperWithTypeArguments();
    popElement(K_SELECTOR);
    MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr];
    if (messageSend == this.assistNode){
        this.lastCheckPoint = messageSend.sourceEnd + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CascadingMethodInvocationFragmentBuilder.java   
public boolean visit(MessageSend messageSend, BlockScope scope) {
    if ((messageSend.receiver.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT == 0) {
        if (messageSend.receiver instanceof MessageSend) {
            this.fragmentsList.add(0, messageSend);
            messageSend.receiver.traverse(this, scope);
            return false;
        }
        this.fragmentsList.add(0, messageSend);
        this.fragmentsList.add(1, messageSend);
    } else {
        this.fragmentsList.add(0, messageSend);
        this.fragmentsList.add(1, messageSend);
    }
    return false;
}