244{
245 AUTO_TRACE(
"CodeFragmentManager::parseCodeFragment({},blockId={},scopeName={},showLineNumber={},trimLeft={},stripCodeComments={}",
246 fileName, blockId, scopeName, showLineNumbers, trimLeft, stripCodeComments);
247 std::string fragmentKey=fileName.
str()+
":"+scopeName.
str();
248 std::unordered_map< std::string,std::unique_ptr<Private::FragmentInfo> >::iterator it;
249 bool inserted = false;
250 {
251
252 std::lock_guard lock(
p->mutex);
253 it =
p->fragments.find(fragmentKey);
254 if (it ==
p->fragments.end())
255 {
256 it =
p->fragments.emplace(fragmentKey, std::make_unique<Private::FragmentInfo>()).first;
257 inserted = true;
259 }
260 }
261
262 auto &codeFragment = it->second;
263 std::lock_guard lock(codeFragment->mutex);
264 if (inserted)
265 {
267 FileInfo cfi( fileName.
str() );
270 intf->resetCodeParserState();
272 bool needs2PassParsing =
274 !filterSourceFiles &&
277
278 if (needs2PassParsing)
279 {
280 OutputCodeList devNullList;
281 devNullList.
add<DevNullCodeGenerator>();
282 intf->parseCode(devNullList,
283 scopeName,
284 codeFragment->fileContents,
285 langExt,
286 stripCodeComments,
287 false,
288 QCString()
289 );
290 }
291 codeFragment->findBlockMarkers();
292 if (codeFragment->fileContents.length()>0)
293 {
294 intf->parseCode(codeFragment->recorderCodeList,
295 scopeName,
296 codeFragment->fileContents,
297 langExt,
298 false,
299 false,
300 QCString(),
301 fd.get(),
302 -1,
303 -1,
304 true,
305 nullptr,
306 true,
307 nullptr,
308 false
309 );
310 }
311 }
312
313 auto blockKv = codeFragment->blocksById.find(blockId.
str());
314 if (blockKv != codeFragment->blocksById.end())
315 {
316 const auto &marker = blockKv->second;
317 int startLine = marker->lines[0];
318 int endLine = marker->lines[1];
319 int indent = marker->indent;
320 AUTO_TRACE_ADD(
"replay(start={},end={},indent={}) fileContentsTrimLeft.empty()={}",
321 startLine,endLine,indent,codeFragment->fileContentsTrimLeft.isEmpty());
323 recorder->replay(codeOutList,
324 startLine+1,
325 endLine,
326 showLineNumbers,
327 stripCodeComments,
328 trimLeft ? static_cast<size_t>(indent) : 0
329 );
330 }
331 else
332 {
334 }
335}
static bool parseSourcesNeeded
static ParserManager * parserManager
void add(OutputCodeIntfPtr &&p)
std::unique_ptr< CodeParserInterface > getCodeParser(const QCString &extension)
Gets the interface to the parser associated with a given extension.
bool isEmpty() const
Returns TRUE iff the string is empty.
const std::string & str() const
static QCString readTextFileByName(const QCString &file)
#define Config_getBool(name)
#define AUTO_TRACE_ADD(...)
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
SrcLangExt
Language as given by extension.
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
QCString getFileFilter(const QCString &name, bool isSourceCode)
QCString getFileNameExtension(const QCString &fn)