Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.ASTNode


        Parameter[] params = new Parameter[2 + localVariableParams.length];
        params[0] = new Parameter(ClassHelper.OBJECT_TYPE, "_outerInstance");
        params[1] = new Parameter(ClassHelper.OBJECT_TYPE, "_thisObject");
        System.arraycopy(localVariableParams, 0, params, 2, localVariableParams.length);

        ASTNode sn = answer.addConstructor(ACC_PUBLIC, params, ClassNode.EMPTY_ARRAY, block);
        sn.setSourcePosition(expression);
       
        correctAccessedVariable(answer,expression);
       
        return answer;
    }
View Full Code Here


* @author Cedric Champeau
*/
public class StaticTypesTypeChooser extends StatementMetaTypeChooser {
    @Override
    public ClassNode resolveType(final Expression exp, final ClassNode current) {
        ASTNode target = exp instanceof VariableExpression ? getTarget((VariableExpression) exp) : exp;
        ClassNode inferredType = (ClassNode) target.getNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE);
        if (inferredType == null) {
            inferredType = (ClassNode) target.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
            if (inferredType == null && target instanceof VariableExpression && ((VariableExpression) target).getAccessedVariable() instanceof Parameter) {
                target = (Parameter) ((VariableExpression) target).getAccessedVariable();
                inferredType = ((Parameter) target).getOriginType();
            }
        }
View Full Code Here

        return Pair.of(start, end);
    }

    @Override
    protected int getStartOffset(@NonNull Context context, @NonNull Object cookie) {
        ASTNode node = (ASTNode) cookie;
        Pair<Integer, Integer> offsets = getOffsets(node, context);
        return offsets.getFirst();
    }
View Full Code Here

        return offsets.getFirst();
    }

    @Override
    protected Location createLocation(@NonNull Context context, @NonNull Object cookie) {
        ASTNode node = (ASTNode) cookie;
        Pair<Integer, Integer> offsets = getOffsets(node, context);
        int fromLine = node.getLineNumber() - 1;
        int fromColumn = node.getColumnNumber() - 1;
        int toLine = node.getLastLineNumber() - 1;
        int toColumn = node.getLastColumnNumber() - 1;
        return Location.create(context.file,
                new DefaultPosition(fromLine, fromColumn, offsets.getFirst()),
                new DefaultPosition(toLine, toColumn, offsets.getSecond()));
    }
View Full Code Here

       new ClassNode(grails.plugin.cache.Cacheable.class)new ClassNode(org.springframework.cache.annotation.Cacheable.class),
       new ClassNode(grails.plugin.cache.CachePut.class),   new ClassNode(org.springframework.cache.annotation.CachePut.class),
       new ClassNode(grails.plugin.cache.CacheEvict.class), new ClassNode(org.springframework.cache.annotation.CacheEvict.class));

  public void visit(final ASTNode[] astNodes, final SourceUnit sourceUnit) {
    final ASTNode firstNode = astNodes[0];
    final ASTNode secondNode = astNodes[1];
    if (!(firstNode instanceof AnnotationNode) || !(secondNode instanceof AnnotatedNode)) {
      throw new RuntimeException("Internal error: wrong types: " + firstNode.getClass().getName() +
          " / " + secondNode.getClass().getName());
    }

    final AnnotationNode grailsCacheAnnotationNode = (AnnotationNode) firstNode;
    final AnnotatedNode annotatedNode = (AnnotatedNode) secondNode;
    final AnnotationNode springCacheAnnotationNode = getCorrespondingSpringAnnotation(
View Full Code Here

public class AuthoritiesTransformation implements ASTTransformation {

  protected static final ClassNode SECURED = new ClassNode(Secured.class);

  public void visit(final ASTNode[] astNodes, final SourceUnit sourceUnit) {
    ASTNode firstNode = astNodes[0];
    ASTNode secondNode = astNodes[1];
    try {
      if (!(firstNode instanceof AnnotationNode) || !(secondNode instanceof AnnotatedNode)) {
        throw new IllegalArgumentException("Internal error: wrong types: " + firstNode.getClass().getName() +
            " / " + secondNode.getClass().getName());
      }

      AnnotationNode rolesAnnotationNode = (AnnotationNode) firstNode;
      AnnotatedNode annotatedNode = (AnnotatedNode) secondNode;
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.ASTNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.