88
99import { CompileSummaryKind , StaticSymbol } from '@angular/compiler' ;
1010import * as ts from 'typescript' ;
11+
1112import { AstResult } from './common' ;
1213import { locateSymbol } from './locate_symbol' ;
14+ import * as ng from './types' ;
1315import { TypeScriptServiceHost } from './typescript_host' ;
1416import { findTightestNode } from './utils' ;
1517
18+
1619// Reverse mappings of enum would generate strings
1720const SYMBOL_SPACE = ts . SymbolDisplayPartKind [ ts . SymbolDisplayPartKind . space ] ;
1821const SYMBOL_PUNC = ts . SymbolDisplayPartKind [ ts . SymbolDisplayPartKind . punctuation ] ;
@@ -37,7 +40,7 @@ export function getHover(info: AstResult, position: number, host: Readonly<TypeS
3740 const textSpan = { start : span . start , length : span . end - span . start } ;
3841
3942 if ( compileTypeSummary && compileTypeSummary . summaryKind === CompileSummaryKind . Directive ) {
40- return getDirectiveModule ( compileTypeSummary . type . reference , textSpan , host ) ;
43+ return getDirectiveModule ( compileTypeSummary . type . reference , textSpan , host , symbol ) ;
4144 }
4245
4346 const containerDisplayParts : ts . SymbolDisplayPart [ ] = symbol . container ?
@@ -57,6 +60,7 @@ export function getHover(info: AstResult, position: number, host: Readonly<TypeS
5760 kind : symbol . kind as ts . ScriptElementKind ,
5861 kindModifiers : '' , // kindModifier info not available on 'ng.Symbol'
5962 textSpan,
63+ documentation : symbol . documentation ,
6064 // this would generate a string like '(property) ClassX.propY: type'
6165 // 'kind' in displayParts does not really matter because it's dropped when
6266 // displayParts get converted to string.
@@ -105,11 +109,13 @@ export function getTsHover(
105109/**
106110 * Attempts to get quick info for the NgModule a Directive is declared in.
107111 * @param directive identifier on a potential Directive class declaration
112+ * @param textSpan span of the symbol
108113 * @param host Language Service host to query
114+ * @param symbol the internal symbol that represents the directive
109115 */
110116function getDirectiveModule (
111- directive : StaticSymbol , textSpan : ts . TextSpan ,
112- host : Readonly < TypeScriptServiceHost > ) : ts . QuickInfo | undefined {
117+ directive : StaticSymbol , textSpan : ts . TextSpan , host : Readonly < TypeScriptServiceHost > ,
118+ symbol ?: ng . Symbol ) : ts . QuickInfo | undefined {
113119 const analyzedModules = host . getAnalyzedModules ( false ) ;
114120 const ngModule = analyzedModules . ngModuleByPipeOrDirective . get ( directive ) ;
115121 if ( ! ngModule ) return ;
@@ -124,6 +130,7 @@ function getDirectiveModule(
124130 kindModifiers :
125131 ts . ScriptElementKindModifier . none , // kindModifier info not available on 'ng.Symbol'
126132 textSpan,
133+ documentation : symbol ? symbol . documentation : undefined ,
127134 // This generates a string like '(directive) NgModule.Directive: class'
128135 // 'kind' in displayParts does not really matter because it's dropped when
129136 // displayParts get converted to string.
0 commit comments