Skip to content

Commit e0227d1

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into for-ofES6
2 parents 7dd7b43 + 18b7257 commit e0227d1

File tree

363 files changed

+8292
-8316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+8292
-8316
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
root = true
3+
4+
[{src,scripts}/**.{ts,json,js}]
5+
end_of_line = crlf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 4

src/harness/harnessLanguageService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path='..\services\services.ts' />
1+
/// <reference path='..\services\services.ts' />
22
/// <reference path='..\services\shims.ts' />
33
/// <reference path='..\server\client.ts' />
44
/// <reference path='harness.ts' />

src/services/services.ts

+52-30
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ module ts {
5858
}
5959

6060
export interface SourceFile {
61-
version: string;
62-
scriptSnapshot: IScriptSnapshot;
63-
nameTable: Map<string>;
61+
/* @internal */ version: string;
62+
/* @internal */ scriptSnapshot: IScriptSnapshot;
63+
/* @internal */ nameTable: Map<string>;
64+
6465
getNamedDeclarations(): Declaration[];
6566
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
6667
getLineStarts(): number[];
@@ -4138,27 +4139,6 @@ module ts {
41384139
return getReferencesForNode(node, program.getSourceFiles(), /*searchOnlyInCurrentFile*/ false, findInStrings, findInComments);
41394140
}
41404141

4141-
function initializeNameTable(sourceFile: SourceFile): void {
4142-
var nameTable: Map<string> = {};
4143-
4144-
walk(sourceFile);
4145-
sourceFile.nameTable = nameTable;
4146-
4147-
function walk(node: Node) {
4148-
switch (node.kind) {
4149-
case SyntaxKind.Identifier:
4150-
nameTable[(<Identifier>node).text] = (<Identifier>node).text;
4151-
break;
4152-
case SyntaxKind.StringLiteral:
4153-
case SyntaxKind.NumericLiteral:
4154-
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
4155-
break;
4156-
default:
4157-
forEachChild(node, walk);
4158-
}
4159-
}
4160-
}
4161-
41624142
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
41634143
// Labels
41644144
if (isLabelName(node)) {
@@ -4225,13 +4205,9 @@ module ts {
42254205
forEach(sourceFiles, sourceFile => {
42264206
cancellationToken.throwIfCancellationRequested();
42274207

4228-
if (!sourceFile.nameTable) {
4229-
initializeNameTable(sourceFile)
4230-
}
4208+
var nameTable = getNameTable(sourceFile);
42314209

4232-
Debug.assert(sourceFile.nameTable !== undefined);
4233-
4234-
if (lookUp(sourceFile.nameTable, internedName)) {
4210+
if (lookUp(nameTable, internedName)) {
42354211
result = result || [];
42364212
getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
42374213
}
@@ -5775,6 +5751,52 @@ module ts {
57755751
};
57765752
}
57775753

5754+
/* @internal */
5755+
export function getNameTable(sourceFile: SourceFile): Map<string> {
5756+
if (!sourceFile.nameTable) {
5757+
initializeNameTable(sourceFile)
5758+
}
5759+
5760+
return sourceFile.nameTable;
5761+
}
5762+
5763+
function initializeNameTable(sourceFile: SourceFile): void {
5764+
var nameTable: Map<string> = {};
5765+
5766+
walk(sourceFile);
5767+
sourceFile.nameTable = nameTable;
5768+
5769+
function walk(node: Node) {
5770+
switch (node.kind) {
5771+
case SyntaxKind.Identifier:
5772+
nameTable[(<Identifier>node).text] = (<Identifier>node).text;
5773+
break;
5774+
case SyntaxKind.StringLiteral:
5775+
case SyntaxKind.NumericLiteral:
5776+
// We want to store any numbers/strings if they were a name that could be
5777+
// related to a declaration. So, if we have 'import x = require("something")'
5778+
// then we want 'something' to be in the name table. Similarly, if we have
5779+
// "a['propname']" then we want to store "propname" in the name table.
5780+
if (isDeclarationName(node) ||
5781+
node.parent.kind === SyntaxKind.ExternalModuleReference ||
5782+
isArgumentOfElementAccessExpression(node)) {
5783+
5784+
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
5785+
}
5786+
break;
5787+
default:
5788+
forEachChild(node, walk);
5789+
}
5790+
}
5791+
}
5792+
5793+
function isArgumentOfElementAccessExpression(node: Node) {
5794+
return node &&
5795+
node.parent &&
5796+
node.parent.kind === SyntaxKind.ElementAccessExpression &&
5797+
(<ElementAccessExpression>node.parent).argumentExpression === node;
5798+
}
5799+
57785800
/// Classifier
57795801
export function createClassifier(): Classifier {
57805802
var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);

src/services/signatureHelp.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ module ts.SignatureHelp {
295295
var tagExpression = <TaggedTemplateExpression>templateExpression.parent;
296296
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
297297

298-
// If we're just after a template tail, don't show signature help.
299-
if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(<LiteralExpression>node, position)) {
298+
// If we're just after a template tail, don't show signature help.
299+
if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(<LiteralExpression>node, position)) {
300300
return undefined;
301301
}
302302

tests/baselines/reference/APISample_compile.js

-3
Original file line numberDiff line numberDiff line change
@@ -1518,9 +1518,6 @@ declare module "typescript" {
15181518
getDocumentationComment(): SymbolDisplayPart[];
15191519
}
15201520
interface SourceFile {
1521-
version: string;
1522-
scriptSnapshot: IScriptSnapshot;
1523-
nameTable: Map<string>;
15241521
getNamedDeclarations(): Declaration[];
15251522
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
15261523
getLineStarts(): number[];

tests/baselines/reference/APISample_compile.types

-11
Original file line numberDiff line numberDiff line change
@@ -4896,17 +4896,6 @@ declare module "typescript" {
48964896
interface SourceFile {
48974897
>SourceFile : SourceFile
48984898

4899-
version: string;
4900-
>version : string
4901-
4902-
scriptSnapshot: IScriptSnapshot;
4903-
>scriptSnapshot : IScriptSnapshot
4904-
>IScriptSnapshot : IScriptSnapshot
4905-
4906-
nameTable: Map<string>;
4907-
>nameTable : Map<string>
4908-
>Map : Map<T>
4909-
49104899
getNamedDeclarations(): Declaration[];
49114900
>getNamedDeclarations : () => Declaration[]
49124901
>Declaration : Declaration

tests/baselines/reference/APISample_linter.js

-3
Original file line numberDiff line numberDiff line change
@@ -1549,9 +1549,6 @@ declare module "typescript" {
15491549
getDocumentationComment(): SymbolDisplayPart[];
15501550
}
15511551
interface SourceFile {
1552-
version: string;
1553-
scriptSnapshot: IScriptSnapshot;
1554-
nameTable: Map<string>;
15551552
getNamedDeclarations(): Declaration[];
15561553
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
15571554
getLineStarts(): number[];

tests/baselines/reference/APISample_linter.types

-11
Original file line numberDiff line numberDiff line change
@@ -5042,17 +5042,6 @@ declare module "typescript" {
50425042
interface SourceFile {
50435043
>SourceFile : SourceFile
50445044

5045-
version: string;
5046-
>version : string
5047-
5048-
scriptSnapshot: IScriptSnapshot;
5049-
>scriptSnapshot : IScriptSnapshot
5050-
>IScriptSnapshot : IScriptSnapshot
5051-
5052-
nameTable: Map<string>;
5053-
>nameTable : Map<string>
5054-
>Map : Map<T>
5055-
50565045
getNamedDeclarations(): Declaration[];
50575046
>getNamedDeclarations : () => Declaration[]
50585047
>Declaration : Declaration

tests/baselines/reference/APISample_transform.js

-3
Original file line numberDiff line numberDiff line change
@@ -1550,9 +1550,6 @@ declare module "typescript" {
15501550
getDocumentationComment(): SymbolDisplayPart[];
15511551
}
15521552
interface SourceFile {
1553-
version: string;
1554-
scriptSnapshot: IScriptSnapshot;
1555-
nameTable: Map<string>;
15561553
getNamedDeclarations(): Declaration[];
15571554
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
15581555
getLineStarts(): number[];

tests/baselines/reference/APISample_transform.types

-11
Original file line numberDiff line numberDiff line change
@@ -4992,17 +4992,6 @@ declare module "typescript" {
49924992
interface SourceFile {
49934993
>SourceFile : SourceFile
49944994

4995-
version: string;
4996-
>version : string
4997-
4998-
scriptSnapshot: IScriptSnapshot;
4999-
>scriptSnapshot : IScriptSnapshot
5000-
>IScriptSnapshot : IScriptSnapshot
5001-
5002-
nameTable: Map<string>;
5003-
>nameTable : Map<string>
5004-
>Map : Map<T>
5005-
50064995
getNamedDeclarations(): Declaration[];
50074996
>getNamedDeclarations : () => Declaration[]
50084997
>Declaration : Declaration

tests/baselines/reference/APISample_watcher.js

-3
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,6 @@ declare module "typescript" {
15871587
getDocumentationComment(): SymbolDisplayPart[];
15881588
}
15891589
interface SourceFile {
1590-
version: string;
1591-
scriptSnapshot: IScriptSnapshot;
1592-
nameTable: Map<string>;
15931590
getNamedDeclarations(): Declaration[];
15941591
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
15951592
getLineStarts(): number[];

tests/baselines/reference/APISample_watcher.types

-11
Original file line numberDiff line numberDiff line change
@@ -5165,17 +5165,6 @@ declare module "typescript" {
51655165
interface SourceFile {
51665166
>SourceFile : SourceFile
51675167

5168-
version: string;
5169-
>version : string
5170-
5171-
scriptSnapshot: IScriptSnapshot;
5172-
>scriptSnapshot : IScriptSnapshot
5173-
>IScriptSnapshot : IScriptSnapshot
5174-
5175-
nameTable: Map<string>;
5176-
>nameTable : Map<string>
5177-
>Map : Map<T>
5178-
51795168
getNamedDeclarations(): Declaration[];
51805169
>getNamedDeclarations : () => Declaration[]
51815170
>Declaration : Declaration
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/// <reference path="fourslash.ts" />
2-
3-
//// /**/module mAmbient {
4-
//// module m3 { }
5-
//// }
6-
7-
goTo.marker('');
8-
edit.insert("declare ");
1+
/// <reference path="fourslash.ts" />
2+
3+
//// /**/module mAmbient {
4+
//// module m3 { }
5+
//// }
6+
7+
goTo.marker('');
8+
edit.insert("declare ");
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/// <reference path="fourslash.ts" />
2-
3-
//// class C {
4-
//// set foo(value) { }
5-
//// /**/
6-
//// }
7-
8-
goTo.marker();
9-
edit.insert("set foo(value) { }");
10-
1+
/// <reference path="fourslash.ts" />
2+
3+
//// class C {
4+
//// set foo(value) { }
5+
//// /**/
6+
//// }
7+
8+
goTo.marker();
9+
edit.insert("set foo(value) { }");
10+
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/// <reference path="fourslash.ts" />
2-
3-
//// class Foo {
4-
//// constructor() { }
5-
//// constructor() { }
6-
//// /**/
7-
//// }
8-
9-
goTo.marker();
10-
var func = 'fn() { }';
11-
edit.insert(func);
12-
verify.numberOfErrorsInCurrentFile(2);
1+
/// <reference path="fourslash.ts" />
2+
3+
//// class Foo {
4+
//// constructor() { }
5+
//// constructor() { }
6+
//// /**/
7+
//// }
8+
9+
goTo.marker();
10+
var func = 'fn() { }';
11+
edit.insert(func);
12+
verify.numberOfErrorsInCurrentFile(2);
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
/// <reference path="fourslash.ts" />
2-
3-
////
4-
//// interface Intersection {
5-
//// /*insertHere*/
6-
//// }
7-
//// interface Scene { }
8-
//// class /*className*/Sphere {
9-
//// constructor() {
10-
//// }
11-
//// }
12-
13-
goTo.marker('className');
14-
verify.quickInfoIs('class Sphere');
15-
16-
goTo.marker('insertHere');
17-
edit.insert("ray: Ray;");
18-
19-
goTo.marker('className');
20-
1+
/// <reference path="fourslash.ts" />
2+
3+
////
4+
//// interface Intersection {
5+
//// /*insertHere*/
6+
//// }
7+
//// interface Scene { }
8+
//// class /*className*/Sphere {
9+
//// constructor() {
10+
//// }
11+
//// }
12+
13+
goTo.marker('className');
14+
verify.quickInfoIs('class Sphere');
15+
16+
goTo.marker('insertHere');
17+
edit.insert("ray: Ray;");
18+
19+
goTo.marker('className');
20+
2121
verify.quickInfoIs('class Sphere');
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/// <reference path="fourslash.ts" />
2-
3-
//// interface A {
4-
//// a: number;
5-
//// }
6-
//// /**/
7-
//// interface C<T extends A> {
8-
//// x: T;
9-
//// }
10-
////
11-
//// var v2: C<B>; // should not work
12-
13-
goTo.marker();
14-
edit.insert("interface B { b: string; }");
1+
/// <reference path="fourslash.ts" />
2+
3+
//// interface A {
4+
//// a: number;
5+
//// }
6+
//// /**/
7+
//// interface C<T extends A> {
8+
//// x: T;
9+
//// }
10+
////
11+
//// var v2: C<B>; // should not work
12+
13+
goTo.marker();
14+
edit.insert("interface B { b: string; }");

0 commit comments

Comments
 (0)