mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
NNBD preview: Nav tree hrefs should always use forward slashes
Change-Id: I64cfb42f8623649707b153fbefa3a6cccf343a5b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134788 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
d47391ec41
commit
af7b5fa4c6
4 changed files with 12 additions and 18 deletions
|
@ -69,15 +69,14 @@ class MigrationInfo {
|
||||||
for (UnitInfo unit in units) {
|
for (UnitInfo unit in units) {
|
||||||
int count = unit.fixRegions.length;
|
int count = unit.fixRegions.length;
|
||||||
links.add(UnitLink(
|
links.add(UnitLink(
|
||||||
_pathTo(target: unit), path.split(computeName(unit)), count));
|
_pathTo(target: unit), pathContext.split(computeName(unit)), count));
|
||||||
}
|
}
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The path to [target], relative to [from].
|
/// The path to [target], as an HTTP URI path, using forward slash separators.
|
||||||
String _pathTo({@required UnitInfo target}) {
|
String _pathTo({@required UnitInfo target}) =>
|
||||||
return target.path;
|
'/' + pathContext.split(target.path).skip(1).join('/');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A location from or to which a user might want to navigate.
|
/// A location from or to which a user might want to navigate.
|
||||||
|
|
|
@ -47,7 +47,7 @@ class NavigationTreeRenderer {
|
||||||
{
|
{
|
||||||
'type': 'file',
|
'type': 'file',
|
||||||
'name': link.fileName,
|
'name': link.fileName,
|
||||||
'path': link.relativePath,
|
'path': pathContext.joinAll(link.pathParts),
|
||||||
'href': link.url,
|
'href': link.url,
|
||||||
'editCount': link.editCount,
|
'editCount': link.editCount,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// for details. All rights reserved. Use of this source code is governed by a
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
|
|
||||||
/// Information about a link to a compilation unit.
|
/// Information about a link to a compilation unit.
|
||||||
class UnitLink {
|
class UnitLink {
|
||||||
/// The relative URL of this compilation unit on the preview server.
|
/// The relative URL of this compilation unit on the preview server.
|
||||||
|
@ -19,7 +17,5 @@ class UnitLink {
|
||||||
UnitLink(this.url, this.pathParts, this.editCount)
|
UnitLink(this.url, this.pathParts, this.editCount)
|
||||||
: depth = pathParts.length - 1;
|
: depth = pathParts.length - 1;
|
||||||
|
|
||||||
String get relativePath => path.joinAll(pathParts);
|
|
||||||
|
|
||||||
String get fileName => pathParts.last;
|
String get fileName => pathParts.last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,16 +134,15 @@ class NavigationTreeRendererTest extends NnbdMigrationTestBase {
|
||||||
isJsonMap.containing({
|
isJsonMap.containing({
|
||||||
'name': 'src',
|
'name': 'src',
|
||||||
'subtree': [
|
'subtree': [
|
||||||
isJsonMap.containing(
|
isJsonMap.containing({'href': '/project/lib/src/b.dart'})
|
||||||
{'href': convertPath('/project/lib/src/b.dart')})
|
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
isJsonMap.containing({'href': convertPath('/project/lib/a.dart')})
|
isJsonMap.containing({'href': '/project/lib/a.dart'})
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var toolNode = response[1];
|
var toolNode = response[1];
|
||||||
expect(toolNode['href'], convertPath('/project/tool.dart'));
|
expect(toolNode['href'], '/project/tool.dart');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> test_containsMultipleLinks_multipleDepths() async {
|
Future<void> test_containsMultipleLinks_multipleDepths() async {
|
||||||
|
@ -208,12 +207,12 @@ class NavigationTreeRendererTest extends NnbdMigrationTestBase {
|
||||||
isJsonMap.containing({
|
isJsonMap.containing({
|
||||||
'name': 'a.dart',
|
'name': 'a.dart',
|
||||||
'path': convertPath('lib/a.dart'),
|
'path': convertPath('lib/a.dart'),
|
||||||
'href': convertPath('/project/lib/a.dart')
|
'href': '/project/lib/a.dart'
|
||||||
}),
|
}),
|
||||||
isJsonMap.containing({
|
isJsonMap.containing({
|
||||||
'name': 'b.dart',
|
'name': 'b.dart',
|
||||||
'path': convertPath('lib/b.dart'),
|
'path': convertPath('lib/b.dart'),
|
||||||
'href': convertPath('/project/lib/b.dart')
|
'href': '/project/lib/b.dart'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
@ -264,7 +263,7 @@ class NavigationTreeRendererTest extends NnbdMigrationTestBase {
|
||||||
isJsonMap.containing({
|
isJsonMap.containing({
|
||||||
'name': 'a.dart',
|
'name': 'a.dart',
|
||||||
'path': convertPath('lib/src/a.dart'),
|
'path': convertPath('lib/src/a.dart'),
|
||||||
'href': convertPath('/project/lib/src/a.dart')
|
'href': '/project/lib/src/a.dart'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@ -281,7 +280,7 @@ class NavigationTreeRendererTest extends NnbdMigrationTestBase {
|
||||||
var aNode = response[0];
|
var aNode = response[0];
|
||||||
expect(aNode['name'], 'a.dart');
|
expect(aNode['name'], 'a.dart');
|
||||||
expect(aNode['path'], 'a.dart');
|
expect(aNode['path'], 'a.dart');
|
||||||
expect(aNode['href'], convertPath('/project/a.dart'));
|
expect(aNode['href'], '/project/a.dart');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue