@@ -3,8 +3,8 @@ import { getCannotFindCodes } from '../utils/cannotFindCodes'
33
44const cannotFindCodes = getCannotFindCodes ( { includeFromLib : true } )
55
6- // 1. add suggestions for unresolved indentifiers in code
7- // 2. boost identifer or type name suggestion
6+ // 1. add suggestions for unresolved identifiers in code
7+ // 2. boost identifier or type name suggestion
88export default (
99 entries : ts . CompletionEntry [ ] ,
1010 position : number ,
@@ -17,35 +17,7 @@ export default (
1717 const fileText = sourceFile . getFullText ( )
1818 const fileTextBeforePos = fileText . slice ( 0 , position )
1919 const beforeConstNodeOffset = fileTextBeforePos . match ( / (?: c o n s t | l e t ) ( [ \w \d ] * ) $ / i) ?. [ 1 ]
20- const nodeWithStatements = node => {
21- return node && 'statements' in node && Array . isArray ( node . statements ) ? node : undefined
22- }
23- const statementsNode = nodeWithStatements ( node ) || nodeWithStatements ( node . parent )
24- // Workaround for current locality bonus & TS 5.1
25- if (
26- statementsNode &&
27- // ensure completions are not blocked
28- entries . length > 0
29- ) {
30- const statements = statementsNode . statements as any [ ]
31- const prevNode =
32- statementsNode === node
33- ? [ ...statements ] . reverse ( ) . find ( ( statement : ts . Node ) => statement . pos + statement . getLeadingTriviaWidth ( ) < position )
34- : statements [ statements . indexOf ( node ) - 1 ]
35- if ( prevNode && ts . isVariableStatement ( prevNode ) && prevNode . declarationList . declarations . length === 1 ) {
36- const { name } = prevNode . declarationList . declarations [ 0 ] !
37- if ( ts . isIdentifier ( name ) ) {
38- const kind : ts . ScriptElementKind =
39- prevNode . declarationList . flags & ts . NodeFlags . Const ? ts . ScriptElementKind . constElement : ts . ScriptElementKind . letElement
40- entries = boostOrAddSuggestions ( entries , [
41- {
42- name : name . text ,
43- kind,
44- } ,
45- ] )
46- }
47- }
48- }
20+
4921 /** false - pick all identifiers after cursor
5022 * node - pick identifiers that within node */
5123 let filterBlock : undefined | false | ts . Node
0 commit comments