@@ -67,10 +67,6 @@ public void visitNode(SubscriptionContext context, Tree pTree) {
6767
6868 FunctionDef method = (FunctionDef )pTree ;
6969
70- // if (!method.body().is(Tree.Kind.)) {
71- // return;
72- // }
73-
7470 // reinit data structure before each method analysis
7571 variablesStruct = new VariablesPerLevelDataStructure ();
7672
@@ -91,10 +87,6 @@ private void visitNodeContent(SubscriptionContext context, List<Statement> pLstS
9187 }
9288
9389 for (Statement statement : pLstStatements ) {
94- // if (statement.is(Kind.BLOCK)) {
95- // // the cirrent node is a block : visit block content
96- // visitNodeContent(((BlockTree)statement).statements(), pLevel);
97- // } else
9890 if (statement .is (IF_STMT )) {
9991 visitIfNode (context , (IfStatement )statement , pLevel );
10092 }
@@ -166,25 +158,12 @@ private void computeConditionVariables(SubscriptionContext context, BinaryExpres
166158 computeConditionVariables (context , (BinaryExpression ) pBinExprTree .rightOperand (), pLevel );
167159 }
168160 } else if (pBinExprTree .is (COMPARISON )) {
169- // else if (pBinExprTree.is(Tree.Kind.EQUAL_TO)
170- // || pBinExprTree.is(Tree.Kind.NOT_EQUAL_TO)
171- // || pBinExprTree.is(Tree.Kind.GREATER_THAN)
172- // || pBinExprTree.is(Tree.Kind.GREATER_THAN_OR_EQUAL_TO)
173- // || pBinExprTree.is(Tree.Kind.LESS_THAN_OR_EQUAL_TO)
174- // || pBinExprTree.is(Tree.Kind.LESS_THAN)
175- // ) {
176-
177- // continue analyze with variables if some key-words are found
161+
162+ // continue to analyze with variables if some key-words are found
178163 if (pBinExprTree .leftOperand ().is (NAME )) {
179- // if (pBinExprTree.leftOperand().is(Tree.Kind.VARIABLE_IDENTIFIER)) {
180- // if ("IDENTIFIER".equals(pBinExprTree.leftOperand().firstToken().type().getName())) {
181- // computeVariables(context, (VariableIdentifierTree) pBinExprTree.leftOperand(), pLevel);
182164 computeVariables (context , pBinExprTree .leftOperand (), pLevel );
183165 }
184166 if (pBinExprTree .rightOperand ().is (NAME )) {
185- // if ("IDENTIFIER".equals(pBinExprTree.rightOperand().firstToken().type().getName())) {
186- // if (pBinExprTree.rightOperand().is(Tree.Kind.VARIABLE_IDENTIFIER)) {
187- // computeVariables(context, (VariableIdentifierTree) pBinExprTree.rightOperand(), pLevel);
188167 computeVariables (context , pBinExprTree .rightOperand (), pLevel );
189168 }
190169 }
@@ -195,22 +174,17 @@ private void computeConditionVariables(SubscriptionContext context, BinaryExpres
195174 * @param pVarIdTree The Variable AST structure
196175 * @param pLevel the level of structure
197176 */
198- // private void computeVariables(SubscriptionContext context, VariableIdentifierTree pVarIdTree, int pLevel) {
199177 private void computeVariables (SubscriptionContext context , Expression pVarIdTree , int pLevel ) {
200- // if (pVarIdTree.variableExpression().is(Kind.VARIABLE_IDENTIFIER)) {
201- // increment the variable counter to list of all variables
202- // int nbUsed = variablesStruct.incrementVariableUsageForLevel(pVarIdTree.text(), pLevel);
178+ // increment the variable counter to list of all variables
203179 int nbUsed = variablesStruct .incrementVariableUsageForLevel (pVarIdTree .firstToken ().value (), pLevel );
204180
205- // increment variable counter to list of variables already declared for current if or elseif struture
206- // variablesStruct.incrementVariableUsageForLevelForCurrentIfStruct(pVarIdTree.text(), pLevel);
181+ // increment variable counter to list of variables already declared for current if or elseif struture
207182 variablesStruct .incrementVariableUsageForLevelForCurrentIfStruct (pVarIdTree .firstToken ().value (), pLevel );
208183
209- // raise an error if maximum
210- if (nbUsed > 2 ) {
211- context .addIssue (pVarIdTree .firstToken (), ERROR_MESSAGE );
212- }
213- // }
184+ // raise an error if maximum
185+ if (nbUsed > 2 ) {
186+ context .addIssue (pVarIdTree .firstToken (), ERROR_MESSAGE );
187+ }
214188 }
215189
216190 /**
@@ -306,7 +280,7 @@ private static class VariablesPerLevelDataStructure {
306280
307281 // map variable counters per level for current If / ElseIf structure
308282 // purpose : used by compute variables Else process (because Else structure is particular :
309- // we don't know previous variables and we need previous If / ElseIf structure to know variables)
283+ // we don't know previous variables, and we need previous If / ElseIf structure to know variables)
310284 private final Map <Integer , Map <String , Integer >> mapVariablesPerLevelForCurrentIfStruct ;
311285
312286 public VariablesPerLevelDataStructure () {
0 commit comments