org.codehaus.groovy.ast.expr.GStringExpression Java Examples

The following examples show how to use org.codehaus.groovy.ast.expr.GStringExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InnerClassVisitorHelper.java    From groovy with Apache License 2.0 6 votes vote down vote up
protected static void setPropertySetterDispatcher(BlockStatement block, Expression thiz, Parameter[] parameters) {
    List<ConstantExpression> gStringStrings = new ArrayList<ConstantExpression>();
    gStringStrings.add(new ConstantExpression(""));
    gStringStrings.add(new ConstantExpression(""));
    List<Expression> gStringValues = new ArrayList<Expression>();
    gStringValues.add(new VariableExpression(parameters[0]));
    block.addStatement(
            new ExpressionStatement(
                    new BinaryExpression(
                            new PropertyExpression(
                                    thiz,
                                    new GStringExpression("$name", gStringStrings, gStringValues)
                            ),
                            Token.newSymbol(Types.ASSIGN, -1, -1),
                            new VariableExpression(parameters[1])
                    )
            )
    );
}
 
Example #2
Source File: InnerClassVisitorHelper.java    From groovy with Apache License 2.0 6 votes vote down vote up
protected static void setMethodDispatcherCode(BlockStatement block, Expression thiz, Parameter[] parameters) {
    List<ConstantExpression> gStringStrings = new ArrayList<ConstantExpression>();
    gStringStrings.add(new ConstantExpression(""));
    gStringStrings.add(new ConstantExpression(""));
    List<Expression> gStringValues = new ArrayList<Expression>();
    gStringValues.add(new VariableExpression(parameters[0]));
    block.addStatement(
            new ReturnStatement(
                    new MethodCallExpression(
                            thiz,
                            new GStringExpression("$name", gStringStrings, gStringValues),
                            new ArgumentListExpression(
                                    new SpreadExpression(new VariableExpression(parameters[1]))
                            )
                    )
            )
    );
}
 
Example #3
Source File: ASTNodeVisitor.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
public void visitGStringExpression(GStringExpression node) {
	pushASTNode(node);
	try {
		super.visitGStringExpression(node);
	} finally {
		popASTNode();
	}
}
 
Example #4
Source File: InnerClassVisitorHelper.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected static void setPropertyGetterDispatcher(BlockStatement block, Expression thiz, Parameter[] parameters) {
    List<ConstantExpression> gStringStrings = new ArrayList<ConstantExpression>();
    gStringStrings.add(new ConstantExpression(""));
    gStringStrings.add(new ConstantExpression(""));
    List<Expression> gStringValues = new ArrayList<Expression>();
    gStringValues.add(new VariableExpression(parameters[0]));
    block.addStatement(
            new ReturnStatement(
                    new PropertyExpression(
                            thiz,
                            new GStringExpression("$name", gStringStrings, gStringValues)
                    )
            )
    );
}
 
Example #5
Source File: AsmClassGenerator.java    From groovy with Apache License 2.0 5 votes vote down vote up
@Override
public void visitGStringExpression(final GStringExpression expression) {
    MethodVisitor mv = controller.getMethodVisitor();

    mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/GStringImpl");
    mv.visitInsn(DUP);

    int size = expression.getValues().size();
    BytecodeHelper.pushConstant(mv, size);
    mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");

    for (int i = 0; i < size; i += 1) {
        mv.visitInsn(DUP);
        BytecodeHelper.pushConstant(mv, i);
        expression.getValue(i).visit(this);
        controller.getOperandStack().box();
        mv.visitInsn(AASTORE);
    }
    controller.getOperandStack().remove(size);

    List<ConstantExpression> strings = expression.getStrings();
    size = strings.size();
    BytecodeHelper.pushConstant(mv, size);
    mv.visitTypeInsn(ANEWARRAY, "java/lang/String");

    for (int i = 0; i < size; i += 1) {
        mv.visitInsn(DUP);
        BytecodeHelper.pushConstant(mv, i);
        controller.getOperandStack().pushConstant(strings.get(i));
        controller.getOperandStack().box();
        mv.visitInsn(AASTORE);
    }
    controller.getOperandStack().remove(size);

    mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/GStringImpl", "<init>", "([Ljava/lang/Object;[Ljava/lang/String;)V", false);
    controller.getOperandStack().push(ClassHelper.GSTRING_TYPE);
}
 
Example #6
Source File: PathFinderVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(GStringExpression node) {
    if (isInside(node, line, column)) {
        super.visitGStringExpression(node);
    }
}
 
Example #7
Source File: ASTFinder.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(final GStringExpression expression) {
    super.visitGStringExpression(expression);
    tryFind(GStringExpression.class, expression);
}
 
Example #8
Source File: ContextualClassCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(final GStringExpression expression) {
    pushContext(expression);
    super.visitGStringExpression(expression);
    popContext();
}
 
Example #9
Source File: SecureASTCustomizer.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(final GStringExpression expression) {
    assertExpressionAuthorized(expression);
    visitListOfExpressions(expression.getStrings());
    visitListOfExpressions(expression.getValues());
}
 
Example #10
Source File: TransformingCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(final GStringExpression expression) {
    super.visitGStringExpression(expression);
    trn.visitGStringExpression(expression);
}
 
Example #11
Source File: CodeVisitorSupport.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitGStringExpression(GStringExpression expression) {
    visitListOfExpressions(expression.getStrings());
    visitListOfExpressions(expression.getValues());
}
 
Example #12
Source File: ClassCompletionVerifier.java    From groovy with Apache License 2.0 4 votes vote down vote up
public void visitGStringExpression(GStringExpression expression) {
    super.visitGStringExpression(expression);
    for (ConstantExpression ce : expression.getStrings()) {
        checkStringExceedingMaximumLength(ce);
    }
}
 
Example #13
Source File: GroovyCodeVisitor.java    From groovy with Apache License 2.0 votes vote down vote up
void visitGStringExpression(GStringExpression expression);