示例#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)
 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()) + '()'
             )
示例#3
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)