Skip to content

Commit

Permalink
modified the service file
Browse files Browse the repository at this point in the history
  • Loading branch information
rpgeeganage committed May 5, 2019
1 parent 4ee0084 commit 578013b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/services/services.ts
Expand Up @@ -1467,33 +1467,49 @@ namespace ts {
}

const typeChecker = program.getTypeChecker();
const symbol = getSymbolAtLocationForQuickInfo(node, typeChecker);
const nodeForQuickInfo = getNodeForQuickInfo(node, typeChecker);
const symbol = getSymbolAtLocationForQuickInfo(nodeForQuickInfo, typeChecker);

if (!symbol || typeChecker.isUnknownSymbol(symbol)) {
const type = shouldGetType(sourceFile, node, position) ? typeChecker.getTypeAtLocation(node) : undefined;
const type = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined;
return type && {
kind: ScriptElementKind.unknown,
kindModifiers: ScriptElementKindModifier.none,
textSpan: createTextSpanFromNode(node, sourceFile),
displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(node))),
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(nodeForQuickInfo))),
documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : undefined,
tags: type.symbol ? type.symbol.getJsDocTags() : undefined
};
}

const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, typeChecker =>
SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(node), node)
SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(nodeForQuickInfo), nodeForQuickInfo)
);
return {
kind: symbolKind,
kindModifiers: SymbolDisplay.getSymbolModifiers(symbol),
textSpan: createTextSpanFromNode(node, sourceFile),
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
displayParts,
documentation,
tags,
};
}

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;
}
}
}
return node;
}

function shouldGetType(sourceFile: SourceFile, node: Node, position: number): boolean {
switch (node.kind) {
case SyntaxKind.Identifier:
Expand Down

0 comments on commit 578013b

Please sign in to comment.