@@ -82,33 +82,31 @@ public List<Node> visitExecRule(Db2SqlParser.ExecRuleContext ctx) {
82
82
}
83
83
84
84
@ Override
85
- public List <Node > visitSql_host_variables (
86
- Db2SqlParser .Sql_host_variablesContext ctx ) {
85
+ public List <Node > visitResult_set_locator_variable (Db2SqlParser .Result_set_locator_variableContext ctx ) {
86
+ return createHostVariableDefinitionNode (ctx , ctx .dbs_level_01 (), ctx .entry_name ());
87
+ }
88
+
89
+ @ Override
90
+ public List <Node > visitTableLocators_variable (Db2SqlParser .TableLocators_variableContext ctx ) {
91
+ return createHostVariableDefinitionNode (ctx , ctx .dbs_host_var_levels (), ctx .entry_name ());
92
+ }
93
+
94
+ private List <Node > createHostVariableDefinitionNode (ParserRuleContext ctx , ParserRuleContext levelCtx , ParserRuleContext nameCtx ) {
87
95
addReplacementContext (ctx );
88
- Locality statementLocality =
89
- getLocality (this .context .getExtendedDocument ().mapLocation (constructRange (ctx )));
96
+ Locality statementLocality = getLocality (this .context .getExtendedDocument ().mapLocation (constructRange (ctx )));
90
97
91
- // semantics node just checks that the statement is present at right location
92
- Db2WorkingAndLinkageSectionNode semanticsNode =
93
- new Db2WorkingAndLinkageSectionNode (statementLocality );
98
+ Db2WorkingAndLinkageSectionNode semanticsNode = new Db2WorkingAndLinkageSectionNode (statementLocality );
99
+
100
+ VariableDefinitionNode variableDefinitionNode = VariableDefinitionNode .builder ()
101
+ .level (Integer .parseInt (levelCtx .getText ()))
102
+ .levelLocality (getLocality (this .context .getExtendedDocument ().mapLocation (constructRange (levelCtx ))))
103
+ .statementLocality (statementLocality )
104
+ .variableNameAndLocality (new VariableNameAndLocality (
105
+ VisitorHelper .getName (nameCtx ),
106
+ getLocality (this .context .getExtendedDocument ().mapLocation (constructRange (nameCtx )))))
107
+ .usageClauses (ImmutableList .of (UsageFormat .DISPLAY ))
108
+ .build ();
94
109
95
- // variable definition node
96
- VariableDefinitionNode variableDefinitionNode =
97
- VariableDefinitionNode .builder ()
98
- .level (Integer .parseInt (ctx .dbs_level_01 ().getText ()))
99
- .levelLocality (
100
- getLocality (
101
- this .context .getExtendedDocument ().mapLocation (constructRange (ctx .dbs_level_01 ()))))
102
- .statementLocality (statementLocality )
103
- .variableNameAndLocality (
104
- new VariableNameAndLocality (
105
- VisitorHelper .getName (ctx .entry_name ()),
106
- getLocality (
107
- this .context
108
- .getExtendedDocument ()
109
- .mapLocation (constructRange (ctx .entry_name ())))))
110
- .usageClauses (ImmutableList .of (UsageFormat .DISPLAY ))
111
- .build ();
112
110
variableDefinitionNode .addChild (semanticsNode );
113
111
return ImmutableList .of (variableDefinitionNode );
114
112
}
0 commit comments