Example #1
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if not self.is_class:
         return None
     ctx_grandparent = ctx.parentCtx.parentCtx
     if ctx.variableDeclaratorId().IDENTIFIER().getText(
     ) in self.object_name:
         self.objectName = ctx.variableDeclaratorId().IDENTIFIER().getText()
         if ctx_grandparent.typeType().classOrInterfaceType().IDENTIFIER(
                 0).getText() in self.source_class:
             self.token_stream_rewriter.delete(
                 from_idx=ctx_grandparent.start.tokenIndex,
                 to_idx=ctx_grandparent.stop.tokenIndex,
                 program_name=self.token_stream_rewriter.
                 DEFAULT_PROGRAM_NAME)
Example #2
0
 def exitVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if self.is_other_class:
         variable_name = ctx.variableDeclaratorId().IDENTIFIER().getText()
         print(variable_name, "-->", self.type)
         if self.type == self.source_class:
             self.usages.append({
                 "identifier":
                 variable_name,
                 "startTokenIndex":
                 ctx.variableDeclaratorId().start.tokenIndex,
                 "inClass":
                 self.class_name,
                 "inMethod":
                 self.method_name
             })
 def enterVariableDeclarator(self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if not self.is_class:
         return None
     grand_parent_ctx = ctx.parentCtx.parentCtx
     if grand_parent_ctx.typeType().classOrInterfaceType() != None:
         className = grand_parent_ctx.typeType().classOrInterfaceType().IDENTIFIER(0).getText()
         if className in self.source_class:
             objectname = ctx.variableDeclaratorId().IDENTIFIER().getText()
             self.objects.append(objectname)
Example #4
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if not self.is_class:
         return None
     if ctx.variableDeclaratorId().IDENTIFIER().getText(
     ) in self.using_variable_name:
         count = ctx.getChildCount()
         if count == 3:
             self.token_stream_rewriter.insertBefore(
                 index=ctx.variableInitializer().start.tokenIndex,
                 text=self.object + '.',
                 program_name=self.token_stream_rewriter.
                 DEFAULT_PROGRAM_NAME)
Example #5
0
 def exitVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     variableIdentifier = ctx.variableDeclaratorId().IDENTIFIER().getText()
     grandParentCtx = ctx.parentCtx.parentCtx.parentCtx
     if self.Variable and self.VariableIndex < len(
             self.Variables) and self.Variables[self.VariableIndex].split(
                 '/')[2] == variableIdentifier:
         if self.IsSourceClassForVariables[
                 self.VariableIndex] and self.IsSourceMethodForVariables[
                     self.VariableIndex]:
             self.CodeRewrite.delete(self.CodeRewrite.DEFAULT_PROGRAM_NAME,
                                     grandParentCtx.start.tokenIndex,
                                     grandParentCtx.stop.tokenIndex)
             self.VariableIndex += 1
 def enterVariableDeclarator(self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if not self.is_class:
         return None
     usingfieldidentifier = ctx.variableDeclaratorId().IDENTIFIER().getText()
     grand_child_ctx = ctx.variableInitializer().expression()
     if usingfieldidentifier in self.using_field_name:
         objectidentifier = grand_child_ctx.expression(0).primary().IDENTIFIER().getText()
         if objectidentifier in self.object_name:
             self.token_stream_rewriter.replaceRange(
                 from_idx=grand_child_ctx.start.tokenIndex,
                 to_idx=grand_child_ctx.stop.tokenIndex,
                 text=grand_child_ctx.expression(0).primary().IDENTIFIER().getText() + '.' + 'get' + str.capitalize(
                     grand_child_ctx.IDENTIFIER().getText()) + '()'
             )
Example #7
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     self.Variables.append(str(ctx.variableDeclaratorId().IDENTIFIER()))
Example #8
0
 def exitVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if self.detected_class and self.is_safe:
         self.variable = ctx.variableDeclaratorId().IDENTIFIER().getText()
         self.detected_class = False
Example #9
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     print(
         "fjksdlajflkasdjfklasdjflkasjdfkljsdfkljasdklfjaslkdfjlfjksdlajflkasdjfklasdjflkasjdfkljsdfkljasdklfjaslkdfjl"
     )
     print(ctx.variableDeclaratorId().getText())