Exemplo n.º 1
0
 def exitExpression21(self, ctx: JavaParserLabeled.Expression21Context):
     for instance in self.instances:
         if ctx.expression(
                 0).getText() == instance + '.' + self.field_identifier:
             expr_code = self.token_stream_rewriter.getText(
                 program_name=self.token_stream_rewriter.
                 DEFAULT_PROGRAM_NAME,
                 start=ctx.expression(1).start.tokenIndex,
                 stop=ctx.expression(1).stop.tokenIndex)
             new_code = instance + '.set' + str.capitalize(
                 self.field_identifier) + '(' + expr_code + ')'
             self.token_stream_rewriter.replaceRange(
                 ctx.start.tokenIndex, ctx.stop.tokenIndex, new_code)
Exemplo n.º 2
0
 def exitExpression21(self, ctx: JavaParserLabeled.Expression21Context):
     if self.in_source_class and self.in_selected_package:
         if ctx.expression(0).getText() == self.field_identifier or \
                 ctx.expression(0).getText() == 'this.' + self.field_identifier:
             expr_code = self.token_stream_rewriter.getText(
                 program_name=self.token_stream_rewriter.
                 DEFAULT_PROGRAM_NAME,
                 start=ctx.expression(1).start.tokenIndex,
                 stop=ctx.expression(1).stop.tokenIndex)
             new_code = 'this.set' + str.capitalize(
                 self.field_identifier) + '(' + expr_code + ')'
             self.token_stream_rewriter.replaceRange(
                 ctx.start.tokenIndex, ctx.stop.tokenIndex, new_code)
Exemplo n.º 3
0
    def enterExpression21(self, ctx: JavaParserLabeled.Expression21Context):
        if self.in_class:
            if ctx.expression(0).getText() == self.field_identifier:
                self.token_stream_rewriter.replaceIndex(
                    index=ctx.expression(0).start.tokenIndex,
                    text=self.field_new_name)
                print("expression21 changed! ")
            elif ctx.expression(
                    0).getText() == "this." + self.field_identifier:
                self.token_stream_rewriter.replaceIndex(
                    index=ctx.expression(0).start.tokenIndex + 2,
                    text=self.field_new_name)
                # print("expression21 ", ctx.expression(0).getText(), " changed to: ", "this.", self.field_new_name)
                print("expression21 changed! ")

            if ctx.expression(1).getText() == self.field_identifier:
                self.token_stream_rewriter.replaceIndex(
                    index=ctx.expression(1).start.tokenIndex,
                    text=self.field_new_name)
                # print("expression21 ", ctx.expression(1).getText(), " changed to: ", self.field_new_name)
                print("expression21 changed! ")

            elif ctx.expression(
                    1).getText() == "this." + self.field_identifier:
                self.token_stream_rewriter.replaceIndex(
                    index=ctx.expression(1).start.tokenIndex + 2,
                    text=self.field_new_name)
                # print("expression21 ", ctx.expression(1).getText(), " changed to: ", "this.", self.field_new_name)
                print("expression21 changed! ")
Exemplo n.º 4
0
 def enterExpression21(self, ctx: JavaParserLabeled.Expression21Context):
     if self.isRelevant:
         if ctx.expression(0).getText() == self.relevantVariable:
             interval = ctx.getSourceInterval()
             self.token_stream_rewriter.replaceRange(
                 interval[0], interval[1], "break")