Adds a source to the source map
(fileName string)
| 76 | |
| 77 | // Adds a source to the source map |
| 78 | func (gen *Generator) AddSource(fileName string) SourceIndex { |
| 79 | source := tspath.GetRelativePathToDirectoryOrUrl( |
| 80 | gen.sourcesDirectoryPath, |
| 81 | fileName, |
| 82 | true, /*isAbsolutePathAnUrl*/ |
| 83 | gen.pathOptions, |
| 84 | ) |
| 85 | |
| 86 | sourceIndex, found := gen.sourceToSourceIndexMap[source] |
| 87 | if !found { |
| 88 | sourceIndex = SourceIndex(len(gen.sources)) |
| 89 | gen.sources = append(gen.sources, source) |
| 90 | gen.rawSources = append(gen.rawSources, fileName) |
| 91 | if gen.sourceToSourceIndexMap == nil { |
| 92 | gen.sourceToSourceIndexMap = make(map[string]SourceIndex) |
| 93 | } |
| 94 | gen.sourceToSourceIndexMap[source] = sourceIndex |
| 95 | } |
| 96 | |
| 97 | return sourceIndex |
| 98 | } |
| 99 | |
| 100 | // Sets the content for a source |
| 101 | func (gen *Generator) SetSourceContent(sourceIndex SourceIndex, content string) error { |