MCPcopy Index your code
hub / github.com/microsoft/typescript-go / AddSource

Method AddSource

internal/sourcemap/generator.go:78–98  ·  view source on GitHub ↗

Adds a source to the source map

(fileName string)

Source from the content-addressed store, hash-verified

76
77// Adds a source to the source map
78func (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
101func (gen *Generator) SetSourceContent(sourceIndex SourceIndex, content string) error {

Calls 5

SourceIndexTypeAlias · 0.85
lenFunction · 0.85
appendFunction · 0.50
makeFunction · 0.50