233def _index_source() -> SymbolsIndex:
234 indexer = _Indexer()
235
236 _create_compilation_database()
237 with _change_working_directory_to(_DART_BUILD_DIR):
238 index = Index.create()
239 compdb = CompilationDatabase.fromDirectory('.')
240
241 commands = list(compdb.getAllCompileCommands())
242 with ShadyBar('Indexing',
243 max=len(commands),
244 suffix='%(percent)d%% eta %(eta_td)s') as progress_bar:
245 for command in commands:
246 args = [
247 arg for arg in command.arguments
248 if arg.startswith('-I') or arg.startswith('-W') or
249 arg.startswith('-D') or arg.startswith('-i') or
250 arg.startswith('sdk/') or arg.startswith('-std')
251 ] + [
252 '-Wno-macro-redefined', '-Wno-unused-const-variable',
253 '-Wno-unused-function', '-Wno-unused-variable'
254 ]
255
256 if _clang_include_dir is not None:
257 args.append(f'-I{_clang_include_dir}')
258
259 unit = index.parse(command.filename, args=args)
260 for diag in unit.diagnostics:
262
263 indexer.index(unit)
264 progress_bar.next()
265
266 return indexer.symbols_index
267
268