Пример #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)
Пример #2
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if self.is_package_imported or self.in_selected_package:
         if self.in_class:
             if ctx.IDENTIFIER().getText() == self.method_identifier:
                 self.token_stream_rewriter.replaceIndex(
                     index=ctx.start.tokenIndex, text=self.method_new_name)
                 print("method call name changed !")
Пример #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
Пример #4
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     if self.InMainClass == True:
         # 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 +
                 "())")
Пример #5
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)
Пример #6
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
Пример #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())
Пример #8
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     parametersList = ctx.expressionList()
     # print(parametersList.parentCtx.IDENTIFIER().getText())
     if self.Parameter and parametersList.parentCtx.IDENTIFIER().getText(
     ) in self.Parameters:
         pass
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     self.current_method_call = ctx.IDENTIFIER().getText()
Пример #10
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
Пример #11
0
 def enterMethodCall0(self, ctx: JavaParserLabeled.MethodCall0Context):
     print(ctx.expressionList())