Skip to content

Commit 1cf8870

Browse files
authored
Convert 'p' prefixes to 'path' in tool/ (dart-lang#3472)
1 parent d44c805 commit 1cf8870

File tree

5 files changed

+87
-85
lines changed

5 files changed

+87
-85
lines changed

tool/mustachio/builder.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import 'package:analyzer/file_system/physical_file_system.dart';
77
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart'
88
show AnalysisContextCollectionImpl;
99
import 'package:dartdoc/src/mustachio/annotations.dart';
10-
import 'package:path/path.dart' as p;
10+
import 'package:path/path.dart' as path;
1111

1212
import 'codegen_aot_compiler.dart';
1313
import 'codegen_runtime_renderer.dart';
1414

1515
void main() async {
16-
await build(p.join('lib', 'src', 'generator', 'templates.dart'));
16+
await build(path.join('lib', 'src', 'generator', 'templates.dart'));
1717
await build(
18-
p.join('test', 'mustachio', 'foo.dart'),
18+
path.join('test', 'mustachio', 'foo.dart'),
1919
rendererClassesArePublic: true,
2020
);
2121
}
@@ -36,7 +36,7 @@ Future<void> build(
3636
);
3737
var analysisContext = contextCollection.contextFor(root);
3838
final libraryResult = await analysisContext.currentSession
39-
.getResolvedLibrary(p.join(root, sourcePath));
39+
.getResolvedLibrary(path.join(root, sourcePath));
4040
if (libraryResult is! ResolvedLibraryResult) {
4141
throw StateError(
4242
'Expected library result to be ResolvedLibraryResult, but is '
@@ -59,8 +59,8 @@ Future<void> build(
5959
typeSystem,
6060
rendererClassesArePublic: rendererClassesArePublic,
6161
);
62-
await File(p.join(
63-
root, '${p.withoutExtension(sourcePath)}.runtime_renderers.dart'))
62+
var basePath = path.withoutExtension(sourcePath);
63+
await File(path.join(root, '$basePath.runtime_renderers.dart'))
6464
.writeAsString(runtimeRenderersContents);
6565

6666
for (var format in templateFormats) {
@@ -79,8 +79,8 @@ Future<void> build(
7979
aotRenderersContents = '';
8080
}
8181

82-
var basePath = p.withoutExtension(sourcePath);
83-
await File(p.join(root, format.aotLibraryPath(basePath)))
82+
var basePath = path.withoutExtension(sourcePath);
83+
await File(path.join(root, format.aotLibraryPath(basePath)))
8484
.writeAsString(aotRenderersContents);
8585
}
8686
}

tool/mustachio/codegen_aot_compiler.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'package:dartdoc/src/mustachio/parser.dart';
1515
import 'package:dartdoc/src/mustachio/renderer_base.dart';
1616
import 'package:dartdoc/src/type_utils.dart';
1717
import 'package:meta/meta.dart';
18-
import 'package:path/path.dart' as p;
18+
import 'package:path/path.dart' as path;
1919

2020
/// Compiles all templates specified in [specs] into a Dart library containing
2121
/// a renderer for each template.
@@ -111,8 +111,8 @@ Future<Map<_AotCompiler, String>> _deduplicateRenderers(
111111
.add(compiler);
112112
}
113113
var partialsToRemove = <_AotCompiler>{};
114-
for (var path in compilersPerPartial.keys) {
115-
var compilers = compilersPerPartial[path]!;
114+
for (var filePath in compilersPerPartial.keys) {
115+
var compilers = compilersPerPartial[filePath]!;
116116
if (compilers.length < 2) {
117117
// Nothing to deduplicate.
118118
continue;
@@ -138,11 +138,11 @@ Future<Map<_AotCompiler, String>> _deduplicateRenderers(
138138
// Each of the render functions generated by a compiler for this asset can
139139
// be replaced by a more generic renderer which accepts the LUB types. The
140140
// body of each replaced renderer can perform a simple redirect.
141-
var rendererName = path.replaceAll('.', '_').replaceAll('/', '_');
141+
var rendererName = filePath.replaceAll('.', '_').replaceAll('/', '_');
142142
var lubCompiler = _AotCompiler._(
143143
contextStackTypes.first,
144144
'_deduplicated_$rendererName',
145-
path,
145+
filePath,
146146
firstCompiler._syntaxTree,
147147
firstCompiler._buildData,
148148
contextStack: [
@@ -158,7 +158,7 @@ Future<Map<_AotCompiler, String>> _deduplicateRenderers(
158158
// likely the properties accessed in the partial are not all declared on
159159
// the LUB type.
160160
var names = compilers.map((c) => c._rendererName);
161-
print('Could not deduplicate $path ${names.join(', ')}');
161+
print('Could not deduplicate $filePath ${names.join(', ')}');
162162
continue;
163163
}
164164

@@ -281,7 +281,7 @@ class _AotCompiler {
281281
List<_VariableLookup> contextStack = const [],
282282
}) async {
283283
var template =
284-
await File(p.join(buildData._root, templatePath)).readAsString();
284+
await File(path.join(buildData._root, templatePath)).readAsString();
285285
var syntaxTree = MustachioParser(template, templatePath).parse();
286286
return _AotCompiler._(
287287
contextType, rendererName, templatePath, syntaxTree, buildData,
@@ -381,8 +381,8 @@ class _AotCompiler {
381381
var libraryElement = element.library!;
382382
var libraryUri = libraryElement.source.uri;
383383
if (libraryUri.scheme == 'file') {
384-
return p.relative(libraryUri.path,
385-
from: p.absolute(p.dirname(_buildData._sourcePath)));
384+
return path.relative(libraryUri.path,
385+
from: path.absolute(path.dirname(_buildData._sourcePath)));
386386
}
387387
return libraryUri.toString();
388388
}
@@ -449,11 +449,11 @@ class _BlockCompiler {
449449
/// Compiles [node] into a renderer's Dart source.
450450
Future<void> _compilePartial(Partial node, Set<String> referenceUris) async {
451451
var extension = format == TemplateFormat.html ? 'html' : 'md';
452-
var path = node.key.split('/');
453-
var fileName = path.removeLast();
454-
path.add('_$fileName.$extension');
455-
var partialPath =
456-
p.join(p.dirname(_templateCompiler._templatePath), path.join('/'));
452+
var filePath = node.key.split('/');
453+
var fileName = filePath.removeLast();
454+
filePath.add('_$fileName.$extension');
455+
var partialPath = path.join(
456+
path.dirname(_templateCompiler._templatePath), filePath.join('/'));
457457
var partialCompiler = _templateCompiler._partialCompilers
458458
.firstWhereOrNull((p) => p._templatePath == partialPath);
459459
if (partialCompiler == null) {

tool/mustachio/codegen_runtime_renderer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:analyzer/dart/element/type_system.dart';
1212
import 'package:dart_style/dart_style.dart';
1313
import 'package:dartdoc/src/mustachio/annotations.dart';
1414
import 'package:dartdoc/src/type_utils.dart';
15-
import 'package:path/path.dart' as p;
15+
import 'package:path/path.dart' as path;
1616

1717
import 'utilities.dart';
1818

@@ -97,7 +97,7 @@ import 'package:dartdoc/src/model/model_object_builder.dart';
9797
import 'package:dartdoc/src/mustachio/parser.dart';
9898
import 'package:dartdoc/src/mustachio/renderer_base.dart';
9999
import 'package:dartdoc/src/warnings.dart';
100-
import '${p.basename(_sourceUri.path)}';
100+
import '${path.basename(_sourceUri.path)}';
101101
''');
102102

103103
specs.forEach(_addTypesForRendererSpec);

tool/src/flutter_repo.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,44 @@ import 'dart:async';
66
import 'dart:io';
77

88
import 'package:dartdoc/src/io_utils.dart';
9-
import 'package:path/path.dart' as p;
9+
import 'package:path/path.dart' as path;
1010

1111
import 'io_utils.dart' as io_utils;
1212
import 'subprocess_launcher.dart';
1313

1414
/// A class representing a Flutter SDK repository.
1515
class FlutterRepo {
16-
final String path;
16+
final String repoPath;
1717
final Map<String, String> env;
18-
final String flutterCmd = p.join('bin', 'flutter');
18+
final String flutterCmd = path.join('bin', 'flutter');
1919

2020
final String cacheDart;
2121
final SubprocessLauncher launcher;
2222

23-
FlutterRepo._(this.path, this.env, this.cacheDart, this.launcher);
23+
FlutterRepo._(this.repoPath, this.env, this.cacheDart, this.launcher);
2424

2525
Future<void> init() async {
26-
Directory(path).createSync(recursive: true);
26+
Directory(repoPath).createSync(recursive: true);
2727
await launcher.runStreamed(
2828
'git', ['clone', 'https://github.com/flutter/flutter.git', '.'],
29-
workingDirectory: path);
29+
workingDirectory: repoPath);
3030
await launcher.runStreamed(
3131
flutterCmd,
3232
['--version'],
33-
workingDirectory: path,
33+
workingDirectory: repoPath,
3434
);
3535
await launcher.runStreamed(
3636
flutterCmd,
3737
['update-packages'],
38-
workingDirectory: path,
38+
workingDirectory: repoPath,
3939
);
4040
}
4141

4242
factory FlutterRepo.fromPath(String flutterPath, Map<String, String> env,
4343
[String? label]) {
4444
var cacheDart =
45-
p.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
46-
var flutterBinPath = p.join(p.canonicalize(flutterPath), 'bin');
45+
path.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
46+
var flutterBinPath = path.join(path.canonicalize(flutterPath), 'bin');
4747
var existingPathVariable = env['PATH'] ?? Platform.environment['PATH'];
4848
env['PATH'] = '$flutterBinPath:$existingPathVariable';
4949
env['FLUTTER_ROOT'] = flutterPath;
@@ -56,20 +56,20 @@ class FlutterRepo {
5656
static Future<FlutterRepo> copyFromExistingFlutterRepo(
5757
FlutterRepo originalRepo, String flutterPath, Map<String, String> env,
5858
[String? label]) async {
59-
io_utils.copy(Directory(originalRepo.path), Directory(flutterPath));
59+
io_utils.copy(Directory(originalRepo.repoPath), Directory(flutterPath));
6060
return FlutterRepo.fromPath(flutterPath, env, label);
6161
}
6262

6363
/// Doesn't actually copy the existing repo; use for read-only operations
6464
/// only.
6565
static Future<FlutterRepo> fromExistingFlutterRepo(FlutterRepo originalRepo,
6666
[String? label]) async {
67-
return FlutterRepo.fromPath(originalRepo.path, {}, label);
67+
return FlutterRepo.fromPath(originalRepo.repoPath, {}, label);
6868
}
6969
}
7070

71-
Directory cleanFlutterDir = Directory(
72-
p.join(p.context.resolveTildePath('~/.dartdoc_grinder'), 'cleanFlutter'));
71+
Directory cleanFlutterDir = Directory(path.join(
72+
path.context.resolveTildePath('~/.dartdoc_grinder'), 'cleanFlutter'));
7373

7474
/// Global so that the lock is retained for the life of the process.
7575
Future<void>? _lockFuture;
@@ -93,11 +93,11 @@ Future<FlutterRepo> get cleanFlutterRepo async {
9393
// Figure out where the repository is supposed to be and lock updates for it.
9494
await cleanFlutterDir.parent.create(recursive: true);
9595
assert(_lockFuture == null);
96-
_lockFuture = File(p.join(cleanFlutterDir.parent.path, 'lock'))
96+
_lockFuture = File(path.join(cleanFlutterDir.parent.path, 'lock'))
9797
.openSync(mode: FileMode.write)
9898
.lock();
9999
await _lockFuture;
100-
var lastSynced = File(p.join(cleanFlutterDir.parent.path, 'lastSynced'));
100+
var lastSynced = File(path.join(cleanFlutterDir.parent.path, 'lastSynced'));
101101
var newRepo = FlutterRepo.fromPath(cleanFlutterDir.path, {}, 'clean');
102102

103103
// We have a repository, but is it up to date?

0 commit comments

Comments
 (0)