MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseTokensForScoring

Function parseTokensForScoring

packages/code-map/src/parse.ts:150–180  ·  view source on GitHub ↗
(params: {
  filePath: string
  fullPath: string
  languageConfig: LanguageConfig
  readFile?: SourceReader
  remainingBytes: number
})

Source from the content-addressed store, hash-verified

148}
149
150async function parseTokensForScoring(params: {
151 filePath: string
152 fullPath: string
153 languageConfig: LanguageConfig
154 readFile?: SourceReader
155 remainingBytes: number
156}): Promise<ParsedTokensForScoring> {
157 const { filePath, fullPath, languageConfig, readFile, remainingBytes } =
158 params
159
160 if (!readFile) {
161 return parseTokensWithLimits(fullPath, languageConfig, undefined, {
162 maxBytes: MAX_PARSE_FILE_BYTES,
163 remainingBytes,
164 })
165 }
166
167 try {
168 const source = await readFile(filePath)
169 return parseTokensWithLimits(filePath, languageConfig, () => source, {
170 maxBytes: MAX_PARSE_FILE_BYTES,
171 remainingBytes,
172 })
173 } catch (e) {
174 if (DEBUG_PARSING) {
175 console.error(`Error reading source: ${e}`)
176 console.log(filePath)
177 }
178 return emptyParsedTokens(false)
179 }
180}
181
182function parseTokensWithLimits(
183 filePath: string,

Callers 1

getFileTokenScoresFunction · 0.85

Calls 2

parseTokensWithLimitsFunction · 0.85
emptyParsedTokensFunction · 0.85

Tested by

no test coverage detected