Skip to content

Commit

Permalink
Detailed comments for regular expressions and renamed some files.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Dec 16, 2015
1 parent 6f85fe9 commit d23df34
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var languageServiceLibrarySources = [

var harnessCoreSources = [
"harness.ts",
"vfs.ts",
"virtualFileSystem.ts",
"sourceMapRecorder.ts",
"harnessLanguageService.ts",
"fourslash.ts",
Expand Down Expand Up @@ -163,7 +163,7 @@ var harnessSources = harnessCoreSources.concat([
"cachingInServerLSHost.ts",
"moduleResolution.ts",
"tsconfigParsing.ts",
"expandFiles.ts"
"matchFiles.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
Expand Down
55 changes: 52 additions & 3 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,61 @@ namespace ts {
return { options, errors };
}

/**
* Tests for a path that ends in a recursive directory wildcard.
* Matches **, /**, /**\/, and /**\/, but not a**b.

This comment has been minimized.

Copy link
@mihailik

mihailik Dec 17, 2015

Contributor

twice?

     * Matches **, /**, /**\/, and /**\/, but not a**b.
                        ^^^^^      ^^^^^
*
* NOTE: used \/ in place of / above to avoid ending the comment.
*
* Breakdown:
* (^|\/) # matches either the beginning of the string or a directory separator.
* \*\* # matches the recursive directory wildcard "**".
* \/?$ # matches an optional trailing directory separator at the end of the string.
*/
const invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;

/**
* Tests for a path with multiple recursive directory wildcards.
* Matches **\/** and **\/a/**, but not **\/a**b.
*
* NOTE: used \/ in place of / above to avoid ending the comment.
*
* Breakdown:
* (^|\/) # matches either the beginning of the string or a directory separator.
* \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
* (.*\/)? # optionally matches any number of characters followed by a directory separator.
* \*\* # matches a recursive directory wildcard "**"
* ($|\/) # matches either the end of the string or a directory separator.
*/
const invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/;

/**
* Tests for a path containing a wildcard character in a directory component of the path.
* Matches /*\/, /?/, and /a*b/, but not /a/ or /a/*.
*
* NOTE: used \/ in place of / above to avoid ending the comment.
*
* Breakdown:
* \/ # matches a directory separator.
* [^/]*? # matches any number of characters excluding directory separators (non-greedy).
* [*?] # matches either a wildcard character (* or ?)
* [^/]* # matches any number of characters excluding directory separators (greedy).
* \/ # matches a directory separator.
*/
const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;

/**
* Matches the portion of a wildcard path that does not contain wildcards.
* Matches /a of /a/*, or /a/b/c of /a/b/c/?/d.
*
* Breakdown:
* ^ # matches the beginning of the string
* [^*?]* # matches any number of non-wildcard characters
* (?=\/[^/]*[*?]) # lookahead that matches a directory separator followed by
* # a path component that contains at least one wildcard character (* or ?).
*/
const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;

/**
* Expands an array of file specifications.
*
Expand Down Expand Up @@ -693,9 +745,6 @@ namespace ts {
return validSpecs;
}

const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;

/**
* Gets directories in a set of include patterns that should be watched for changes.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// <reference path="external\chai.d.ts"/>
/// <reference path="sourceMapRecorder.ts"/>
/// <reference path="runnerbase.ts"/>
/// <reference path="vfs.ts" />
/// <reference path="virtualFileSystem.ts" />
/* tslint:disable:no-null */

// Block scoped definitions work poorly for global variables, temporarily enable var
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path="..\..\..\src\harness\external\mocha.d.ts" />
/// <reference path="..\..\..\src\harness\harness.ts" />
/// <reference path="..\..\..\src\harness\virtualFileSystem.ts" />

namespace ts {
class MockParseConfigHost extends Utils.VirtualFileSystem implements ParseConfigHost {
Expand Down Expand Up @@ -89,7 +90,7 @@ namespace ts {
"c:/dev/f.other"
]);

describe("expandFiles", () => {
describe("matchFiles", () => {
describe("with literal file list", () => {
it("without exclusions", () => {
const json = {
Expand Down

0 comments on commit d23df34

Please sign in to comment.