MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / processFiles

Method processFiles

libs/parser/ThreadedDeclParser.h:76–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 virtual void parse(std::istream& stream, const vfs::FileInfo& fileInfo, const std::string& modDir) = 0;
75
76 void processFiles()
77 {
78 ScopedDebugTimer timer("[DeclParser] Parsed " + decl::getTypeName(_declType) + " declarations");
79
80 // Accumulate all the files and sort them before calling the protected parse() method
81 std::vector<vfs::FileInfo> _incomingFiles;
82 _incomingFiles.reserve(200);
83
84 GlobalFileSystem().forEachFile(_baseDir, _extension, [&](const vfs::FileInfo& info)
85 {
86 _incomingFiles.push_back(info);
87 }, _depth);
88
89 // Sort the files by name
90 std::sort(_incomingFiles.begin(), _incomingFiles.end(), [](const vfs::FileInfo& a, const vfs::FileInfo& b)
91 {
92 return a.name < b.name;
93 });
94
95 // Dispatch the sorted list to the protected parse() method
96 for (const auto& fileInfo : _incomingFiles)
97 {
98 auto file = GlobalFileSystem().openTextFile(fileInfo.fullPath());
99
100 if (!file) continue;
101
102 try
103 {
104 // Parse entity defs from the file
105 std::istream stream(&file->getInputStream());
106 parse(stream, fileInfo, file->getModName());
107 }
108 catch (ParseException& e)
109 {
110 rError() << "[DeclParser] Failed to parse " << fileInfo.fullPath()
111 << " (" << e.what() << ")" << std::endl;
112 }
113 }
114 }
115};
116
117}

Callers

nothing calls this directly

Calls 13

getTypeNameFunction · 0.85
sortFunction · 0.85
rErrorFunction · 0.85
fullPathMethod · 0.80
whatMethod · 0.80
parseFunction · 0.50
reserveMethod · 0.45
forEachFileMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
openTextFileMethod · 0.45

Tested by

no test coverage detected