Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
0
 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)
Esempio n. 4
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
Esempio n. 5
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     if not self.is_class:
         return None
     grand_parent_ctx = ctx.parentCtx.parentCtx
     class_identifier = grand_parent_ctx.typeType().getText()
     if class_identifier in self.old_class_name:
         self.token_stream_rewriter.replaceRange(
             from_idx=grand_parent_ctx.typeType().start.tokenIndex,
             to_idx=grand_parent_ctx.typeType().stop.tokenIndex,
             text=self.new_class_name)
         grand_child_ctx = ctx.variableInitializer().expression().creator(
         ).createdName()
         self.token_stream_rewriter.replaceRange(
             from_idx=grand_child_ctx.start.tokenIndex,
             to_idx=grand_child_ctx.stop.tokenIndex,
             text=self.new_class_name)
Esempio n. 6
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
Esempio n. 7
0
 def enterVariableDeclarator(
         self, ctx: JavaParserLabeled.VariableDeclaratorContext):
     self.Variables.append(str(ctx.variableDeclaratorId().IDENTIFIER()))