Skip to content

Commit

Permalink
Chore: Trigger the analyze when the scan completes
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Dec 1, 2023
1 parent 543a9d1 commit ece8e93
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ let parseOnSave = true

const disposables: Disposable[] = []

let currentActiveTextDocument: TextDocument = TextDocument.create(
'file://dummy_uri',
'bitbake',
0,
''
)

connection.onInitialize(async (params: InitializeParams): Promise<InitializeResult> => {
logger.level = 'debug'
logger.info('[onInitialize] Initializing connection')
Expand All @@ -57,6 +64,11 @@ connection.onInitialize(async (params: InitializeParams): Promise<InitializeResu
const parser = await generateParser()
analyzer.initialize(parser)

bitBakeProjectScannerClient.onChange.on('scanReady', () => {
logger.debug('[On scanReady] Analyzing the current document again...')
void analyzer.analyze({ document: currentActiveTextDocument, uri: currentActiveTextDocument.uri })
})

return {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Incremental,
Expand Down Expand Up @@ -140,6 +152,8 @@ documents.onDidChangeContent(async (event) => {
void connection.sendDiagnostics({ uri: textDocument.uri, diagnostics })
}

currentActiveTextDocument = textDocument

// Other language extensions might also associate .conf files with their langauge modes
if (textDocument.uri.endsWith('.conf')) {
logger.debug('verifyConfigurationFileAssociation')
Expand Down

0 comments on commit ece8e93

Please sign in to comment.