Ejemplo n.º 1
0
    def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
        identifier = ctx.IDENTIFIER()
        self.fields = self.method_map.get(identifier.getText())
        if identifier and ctx.start.line in self.lines and identifier.getText(
        ) == self.method_name:
            if self.fields:
                parent = ctx.parentCtx
                caller = parent.children[0]
                caller = self.rewriter.getText(
                    program_name=self.rewriter.DEFAULT_PROGRAM_NAME,
                    start=caller.start.tokenIndex,
                    stop=caller.stop.tokenIndex)

                if ctx.expressionList():
                    self.rewriter.insertAfterToken(
                        token=ctx.expressionList().stop,
                        text=", " + caller,
                        program_name=self.rewriter.DEFAULT_PROGRAM_NAME)
                else:
                    self.rewriter.insertAfter(
                        index=ctx.stop.tokenIndex - 1,
                        text=caller,
                        program_name=self.rewriter.DEFAULT_PROGRAM_NAME)

            if self.is_in_target_class:
                self.rewriter.replaceSingleToken(token=ctx.parentCtx.start,
                                                 text="this")
            else:
                self.rewriter.replaceSingleToken(token=ctx.start,
                                                 text=self.new_name)
Ejemplo n.º 2
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if self.InMainClass:
         # Modify Main Method
         if ctx.IDENTIFIER().getText() in self.Visitors:
             self.token_stream_rewriter.replaceRange(
                 from_idx=ctx.start.tokenIndex,
                 to_idx=ctx.stop.tokenIndex,
                 text="accept(new DoVisitor" + self.SuperClass_identifier + "())")
Ejemplo n.º 3
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if self.in_class and self.reference:
         name = ctx.IDENTIFIER()
         if name.getText() == self.method_name:
             node = name.getSymbol()
             if node.line == self.reference["line"]:
                 self.token_stream_rewriter.replaceIndex(
                     node.tokenIndex, self.new_method_name)
                 self.changed = True
Ejemplo n.º 4
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if ctx.IDENTIFIER().getText() in self.target_methods:
         if ctx.parentCtx.expression().getText() in self.detected_instance_of_target_class:
             self.token_stream_rewriter.replace(
                 program_name=self.token_stream_rewriter.DEFAULT_PROGRAM_NAME,
                 from_idx=ctx.parentCtx.expression().start.tokenIndex,
                 to_idx=ctx.parentCtx.expression().stop.tokenIndex,
                 text=self.target_class
             )
Ejemplo n.º 5
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if ctx.IDENTIFIER().getText(
     ) == self.method_name and self.is_safe and self.detected_class:
         # Change Name
         if ctx.start.line == self.ref_line:
             self.token_stream_rewriter.replaceRange(
                 from_idx=self.start.tokenIndex,
                 to_idx=self.stop.tokenIndex,
                 text=self.child_class)
         self.detected_class = False
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     self.current_method_call = ctx.IDENTIFIER().getText()
Ejemplo n.º 7
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if self.is_source_class and self.is_in_constructor:
         self.methods_in_constructor.append(ctx.IDENTIFIER())
Ejemplo n.º 8
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     method_name = ctx.IDENTIFIER().getText()
     if method_name == self.method_name and self.is_safe:
         self.detected_method = True