Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0e91347

Browse filesBrowse files
Port fidelity changes to github.
1 parent 80bab05 commit 0e91347
Copy full SHA for 0e91347

44 files changed

+379-17Lines changed: 379 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/compiler/astWalker.ts‎

Copy file name to clipboardExpand all lines: src/services/compiler/astWalker.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ module TypeScript {
4242
walker.walk(preAst.typeArguments);
4343
}
4444

45+
function walkTupleTypeChildren(preAst: TupleTypeSyntax, walker: AstWalker): void {
46+
walker.walk(preAst.types);
47+
}
48+
4549
function walkTypeOfExpressionChildren(preAst: TypeOfExpressionSyntax, walker: AstWalker): void {
4650
walker.walk(preAst.expression);
4751
}
@@ -561,6 +565,7 @@ module TypeScript {
561565
childrenWalkers[SyntaxKind.TriviaList] = null;
562566
childrenWalkers[SyntaxKind.TrueKeyword] = null;
563567
childrenWalkers[SyntaxKind.TryStatement] = walkTryStatementChildren;
568+
childrenWalkers[SyntaxKind.TupleType] = walkTupleTypeChildren;
564569
childrenWalkers[SyntaxKind.TypeAnnotation] = walkTypeAnnotationChildren;
565570
childrenWalkers[SyntaxKind.TypeArgumentList] = walkTypeArgumentListChildren;
566571
childrenWalkers[SyntaxKind.TypeOfExpression] = walkTypeOfExpressionChildren;
Collapse file

‎src/services/syntax/defaultSyntaxVisitor.generated.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/defaultSyntaxVisitor.generated.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ module TypeScript {
4242
return this.defaultVisit(node);
4343
}
4444

45+
public visitTupleType(node: TupleTypeSyntax): any {
46+
return this.defaultVisit(node);
47+
}
48+
4549
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any {
4650
return this.defaultVisit(node);
4751
}
Collapse file

‎src/services/syntax/parser.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/parser.ts
+41-8Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,7 @@ module TypeScript.Parser {
10481048
case SyntaxKind.ExportKeyword:
10491049
case SyntaxKind.PublicKeyword:
10501050
case SyntaxKind.PrivateKeyword:
1051+
case SyntaxKind.ProtectedKeyword:
10511052
case SyntaxKind.StaticKeyword:
10521053
case SyntaxKind.DeclareKeyword:
10531054
return true;
@@ -1434,6 +1435,19 @@ module TypeScript.Parser {
14341435
return new syntaxFactory.ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers, eatToken(SyntaxKind.CloseBraceToken));
14351436
}
14361437

1438+
function parseTupleType(currentToken: ISyntaxToken): TupleTypeSyntax {
1439+
var openBracket = consumeToken(currentToken);
1440+
1441+
var types = Syntax.emptySeparatedList<ITypeSyntax>();
1442+
if (openBracket.fullWidth() > 0) {
1443+
var skippedTokens: ISyntaxToken[] = getArray();
1444+
types = parseSeparatedSyntaxList<ITypeSyntax>(ListParsingState.TupleType_Types, skippedTokens);
1445+
openBracket = addSkippedTokensAfterToken(openBracket, skippedTokens);
1446+
}
1447+
1448+
return new syntaxFactory.TupleTypeSyntax(parseNodeData, openBracket, types, eatToken(SyntaxKind.CloseBracketToken));
1449+
}
1450+
14371451
function isTypeMember(inErrorRecovery: boolean): boolean {
14381452
if (SyntaxUtilities.isTypeMember(currentNode())) {
14391453
return true;
@@ -1663,6 +1677,7 @@ module TypeScript.Parser {
16631677
// ERROR RECOVERY
16641678
case SyntaxKind.PublicKeyword:
16651679
case SyntaxKind.PrivateKeyword:
1680+
case SyntaxKind.ProtectedKeyword:
16661681
case SyntaxKind.StaticKeyword:
16671682
// None of the above are actually keywords. And they might show up in a real
16681683
// statement (i.e. "public();"). However, if we see 'public <identifier>' then
@@ -1731,6 +1746,7 @@ module TypeScript.Parser {
17311746
// ERROR RECOVERY
17321747
case SyntaxKind.PublicKeyword:
17331748
case SyntaxKind.PrivateKeyword:
1749+
case SyntaxKind.ProtectedKeyword:
17341750
case SyntaxKind.StaticKeyword:
17351751
// None of the above are actually keywords. And they might show up in a real
17361752
// statement (i.e. "public();"). However, if we see 'public <identifier>' then
@@ -3133,7 +3149,7 @@ module TypeScript.Parser {
31333149
token2 = peekToken(2);
31343150
token2Kind = token2.kind();
31353151

3136-
if (token1Kind === SyntaxKind.PublicKeyword || token1Kind === SyntaxKind.PrivateKeyword) {
3152+
if (SyntaxFacts.isAccessibilityModifier(token1Kind)) {
31373153
if (isIdentifier(token2)) {
31383154
// "(public id" or "(function id". Definitely an arrow function. Could never
31393155
// be a parenthesized expression. Note: this will be an *illegal* arrow
@@ -3557,11 +3573,12 @@ module TypeScript.Parser {
35573573

35583574
return consumeToken(_currentToken);
35593575
case SyntaxKind.OpenParenToken:
3560-
case SyntaxKind.LessThanToken: return tryParseFunctionType();
3561-
case SyntaxKind.VoidKeyword: return consumeToken(_currentToken);
3562-
case SyntaxKind.OpenBraceToken: return parseObjectType();
3563-
case SyntaxKind.NewKeyword: return parseConstructorType();
3564-
case SyntaxKind.TypeOfKeyword: return parseTypeQuery(_currentToken);
3576+
case SyntaxKind.LessThanToken: return tryParseFunctionType();
3577+
case SyntaxKind.VoidKeyword: return consumeToken(_currentToken);
3578+
case SyntaxKind.OpenBraceToken: return parseObjectType();
3579+
case SyntaxKind.NewKeyword: return parseConstructorType();
3580+
case SyntaxKind.TypeOfKeyword: return parseTypeQuery(_currentToken);
3581+
case SyntaxKind.OpenBracketToken: return parseTupleType(_currentToken);
35653582
}
35663583

35673584
return tryParseNameOrGenericType();
@@ -3973,6 +3990,7 @@ module TypeScript.Parser {
39733990
case ListParsingState.IndexSignature_Parameters: return isExpectedIndexSignature_ParametersTerminator();
39743991
case ListParsingState.TypeArgumentList_Types: return isExpectedTypeArgumentList_TypesTerminator();
39753992
case ListParsingState.TypeParameterList_TypeParameters: return isExpectedTypeParameterList_TypeParametersTerminator();
3993+
case ListParsingState.TupleType_Types: return isExpectedTupleType_TypesTerminator();
39763994
default:
39773995
throw Errors.invalidOperation();
39783996
}
@@ -4019,6 +4037,17 @@ module TypeScript.Parser {
40194037
return false;
40204038
}
40214039

4040+
function isExpectedTupleType_TypesTerminator(): boolean {
4041+
var token = currentToken();
4042+
var tokenKind = token.kind();
4043+
if (tokenKind === SyntaxKind.CloseBracketToken) {
4044+
return true;
4045+
}
4046+
4047+
// TODO: add more cases as necessary for error tolerance.
4048+
return false;
4049+
}
4050+
40224051
function isExpectedTypeParameterList_TypeParametersTerminator(): boolean {
40234052
var tokenKind = currentToken().kind();
40244053
if (tokenKind === SyntaxKind.GreaterThanToken) {
@@ -4187,7 +4216,8 @@ module TypeScript.Parser {
41874216
case ListParsingState.IndexSignature_Parameters: return isParameter();
41884217
case ListParsingState.TypeArgumentList_Types: return isType();
41894218
case ListParsingState.TypeParameterList_TypeParameters: return isTypeParameter();
4190-
default: throw Errors.invalidOperation();
4219+
case ListParsingState.TupleType_Types: return isType();
4220+
default: throw Errors.invalidOperation();
41914221
}
41924222
}
41934223

@@ -4230,6 +4260,7 @@ module TypeScript.Parser {
42304260
case ListParsingState.IndexSignature_Parameters: return tryParseParameter();
42314261
case ListParsingState.TypeArgumentList_Types: return tryParseType();
42324262
case ListParsingState.TypeParameterList_TypeParameters: return tryParseTypeParameter();
4263+
case ListParsingState.TupleType_Types: return tryParseType();
42334264
default: throw Errors.invalidOperation();
42344265
}
42354266
}
@@ -4254,6 +4285,7 @@ module TypeScript.Parser {
42544285
case ListParsingState.IndexSignature_Parameters: return getLocalizedText(DiagnosticCode.parameter, null);
42554286
case ListParsingState.TypeArgumentList_Types: return getLocalizedText(DiagnosticCode.type, null);
42564287
case ListParsingState.TypeParameterList_TypeParameters: return getLocalizedText(DiagnosticCode.type_parameter, null);
4288+
case ListParsingState.TupleType_Types: return getLocalizedText(DiagnosticCode.type, null);
42574289
case ListParsingState.ArrayLiteralExpression_AssignmentExpressions: return getLocalizedText(DiagnosticCode.expression, null);
42584290
default: throw Errors.invalidOperation();
42594291
}
@@ -4376,9 +4408,10 @@ module TypeScript.Parser {
43764408
IndexSignature_Parameters = 18,
43774409
TypeArgumentList_Types = 19,
43784410
TypeParameterList_TypeParameters = 20,
4411+
TupleType_Types = 21,
43794412

43804413
FirstListParsingState = SourceUnit_ModuleElements,
4381-
LastListParsingState = TypeParameterList_TypeParameters,
4414+
LastListParsingState = TupleType_Types,
43824415
}
43834416

43844417
// We keep the parser around as a singleton. This is because calling createParser is actually
Collapse file

‎src/services/syntax/prettyPrinter.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/prettyPrinter.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ module TypeScript.PrettyPrinter {
421421
this.appendToken(node.greaterThanToken);
422422
}
423423

424+
public visitTupleType(node: TupleTypeSyntax): void {
425+
this.appendToken(node.openBracketToken);
426+
this.appendSeparatorSpaceList(node.types);
427+
this.appendToken(node.closeBracketToken);
428+
}
429+
424430
public visitConstructorType(node: ConstructorTypeSyntax): void {
425431
this.appendToken(node.newKeyword);
426432
this.ensureSpace();
Collapse file

‎src/services/syntax/syntaxFacts2.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/syntaxFacts2.ts
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ module TypeScript.SyntaxFacts {
2626
var tokenKind = token.kind();
2727
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
2828
}
29+
30+
export function isAccessibilityModifier(kind: SyntaxKind): boolean {
31+
switch (kind) {
32+
case SyntaxKind.PublicKeyword:
33+
case SyntaxKind.PrivateKeyword:
34+
case SyntaxKind.ProtectedKeyword:
35+
return true;
36+
}
37+
38+
return false;
39+
}
2940
}
Collapse file

‎src/services/syntax/syntaxGenerator.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/syntaxGenerator.ts
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ var definitions:ITypeDefinition[] = [
354354
],
355355
isTypeScriptSpecific: true
356356
},
357+
<any> {
358+
name: 'TupleTypeSyntax',
359+
baseType: 'ISyntaxNode',
360+
interfaces: ['ITypeSyntax'],
361+
children: [
362+
<any>{ name: 'openBracketToken', isToken: true, excludeFromAST: true },
363+
<any>{ name: 'types', isSeparatedList: true, elementType: 'ITypeSyntax' },
364+
<any>{ name: 'closeBracketToken', isToken: true, excludeFromAST: true }
365+
],
366+
isTypeScriptSpecific: true
367+
},
357368
<any>{
358369
name: 'TypeAnnotationSyntax',
359370
baseType: 'ISyntaxNode',
Collapse file

‎src/services/syntax/syntaxKind.ts‎

Copy file name to clipboardExpand all lines: src/services/syntax/syntaxKind.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ module TypeScript {
158158
ConstructorType,
159159
GenericType,
160160
TypeQuery,
161+
TupleType,
161162

162163
// Module elements.
163164
InterfaceDeclaration,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.