From c2f253f4aa84f9259a2d861154df49e0fec5b353 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Nov 2014 13:19:00 -0800 Subject: [PATCH 1/3] Fix for crash in QuickInfo on module path in import statement. --- src/services/services.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 2bc429ce43b..4fa28c56016 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2751,7 +2751,7 @@ module ts { while (true) { node = node.parent; if (!node) { - return node; + return undefined; } switch (node.kind) { case SyntaxKind.SourceFile: @@ -3966,6 +3966,10 @@ module ts { for (var i = 0, n = declarations.length; i < n; i++) { var container = getContainerNode(declarations[i]); + if (!container) { + return undefined; + } + if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; @@ -4530,8 +4534,8 @@ module ts { fileName: filename, textSpan: TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()), // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: container.name ? (container.name).text : "", - containerKind: container.name ? getNodeKind(container) : "" + containerName: container && container.name ? (container.name).text : "", + containerKind: container && container.name ? getNodeKind(container) : "" }); } } @@ -4685,10 +4689,12 @@ module ts { else { return SemanticMeaning.Namespace; } - break; case SyntaxKind.ImportDeclaration: return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; + + case SyntaxKind.SourceFile: + return SemanticMeaning.Namespace | SemanticMeaning.Value; } Debug.fail("Unknown declaration type"); } From 57780944288f6f39e157fd71a43c454d0b050c47 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 19 Nov 2014 14:03:20 -0800 Subject: [PATCH 2/3] Added test case for quickinfo on import statement. --- tests/cases/fourslash/quickInfoForRequire.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoForRequire.ts diff --git a/tests/cases/fourslash/quickInfoForRequire.ts b/tests/cases/fourslash/quickInfoForRequire.ts new file mode 100644 index 00000000000..394f1074363 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForRequire.ts @@ -0,0 +1,10 @@ +/// + +//@Filename: AA/BB.ts +////export class a{} + +//@Filename: quickInfoForRequire_input.ts +////import a = require("AA/B/*1*/B"); + +goTo.marker('1'); +verify.quickInfoIs('module a'); \ No newline at end of file From 629ea860430c58d7054a31c5cf75c05cc7d1a2cc Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 19 Nov 2014 15:05:07 -0800 Subject: [PATCH 3/3] Updated test case and added comment --- src/services/services.ts | 1 + tests/cases/fourslash/quickInfoForRequire.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 4fa28c56016..ef16b1f1cc7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4693,6 +4693,7 @@ module ts { case SyntaxKind.ImportDeclaration: return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; + // An external module can be a Value case SyntaxKind.SourceFile: return SemanticMeaning.Namespace | SemanticMeaning.Value; } diff --git a/tests/cases/fourslash/quickInfoForRequire.ts b/tests/cases/fourslash/quickInfoForRequire.ts index 394f1074363..91d59cb4318 100644 --- a/tests/cases/fourslash/quickInfoForRequire.ts +++ b/tests/cases/fourslash/quickInfoForRequire.ts @@ -7,4 +7,5 @@ ////import a = require("AA/B/*1*/B"); goTo.marker('1'); -verify.quickInfoIs('module a'); \ No newline at end of file +verify.quickInfoIs('module a'); +verify.referencesCountIs(0); \ No newline at end of file