|
8 | 8 |
|
9 | 9 | import {NgAnalyzedModules} from '@angular/compiler'; |
10 | 10 | import * as ts from 'typescript'; |
| 11 | + |
| 12 | +import {createQuickInfo} from '../common/quick_info'; |
| 13 | + |
11 | 14 | import {locateSymbols} from './locate_symbol'; |
12 | 15 | import * as ng from './types'; |
13 | 16 | import {inSpan} from './utils'; |
14 | 17 |
|
15 | | -// Reverse mappings of enum would generate strings |
16 | | -export const SYMBOL_SPACE = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.space]; |
17 | | -export const SYMBOL_PUNC = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.punctuation]; |
18 | | -export const SYMBOL_TEXT = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.text]; |
19 | | -export const SYMBOL_INTERFACE = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.interfaceName]; |
20 | | -export const ALIAS_NAME = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.aliasName]; |
21 | | - |
22 | 18 | /** |
23 | 19 | * Traverse the template AST and look for the symbol located at `position`, then |
24 | 20 | * return the corresponding quick info. |
@@ -71,47 +67,3 @@ export function getTsHover( |
71 | 67 | } |
72 | 68 | } |
73 | 69 | } |
74 | | - |
75 | | -/** |
76 | | - * Construct a QuickInfo object taking into account its container and type. |
77 | | - * @param name Name of the QuickInfo target |
78 | | - * @param kind component, directive, pipe, etc. |
79 | | - * @param textSpan span of the target |
80 | | - * @param containerName either the Symbol's container or the NgModule that contains the directive |
81 | | - * @param type user-friendly name of the type |
82 | | - * @param documentation docstring or comment |
83 | | - */ |
84 | | -export function createQuickInfo( |
85 | | - name: string, kind: string, textSpan: ts.TextSpan, containerName?: string, type?: string, |
86 | | - documentation?: ts.SymbolDisplayPart[]): ts.QuickInfo { |
87 | | - const containerDisplayParts = containerName ? |
88 | | - [ |
89 | | - {text: containerName, kind: SYMBOL_INTERFACE}, |
90 | | - {text: '.', kind: SYMBOL_PUNC}, |
91 | | - ] : |
92 | | - []; |
93 | | - |
94 | | - const typeDisplayParts = type ? |
95 | | - [ |
96 | | - {text: ':', kind: SYMBOL_PUNC}, |
97 | | - {text: ' ', kind: SYMBOL_SPACE}, |
98 | | - {text: type, kind: SYMBOL_INTERFACE}, |
99 | | - ] : |
100 | | - []; |
101 | | - |
102 | | - return { |
103 | | - kind: kind as ts.ScriptElementKind, |
104 | | - kindModifiers: ts.ScriptElementKindModifier.none, |
105 | | - textSpan: textSpan, |
106 | | - displayParts: [ |
107 | | - {text: '(', kind: SYMBOL_PUNC}, |
108 | | - {text: kind, kind: SYMBOL_TEXT}, |
109 | | - {text: ')', kind: SYMBOL_PUNC}, |
110 | | - {text: ' ', kind: SYMBOL_SPACE}, |
111 | | - ...containerDisplayParts, |
112 | | - {text: name, kind: SYMBOL_INTERFACE}, |
113 | | - ...typeDisplayParts, |
114 | | - ], |
115 | | - documentation, |
116 | | - }; |
117 | | -} |
0 commit comments