@@ -15,28 +15,28 @@ const COMPL_REGEXP = /([a-zA-Z0-9_]+)(\.([A-Za-z0-9_]+))?$/;
1515const R_GROUP_PKG = 1 ;
1616const R_GROUP_METHOD = 3 ;
1717
18- class GoCompletionItemProvider implements monaco . languages . CompletionItemProvider {
19- constructor ( private client : IAPIClient ) { }
18+ const parseExpression = ( expr : string ) => {
19+ COMPL_REGEXP . lastIndex = 0 ; // Reset regex state
20+ const m = COMPL_REGEXP . exec ( expr ) ;
21+ if ( ! m ) {
22+ return null ;
23+ }
2024
21- private parseExpression ( expr : string ) {
22- COMPL_REGEXP . lastIndex = 0 ; // Reset regex state
23- const m = COMPL_REGEXP . exec ( expr ) ;
24- if ( ! m ) {
25- return null ;
26- }
25+ const varName = m [ R_GROUP_PKG ] ;
26+ const propValue = m [ R_GROUP_METHOD ] ;
2727
28- const varName = m [ R_GROUP_PKG ] ;
29- const propValue = m [ R_GROUP_METHOD ] ;
28+ if ( ! propValue ) {
29+ return { value : varName } ;
30+ }
3031
31- if ( ! propValue ) {
32- return { value : varName } ;
33- }
32+ return {
33+ packageName : varName ,
34+ value : propValue
35+ } ;
36+ } ;
3437
35- return {
36- packageName : varName ,
37- value : propValue
38- } ;
39- }
38+ class GoCompletionItemProvider implements monaco . languages . CompletionItemProvider {
39+ constructor ( private client : IAPIClient ) { }
4040
4141 async provideCompletionItems ( model : ITextModel , position : Position , context : CompletionContext , token : CancellationToken ) : Promise < CompletionList > {
4242 const val = model . getValueInRange ( {
@@ -46,7 +46,7 @@ class GoCompletionItemProvider implements monaco.languages.CompletionItemProvide
4646 endColumn : position . column ,
4747 } ) . trim ( ) ;
4848
49- const query = this . parseExpression ( val ) ;
49+ const query = parseExpression ( val ) ;
5050 if ( ! query ) {
5151 return Promise . resolve ( { suggestions : [ ] } ) ;
5252 }
0 commit comments