Skip to content

Commit b04c9c1

Browse files
authored
Fix breadcrumbs for google3 (#3623)
1 parent 7d4c9d4 commit b04c9c1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/src/model/library.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,17 @@ class Library extends ModelElement
330330
String get _importPath {
331331
// This code should not be used for Dart SDK libraries.
332332
assert(!element.source.uri.isScheme('dart'));
333-
var relativePath = pathContext.relative(element.source.fullName,
334-
from: package.packagePath);
333+
var fullName = element.source.fullName;
334+
if (!pathContext.isWithin(fullName, package.packagePath) &&
335+
package.packagePath.contains('/google3/')) {
336+
// In google3, `fullName` is specified as if the root of google3 was `/`.
337+
// And `package.packagePath` contains the true google3 root.
338+
var root = pathContext
339+
.joinAll(pathContext.split(package.packagePath)..removeLast());
340+
fullName = '$root$fullName';
341+
}
342+
var relativePath =
343+
pathContext.relative(fullName, from: package.packagePath);
335344
assert(relativePath.startsWith('lib${pathContext.separator}'));
336345
const libDirectoryLength = 'lib/'.length;
337346
return relativePath.substring(libDirectoryLength);

0 commit comments

Comments
 (0)