if( !isEmpty() ) Token root = getRoot( true ); int type = root.getType(); int meaning = root.getMeaning(); if( getStartLine() > -1 ) writer.print( " at " + getStartLine() + ":" + getStartColumn() ); writer.print( "\" " ); else if( children() > 0 ) int count = size(); if( count > 1 ) writer.print( ": " ); get( i, true ).write( writer, indent2 );
/** * Returns true if the node can be coerced to the specified type. */ public boolean canMean( int type ) { return Types.canMean( getMeaning(), type ); }
/** * Returns the root of the node, the Token that indicates it's * type. Returns a Token.NULL if safe and the actual root is null. */ public Token getRoot( boolean safe ) { Token root = getRoot(); if( root == null && safe ) { root = Token.NULL; } return root; }
public void write( PrintWriter writer, Janitor janitor ) { if (owner instanceof SourceUnit) { SourceUnit source = (SourceUnit) owner; String name = source.getName(); int line = context.getStartLine(); int column = context.getStartColumn(); String sample = source.getSample( line, column, janitor ); if( sample != null ) { writer.println( source.getSample(line, column, janitor) ); } writer.println( name + ": " + line + ": " + this.message ); writer.println(""); } else { writer.println( "<No Relevant Source>: " + this.message ); writer.println(""); } }
/** * Converts a node from a generic type to a specific postfix type. * Throws a <code>GroovyBugError</code> if the type can't be converted. */ public static void makePostfix( CSTNode node, boolean throwIfInvalid ) { switch( node.getMeaning() ) { case PLUS_PLUS: node.setMeaning( POSTFIX_PLUS_PLUS ); break; case MINUS_MINUS: node.setMeaning( POSTFIX_MINUS_MINUS ); break; default: if( throwIfInvalid ) { throw new GroovyBugError( "cannot convert to postfix for type [" + node.getMeaning() + "]" ); } } }
/** * Returns true if the node is a complete expression. */ public boolean isAnExpression() { return isA(Types.SIMPLE_EXPRESSION); }
/** * Returns true if the node has any non-root elements. */ public boolean hasChildren() { return children() > 0; }
/** * Returns the specified element, or Token.NULL if * safe is set and the specified element is null (or doesn't * exist). */ public CSTNode get( int index, boolean safe ) { CSTNode element = get( index ); if( element == null && safe ) { element = Token.NULL; } return element; }
/** * Returns the starting column of the node. Returns -1 * if not known. */ public int getStartColumn() { return getRoot(true).getStartColumn(); }
public void write( PrintWriter writer, Janitor janitor ) { SourceUnit source = (SourceUnit) owner; String name = source.getName(); int line = context.getStartLine(); int column = context.getStartColumn(); String sample = source.getSample( line, column, janitor ); if( sample != null ) { writer.println( source.getSample(line, column, janitor) ); } writer.println( name + ": " + line + ": " + this.message ); writer.println(""); }
/** * Converts a node from a generic type to a specific prefix type. * Throws a <code>GroovyBugError</code> if the type can't be converted * and requested. */ public static void makePrefix( CSTNode node, boolean throwIfInvalid ) { switch( node.getMeaning() ) { case PLUS: node.setMeaning( PREFIX_PLUS ); break; case MINUS: node.setMeaning( PREFIX_MINUS ); break; case PLUS_PLUS: node.setMeaning( PREFIX_PLUS_PLUS ); break; case MINUS_MINUS: node.setMeaning( PREFIX_MINUS_MINUS ); break; default: if( throwIfInvalid ) { throw new GroovyBugError( "cannot convert to prefix for type [" + node.getMeaning() + "]" ); } } }
/** * Returns true if the node matches the specified type. Effectively * a synonym for <code>isA()</code>. Missing nodes are Token.NULL. */ boolean matches( int type ) { return isA(type); }
/** * Returns true if the node has any non-root elements. */ public boolean hasChildren() { return children() > 0; }
if( !isEmpty() ) Token root = getRoot( true ); int type = root.getType(); int meaning = root.getMeaning(); if( getStartLine() > -1 ) writer.print( " at " + getStartLine() + ":" + getStartColumn() ); writer.print( "\" " ); else if( children() > 0 ) int count = size(); if( count > 1 ) writer.print( ": " ); get( i, true ).write( writer, indent2 );