(params: {
filePath: string
fullPath: string
languageConfig: LanguageConfig
readFile?: SourceReader
remainingBytes: number
})
| 148 | } |
| 149 | |
| 150 | async 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 | |
| 182 | function parseTokensWithLimits( |
| 183 | filePath: string, |
no test coverage detected