From 8f209be149ec626f40031a5b0f904ae5ea74479d Mon Sep 17 00:00:00 2001 From: rpgeeganage Date: Mon, 6 May 2019 21:21:37 +0200 Subject: [PATCH] fixed the comments --- src/services/services.ts | 16 +- tests/baselines/reference/jsDocTags.baseline | 70 ----- ...oDisplayPartsTypeParameterInClass.baseline | 84 +----- ...playPartsTypeParameterInInterface.baseline | 260 +----------------- .../fourslash/quickInfoOnNewKeyword01.ts | 5 +- 5 files changed, 17 insertions(+), 418 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index ab5138fb489ae..628ec395437b6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1467,7 +1467,7 @@ namespace ts { } const typeChecker = program.getTypeChecker(); - const nodeForQuickInfo = getNodeForQuickInfo(node, typeChecker); + const nodeForQuickInfo = getNodeForQuickInfo(node); const symbol = getSymbolAtLocationForQuickInfo(nodeForQuickInfo, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { @@ -1495,17 +1495,9 @@ namespace ts { }; } - function getNodeForQuickInfo(node: Node, typeChecker: TypeChecker): Node { - const firstParentNode = node.parent.getFirstToken(); - const firstNodeSyntaxKind = firstParentNode ? firstParentNode.kind : undefined; - - if (node.kind === SyntaxKind.NewKeyword || firstNodeSyntaxKind === SyntaxKind.NewKeyword) { - for (const singleNode of node.parent.getChildren()) { - const symbol = getSymbolAtLocationForQuickInfo(singleNode, typeChecker); - if (symbol) { - return singleNode; - } - } + function getNodeForQuickInfo(node: Node): Node { + if (isNewExpression(node.parent) && node.pos === node.parent.pos) { + return node.parent.expression; } return node; } diff --git a/tests/baselines/reference/jsDocTags.baseline b/tests/baselines/reference/jsDocTags.baseline index 2d89c183ab344..f316a9c42459d 100644 --- a/tests/baselines/reference/jsDocTags.baseline +++ b/tests/baselines/reference/jsDocTags.baseline @@ -79,76 +79,6 @@ "marker": { "fileName": "/tests/cases/fourslash/jsDocTags.ts", "position": 981 - }, - "quickInfo": { - "kind": "constructor", - "kindModifiers": "", - "textSpan": { - "start": 977, - "length": 3 - }, - "displayParts": [ - { - "text": "constructor", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - } - ], - "documentation": [ - { - "text": "This is the constructor.", - "kind": "text" - } - ], - "tags": [ - { - "name": "myjsdoctag", - "text": "this is a comment" - } - ] } }, { diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline index 68e48ff9b68e4..48bd280a1b505 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline @@ -2991,15 +2991,15 @@ "position": 337 }, "quickInfo": { - "kind": "constructor", + "kind": "var", "kindModifiers": "", "textSpan": { - "start": 334, - "length": 2 + "start": 337, + "length": 9 }, "displayParts": [ { - "text": "constructor", + "text": "var", "kind": "keyword" }, { @@ -3007,68 +3007,8 @@ "kind": "space" }, { - "text": "c2", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "c", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" + "text": "cInstance", + "kind": "localName" }, { "text": ":", @@ -3078,14 +3018,6 @@ "text": " ", "kind": "space" }, - { - "text": "c2", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, { "text": "c", "kind": "className" @@ -3098,10 +3030,6 @@ "text": "string", "kind": "keyword" }, - { - "text": ">", - "kind": "punctuation" - }, { "text": ">", "kind": "punctuation" diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline index 6830394801c48..715811f9918a1 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline @@ -5568,8 +5568,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 409, - "length": 5 + "start": 415, + "length": 4 }, "displayParts": [ { @@ -5581,7 +5581,7 @@ "kind": "space" }, { - "text": "iVal1", + "text": "iVal", "kind": "localName" }, { @@ -5592,130 +5592,6 @@ "text": " ", "kind": "space" }, - { - "text": "I1", - "kind": "interfaceName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "b", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, { "text": "I", "kind": "interfaceName" @@ -5745,8 +5621,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 409, - "length": 5 + "start": 421, + "length": 4 }, "displayParts": [ { @@ -5758,7 +5634,7 @@ "kind": "space" }, { - "text": "iVal1", + "text": "iVal", "kind": "localName" }, { @@ -5769,130 +5645,6 @@ "text": " ", "kind": "space" }, - { - "text": "I1", - "kind": "interfaceName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "b", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, { "text": "I", "kind": "interfaceName" diff --git a/tests/cases/fourslash/quickInfoOnNewKeyword01.ts b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts index 21ccb8a65024d..f7d1e359b8d2a 100644 --- a/tests/cases/fourslash/quickInfoOnNewKeyword01.ts +++ b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts @@ -9,13 +9,10 @@ //// static makeCat() { new Cat(); } ////} //// -////ne/*1*/w Ca/*2*/t(/*3*/); +////ne/*1*/w Ca/*2*/t(); verify.quickInfoAt('1', 'constructor Cat(): Cat', 'NOTE: this constructor is private! Please use the factory function'); verify.quickInfoAt('2', 'constructor Cat(): Cat', 'NOTE: this constructor is private! Please use the factory function'); - -verify.quickInfoAt('3', 'constructor Cat(): Cat', -'NOTE: this constructor is private! Please use the factory function');