View Javadoc

1   package org.codehaus.groovy.antlr.java;
2   
3   import org.codehaus.groovy.antlr.GroovySourceAST;
4   import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
5   import org.codehaus.groovy.antlr.treewalker.VisitorAdapter;
6   
7   public class Groovifier extends VisitorAdapter implements GroovyTokenTypes {
8       private String[] tokenNames;
9       
10  	public Groovifier(String[] tokenNames) {
11  		this.tokenNames = tokenNames;
12  	}
13  	
14      public void visitDefault(GroovySourceAST t,int visit) {
15          if (visit == OPENING_VISIT) {
16              // only want to do this once per node...
17  
18          	// remove 'public' when implied already
19          	if (t.getType() == LITERAL_public) {
20          		t.setType(EXPR);
21          	}
22  /*        	if (t.getType() == MODIFIERS) {
23         			GroovySourceAST publicNode = t.childOfType(LITERAL_public);
24         			if (t.getNumberOfChildren() > 1 && publicNode != null) {
25         				// has more than one modifier, and one of them is public
26         				
27         				// delete 'public' node
28         				publicNode.setType(EXPR); // near enough the same as delete for now...
29         			}
30          	}*/
31          	// ----        	
32          }
33      }
34  }