Class AstBuilder
- All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeVisitor<Object>,GroovyParserVisitor<Object>
-
Constructor Summary
ConstructorsConstructorDescriptionAstBuilder(SourceUnit sourceUnit, boolean groovydocEnabled, boolean runtimeGroovydocEnabled) Creates a builder forsourceUnitand allocates itsModuleNode. -
Method Summary
Modifier and TypeMethodDescriptionappendStatementsToBlockStatement(BlockStatement bs, Statement... statements) Addsstatementstobsand returns that same block.buildAST()Builds theModuleNodeby visiting the concrete syntax tree frombuildCST.visit(org.antlr.v4.runtime.tree.ParseTree tree) Visit tree safely, no NPE occurred when the tree is null.Builds a bitwiseBinaryExpressionfor&.Returns theClassNodefor a qualified class name and adds the type annotations fromctx.Builds anAnnotationNodefor the annotation's class name, positioned onctx.Returns the annotation class name by visiting the qualified class name and reading that node's name.Returns theAnnotationNodes.Builds the anonymousInnerClassNode.Returns the argumentExpression.Returns the initializerExpressions.Builds anAssertStatementwhose condition is aBooleanExpression.Builds an assignmentBinaryExpressionpositioned onctx.Returns the expression produced byAsyncTransformHelper.transformAsyncClosure, positioned onctx.Returns the expression produced byAsyncTransformHelper.buildAwaitCallfor an unparenthesizedawait, positioned onctx.Returns the expression produced byAsyncTransformHelper.buildAwaitCallfor a parenthesizedawait, positioned onctx.Returns the blockStatement.Builds aBlockStatementof the block's statements, positioned onctx.Returns aBlockStatementpositioned onctx.Builds aBreakStatement.Returns aVariableExpressionofvoidor a built-in primitive, marked as a built-in type and positioned onctx.Builds the castExpression, including the parenthesized-name repairs.Returns the cast or coercionClassNodeby delegating tovisitIntersectionType(org.apache.groovy.parser.antlr4.GroovyParser.IntersectionTypeContext).Multi-catch(1..*) clause will be unpacked to several normal catch clauses, so the return type is ListReturns the exception types of acatch.Attaches the enum constants and class-body declarations to the class node stored onctx, passing that node down in node metadata.Adds one class-body member and returnsnull.Builds theClassNodefor a class, interface, trait, enum, record, or annotation, positioned onctx.Returns the class-name text ofctx.Returns one class or interfaceModifierNode, positioned onctx.Returns every class or interfaceModifierNode, in source order.Returns the class or interfaceModifierNodes.Builds aClosureExpressionpositioned onctx.Returns aClosureExpressionpositioned onctx.Returns the coercionClassNode.Builds the nextExpressionof a command chain from the base expression stored onctx.Returns anExpressionStatementfor a command expression, positioned onctx.Builds theExpressionfor a command expression.Stores a record's compact-constructor body as thepreclosure of itsTupleConstructorannotation and returnsnull.Builds theModuleNodefor a compilation unit.Builds a conditionalExpression.Builds aContinueStatement.Returns the createdClassNode, with the type annotations fromctxadded.Builds a creationExpressionpositioned onctx.Builds anExpressionStatementwhose expression is the call produced byAsyncTransformHelper.buildDeferCall.Builds aDoWhileStatementfrom the parenthesized condition and the unpacked body, adds any statement annotations, and positions the node onctx.Returns the dynamic memberExpression, positioned onctx: a parenthesized expression or a gstring.Returns one annotation valueExpression, positioned onctx: a visited expression, anAnnotationConstantExpressionfor a nested annotation, or the list from an array initializer.Builds aListExpressionof the element values, positioned onctx.Returns the member name paired with itsExpression.Returns the annotation members as a map from name toExpression, in source order.Returns the annotation member names paired with theirExpressions.Returns one argumentExpression, positioned onctx: an expression-list element, a lambda, or a map entry.Returns anExpressionpositioned onctx.Returns aFunctionthat builds a for-eachForStatement.Returns anExpressionpositioned onctx.Builds the enum-constantFieldNodeand adds it to the enum class.Returns theFieldNodes of the enum constants.Builds a bitwiseBinaryExpressionfor^.Returns theExpressioninside parentheses by delegating tovisitEnhancedStatementExpression(org.apache.groovy.parser.antlr4.GroovyParser.EnhancedStatementExpressionContext).Returns the list'sExpressions.Returns one listExpression, positioned onctx.Adds the variable declaration as a field or property of the enclosing class and returnsnull.Returns thefinallyStatement.Returns a numericConstantExpressionfor the floating-point literal, remembering the original text.Returns theFunctionthat builds aForStatementfrom a loop body.Returns the initExpressionof a classicfor.Returns oneParameterby delegating toprocessFormalParameter.Returns theParameters.Returns theParameters.Builds aForStatementfromvisitForControlapplied to the unpacked body, then adds any statement annotations.Returns the updateExpressionof a classicfor.Builds aGStringExpressionpositioned onctx.Returns one gstring valueExpression.Returns the identifier text ofctx.Returns a primaryExpressionpositioned onctx.Builds anIfStatement.Builds an implicationBinaryExpressionfor==>.Returns theImportNodejust added to the module, positioned onctx.Builds a bitwiseBinaryExpressionfor|.Tuple2<org.antlr.v4.runtime.Token,Expression> Returns the index token (the bracket or the safe-index symbol) paired with the indexExpression.Builds the indexParameterof a for-each loop.Returns a numericConstantExpressionfor the integer literal, remembering the original text.Returns the cast type.Builds theVariableExpressionfor a map-style multi-assignment target (key: name), positioned onctx.Returns aConstantExpressionof the keyword text, positioned onctx.Returns the nestedStatementafter adding the identifier as a statement label.Returns the lambda bodyStatement, positioned onctx.Builds aListExpressionfrom the expression list, positioned onctx.org.apache.groovy.parser.antlr4.AstBuilder.DeclarationListStatementReturns the declaration-list statement fromvisitVariableDeclaration(org.apache.groovy.parser.antlr4.GroovyParser.VariableDeclarationContext), positioned onctx.Builds a logicalBinaryExpressionfor&&.Builds a logicalBinaryExpressionfor||.Returns the loopStatement, positioned onctx.Builds aMapExpressionfromvisitMapEntryList(org.apache.groovy.parser.antlr4.GroovyParser.MapEntryListContext), positioned onctx.Builds aMapEntryExpressionpositioned onctx.Returns the keyExpression, positioned onctx.Returns theMapEntryExpressions.Dispatches one member and returnsnull.Returns the method bodyStatement.Builds theMethodNodeor constructor for a class member or a script method.Returns the method name.Returns oneModifierNode, positioned onctx.Returns everyModifierNode, in source order.Returns theModifierNodes.Builds a multiple-assignmentBinaryExpressionpositioned onctx.Returns theMapEntryExpressions of a named bracket argument by delegating tovisitMapEntryList(org.apache.groovy.parser.antlr4.GroovyParser.MapEntryListContext).Returns the nameExpression, positioned onctx.Returns the creatorExpression, positioned onctx.Returns the explicit type arguments asGenericsTypes.Returns aConstantExpressionwhose value is null, positioned onctx.Returns aFunctionthat builds a classicForStatement.Returns the module'sPackageNode.Returns the parenthesizedExpression, positioned on the parentheses.Builds one step of a pathExpressionfrom the base expression stored onctx.Returns the pathExpression.Returns the pathExpression, or aPostfixExpressionwhen an operator is present.Builds a powerBinaryExpression(**).Returns theClassNodefor a qualified class name fromcreateClassNode.Returns theClassNodes of an annotated qualified-name list.Returns the qualified name formed by joining each name element with a dot.Returns theClassNodefor a qualified standard class name fromcreateClassNode.Builds the relationalExpression.Returns theExpressionStatementfor one try-with-resources resource.Returns oneExpressionStatementper resource, in source order, by visiting eachresourcechild.Returns the resourceExpressionStatements of a try-with-resources header by delegating tovisitResourceList(org.apache.groovy.parser.antlr4.GroovyParser.ResourceListContext).Builds aReturnStatement.Returns the method's returnClassNode.Returns the script's top-levelASTNodes.Builds a shift or rangeExpression.Builds aLambdaExpressionpositioned onctx.Returns the lambda'sParameters.Returns aConstantExpressionfor the parsed string contents, marked as a string and positioned onctx.visitSwitchBlockStatementExpressionGroup(GroovyParser.SwitchBlockStatementExpressionGroupContext ctx) Returns the case and defaultStatements of one switch-expression group.Returns theStatements for one switch group, one per label.Returns theSwitchExpressionfromvisitSwitchExpression(org.apache.groovy.parser.antlr4.GroovyParser.SwitchExpressionContext), positioned onctx.Builds aSwitchExpressionas specified by JEP 361.Returns the label descriptor fromswitchExpressionLabel: thecaseordefaultkeyword, the label expressions, and the colon or arrow separator.Tuple2<org.antlr.v4.runtime.Token,Expression> Returns the keywordTokenpaired with its labelExpression.Builds aSwitchStatementwhose selector is the parenthesized expression.Builds aSynchronizedStatementfrom the parenthesized expression and the block, positioned onctx.Builds aThrowStatementfor the visited expression, positioned onctx.Builds aTryCatchStatement.Returns theClassNodefor a type.Builds oneGenericsTypepositioned onctx.Returns oneGenericsTypeper type argument, in source order.Returns theGenericsTypes of a type-argument list or a diamond.Returns the upper-boundClassNodes of a type parameter.Returns theClassNodefor a class, interface, trait, enum, record, or annotation declaration.Returns theClassNodes of a type list.Builds theVariableExpressionfor one multi-assignment target, positioned onctx.Returns the targetExpressions of a multi-assignment.Builds oneGenericsType.Returns the declaredGenericsTypes.org.apache.groovy.parser.antlr4.AstBuilder.DeclarationListStatementReturns a declaration-list statement for a local declaration, ornullwhen the declaration is a field or property of a class.Builds aDeclarationExpressionpositioned onctx.Returns aVariableExpressionof the identifier, positioned onctx.Returns oneDeclarationExpressionper declarator.Returns the initializerExpression.Returns one variableModifierNode, positioned onctx.Returns every variableModifierNode, in source order.Returns the variableModifierNodes.Builds aTupleExpressionof the variable names, positioned onctx.Builds aWhileStatementfrom the parenthesized condition and the unpacked body, adds any statement annotations, and positions the node onctx.Builds anExpressionStatementwhose expression is the call produced byAsyncTransformHelper.buildYieldReturnCallfor the visited expression.Builds aYieldStatementfor the visited expression, positioned onctx.Returns theYieldStatementfromvisitYieldStatement(org.apache.groovy.parser.antlr4.GroovyParser.YieldStatementContext), positioned onctx.Methods inherited from class org.apache.groovy.parser.antlr4.GroovyParserBaseVisitor
visitAssertStmtAlt, visitBlockStmtAlt, visitBreakStmtAlt, visitBuiltInTypePrmrAlt, visitClosureOrLambdaExpressionPrmrAlt, visitConditionalStmtAlt, visitContinueStmtAlt, visitDim0, visitDim1, visitElementValuePairName, visitEmptyStmtAlt, visitExpression, visitExpressionStmtAlt, visitGstringPrmrAlt, visitListPrmrAlt, visitLiteral, visitLiteralPrmrAlt, visitLocalVariableDeclarationStmtAlt, visitLoopStatement, visitMapPrmrAlt, visitNotInstanceofType, visitParenPrmrAlt, visitPostfixExprAlt, visitPrimary, visitQualifiedNameElement, visitQualifiedNameElements, visitScriptStatement, visitSep, visitStatement, visitStatementExpression, visitStringLiteralAlt, visitTryCatchStmtAltMethods inherited from class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor
aggregateResult, defaultResult, shouldVisitNextChild, visitChildren, visitErrorNode, visitTerminalMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.antlr.v4.runtime.tree.ParseTreeVisitor
visitChildren, visitErrorNode, visitTerminal
-
Constructor Details
-
AstBuilder
Creates a builder forsourceUnitand allocates itsModuleNode. The lexer and parser read that source unit. Error recovery follows the compiler configuration, and the parser uses a descriptive error strategy for that mode. Groovydoc handling is created fromgroovydocEnabledandruntimeGroovydocEnabled, and a try-with-resources transform is attached to this builder.
-
-
Method Details
-
buildAST
Builds theModuleNodeby visiting the concrete syntax tree frombuildCST.A failure is converted to a
CompilationFailedException. The partialmoduleNodeis returned whenshouldReturnPartialModuleOnFailure()is true; otherwise the exception is rethrown. Thefinallyblock releases the lexer and parser and clears the parameter maps kept for this parse. -
visitCompilationUnit
Builds theModuleNodefor a compilation unit. The package declaration is visited, then each script statement is added as a statement (a declaration list is flattened into its statements) or as a method, and every class collected during the walk is added.A
package-info.groovysource gains apackage-infoclass when the module does not already contain one. A module with no classes, methods, or statements receivesReturnStatement.RETURN_NULL_OR_VOID. The script class dummy, when present, takes its source position from the first and last statements. A number-format error recorded while visiting literals is thrown after the module is assembled.- Specified by:
visitCompilationUnitin interfaceGroovyParserVisitor<Object>- Overrides:
visitCompilationUnitin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitScriptStatements
Returns the script's top-levelASTNodes. An absent context yields an empty list; otherwise eachscriptStatementchild is visited.- Specified by:
visitScriptStatementsin interfaceGroovyParserVisitor<Object>- Overrides:
visitScriptStatementsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPackageDeclaration
Returns the module'sPackageNode. The qualified name plus a trailing dot is set as the package name, annotations from the declaration are copied onto the node, and the node is positioned onctx.- Specified by:
visitPackageDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitPackageDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitImportDeclaration
Returns theImportNodejust added to the module, positioned onctx. Annotations are collected first. A module import is expanded byexpandModuleImport.A static star import, a static member import, a type star import, or a single-type import is recorded on the module. An alias, when present, is the simple name; otherwise the simple name is the member or the last name element. For a static member import the imported type's end position stops before the member name.
- Specified by:
visitImportDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitImportDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAssertStatement
Builds anAssertStatementwhose condition is aBooleanExpression. An assignment used as the condition is rejected.visitingAssertStatementCountis raised before the condition is visited, so a postfix operator inside the assertion is positioned on the operator, and is lowered on the path that also visits the message expression.- Specified by:
visitAssertStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitAssertStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitConditionalStatement
Returns theStatementfor anif/elseor aswitch, positioned onctx. Any other conditional form is rejected.- Specified by:
visitConditionalStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitConditionalStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIfElseStatement
Builds anIfStatement. The parenthesized condition becomes aBooleanExpression. The then and else statements are unpacked, and a missingelseisEmptyStatement.INSTANCE.- Specified by:
visitIfElseStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitIfElseStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLoopStmtAlt
Returns the loopStatement, positioned onctx. The loop context is pushed as the innermost breakable construct while its statement is visited, then popped.- Specified by:
visitLoopStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitLoopStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitForStmtAlt
Builds aForStatementfromvisitForControlapplied to the unpacked body, then adds any statement annotations. Whenawaitis present the statement is wrapped byAsyncTransformHelper.wrapForAwaitLoopand positioned onctx.- Specified by:
visitForStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitForStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitForControl
Returns theFunctionthat builds aForStatementfrom a loop body. An enhanced for-control and a classic for-control are dispatched to their own visitors; any other form is rejected.- Specified by:
visitForControlin interfaceGroovyParserVisitor<Object>- Overrides:
visitForControlin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnhancedForControl
public Function<Statement,ForStatement> visitEnhancedForControl(GroovyParser.EnhancedForControlContext ctx) Returns aFunctionthat builds a for-eachForStatement. The optional index parameter and the value parameter (type, name, and modifiers) are captured now. The collection expression is visited only when that function is applied.- Specified by:
visitEnhancedForControlin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnhancedForControlin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIndexVariable
Builds the indexParameterof a for-each loop. A built-in primitive whose spelling is not three characters is rejected. The parameter type isint, the name is the identifier, and the parameter is final.- Specified by:
visitIndexVariablein interfaceGroovyParserVisitor<Object>- Overrides:
visitIndexVariablein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitOriginalForControl
public Function<Statement,ForStatement> visitOriginalForControl(GroovyParser.OriginalForControlContext ctx) Returns aFunctionthat builds a classicForStatement. Init, condition, and update are visited immediately and stored in aClosureListExpression; a missing condition isEmptyExpression.INSTANCE. That list is positioned on the for-control, including the semicolons, and the function only attaches the body.- Specified by:
visitOriginalForControlin interfaceGroovyParserVisitor<Object>- Overrides:
visitOriginalForControlin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitForInit
Returns the initExpressionof a classicfor. An absent context yieldsEmptyExpression.INSTANCE. A local-variable declaration becomes that single declaration, or aClosureListExpressionwhen several are declared together. An expression list becomes one expression, or aClosureListExpressionwhen it has more than one element.- Specified by:
visitForInitin interfaceGroovyParserVisitor<Object>- Overrides:
visitForInitin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitForUpdate
Returns the updateExpressionof a classicfor. An absent context yieldsEmptyExpression.INSTANCE; otherwise the expression list becomes one expression, or aClosureListExpressionwhen it has more than one element.- Specified by:
visitForUpdatein interfaceGroovyParserVisitor<Object>- Overrides:
visitForUpdatein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitWhileStmtAlt
Builds aWhileStatementfrom the parenthesized condition and the unpacked body, adds any statement annotations, and positions the node onctx.- Specified by:
visitWhileStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitWhileStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitDoWhileStmtAlt
Builds aDoWhileStatementfrom the parenthesized condition and the unpacked body, adds any statement annotations, and positions the node onctx.- Specified by:
visitDoWhileStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitDoWhileStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTryCatchStatement
Builds aTryCatchStatement. Atrywith neither resources, acatch, nor afinallyis rejected. Resources and every catch clause are added (multi-catch clauses are flattened into one list), a missingfinallyis empty, and the node is positioned onctx, the try-with-resources transform is applied, and the result is positioned onctxagain.- Specified by:
visitTryCatchStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitTryCatchStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitResources
Returns the resourceExpressionStatements of a try-with-resources header by delegating tovisitResourceList(org.apache.groovy.parser.antlr4.GroovyParser.ResourceListContext).- Specified by:
visitResourcesin interfaceGroovyParserVisitor<Object>- Overrides:
visitResourcesin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitResourceList
Returns oneExpressionStatementper resource, in source order, by visiting eachresourcechild.- Specified by:
visitResourceListin interfaceGroovyParserVisitor<Object>- Overrides:
visitResourceListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitResource
Returns theExpressionStatementfor one try-with-resources resource. A local-variable declaration is used as-is and must declare exactly one variable.An expression must be an assignment to a variable or a bare variable. A bare variable is rewritten by the try-with-resources transform. Either form is then rebuilt as a
DeclarationExpressionwhose left side is aVariableExpressionof the assignment's left text, and that declaration is wrapped in anExpressionStatementpositioned onctx.- Specified by:
visitResourcein interfaceGroovyParserVisitor<Object>- Overrides:
visitResourcein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCatchClause
Multi-catch(1..*) clause will be unpacked to several normal catch clauses, so the return type is List- Specified by:
visitCatchClausein interfaceGroovyParserVisitor<Object>- Overrides:
visitCatchClausein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- a list of CatchStatement instances
-
visitCatchType
Returns the exception types of acatch. An absent context yields a single dynamic type; otherwise each qualified class name is visited.- Specified by:
visitCatchTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitCatchTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFinallyBlock
Returns thefinallyStatement. An absent context yieldsEmptyStatement.INSTANCE; otherwise the block is wrapped in a block statement and positioned onctx.- Specified by:
visitFinallyBlockin interfaceGroovyParserVisitor<Object>- Overrides:
visitFinallyBlockin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchStatement
Builds aSwitchStatementwhose selector is the parenthesized expression. The switch context is pushed while the groups are visited. Each group is flattened into case statements and at most one default statement.A second default is rejected, and a default that is not the last branch is rejected. The error is anchored on the default keyword when that token was recorded. A missing default is
EmptyStatement.INSTANCE.- Specified by:
visitSwitchStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchBlockStatementGroup
public List<Statement> visitSwitchBlockStatementGroup(GroovyParser.SwitchBlockStatementGroupContext ctx) Returns theStatements for one switch group, one per label. The lastcaselabel carries the group body when a body is present; earlier case labels getEmptyStatement.INSTANCEand are positioned on the group's firstcasetoken.A
defaultlabel is the group body, or a fresh empty statement positioned on thedefaulttoken when the group has no body. That statement is marked as the switch default and remembers the keyword token.- Specified by:
visitSwitchBlockStatementGroupin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchBlockStatementGroupin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchLabel
public Tuple2<org.antlr.v4.runtime.Token,Expression> visitSwitchLabel(GroovyParser.SwitchLabelContext ctx) Returns the keywordTokenpaired with its labelExpression.casevisits the expression;defaultusesEmptyExpression.INSTANCE. Any other label is rejected.- Specified by:
visitSwitchLabelin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchLabelin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSynchronizedStmtAlt
Builds aSynchronizedStatementfrom the parenthesized expression and the block, positioned onctx.- Specified by:
visitSynchronizedStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitSynchronizedStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitReturnStmtAlt
Builds aReturnStatement. Areturninside a switch expression that produces a value is rejected. A missing expression isConstantExpression.EMPTY_EXPRESSION.- Specified by:
visitReturnStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitReturnStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitThrowStmtAlt
Builds aThrowStatementfor the visited expression, positioned onctx.- Specified by:
visitThrowStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitThrowStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLabeledStmtAlt
Returns the nestedStatementafter adding the identifier as a statement label. The statement node itself is not rebuilt.- Specified by:
visitLabeledStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitLabeledStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBreakStatement
Builds aBreakStatement. Abreakwhose innermost breakable construct is a switch expression that produces a value is rejected. The label is the identifier when one is present, otherwisenull.- Specified by:
visitBreakStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitBreakStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitYieldStatement
Builds aYieldStatementfor the visited expression, positioned onctx.- Specified by:
visitYieldStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitYieldStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitYieldReturnStmtAlt
Builds anExpressionStatementwhose expression is the call produced byAsyncTransformHelper.buildYieldReturnCallfor the visited expression.- Specified by:
visitYieldReturnStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitYieldReturnStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitYieldStmtAlt
Returns theYieldStatementfromvisitYieldStatement(org.apache.groovy.parser.antlr4.GroovyParser.YieldStatementContext), positioned onctx.- Specified by:
visitYieldStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitYieldStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitDeferStmtAlt
Builds anExpressionStatementwhose expression is the call produced byAsyncTransformHelper.buildDeferCall.deferis rejected unless the innermost closure or lambda frame is the closure of anasyncexpression; a nested closure inside that frame gets a distinct error.A closure expression is passed through as the action. Any other statement expression is wrapped in a closure whose body is that statement and whose source position is the statement.
- Specified by:
visitDeferStmtAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitDeferStmtAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitContinueStatement
Builds aContinueStatement. Acontinuewhose innermost breakable construct is a switch expression that produces a value is rejected. The label is the identifier when one is present, otherwisenull.- Specified by:
visitContinueStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitContinueStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchExprAlt
Returns theSwitchExpressionfromvisitSwitchExpression(org.apache.groovy.parser.antlr4.GroovyParser.SwitchExpressionContext), positioned onctx.- Specified by:
visitSwitchExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchExpression
Builds aSwitchExpressionas specified by JEP 361. Arrow arms that are a single expression becomeYieldStatements; colon arms use explicityield.- Specified by:
visitSwitchExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchBlockStatementExpressionGroup
public List<Statement> visitSwitchBlockStatementExpressionGroup(GroovyParser.SwitchBlockStatementExpressionGroupContext ctx) Returns the case and defaultStatements of one switch-expression group. The group must have a label, and an arrow label cannot share the group with another label.The arm is built by
switchExpressionArm: an arrow arm must be a single statement, an expression statement becomes aYieldStatement, and an empty arrow arm is kept only when the enclosing switch is in statement position. Only the last label receives that arm; earlier labels in the group get an empty statement. Adefaultarm is marked as the switch default.- Specified by:
visitSwitchBlockStatementExpressionGroupin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchBlockStatementExpressionGroupin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSwitchExpressionLabel
Returns the label descriptor fromswitchExpressionLabel: thecaseordefaultkeyword, the label expressions, and the colon or arrow separator.A pattern label is visited as a pattern expression and must use the arrow form. A colon label that is a zero-argument call, or a list or map literal that is not pattern-shaped, is rebuilt as that legacy expression; a
whenguard on such a list or map is rejected. A plaincaseuses the expression list, anddefaultuses an empty expression.- Specified by:
visitSwitchExpressionLabelin interfaceGroovyParserVisitor<Object>- Overrides:
visitSwitchExpressionLabelin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeDeclaration
Returns theClassNodefor a class, interface, trait, enum, record, or annotation declaration. The class-or-interface modifiers are stored on the class-declaration context before it is visited, and the result is positioned onctx. Any other type declaration is rejected.- Specified by:
visitTypeDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassDeclaration
Builds theClassNodefor a class, interface, trait, enum, record, or annotation, positioned onctx. An enum is built withEnumHelper, including a nested enum. A nested non-enum type is anInnerClassNode. A top-level non-enum type uses the package plus the identifier.var, andvalwhen that spelling is enabled, are rejected as type names.Annotation, enum, interface, and record declarations reject the clauses and modifiers the grammar still allows them to carry (type parameters,
extends,implements,sealed,non-sealed, or a header that is not a record header).sealedtogether withnon-sealedorfinalis rejected, andpermitsis rejected on a type that is not sealed.The synthetic-public bit is stripped from the modifiers and recorded with
setSyntheticPublic. Generics are applied. Sealed, non-sealed, trait, and record markers are added as annotations, along with the annotations carried by the modifiers. A sealed type's permitted subclasses are a list of class expressions when apermitsclause is present. Classes and traits take a single superclass and their interfaces. Interfaces and annotations receive the interface and abstract modifiers (and static when nested) and their mixin list is cleared; an annotation also receives the annotation modifier and the annotation interface. Records turn the header into properties.The class is pushed while its body is visited. A record is then rejected if it still has an instance field that the header did not generate, or an instance initializer. A top-level class, followed by its inner classes, is appended to the module's class list. Groovydoc is attached, and the class node is returned.
- Specified by:
visitClassDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassBody
Attaches the enum constants and class-body declarations to the class node stored onctx, passing that node down in node metadata. Returnsnull; the members are recorded on the class as a side effect.- Specified by:
visitClassBodyin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassBodyin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnumConstants
Returns theFieldNodes of the enum constants. The enclosing class node is copied onto each constant context before it is visited.- Specified by:
visitEnumConstantsin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnumConstantsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnumConstant
Builds the enum-constantFieldNodeand adds it to the enum class. An anonymous body is visited with the enum as its superclass and becomes part of the constant's initializer. Annotations and groovydoc are attached, and the field is positioned onctx.- Specified by:
visitEnumConstantin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnumConstantin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassBodyDeclaration
Adds one class-body member and returnsnull. A member declaration is visited with the enclosing class node. Astaticblock is added as a static initializer; an instance block is added as an object initializer wrapped in a block statement.- Specified by:
visitClassBodyDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassBodyDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMemberDeclaration
Dispatches one member and returnsnull. A method, field, or compact constructor is visited with the enclosing class node; the compact constructor also receives the member's modifiers. A nested type declaration receives those modifiers and is positioned onctx.- Specified by:
visitMemberDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitMemberDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeParameters
Returns the declaredGenericsTypes. An absent context yieldsnullrather than an empty array; otherwise each type parameter is visited.- Specified by:
visitTypeParametersin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeParametersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeParameter
Builds oneGenericsType. The parameter's class node carries the annotations written on the name, and its bounds are the types fromvisitTypeBound. The generics type is positioned onctx.- Specified by:
visitTypeParameterin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeParameterin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeBound
Returns the upper-boundClassNodes of a type parameter. An absent context yieldsnull; otherwise each bound type is visited.- Specified by:
visitTypeBoundin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeBoundin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFieldDeclaration
Adds the variable declaration as a field or property of the enclosing class and returnsnull. The class node is stored on the variable-declaration context beforevisitVariableDeclaration(org.apache.groovy.parser.antlr4.GroovyParser.VariableDeclarationContext)runs.- Specified by:
visitFieldDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitFieldDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCompactConstructorDeclaration
public MethodNode visitCompactConstructorDeclaration(GroovyParser.CompactConstructorDeclarationContext ctx) Stores a record's compact-constructor body as thepreclosure of itsTupleConstructorannotation and returnsnull. The declaration is rejected outside a record, when a modifier isvalorvar, or when the name differs from the record name.The body is walked, and a property expression whose receiver text is
thisand whose property names a record component is rejected. An existing tuple-constructor annotation is reused; otherwise a new one is added.- Specified by:
visitCompactConstructorDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitCompactConstructorDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMethodDeclaration
Builds theMethodNodeor constructor for a class member or a script method. The return type, parameters, and exceptions are visited, and anonymous classes created while the body is visited are given this method as their enclosing method.A declaration whose context carries a class node is added to that class, after interface parameters are checked for default values. A script declaration is public unless the private modifier is present, and the modifier manager then processes the node. Generics are set from the type parameters, synthetic-public is set from
isSyntheticPublic, and a static method marks its parameters and variable scope as static. The node is positioned onctx, validated, and given groovydoc.- Specified by:
visitMethodDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitMethodDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMethodName
Returns the method name. An identifier is visited as an identifier, and a string literal contributes its parsed text. Any other form is rejected.- Specified by:
visitMethodNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitMethodNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitReturnType
Returns the method's returnClassNode. An absent context yields the dynamic type. A type is visited as a type.voidis a plain void node positioned on the keyword, and is rejected for an annotation element. Any other form is rejected.- Specified by:
visitReturnTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitReturnTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMethodBody
Returns the method bodyStatement. An absent context yieldsnull; otherwise the block is visited and positioned onctx.- Specified by:
visitMethodBodyin interfaceGroovyParserVisitor<Object>- Overrides:
visitMethodBodyin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLocalVariableDeclaration
public org.apache.groovy.parser.antlr4.AstBuilder.DeclarationListStatement visitLocalVariableDeclaration(GroovyParser.LocalVariableDeclarationContext ctx) Returns the declaration-list statement fromvisitVariableDeclaration(org.apache.groovy.parser.antlr4.GroovyParser.VariableDeclarationContext), positioned onctx.- Specified by:
visitLocalVariableDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitLocalVariableDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableDeclaration
public org.apache.groovy.parser.antlr4.AstBuilder.DeclarationListStatement visitVariableDeclaration(GroovyParser.VariableDeclarationContext ctx) Returns a declaration-list statement for a local declaration, ornullwhen the declaration is a field or property of a class. Modifiers are collected first. A parenthesized type-name or keyed list is a multi-assignment declaration.Otherwise the shared variable type is stored on the declarator list and each declarator is visited. For a class, the resulting declarations are added as fields or properties. For a local declaration, modifiers and annotations are applied to each variable, the single-declarator form is positioned on
ctx, and the first of several declarators has its start moved to the start ofctx.- Specified by:
visitVariableDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeNamePairs
Returns the targetExpressions of a multi-assignment. Keyed pairs are visited as keyed pairs. Otherwise each type-name pair is visited, and a second rest binding (*) is rejected.- Specified by:
visitTypeNamePairsin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeNamePairsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeNamePair
Builds theVariableExpressionfor one multi-assignment target, positioned onctx.def,val, andvarproduce the dynamic type; a written type is visited.valadds the final modifier. A*marks the variable as a rest binding.- Specified by:
visitTypeNamePairin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeNamePairin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitKeyedPair
Builds theVariableExpressionfor a map-style multi-assignment target (key: name), positioned onctx.def,val, andvarproduce the dynamic type; a written type is visited.valadds the final modifier, and the key identifier is stored as the map-key metadata.- Specified by:
visitKeyedPairin interfaceGroovyParserVisitor<Object>- Overrides:
visitKeyedPairin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableDeclarators
public List<DeclarationExpression> visitVariableDeclarators(GroovyParser.VariableDeclaratorsContext ctx) Returns oneDeclarationExpressionper declarator. The shared variable type stored onctxis copied onto each declarator before it is visited.- Specified by:
visitVariableDeclaratorsin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableDeclaratorsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableDeclarator
Builds aDeclarationExpressionpositioned onctx. The variable's name and the shared type make aVariableExpressionpositioned on the declarator id. The operator is the written=, or a synthetic assign token when no initializer is written. The right side isvisitVariableInitializer(org.apache.groovy.parser.antlr4.GroovyParser.VariableInitializerContext).- Specified by:
visitVariableDeclaratorin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableDeclaratorin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableInitializer
Returns the initializerExpression. An absent context yieldsEmptyExpression.INSTANCE; otherwise the enhanced statement expression is visited and positioned onctx.- Specified by:
visitVariableInitializerin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableInitializerin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBlock
Returns the blockStatement. An absent context yields an empty block; otherwisevisitBlockStatementsOpt(org.apache.groovy.parser.antlr4.GroovyParser.BlockStatementsOptContext)is positioned onctx.- Specified by:
visitBlockin interfaceGroovyParserVisitor<Object>- Overrides:
visitBlockin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCommandExprAlt
Returns anExpressionStatementfor a command expression, positioned onctx. ASwitchExpressionthat is the whole statement and either has an incomplete arrow arm or whose value is unused is rewritten to aSwitchStatementfirst, so statement position does not produce a value.- Specified by:
visitCommandExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitCommandExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCommandExpression
Builds theExpressionfor a command expression. A command chain inside an array initializer is rejected. A cast of the identifierinorasfollowed only by an argument list is rewritten byrepairBinaryKeywordCastwhen that rewrite succeeds; otherwise the cast is kept and a resolve hint is attached.A binary base that is not a subscript and not parenthesized is rejected. When that binary is
<between two type-like operands and an argument list follows, the error is a missing>anchored on the argument list.An argument list turns a property into a method call, keeps an existing method call, turns a variable, a gstring, or a string constant into a method call after rejecting a call that looks like a method definition, and otherwise calls
call. The call is marked as a command expression. Further command arguments are folded byvisitCommandArgument(org.apache.groovy.parser.antlr4.GroovyParser.CommandArgumentContext), each receiving the expression so far as its base.- Specified by:
visitCommandExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitCommandExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCommandArgument
Builds the nextExpressionof a command chain from the base expression stored onctx.An argument list becomes a
MethodCallExpressionwith implicitthisturned off, using the primary as the method name. A property-expression base in that form is rejected. A path element becomes a property of the base, then the remaining path. Otherwise the result is aPropertyExpression, and a variable primary is turned into a constant name.- Specified by:
visitCommandArgumentin interfaceGroovyParserVisitor<Object>- Overrides:
visitCommandArgumentin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCastParExpression
Returns the cast or coercionClassNodeby delegating tovisitIntersectionType(org.apache.groovy.parser.antlr4.GroovyParser.IntersectionTypeContext).- Specified by:
visitCastParExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitCastParExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIntersectionType
Returns the cast type. A single component is that type unchanged. Several components become anIntersectionTypeClassNodepositioned onctx, and a repeated component name is rejected.- Specified by:
visitIntersectionTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitIntersectionTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCoercionType
Returns the coercionClassNode. A parenthesized cast type is visited as a cast; otherwise the type is visited directly.- Specified by:
visitCoercionTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitCoercionTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitParExpression
Returns the parenthesizedExpression, positioned on the parentheses. The inside-parentheses level stored on the inner expression is incremented first.- Specified by:
visitParExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitParExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitExpressionInPar
Returns theExpressioninside parentheses by delegating tovisitEnhancedStatementExpression(org.apache.groovy.parser.antlr4.GroovyParser.EnhancedStatementExpressionContext). This method does not itself set a source position.- Specified by:
visitExpressionInParin interfaceGroovyParserVisitor<Object>- Overrides:
visitExpressionInParin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnhancedExpression
Returns anExpressionpositioned onctx. An expression child is visited as an expression, and a lambda is visited as a lambda. Any other form is rejected.- Specified by:
visitEnhancedExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnhancedExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnhancedStatementExpression
public Expression visitEnhancedStatementExpression(GroovyParser.EnhancedStatementExpressionContext ctx) Returns anExpressionpositioned onctx. A statement expression is visited and unwrapped from itsExpressionStatement. A lambda is visited as a lambda. Any other form is rejected.- Specified by:
visitEnhancedStatementExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnhancedStatementExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPathExpression
Returns the pathExpression. The keywordstaticbecomes aVariableExpressionof that text; otherwise the primary is visited.createPathExpressionthen folds each path element, threading the expression so far and copying a safe-chain flag forward.- Specified by:
visitPathExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitPathExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPathElement
Builds one step of a pathExpressionfrom the base expression stored onctx.A name part with
.,?., or??.becomes anAttributeExpressionwhen@is present and aPropertyExpressionotherwise. Safe-chain (??.) also marks the result so a later element stays safe..&is aMethodPointerExpression,::is aMethodReferenceExpression, and a spread dot sets the spread-safe flag. A creator is visited with the base as its enclosing instance and with any explicit type arguments stored for the constructor.An index becomes a subscript
BinaryExpression, safe when the base is a safe chain or the index itself is safe. A named bracket argument becomes a subscript whose right side is an empty spread map, a single spread-map key, or a wrapped list of entries. An argument list on a property becomes a method call of that property. A parenthesized base, an attribute,void, or any other base that is not a name callscall; an attribute call clears spread-safe and uses implicitthis. A primitive type name is rejected.thisorsuperis a constructor call unless it is inside a closure, where it stays a method call. A variable, gstring, or string constant is a method call of that name. A trailing closure is appended to an existing argument list, or starts a call, and named arguments are rewritten as a map expression plus that closure.- Specified by:
visitPathElementin interfaceGroovyParserVisitor<Object>- Overrides:
visitPathElementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNonWildcardTypeArguments
public GenericsType[] visitNonWildcardTypeArguments(GroovyParser.NonWildcardTypeArgumentsContext ctx) Returns the explicit type arguments asGenericsTypes. An absent context yieldsnull; otherwise each type in the list is wrapped as a generics type.- Specified by:
visitNonWildcardTypeArgumentsin interfaceGroovyParserVisitor<Object>- Overrides:
visitNonWildcardTypeArgumentsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeList
Returns theClassNodes of a type list. An absent context yieldsClassNode.EMPTY_ARRAY; otherwise each type is visited.- Specified by:
visitTypeListin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitArguments
Returns the argumentExpression. A comma with no argument is rejected. An absent context yields an unpositioned emptyArgumentListExpression. An empty()yields an empty argument list positioned onctx. Otherwise the enhanced argument list is visited and positioned onctx.- Specified by:
visitArgumentsin interfaceGroovyParserVisitor<Object>- Overrides:
visitArgumentsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnhancedArgumentListInPar
Returns the argumentExpression, ornullwhenctxis absent. Positional arguments become anArgumentListExpression. Named arguments alone become aTupleExpressionholding aNamedArgumentListExpression. A mix becomes an argument list whose first expression is aMapExpressionof the named arguments. A duplicated named argument is rejected unless its key is parenthesized.- Specified by:
visitEnhancedArgumentListInParin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnhancedArgumentListInParin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEnhancedArgumentListElement
public Expression visitEnhancedArgumentListElement(GroovyParser.EnhancedArgumentListElementContext ctx) Returns one argumentExpression, positioned onctx: an expression-list element, a lambda, or a map entry. Any other form is rejected.- Specified by:
visitEnhancedArgumentListElementin interfaceGroovyParserVisitor<Object>- Overrides:
visitEnhancedArgumentListElementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitStringLiteral
Returns aConstantExpressionfor the parsed string contents, marked as a string and positioned onctx. Quotation marks are stripped, multiline text loses carriage returns, and escapes are decoded for the literal's slashy kind.- Specified by:
visitStringLiteralin interfaceGroovyParserVisitor<Object>- Overrides:
visitStringLiteralin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIndexPropertyArgs
public Tuple2<org.antlr.v4.runtime.Token,Expression> visitIndexPropertyArgs(GroovyParser.IndexPropertyArgsContext ctx) Returns the index token (the bracket or the safe-index symbol) paired with the indexExpression. One element is that expression, unless it is a spread, in which case it is an unwrapped one-element list. Several elements become a wrappedListExpressionpositioned onctx.- Specified by:
visitIndexPropertyArgsin interfaceGroovyParserVisitor<Object>- Overrides:
visitIndexPropertyArgsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNamedPropertyArgs
Returns theMapEntryExpressions of a named bracket argument by delegating tovisitMapEntryList(org.apache.groovy.parser.antlr4.GroovyParser.MapEntryListContext).- Specified by:
visitNamedPropertyArgsin interfaceGroovyParserVisitor<Object>- Overrides:
visitNamedPropertyArgsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNamePart
Returns the nameExpression, positioned onctx. An identifier or a keyword becomes aConstantExpressionof its text, a string literal is parsed as a string, and a dynamic member name is visited as one. Any other form is rejected.- Specified by:
visitNamePartin interfaceGroovyParserVisitor<Object>- Overrides:
visitNamePartin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitDynamicMemberName
Returns the dynamic memberExpression, positioned onctx: a parenthesized expression or a gstring. Any other form is rejected.- Specified by:
visitDynamicMemberNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitDynamicMemberNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPostfixExpression
Returns the pathExpression, or aPostfixExpressionwhen an operator is present. Inside an assertion the postfix node is positioned on the operator token; otherwise it is positioned onctx.- Specified by:
visitPostfixExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitPostfixExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitUnaryNotExprAlt
Builds aNotExpressionfor!or aBitwiseNegationExpressionfor~, positioned onctx. When the operand is a repaired parenthesized-name+or-that is not itself parenthesized, only that binary's leading operand is wrapped and the binary is returned.- Specified by:
visitUnaryNotExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitUnaryNotExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCastExprAlt
Builds the castExpression, including the parenthesized-name repairs. A bare name whose final segment does not start with an uppercase letter, followed by unary+or-, becomes a binary expression marked as a repaired parenthesized-name binary. A bare name followed byinand a list or map subscript is rebuilt as a binaryinwhen that shape matches.superas the operand is rejected. An operand that is the identifierinorasbecomes aCastExpressionmarked so the command-expression visitor can restore the binary reading. A repaired parenthesized-name binary is cast on its leading operand only. Any other operand becomes aCastExpression, and an ambiguous operand (a unary sign, a prefix, a list, a map, a closure, a method call, or a parenthesized expression) stores a resolve hint on the cast.- Specified by:
visitCastExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitCastExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAwaitExprAlt
Returns the expression produced byAsyncTransformHelper.buildAwaitCallfor an unparenthesizedawait, positioned onctx.- Specified by:
visitAwaitExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAwaitExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
- See Also:
-
createAwaitCall(List, GroovyParserRuleContext)
-
visitAwaitPrmrAlt
Returns the expression produced byAsyncTransformHelper.buildAwaitCallfor a parenthesizedawait, positioned onctx. As a primary, a following method call, property or index applies to the awaited value.- Specified by:
visitAwaitPrmrAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAwaitPrmrAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
- See Also:
-
createAwaitCall(List, GroovyParserRuleContext)
-
visitAsyncClosureExprAlt
Returns the expression produced byAsyncTransformHelper.transformAsyncClosure, positioned onctx.nextClosureIsAsyncis set before the closure or lambda is visited, so that visit records the closure as the body of anasyncexpression.- Specified by:
visitAsyncClosureExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAsyncClosureExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPowerExprAlt
Builds a powerBinaryExpression(**). The operands go throughcreateBinaryExpression, which reassociates a repaired parenthesized-name+or-so the textual left-to-right grouping is kept. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitPowerExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitPowerExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitUnaryAddExprAlt
Builds the unaryExpressionfor+,-,++, or--. When the operand is a repaired parenthesized-name+or-that is not itself parenthesized, only that binary's leading operand is wrapped.Unary
+on a non-string constant that is not parenthesized returns that constant, positioned onctx, instead of aUnaryPlusExpression. Unary-on such a constant parses the negated integer or decimal text, clearsnumberFormatErrorwhen that parse succeeds, and returns the resulting constant; a missing original literal text is a failure.++and--are aPrefixExpression.- Specified by:
visitUnaryAddExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitUnaryAddExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMultiplicativeExprAlt
Builds a multiplicativeBinaryExpression(*,/, or%). The operands go throughcreateBinaryExpression, which reassociates a repaired parenthesized-name+or-so the textual left-to-right grouping is kept. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitMultiplicativeExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitMultiplicativeExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAdditiveExprAlt
Builds an additiveBinaryExpression(+or-). The operands go throughcreateBinaryExpression, which reassociates a repaired parenthesized-name+or-so the textual left-to-right grouping is kept. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitAdditiveExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAdditiveExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitShiftExprAlt
Builds a shift or rangeExpression. A range operator becomes aRangeExpressionwhose left endpoint is exclusive when the operator text starts with<and whose right endpoint is exclusive when it ends with<.<<,>>, and>>>become aBinaryExpressionwhose operator text is the bracket repeated two or three times. When the expression is marked as inside a conditional, that binary is positioned on the operator token; otherwise it is positioned onctx.- Specified by:
visitShiftExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitShiftExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitRelationalExprAlt
Builds the relationalExpression.asis a coercion, and coercingsuperis rejected.instanceofis aBinaryExpressionwhose right side comes fromvisitMatchingType(org.apache.groovy.parser.antlr4.GroovyParser.MatchingTypeContext): a type with a binding is a declaration of that name, and a plain type is a class expression. The type context is marked as insideinstanceofbefore it is visited.!instanceofof a matching type is also a binary expression, with the same right-hand side rules.!instanceofof a parenthesized intersection is rejected, and a parenthesized type is marked as insideinstanceofbefore it is visited and used as a class expression. Comparisons andin/!inare binary expressions built like the other arithmetic operators, including the conditional source-position rule.- Specified by:
visitRelationalExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitRelationalExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitEqualityExprAlt
Builds an equalityBinaryExpression(==,!=,===,!==, or<=>). The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. The source position is the whole context.- Specified by:
visitEqualityExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitEqualityExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitRegexExprAlt
Builds a regexBinaryExpression(=~or==~). The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. The source position is the whole context.- Specified by:
visitRegexExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitRegexExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAndExprAlt
Builds a bitwiseBinaryExpressionfor&. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitAndExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAndExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitExclusiveOrExprAlt
Builds a bitwiseBinaryExpressionfor^. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitExclusiveOrExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitExclusiveOrExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitInclusiveOrExprAlt
Builds a bitwiseBinaryExpressionfor|. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. When the expression is marked as inside a conditional, the node is positioned on the operator token; otherwise the position is the whole context.- Specified by:
visitInclusiveOrExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitInclusiveOrExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLogicalAndExprAlt
Builds a logicalBinaryExpressionfor&&. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. The source position is the whole context.- Specified by:
visitLogicalAndExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitLogicalAndExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLogicalOrExprAlt
Builds a logicalBinaryExpressionfor||. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. The source position is the whole context.- Specified by:
visitLogicalOrExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitLogicalOrExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitImplicationExprAlt
Builds an implicationBinaryExpressionfor==>. The operands are combined bycreateBinaryExpression. No regrouping applies to this operator. The source position is the whole context.- Specified by:
visitImplicationExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitImplicationExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitConditionalExprAlt
Builds a conditionalExpression.?:becomes anElvisOperatorExpression. The false branch is marked as inside a conditional before it is visited.A
? :expression is aTernaryExpressionwhose condition is aBooleanExpression. Both the true and false branches are marked as inside a conditional before they are visited, which makes a shift or arithmetic operator inside them take the operator's source position.- Specified by:
visitConditionalExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitConditionalExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMultipleAssignmentExprAlt
public BinaryExpression visitMultipleAssignmentExprAlt(GroovyParser.MultipleAssignmentExprAltContext ctx) Builds a multiple-assignmentBinaryExpressionpositioned onctx. The left side is the tuple fromvisitVariableNames(org.apache.groovy.parser.antlr4.GroovyParser.VariableNamesContext). The right side is visited as a statement and unwrapped to its expression.- Specified by:
visitMultipleAssignmentExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitMultipleAssignmentExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAssignmentExprAlt
Builds an assignmentBinaryExpressionpositioned onctx. A built-in type name on the left is rejected. A variable wrapped in exactly one set of parentheses becomes a one-elementTupleExpression; deeper parentheses are rejected.Any other left side must be a variable that is not parenthesized, a property, or an index expression. The right side is the visited expression.
- Specified by:
visitAssignmentExprAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitAssignmentExprAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIdentifierPrmrAlt
Returns a primaryExpressionpositioned onctx. With type arguments the identifier is aClassExpressionwhose generics are those arguments. Without them it is aVariableExpressionof the identifier.- Specified by:
visitIdentifierPrmrAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitIdentifierPrmrAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNewPrmrAlt
Returns the creatorExpression, positioned onctx. Explicit constructor type arguments, when present, are stored on the creator context beforevisitCreator(org.apache.groovy.parser.antlr4.GroovyParser.CreatorContext)runs.- Specified by:
visitNewPrmrAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitNewPrmrAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitThisPrmrAlt
Returns aVariableExpressionof thethiskeyword, positioned onctx. Explicit type arguments, when present, are stored on that variable for a later constructor call.- Specified by:
visitThisPrmrAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitThisPrmrAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSuperPrmrAlt
Returns aVariableExpressionof thesuperkeyword, positioned onctx. Explicit type arguments, when present, are stored on that variable for a later constructor call.- Specified by:
visitSuperPrmrAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitSuperPrmrAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCreator
Builds a creationExpressionpositioned onctx. With arguments, the result is aConstructorCallExpression. An enclosing instance is inserted as the first positional argument and is rejected for named arguments. When that instance is itself a constructor call and the created name contains no dot, the created name is prefixed with the instance's type name. An anonymous body is visited with the created type as its superclass, recorded when the creation is inside a method, and the call is marked as using an anonymous inner class. Constructor type arguments stored onctxare set on the call.A sized array is an
ArrayExpressionof the given sizes, with an empty expression for each unsized dimension, and dimension annotations are applied from the array type down through its array components. An initializer form wraps the element type for the inner dimensions, visits the initializer with that element type, and puts the outermost dimension's annotations on the expression's array type.- Specified by:
visitCreatorin interfaceGroovyParserVisitor<Object>- Overrides:
visitCreatorin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCreatedName
Returns the createdClassNode, with the type annotations fromctxadded. A primitive name is visited as a primitive. Any other name is the parameterized class type fromvisitParameterizedClassType(type arguments or a diamond, without forcing a raw enclosing type). An unrecognised name is rejected.- Specified by:
visitCreatedNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitCreatedNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAnonymousInnerClassDeclaration
public InnerClassNode visitAnonymousInnerClassDeclaration(GroovyParser.AnonymousInnerClassDeclarationContext ctx) Builds the anonymousInnerClassNode. The superclass is the node stored onctx, and the outer class is the class being built or, at the top level, the script class dummy. The generated name is the outer name plus the next anonymous index.An enum-constant body (
ctx.tof1) is anEnumConstantClassNode; any other body is anInnerClassNodeof the superclass. The class is anonymous, does not use generics, and is pushed while its body is visited. When that leaves the class stack empty, the anonymous class is appended to the module's class list.- Specified by:
visitAnonymousInnerClassDeclarationin interfaceGroovyParserVisitor<Object>- Overrides:
visitAnonymousInnerClassDeclarationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitArrayInitializer
Returns the initializerExpressions. An absent context yields an empty list.visitingArrayInitializerCountis raised for the walk, so a command chain inside the initializer is rejected, and lowered afterwards.A nested initializer becomes an
ArrayExpressionof the component type, and that expression's type is then set to the enclosing element type. A variable-initializer child is visited as one; other children are skipped.- Specified by:
visitArrayInitializerin interfaceGroovyParserVisitor<Object>- Overrides:
visitArrayInitializerin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMap
Builds aMapExpressionfromvisitMapEntryList(org.apache.groovy.parser.antlr4.GroovyParser.MapEntryListContext), positioned onctx.- Specified by:
visitMapin interfaceGroovyParserVisitor<Object>- Overrides:
visitMapin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMapEntryList
Returns theMapEntryExpressions. An absent context yields an empty list; otherwise each map entry is visited.- Specified by:
visitMapEntryListin interfaceGroovyParserVisitor<Object>- Overrides:
visitMapEntryListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMapEntry
Builds aMapEntryExpressionpositioned onctx. A*key is aSpreadMapExpressionof the value. Otherwise the key isvisitMapEntryLabel(org.apache.groovy.parser.antlr4.GroovyParser.MapEntryLabelContext)and the value is the enhanced expression.- Specified by:
visitMapEntryin interfaceGroovyParserVisitor<Object>- Overrides:
visitMapEntryin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMapEntryLabel
Returns the keyExpression, positioned onctx. A keyword is a constant of its text. A primary is visited, and aVariableExpressionthat is not parenthesized is replaced by aConstantExpressionof its name, so a bare map key is a constant.- Specified by:
visitMapEntryLabelin interfaceGroovyParserVisitor<Object>- Overrides:
visitMapEntryLabelin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitKeywords
Returns aConstantExpressionof the keyword text, positioned onctx.- Specified by:
visitKeywordsin interfaceGroovyParserVisitor<Object>- Overrides:
visitKeywordsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBuiltInType
Returns aVariableExpressionofvoidor a built-in primitive, marked as a built-in type and positioned onctx. Any other form is rejected.- Specified by:
visitBuiltInTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitBuiltInTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitList
Builds aListExpressionfrom the expression list, positioned onctx. A comma in an otherwise empty list is rejected.- Specified by:
visitListin interfaceGroovyParserVisitor<Object>- Overrides:
visitListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitExpressionList
Returns the list'sExpressions. An absent context yields an empty list; otherwise each element is visited.- Specified by:
visitExpressionListin interfaceGroovyParserVisitor<Object>- Overrides:
visitExpressionListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitExpressionListElement
Returns one listExpression, positioned onctx. A command call with implicitthiswhose name is a primitive or starts with an uppercase letter is rejected as a method declaration. A*wraps the expression in aSpreadExpressionwhen spreading is allowed here, and is rejected otherwise.- Specified by:
visitExpressionListElementin interfaceGroovyParserVisitor<Object>- Overrides:
visitExpressionListElementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIntegerLiteralAlt
Returns a numericConstantExpressionfor the integer literal, remembering the original text. A parse failure is stored innumberFormatErrorand the constant's value is left null; the failure is reported later from the compilation unit. The constant is positioned onctx.- Specified by:
visitIntegerLiteralAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitIntegerLiteralAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFloatingPointLiteralAlt
public ConstantExpression visitFloatingPointLiteralAlt(GroovyParser.FloatingPointLiteralAltContext ctx) Returns a numericConstantExpressionfor the floating-point literal, remembering the original text. A parse failure is stored innumberFormatErrorand the constant's value is left null; the failure is reported later from the compilation unit. The constant is positioned onctx.- Specified by:
visitFloatingPointLiteralAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitFloatingPointLiteralAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBooleanLiteralAlt
- Specified by:
visitBooleanLiteralAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitBooleanLiteralAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNullLiteralAlt
Returns aConstantExpressionwhose value is null, positioned onctx.- Specified by:
visitNullLiteralAltin interfaceGroovyParserVisitor<Object>- Overrides:
visitNullLiteralAltin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitGstring
Builds aGStringExpressionpositioned onctx. The begin, each part, and the end are parsed as string constants by restoring the opening quotation around each fragment. The values are the visited gstring values.The verbatim text interleaves those strings and values. A variable value is appended as
$name; any other value is appended inside braces after$. An empty value is skipped.- Specified by:
visitGstringin interfaceGroovyParserVisitor<Object>- Overrides:
visitGstringin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitGstringValue
Returns one gstring valueExpression. A path is visited as a gstring path.A closure with no arrow contributes its single expression when the body is one expression statement that is not a declaration, a null constant when the body is empty, and otherwise a
callof the closure with implicitthis. A closure that has an arrow is returned as the closure.- Specified by:
visitGstringValuein interfaceGroovyParserVisitor<Object>- Overrides:
visitGstringValuein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitGstringPath
Returns theExpressionfor a$nameor$name.proppath, positioned onctx. The identifier is aVariableExpression. Each following path part, with its leading character removed, becomes a constant property folded onto that variable.- Specified by:
visitGstringPathin interfaceGroovyParserVisitor<Object>- Overrides:
visitGstringPathin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitStandardLambdaExpression
public LambdaExpression visitStandardLambdaExpression(GroovyParser.StandardLambdaExpressionContext ctx) Builds aLambdaExpressionpositioned onctx. The lambda is pushed as a switch and closure frame, andnextClosureIsAsyncis recorded on that frame and then cleared, so a nested closure is not itself async. Both frames are popped when the visit finishes.- Specified by:
visitStandardLambdaExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitStandardLambdaExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitStandardLambdaParameters
Returns the lambda'sParameters. A single variable name becomes one dynamic-typed parameter positioned on that name. A formal parameter list is visited, and an empty list is returned asnullrather than an empty array.- Specified by:
visitStandardLambdaParametersin interfaceGroovyParserVisitor<Object>- Overrides:
visitStandardLambdaParametersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitLambdaBody
Returns the lambda bodyStatement, positioned onctx. A block is visited as a block; otherwise the statement expression is visited as a statement and is not unwrapped.- Specified by:
visitLambdaBodyin interfaceGroovyParserVisitor<Object>- Overrides:
visitLambdaBodyin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClosure
Builds aClosureExpressionpositioned onctx. The closure is pushed as a switch and closure frame,nextClosureIsAsyncis recorded on that frame and then cleared, andvisitingClosureCountis raised sothisandsupercalls inside stay method calls. All three are restored when the visit finishes.Parameters come from the formal parameter list. Without an arrow they are replaced by
Parameter.EMPTY_ARRAY, and an empty body is positioned onctx.- Specified by:
visitClosurein interfaceGroovyParserVisitor<Object>- Overrides:
visitClosurein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFormalParameters
Returns theParameters. An absent context yieldsParameter.EMPTY_ARRAY; otherwise the formal parameter list is visited.- Specified by:
visitFormalParametersin interfaceGroovyParserVisitor<Object>- Overrides:
visitFormalParametersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFormalParameterList
Returns theParameters. An absent context yieldsParameter.EMPTY_ARRAY. A receiver (this) parameter is first when present, then each formal parameter. A var-arg parameter that is not last is rejected, and a duplicated name is rejected; the name_is not compared.- Specified by:
visitFormalParameterListin interfaceGroovyParserVisitor<Object>- Overrides:
visitFormalParameterListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFormalParameter
Returns oneParameterby delegating toprocessFormalParameter. The type is visited, a var-arg type becomes an array type, modifiers are applied, and a default expression is set when present. The parameter and its modifier manager are kept in the builder's parameter maps rather than on the parameter.- Specified by:
visitFormalParameterin interfaceGroovyParserVisitor<Object>- Overrides:
visitFormalParameterin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitThisFormalParameter
Returns the receiverParameter: the visited type with the namethis, positioned onctx. Modifiers and a default value are not applied.- Specified by:
visitThisFormalParameterin interfaceGroovyParserVisitor<Object>- Overrides:
visitThisFormalParameterin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassOrInterfaceModifiersOpt
public List<ModifierNode> visitClassOrInterfaceModifiersOpt(GroovyParser.ClassOrInterfaceModifiersOptContext ctx) Returns the class or interfaceModifierNodes. When none are written the result is an empty list; otherwise each modifier is visited.- Specified by:
visitClassOrInterfaceModifiersOptin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassOrInterfaceModifiersOptin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassOrInterfaceModifiers
public List<ModifierNode> visitClassOrInterfaceModifiers(GroovyParser.ClassOrInterfaceModifiersContext ctx) Returns every class or interfaceModifierNode, in source order.- Specified by:
visitClassOrInterfaceModifiersin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassOrInterfaceModifiersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassOrInterfaceModifier
Returns one class or interfaceModifierNode, positioned onctx. An annotation modifier carries the visited annotation node. A keyword modifier carries the keyword's token type and text. Any other form is rejected.- Specified by:
visitClassOrInterfaceModifierin interfaceGroovyParserVisitor<Object>- Overrides:
visitClassOrInterfaceModifierin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitModifier
Returns oneModifierNode, positioned onctx. A class or interface modifier is visited as one. A keyword modifier carries the keyword's token type and text. Any other form is rejected.- Specified by:
visitModifierin interfaceGroovyParserVisitor<Object>- Overrides:
visitModifierin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitModifiers
Returns everyModifierNode, in source order.- Specified by:
visitModifiersin interfaceGroovyParserVisitor<Object>- Overrides:
visitModifiersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitModifiersOpt
Returns theModifierNodes. When none are written the result is an empty list; otherwisevisitModifiers(org.apache.groovy.parser.antlr4.GroovyParser.ModifiersContext)is used.- Specified by:
visitModifiersOptin interfaceGroovyParserVisitor<Object>- Overrides:
visitModifiersOptin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableModifier
Returns one variableModifierNode, positioned onctx. An annotation modifier carries the visited annotation node. A keyword modifier carries the keyword's token type and text. Any other form is rejected.- Specified by:
visitVariableModifierin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableModifierin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableModifiersOpt
Returns the variableModifierNodes. When none are written the result is an empty list; otherwise each modifier is visited.- Specified by:
visitVariableModifiersOptin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableModifiersOptin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableModifiers
Returns every variableModifierNode, in source order.- Specified by:
visitVariableModifiersin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableModifiersin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitType
Returns theClassNodefor a type. An absent context yields the dynamic type, andvoidis rejected. A primitive or a reference type is visited, type annotations are added, and each array dimension wraps the type and contributes its annotations.When the type is inside
instanceof, that flag is copied onto the reference type and a non-reifiable result is rejected. The node is positioned onctx.- Specified by:
visitTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPrimitiveType
- Specified by:
visitPrimitiveTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitPrimitiveTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitReferenceType
Returns the referenceClassNodefromvisitParameterizedClassType, positioned onctx. A raw enclosing type is recorded when type arguments follow a qualified name.- Specified by:
visitReferenceTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitReferenceTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeArgumentsOrDiamond
Returns theGenericsTypes of a type-argument list or a diamond. Written arguments are visited. A diamond (<>) yieldsGenericsType.EMPTY_ARRAY. Any other form is rejected.- Specified by:
visitTypeArgumentsOrDiamondin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeArgumentsOrDiamondin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeArguments
Returns oneGenericsTypeper type argument, in source order.- Specified by:
visitTypeArgumentsin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeArgumentsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTypeArgument
Builds oneGenericsTypepositioned onctx. A?is a wildcard whose base type carries the annotations written on the question mark;extendssets the upper bound andsupersets the lower bound. A plain type is wrapped as a non-wildcard generics type. Any other form is rejected.- Specified by:
visitTypeArgumentin interfaceGroovyParserVisitor<Object>- Overrides:
visitTypeArgumentin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitMatchingType
Returns aClassExpressionfor the plain type on the right ofinstanceof, positioned onctx. When the context is marked as insideinstanceof, that flag is copied onto the type before it is visited. A pattern on the right is built elsewhere.- Specified by:
visitMatchingTypein interfaceGroovyParserVisitor<Object>- Overrides:
visitMatchingTypein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableDeclaratorId
Returns aVariableExpressionof the identifier, positioned onctx. A built-in type name used as the identifier is rejected.- Specified by:
visitVariableDeclaratorIdin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableDeclaratorIdin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariableNames
Builds aTupleExpressionof the variable names, positioned onctx. Each name is aVariableExpressionfromvisitVariableDeclaratorId(org.apache.groovy.parser.antlr4.GroovyParser.VariableDeclaratorIdContext).- Specified by:
visitVariableNamesin interfaceGroovyParserVisitor<Object>- Overrides:
visitVariableNamesin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClosureOrLambdaExpression
public ClosureExpression visitClosureOrLambdaExpression(GroovyParser.ClosureOrLambdaExpressionContext ctx) Returns aClosureExpressionpositioned onctx. A closure and a lambda are each visited by their own method; a lambda is aLambdaExpression. Any other form is rejected.- Specified by:
visitClosureOrLambdaExpressionin interfaceGroovyParserVisitor<Object>- Overrides:
visitClosureOrLambdaExpressionin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBlockStatementsOpt
Returns aBlockStatementpositioned onctx. When statements are present they are visited; otherwise the block is empty.- Specified by:
visitBlockStatementsOptin interfaceGroovyParserVisitor<Object>- Overrides:
visitBlockStatementsOptin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBlockStatements
Builds aBlockStatementof the block's statements, positioned onctx. A statement whose visit returnsnullis dropped.- Specified by:
visitBlockStatementsin interfaceGroovyParserVisitor<Object>- Overrides:
visitBlockStatementsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitBlockStatement
Returns the nestedStatement, ornullwhen the visit returnsnull. AMethodNodeand anImportNodeare rejected, as is any other non-statement result.- Specified by:
visitBlockStatementin interfaceGroovyParserVisitor<Object>- Overrides:
visitBlockStatementin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAnnotationsOpt
Returns theAnnotationNodes. When none are written the result is an empty list; otherwise each annotation is visited.- Specified by:
visitAnnotationsOptin interfaceGroovyParserVisitor<Object>- Overrides:
visitAnnotationsOptin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAnnotation
Builds anAnnotationNodefor the annotation's class name, positioned onctx. The class node itself is positioned on the annotation name. Each element value is added as a member. A method-pointer value is rewritten to a closure that callsthis.withMethodClosurewith that pointer.- Specified by:
visitAnnotationin interfaceGroovyParserVisitor<Object>- Overrides:
visitAnnotationin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitElementValues
Returns the annotation member names paired with theirExpressions. An absent context yields an empty list. Named pairs are visited as pairs. A single unnamed value is stored under the namevalue.- Specified by:
visitElementValuesin interfaceGroovyParserVisitor<Object>- Overrides:
visitElementValuesin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAnnotationName
Returns the annotation class name by visiting the qualified class name and reading that node's name.- Specified by:
visitAnnotationNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitAnnotationNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitElementValuePairs
Returns the annotation members as a map from name toExpression, in source order. A duplicate name is rejected.- Specified by:
visitElementValuePairsin interfaceGroovyParserVisitor<Object>- Overrides:
visitElementValuePairsin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitElementValuePair
Returns the member name paired with itsExpression. The name is the pair-name text, and the value isvisitElementValue(org.apache.groovy.parser.antlr4.GroovyParser.ElementValueContext).- Specified by:
visitElementValuePairin interfaceGroovyParserVisitor<Object>- Overrides:
visitElementValuePairin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitElementValue
Returns one annotation valueExpression, positioned onctx: a visited expression, anAnnotationConstantExpressionfor a nested annotation, or the list from an array initializer. Any other form is rejected.- Specified by:
visitElementValuein interfaceGroovyParserVisitor<Object>- Overrides:
visitElementValuein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitElementValueArrayInitializer
public ListExpression visitElementValueArrayInitializer(GroovyParser.ElementValueArrayInitializerContext ctx) Builds aListExpressionof the element values, positioned onctx.- Specified by:
visitElementValueArrayInitializerin interfaceGroovyParserVisitor<Object>- Overrides:
visitElementValueArrayInitializerin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitClassName
Returns the class-name text ofctx.- Specified by:
visitClassNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitClassNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIdentifier
Returns the identifier text ofctx.- Specified by:
visitIdentifierin interfaceGroovyParserVisitor<Object>- Overrides:
visitIdentifierin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitQualifiedName
Returns the qualified name formed by joining each name element with a dot.- Specified by:
visitQualifiedNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitQualifiedNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitAnnotatedQualifiedClassName
public ClassNode visitAnnotatedQualifiedClassName(GroovyParser.AnnotatedQualifiedClassNameContext ctx) Returns theClassNodefor a qualified class name and adds the type annotations fromctx.- Specified by:
visitAnnotatedQualifiedClassNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitAnnotatedQualifiedClassNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitQualifiedClassNameList
Returns theClassNodes of an annotated qualified-name list. An absent context yieldsClassNode.EMPTY_ARRAY; otherwise each annotated name is visited.- Specified by:
visitQualifiedClassNameListin interfaceGroovyParserVisitor<Object>- Overrides:
visitQualifiedClassNameListin classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitQualifiedClassName
Returns theClassNodefor a qualified class name fromcreateClassNode. Insideinstanceofthe node is not given a redirect; otherwise a generics-using name is proxied. The node is positioned onctx.- Specified by:
visitQualifiedClassNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitQualifiedClassNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitQualifiedStandardClassName
public ClassNode visitQualifiedStandardClassName(GroovyParser.QualifiedStandardClassNameContext ctx) Returns theClassNodefor a qualified standard class name fromcreateClassNode. Insideinstanceofthe node is not given a redirect; otherwise a generics-using name is proxied. The node is positioned onctx.- Specified by:
visitQualifiedStandardClassNamein interfaceGroovyParserVisitor<Object>- Overrides:
visitQualifiedStandardClassNamein classGroovyParserBaseVisitor<Object>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visit
Visit tree safely, no NPE occurred when the tree is null. -
appendStatementsToBlockStatement
Addsstatementstobsand returns that same block. EachDeclarationListStatementis flattened into its declaration statements; every other statement is added as itself.
-