func PerformRephraseRefactoring(oldStep, newStep string, startChan *runner.StartChannels) *refactoringResult { defer killRunner(startChan) if newStep == oldStep { return &refactoringResult{Success: true} } agent, err := getRefactorAgent(oldStep, newStep, startChan) if err != nil { return rephraseFailure(err.Error()) } result := &refactoringResult{Success: true, Errors: make([]string, 0), warnings: make([]string, 0)} specs, specParseResults := parser.FindSpecs(filepath.Join(config.ProjectRoot, common.SpecsDirectoryName), &parser.ConceptDictionary{}) addErrorsAndWarningsToRefactoringResult(result, specParseResults...) if !result.Success { return result } conceptDictionary, parseResult := parser.CreateConceptsDictionary(false) addErrorsAndWarningsToRefactoringResult(result, parseResult) if !result.Success { return result } refactorResult := agent.performRefactoringOn(specs, conceptDictionary) refactorResult.warnings = append(refactorResult.warnings, result.warnings...) return refactorResult }
func specsFromArgs(conceptDictionary *parser.ConceptDictionary, args []string) []*parser.Specification { allSpecs := make([]*parser.Specification, 0) specs := make([]*parser.Specification, 0) var specParseResults []*parser.ParseResult for _, arg := range args { specSource := arg if isIndexedSpec(specSource) { specs, specParseResults = getSpecWithScenarioIndex(specSource, conceptDictionary) } else { specs, specParseResults = parser.FindSpecs(specSource, conceptDictionary) } parser.HandleParseResult(specParseResults...) allSpecs = append(allSpecs, specs...) } return allSpecs }
func getSpecWithScenarioIndex(specSource string, conceptDictionary *parser.ConceptDictionary) ([]*parser.Specification, []*parser.ParseResult) { specName, indexToFilter := GetIndexedSpecName(specSource) parsedSpecs, parseResult := parser.FindSpecs(specName, conceptDictionary) return filterSpecsItems(parsedSpecs, newScenarioIndexFilterToRetain(indexToFilter)), parseResult }