Skip to content

Commit d23df34

Browse files
committed
Detailed comments for regular expressions and renamed some files.
1 parent 6f85fe9 commit d23df34

File tree

5 files changed

+57
-7
lines changed

5 files changed

+57
-7
lines changed

Jakefile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ var languageServiceLibrarySources = [
131131

132132
var harnessCoreSources = [
133133
"harness.ts",
134-
"vfs.ts",
134+
"virtualFileSystem.ts",
135135
"sourceMapRecorder.ts",
136136
"harnessLanguageService.ts",
137137
"fourslash.ts",
@@ -163,7 +163,7 @@ var harnessSources = harnessCoreSources.concat([
163163
"cachingInServerLSHost.ts",
164164
"moduleResolution.ts",
165165
"tsconfigParsing.ts",
166-
"expandFiles.ts"
166+
"matchFiles.ts"
167167
].map(function (f) {
168168
return path.join(unittestsDirectory, f);
169169
})).concat([

src/compiler/commandLineParser.ts

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,61 @@ namespace ts {
582582
return { options, errors };
583583
}
584584

585+
/**
586+
* Tests for a path that ends in a recursive directory wildcard.
587+
* Matches **, /**, /**\/, and /**\/, but not a**b.
588+
*
589+
* NOTE: used \/ in place of / above to avoid ending the comment.
590+
*
591+
* Breakdown:
592+
* (^|\/) # matches either the beginning of the string or a directory separator.
593+
* \*\* # matches the recursive directory wildcard "**".
594+
* \/?$ # matches an optional trailing directory separator at the end of the string.
595+
*/
585596
const invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
597+
598+
/**
599+
* Tests for a path with multiple recursive directory wildcards.
600+
* Matches **\/** and **\/a/**, but not **\/a**b.
601+
*
602+
* NOTE: used \/ in place of / above to avoid ending the comment.
603+
*
604+
* Breakdown:
605+
* (^|\/) # matches either the beginning of the string or a directory separator.
606+
* \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
607+
* (.*\/)? # optionally matches any number of characters followed by a directory separator.
608+
* \*\* # matches a recursive directory wildcard "**"
609+
* ($|\/) # matches either the end of the string or a directory separator.
610+
*/
586611
const invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/;
587612

613+
/**
614+
* Tests for a path containing a wildcard character in a directory component of the path.
615+
* Matches /*\/, /?/, and /a*b/, but not /a/ or /a/*.
616+
*
617+
* NOTE: used \/ in place of / above to avoid ending the comment.
618+
*
619+
* Breakdown:
620+
* \/ # matches a directory separator.
621+
* [^/]*? # matches any number of characters excluding directory separators (non-greedy).
622+
* [*?] # matches either a wildcard character (* or ?)
623+
* [^/]* # matches any number of characters excluding directory separators (greedy).
624+
* \/ # matches a directory separator.
625+
*/
626+
const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
627+
628+
/**
629+
* Matches the portion of a wildcard path that does not contain wildcards.
630+
* Matches /a of /a/*, or /a/b/c of /a/b/c/?/d.
631+
*
632+
* Breakdown:
633+
* ^ # matches the beginning of the string
634+
* [^*?]* # matches any number of non-wildcard characters
635+
* (?=\/[^/]*[*?]) # lookahead that matches a directory separator followed by
636+
* # a path component that contains at least one wildcard character (* or ?).
637+
*/
638+
const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
639+
588640
/**
589641
* Expands an array of file specifications.
590642
*
@@ -693,9 +745,6 @@ namespace ts {
693745
return validSpecs;
694746
}
695747

696-
const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
697-
const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
698-
699748
/**
700749
* Gets directories in a set of include patterns that should be watched for changes.
701750
*/

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/// <reference path="external\chai.d.ts"/>
2424
/// <reference path="sourceMapRecorder.ts"/>
2525
/// <reference path="runnerbase.ts"/>
26-
/// <reference path="vfs.ts" />
26+
/// <reference path="virtualFileSystem.ts" />
2727
/* tslint:disable:no-null */
2828

2929
// Block scoped definitions work poorly for global variables, temporarily enable var
File renamed without changes.

tests/cases/unittests/expandFiles.ts renamed to tests/cases/unittests/matchFiles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference path="..\..\..\src\harness\external\mocha.d.ts" />
22
/// <reference path="..\..\..\src\harness\harness.ts" />
3+
/// <reference path="..\..\..\src\harness\virtualFileSystem.ts" />
34

45
namespace ts {
56
class MockParseConfigHost extends Utils.VirtualFileSystem implements ParseConfigHost {
@@ -89,7 +90,7 @@ namespace ts {
8990
"c:/dev/f.other"
9091
]);
9192

92-
describe("expandFiles", () => {
93+
describe("matchFiles", () => {
9394
describe("with literal file list", () => {
9495
it("without exclusions", () => {
9596
const json = {

0 commit comments

Comments
 (0)