From 8e2b204ace1901aaced26cde1bb2084d8db11b6d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 23 Jun 2015 11:25:33 -0700 Subject: [PATCH] do not try to classify missing nodes --- src/services/services.ts | 4 ++++ .../fourslash/syntacticClassificationWithErrors.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/cases/fourslash/syntacticClassificationWithErrors.ts diff --git a/src/services/services.ts b/src/services/services.ts index 70022cfe0bf..18510b9a178 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6300,6 +6300,10 @@ namespace ts { } function classifyToken(token: Node): void { + if (nodeIsMissing(token)) { + return; + } + let tokenStart = classifyLeadingTriviaAndGetTokenStart(token); let tokenWidth = token.end - tokenStart; diff --git a/tests/cases/fourslash/syntacticClassificationWithErrors.ts b/tests/cases/fourslash/syntacticClassificationWithErrors.ts new file mode 100644 index 00000000000..b4572d3e620 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationWithErrors.ts @@ -0,0 +1,14 @@ +/// + +////class A { +//// a: +////} +////c = + +let c = classification +verify.syntacticClassificationsAre( + c.keyword("class"), c.className("A"), c.punctuation("{"), + c.text("a"), c.punctuation(":"), + c.punctuation("}"), + c.text("c"), c.operator("=") + ); \ No newline at end of file