<commit_before>package main

import (
	"fmt"
	"github.com/getgauge/gauge/gauge_messages"
	"github.com/golang/protobuf/proto"
	"regexp"
	"strings"
)

type scenario struct {
	heading  *heading
	steps    []*step
	comments []*comment
	tags     *tags
	items    []item
}

type argType string

const (
	static                argType = "static"
	dynamic               argType = "dynamic"
	tableArg              argType = "table"
	specialString         argType = "special_string"
	specialTable          argType = "special_table"
	PARAMETER_PLACEHOLDER         = "{}"
)

type stepArg struct {
	name    string
	value   string
	argType argType
	table   table
}

func (stepArg *stepArg) String() string {
	return fmt.Sprintf("{Name: %s,value %s,argType %s,table %v}", stepArg.name, stepArg.value, string(stepArg.argType), stepArg.table)
}

type paramNameValue struct {
	name    string
	stepArg *stepArg
}

func (paramNameValue paramNameValue) String() string {
	return fmt.Sprintf("ParamName: %s, stepArg: %s", paramNameValue.name, paramNameValue.stepArg)
}

type argLookup struct {
	//helps to access the index of an arg at O(1)
	paramIndexMap map[string]int
	paramValue    []paramNameValue
}

func (argLookup argLookup) String() string {
	return fmt.Sprintln(argLookup.paramValue)
}

type step struct {
	lineNo         int
	value          string
	lineText       string
	args           []*stepArg
	isConcept      bool
	lookup         argLookup
	conceptSteps   []*step
	fragments      []*gauge_messages.Fragment
	parent         *step
	hasInlineTable bool
	items          []item
	preComments    []*comment
}

func (step *step) getArg(name string) *stepArg {
	if step.parent == nil {
		return step.lookup.getArg(name)
	}
	return step.parent.getArg(step.lookup.getArg(name).value)
}

func (step *step) getLineText() string {
	if step.hasInlineTable {
		return fmt.Sprintf("%s <%s>", step.lineText, tableArg)
	}
	return step.lineText
}

func (step *step) rename(oldStep step, newStep step, isRefactored bool, orderMap map[int]int, isConcept *bool) bool {
	if strings.TrimSpace(step.value) != strings.TrimSpace(oldStep.value) {
		return isRefactored
	}
	step.value = newStep.value
	args := make([]*stepArg, len(newStep.args))
	for key, value := range orderMap {
		arg := &stepArg{value: "", argType: static}
		if step.isConcept {
			*isConcept = true
			arg = &stepArg{value: newStep.args[key].value, argType: dynamic}
		}
		if value != -1 {
			arg = step.args[value]
		}
		args[key] = arg
	}
	step.args = args
	return true
}

func (step *step) deepCopyStepArgs() []*stepArg {
	copiedStepArgs := make([]*stepArg, 0)
	for _, conceptStepArg := range step.args {<commit_msg>Keeping parameter value for newly added parameters on refactoring. Fixes #82<commit_after>package main

import (
	"fmt"
	"github.com/getgauge/gauge/gauge_messages"
	"github.com/golang/protobuf/proto"
	"regexp"
	"strings"
)

type scenario struct {
	heading  *heading
	steps    []*step
	comments []*comment
	tags     *tags
	items    []item
}

type argType string

const (
	static                argType = "static"
	dynamic               argType = "dynamic"
	tableArg              argType = "table"
	specialString         argType = "special_string"
	specialTable          argType = "special_table"
	PARAMETER_PLACEHOLDER         = "{}"
)

type stepArg struct {
	name    string
	value   string
	argType argType
	table   table
}

func (stepArg *stepArg) String() string {
	return fmt.Sprintf("{Name: %s,value %s,argType %s,table %v}", stepArg.name, stepArg.value, string(stepArg.argType), stepArg.table)
}

type paramNameValue struct {
	name    string
	stepArg *stepArg
}

func (paramNameValue paramNameValue) String() string {
	return fmt.Sprintf("ParamName: %s, stepArg: %s", paramNameValue.name, paramNameValue.stepArg)
}

type argLookup struct {
	//helps to access the index of an arg at O(1)
	paramIndexMap map[string]int
	paramValue    []paramNameValue
}

func (argLookup argLookup) String() string {
	return fmt.Sprintln(argLookup.paramValue)
}

type step struct {
	lineNo         int
	value          string
	lineText       string
	args           []*stepArg
	isConcept      bool
	lookup         argLookup
	conceptSteps   []*step
	fragments      []*gauge_messages.Fragment
	parent         *step
	hasInlineTable bool
	items          []item
	preComments    []*comment
}

func (step *step) getArg(name string) *stepArg {
	if step.parent == nil {
		return step.lookup.getArg(name)
	}
	return step.parent.getArg(step.lookup.getArg(name).value)
}

func (step *step) getLineText() string {
	if step.hasInlineTable {
		return fmt.Sprintf("%s <%s>", step.lineText, tableArg)
	}
	return step.lineText
}

func (step *step) rename(oldStep step, newStep step, isRefactored bool, orderMap map[int]int, isConcept *bool) bool {
	if strings.TrimSpace(step.value) != strings.TrimSpace(oldStep.value) {
		return isRefactored
	}
	step.value = newStep.value
	args := make([]*stepArg, len(newStep.args))
	for key, value := range orderMap {
		arg := &stepArg{value: newStep.args[key].value, argType: static}
		if step.isConcept {
			*isConcept = true
			arg = &stepArg{value: newStep.args[key].value, argType: dynamic}
		}
		if value != -1 {
			arg = step.args[value]
		}
		args[key] = arg
	}
	step.args = args
	return true
}

func (step *step) deepCopyStepArgs() []*stepArg {
	copiedStepArgs := make([]*stepArg, 0)
	for _, conceptStepArg := range step.args {
{'fraction_non_alphanumeric': 0.1150278293135436, 'fraction_numerical': 0.001484230055658627, 'mean_word_length': 3.440691927512356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2708496', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1828, 'n_words': 469}