11import {
22 buildSuggestions ,
3+ CucumberExpressions ,
34 ExpressionBuilder ,
45 ExpressionBuilderResult ,
56 getGenerateSnippetCodeAction ,
@@ -85,18 +86,21 @@ export class CucumberLanguageServer {
8586 private expressionBuilderResult : ExpressionBuilderResult | undefined = undefined
8687 private reindexingTimeout : NodeJS . Timeout
8788 private rootUri : string
88- #suggestions: readonly Suggestion [ ]
89- #files: Files
90-
91- get suggestions ( ) {
92- return this . #suggestions
93- }
89+ private files : Files
90+ public registry : CucumberExpressions . ParameterTypeRegistry
91+ public expressions : readonly CucumberExpressions . Expression [ ] = [ ]
92+ public suggestions : readonly Suggestion [ ] = [ ]
9493
9594 constructor (
9695 private readonly connection : Connection ,
9796 private readonly documents : TextDocuments < TextDocument > ,
9897 parserAdapter : ParserAdapter ,
99- private readonly makeFiles : ( rootUri : string ) => Files
98+ private readonly makeFiles : ( rootUri : string ) => Files ,
99+ private readonly onReindexed : (
100+ registry : CucumberExpressions . ParameterTypeRegistry ,
101+ expressions : readonly CucumberExpressions . Expression [ ] ,
102+ suggestions : readonly Suggestion [ ]
103+ ) => void
100104 ) {
101105 this . expressionBuilder = new ExpressionBuilder ( parserAdapter )
102106
@@ -120,7 +124,7 @@ export class CucumberLanguageServer {
120124 } else {
121125 connection . console . error ( `Could not determine rootPath` )
122126 }
123- this . # files = makeFiles ( this . rootUri )
127+ this . files = makeFiles ( this . rootUri )
124128 // Some users have reported that the globs don't find any files. This is to debug that issue
125129 connection . console . info ( `Root uri : ${ this . rootUri } ` )
126130 connection . console . info ( `Current dir : ${ process . cwd ( ) } ` )
@@ -224,8 +228,8 @@ export class CucumberLanguageServer {
224228 return [ ]
225229 }
226230 const mustacheTemplate = settings . snippetTemplates [ languageName ]
227- const createFile = ! ( await this . # files. exists ( link . targetUri ) )
228- const relativePath = this . # files. relativePath ( link . targetUri )
231+ const createFile = ! ( await this . files . exists ( link . targetUri ) )
232+ const relativePath = this . files . relativePath ( link . targetUri )
229233 const codeAction = getGenerateSnippetCodeAction (
230234 diagnostics ,
231235 link ,
@@ -401,7 +405,7 @@ export class CucumberLanguageServer {
401405 // https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#workDoneProgress
402406
403407 this . connection . console . info ( `Reindexing ${ this . rootUri } ` )
404- const gherkinSources = await loadGherkinSources ( this . # files, settings . features )
408+ const gherkinSources = await loadGherkinSources ( this . files , settings . features )
405409 this . connection . console . info (
406410 `* Found ${ gherkinSources . length } feature file(s) in ${ JSON . stringify ( settings . features ) } `
407411 )
@@ -410,7 +414,7 @@ export class CucumberLanguageServer {
410414 [ ]
411415 )
412416 this . connection . console . info ( `* Found ${ stepTexts . length } steps in those feature files` )
413- const glueSources = await loadGlueSources ( this . # files, settings . glue )
417+ const glueSources = await loadGlueSources ( this . files , settings . glue )
414418 this . connection . console . info (
415419 `* Found ${ glueSources . length } glue file(s) in ${ JSON . stringify ( settings . glue ) } `
416420 )
@@ -446,15 +450,19 @@ export class CucumberLanguageServer {
446450 this . connection . languages . semanticTokens . refresh ( )
447451
448452 try {
449- this . #suggestions = buildSuggestions (
453+ const expressions = this . expressionBuilderResult . expressionLinks . map ( ( l ) => l . expression )
454+ const suggestions = buildSuggestions (
450455 this . expressionBuilderResult . registry ,
451456 stepTexts ,
452- this . expressionBuilderResult . expressionLinks . map ( ( l ) => l . expression )
453- )
454- this . connection . console . info (
455- `* Built ${ this . #suggestions. length } suggestions for auto complete`
457+ expressions
456458 )
457- this . searchIndex = jsSearchIndex ( this . #suggestions)
459+ this . connection . console . info ( `* Built ${ suggestions . length } suggestions for auto complete` )
460+ this . searchIndex = jsSearchIndex ( suggestions )
461+ const registry = this . expressionBuilderResult . registry
462+ this . registry = registry
463+ this . expressions = expressions
464+ this . suggestions = suggestions
465+ this . onReindexed ( registry , expressions , suggestions )
458466 } catch ( err ) {
459467 this . connection . console . error ( err . stack )
460468 this . connection . console . error (
0 commit comments