The debugger API needs a method to get all the libraries imported by library with a filter parameter to filter on prefix strings #11899
Labels
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Here is the current code for getting imported libraries which match a prefix:
331 void getImportedLibrariesMatchingPrefix(int32_t libraryId, Dart_Handle prefix, V
ector<std::pair<Dart_Handle, intptr_t> >* libraries)
332 {
333 Dart_Handle imports = Dart_GetLibraryImports(libraryId);
334 ASSERT(!Dart_IsError(imports));
335 // Unfortunately dart_debugger_api.h adds a trailing dot to import prefixes.
336 if (!Dart_IsNull(prefix))
337 prefix = addTrailingDot(prefix);
338 intptr_t length = 0;
339 Dart_ListLength(imports, &length);
340 for (intptr_t i = 0; i < length; i += 2) {
341 Dart_Handle importPrefix = Dart_ListGetAt(imports, i);
342 ASSERT(Dart_IsNull(importPrefix) || Dart_IsString(importPrefix));
343 bool equals = false;
344 Dart_Handle result = Dart_ObjectEquals(prefix, importPrefix, &equals);
345 ASSERT(!Dart_IsError(result));
346 if (equals) {
347 Dart_Handle importedLibraryIdHandle = Dart_ListGetAt(imports, i + 1)
;
348 ASSERT(Dart_IsInteger(importedLibraryIdHandle));
349 int64_t importedLibraryId;
350 Dart_IntegerToInt64(importedLibraryIdHandle, &importedLibraryId);
351 Dart_Handle libraryURL = Dart_GetLibraryURL(importedLibraryId);
352 ASSERT(!Dart_IsError(libraryURL));
353 Dart_Handle library = Dart_LookupLibrary(libraryURL);
354 ASSERT(Dart_IsLibrary(library));
355 libraries->append(std::pair<Dart_Handle, intptr_t>(library, imported
LibraryId));
356 }
357 }
358 }
The text was updated successfully, but these errors were encountered: