diff --git a/src/services/services.ts b/src/services/services.ts index b27ab36b915..0a7aa8652f1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1118,7 +1118,7 @@ module ts { } export interface Classifier { - getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult; + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult; } export interface DocumentRegistry { @@ -5307,7 +5307,8 @@ module ts { return true; } - function getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult { + // 'classifyKeywordsInGenerics' should be 'true' when a syntactic classifier is not present. + function getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult { var offset = 0; var lastTokenOrCommentEnd = 0; var token = SyntaxKind.Unknown; @@ -5395,7 +5396,7 @@ module ts { token === SyntaxKind.StringKeyword || token === SyntaxKind.NumberKeyword || token === SyntaxKind.BooleanKeyword) { - if (angleBracketStack > 0) { + if (angleBracketStack > 0 && !classifyKeywordsInGenerics) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. diff --git a/src/services/shims.ts b/src/services/shims.ts index fdea0202323..c3df67e6db1 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -162,7 +162,7 @@ module ts { } export interface ClassifierShim extends Shim { - getClassificationsForLine(text: string, lexState: EndOfLineState): string; + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string; } export interface CoreServicesShim extends Shim { @@ -821,8 +821,8 @@ module ts { } /// COLORIZATION - public getClassificationsForLine(text: string, lexState: EndOfLineState): string { - var classification = this.classifier.getClassificationsForLine(text, lexState); + public getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); var items = classification.entries; var result = ""; for (var i = 0; i < items.length; i++) {