示例#1
0
 def exitFormalParameter(self,
                         ctx: JavaParserLabeled.FormalParameterContext):
     if ctx.typeType().getText() == self.source_class:
         self.token_stream_rewriter.replaceRange(
             from_idx=ctx.typeType().start.tokenIndex,
             to_idx=ctx.typeType().stop.tokenIndex,
             text=f"{self.new_class}")
示例#2
0
 def enterFormalParameter(self,
                          ctx: JavaParserLabeled.FormalParameterContext):
     if self.method_selected == True:
         self.inputPara = True
         self.oldPara.append(ctx.typeType().getText() + " " +
                             ctx.variableDeclaratorId().getText())
         self.typePara.append(ctx.typeType().getText())
示例#3
0
 def enterFormalParameter(self, ctx: JavaParserLabeled.FormalParameterContext):
     # print(ctx.typeType().getText())
     # print(ctx.variableDeclaratorId().getText())
     constructorName = ctx.parentCtx.parentCtx.parentCtx.IDENTIFIER().getText()
     if self.target_class == constructorName:
         text = ctx.typeType().getText() + " " + ctx.variableDeclaratorId().getText()
         self.new_parameters.append(text)
         self.new_parameters_names.append(ctx.variableDeclaratorId().getText())
示例#4
0
    def enterFormalParameter(self,
                             ctx: JavaParserLabeled.FormalParameterContext):

        # checks if we are in target method
        if self.is_in_target_method:
            # adding all created variables
            self.pre_variables[ctx.variableDeclaratorId().getText()] = \
                {
                    'type': ctx.typeType().getText(),
                    'write': True
                }
示例#5
0
 def enterFormalParameter(self, ctx: JavaParserLabeled.FormalParameterContext):
     class_type = ctx.typeType().classOrInterfaceType()
     if class_type:
         if class_type.IDENTIFIER(0).getText() == self.source_class and self.target_class:
             self.token_stream_rewriter.replaceIndex(
                 index=class_type.start.tokenIndex,
                 text=self.target_class
             )
示例#6
0
    def exitFormalParameter(self,
                            ctx: JavaParserLabeled.FormalParameterContext):
        parameterIdentifier = ctx.variableDeclaratorId().IDENTIFIER().getText()
        grandParentCtx = ctx
        Parent = ctx.parentCtx.children
        # for i in range(len(Parent)):
        #     print(Parent[i].variableDeclaratorId().IDENTIFIER().getText())

        start = grandParentCtx.start.tokenIndex
        stop = grandParentCtx.stop.tokenIndex
        if self.Parameter and self.ParameterIndex < len(
                self.Parameters) and self.Parameters[
                    self.ParameterIndex].split('/')[2] == parameterIdentifier:
            if self.IsSourceClassForParameters[
                    self.ParameterIndex] and self.IsSourceMethodForParameters[
                        self.ParameterIndex]:
                self.CodeRewrite.delete(self.CodeRewrite.DEFAULT_PROGRAM_NAME,
                                        start, stop)
                self.ParameterIndex += 1
示例#7
0
 def enterFormalParameter(self,
                          ctx: JavaParserLabeled.FormalParameterContext):
     if self.detected_method:
         self.parameters.append(
             ctx.variableDeclaratorId().IDENTIFIER().getText())
示例#8
0
 def enterFormalParameter(self,
                          ctx: JavaParserLabeled.FormalParameterContext):
     if self.is_in_target_method:
         self.variable_info['variables'][ctx.variableDeclaratorId().getText(
         )] = ctx.typeType().getText()