@@ -10,6 +10,7 @@ import 'dart:io';
10
10
import 'package:analyzer/dart/ast/ast.dart' ;
11
11
import 'package:analyzer/dart/element/element.dart' ;
12
12
import 'package:analyzer/src/dart/ast/utilities.dart' ;
13
+ import 'package:dartdoc/dartdoc.dart' ;
13
14
import 'package:dartdoc/src/model/model.dart' ;
14
15
import 'package:path/path.dart' as path;
15
16
import 'package:glob/glob.dart' ;
@@ -23,18 +24,27 @@ final Map<String, String> _fileContents = <String, String>{};
23
24
/// Assumes that globs and resource provider are from the same drive, which
24
25
/// will be the case for globs relative to dartdoc_options.yaml.
25
26
///
26
- /// On windows, globs are assumed to use Windows paths in combination with
27
- /// globs, e.g. `C:\foo\bar\*.txt` .
27
+ /// On windows, globs are assumed to use absolute Windows paths with drive
28
+ /// letters in combination with globs, e.g. `C:\foo\bar\*.txt` . `fullName`
29
+ /// also is assumed to have a drive letter.
28
30
bool matchGlobs (List <String > globs, String fullName, {bool isWindows}) {
29
31
isWindows ?? = Platform .isWindows;
30
32
var filteredGlobs = < String > [];
31
33
32
34
if (isWindows) {
33
- assert (_driveLetterMatcher.hasMatch (fullName),
34
- 'can not find drive letter in $fullName ' );
35
- // TODO(jcollins-g): handle globs referencing different drives?
35
+ // TODO(jcollins-g): port this special casing to the glob package.
36
+ var fullNameDriveLetter = _driveLetterMatcher.stringMatch (fullName);
37
+ if (fullNameDriveLetter == null ) {
38
+ throw DartdocFailure (
39
+ 'Unable to recognize drive letter on Windows in: $fullName ' );
40
+ }
41
+ // Build a matcher from the [fullName]'s drive letter to filter the globs.
42
+ var driveGlob = RegExp (fullNameDriveLetter.replaceFirst (r'\' , r'\\' ),
43
+ caseSensitive: false );
36
44
fullName = fullName.replaceFirst (_driveLetterMatcher, r'\' );
37
45
for (var glob in globs) {
46
+ // Globs don't match if they aren't for the same drive.
47
+ if (! driveGlob.hasMatch (glob)) continue ;
38
48
// `C:\` => `\` for rejoining via posix.
39
49
glob = glob.replaceFirst (_driveLetterMatcher, r'/' );
40
50
filteredGlobs.add (path.posix.joinAll (path.windows.split (glob)));
0 commit comments