File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { CompletionItem } from 'vscode' ;
1+ import { CompletionItem , SymbolKind } from 'vscode' ;
2+ import * as proxy from '../../providers/jediProxy' ;
3+ import { extractSignatureAndDocumentation } from '../../providers/jediHelpers' ;
4+ import { PythonSettings } from '../../common/configSettings' ;
5+
6+ const pythonSettings = PythonSettings . getInstance ( ) ;
7+
28export class CompletionParser {
3- public static parse ( data : Object ) : CompletionItem [ ] {
4- return [ ] ;
9+ public static parse ( data : proxy . ICompletionResult ) : CompletionItem [ ] {
10+ if ( ! data || data . items . length === 0 ) {
11+ return [ ] ;
12+ }
13+ return data . items . map ( item => {
14+ const sigAndDocs = extractSignatureAndDocumentation ( item ) ;
15+ let completionItem = new CompletionItem ( item . text ) ;
16+ completionItem . kind = item . type ;
17+ completionItem . documentation = sigAndDocs [ 1 ] . length === 0 ? item . description : sigAndDocs [ 1 ] ;
18+ completionItem . detail = sigAndDocs [ 0 ] . split ( / \r ? \n / ) . join ( '' ) ;
19+ if ( pythonSettings . autoComplete . addBrackets === true &&
20+ ( item . kind === SymbolKind . Function || item . kind === SymbolKind . Method ) ) {
21+ completionItem . insertText = item . text + '({{}})' ;
22+ }
23+
24+ // ensure the built in memebers are at the bottom
25+ completionItem . sortText = ( completionItem . label . startsWith ( '__' ) ? 'z' : ( completionItem . label . startsWith ( '_' ) ? 'y' : '__' ) ) + completionItem . label ;
26+ return completionItem ;
27+ } ) ;
528 }
629}
You can’t perform that action at this time.
0 commit comments