MCPcopy Create free account
hub / github.com/VKCOM/nocc / processHFile

Method processHFile

internal/client/own-includes-parser.go:368–392  ·  view source on GitHub ↗
(hFile *IncludedFile, file *os.File, shouldCache bool)

Source from the content-addressed store, hash-verified

366}
367
368func (inc *ownIncludesParser) processHFile(hFile *IncludedFile, file *os.File, shouldCache bool) {
369 fileSHA256, buffer, err := CalcSHA256OfFile(file, hFile.fileSize, inc.preallocatedBuf)
370 _ = file.Close() // close a file before digging into nested .h, not to keep open descriptors
371 if err != nil {
372 inc.err = err // keep the last error here
373 return
374 }
375
376 hFile.fileSHA256 = fileSHA256
377 includeStatements := inc.collectIncludeStatementsInFile(buffer)
378
379 if !shouldCache {
380 for _, includedArg := range includeStatements {
381 inc.onHashInclude(hFile.fileName, includedArg, false)
382 }
383 } else {
384 nestedIncludes := make([]string, 0, len(includeStatements))
385 for _, includedArg := range includeStatements {
386 if hNested := inc.onHashInclude(hFile.fileName, includedArg, false); hNested != nil {
387 nestedIncludes = append(nestedIncludes, hNested.fileName)
388 }
389 }
390 inc.includesCache.AddHFileInfo(hFile.fileName, hFile.fileSize, hFile.fileSHA256, nestedIncludes)
391 }
392}
393
394func (inc *ownIncludesParser) processCppInFile(cppInFile string, searchForPch bool, explicitIncludes []string) (IncludedFile, error) {
395 // on some systems, g++ includes <stdc-predef.h> implicitly

Callers 1

onHashIncludeMethod · 0.95

Calls 5

onHashIncludeMethod · 0.95
CalcSHA256OfFileFunction · 0.85
CloseMethod · 0.80
AddHFileInfoMethod · 0.80

Tested by

no test coverage detected