 PROPERTY_PREFIX_PATTERN = /(?:^|\[|\(|,|=|:|\s)\s*((?:And|Given|Then|When)\s(?:[a-zA-Z]+\.?){0,2})$/
 PATH_CONFIG_KEY = 'cucumber-autocomplete.path'
 CUCUMBER_KEYWORDS_PATTERN = /(Given|And|When|Then)(.*)/g
+CUCUMBER_STEP_DEF_PATTERN = /(Given|And|When|Then)\(\/\^(.*?)\$/g
 
 module.exports =
   selector: '.source.feature, .feature'


  getCompletions: (line, file) ->
    return [] unless @matchCucumberKeyword(line)

    results = []
    regex = /(Given|And|When|Then)(.*)/g
    while (myRegexArray = regex.exec(file)) != null
      results.push({"text":myRegexArray[2].replace /^\s+|\s+$/g, ""})

    for feature in fs.readdirSync("#{@rootDirectory()}#{@featuresDirectory()}")
      continue unless /.feature/.test(feature)
      data = fs.readFileSync "#{@rootDirectory()}#{@featuresDirectory()}/#{feature}", 'utf8'
      while (myRegexArray = CUCUMBER_KEYWORDS_PATTERN.exec(data)) != null
        results.push({"text":myRegexArray[2].replace /^\s+|\s+$/g, ""})

    return results



  featuresDirectory: (path=PATH_CONFIG_KEY) ->
    atom.config.get(path)

  replacedCucumberRegex: (step) ->
    #TODO: figure out how to loop through if there are multiple matches
    #      eg: 1:numberArgument, 2:numberArgument
    step = step.replace(/^\s+|\s+$/g, "")
    step = step.replace(/\(\\d\+\)/g, "${1:numberArgument}")
    step.replace(/\(\.\*\?\)/g, "${1:textArgument}")

  featureDirError: ->
    throw new Error("Cannot find features directory at #{@rootDirectory()}#{@featuresDirectory()}")
