Class AstToTextHelper

java.lang.Object
org.codehaus.groovy.ast.AstToTextHelper

public class AstToTextHelper extends Object
Helper class for converting AST into text.
  • Constructor Details

    • AstToTextHelper

      public AstToTextHelper()
  • Method Details

    • getClassText

      public static String getClassText(ClassNode node)
      Renders node without generics. A null node is rendered as <unknown>.
      Parameters:
      node - class to render, or null
      Returns:
      node.toString(false), or <unknown>
    • getParameterText

      public static String getParameterText(Parameter node)
      Renders node as type name, plus = and the initial expression when one is present. A null parameter, or a parameter with a null name, uses <unknown> for that part.
      Parameters:
      node - parameter to render, or null
      Returns:
      that declaration text
    • getParametersText

      public static String getParametersText(Parameter[] parameters)
      Joins getParameterText(org.codehaus.groovy.ast.Parameter) for each parameter with ", ". A null or empty array is an empty string.
      Parameters:
      parameters - parameters to render, or null
      Returns:
      the joined parameter list, without parentheses
    • getThrowsClauseText

      public static String getThrowsClauseText(ClassNode[] exceptions)
      Renders a throws clause, including the leading space. A null or empty array is an empty string.
      Parameters:
      exceptions - checked exception types, or null
      Returns:
      a leading space, throws, the joined type names, or empty
    • getModifiersText

      public static String getModifiersText(int modifiers)
      Renders the modifier bits of modifiers as keywords, in this order: private, protected, public, static, abstract, final, interface, native, synchronized, transient, volatile. Bits outside that set are ignored.
      Parameters:
      modifiers - JVM access flags
      Returns:
      the keywords separated by spaces, or empty when none apply