Skip to content

Commit

Permalink
feat(diagnostic): Add action diagnosticRelatedInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
hexh250786313 committed Jul 22, 2024
1 parent eaa43f0 commit 51d54c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/diagnostic/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,7 @@ class DiagnosticManager implements Disposable {
}

public async jumpRelated(): Promise<void> {
let diagnostics = await this.getCurrentDiagnostics()
let diagnostic = diagnostics.find(o => o.relatedInformation != null)
let locations = diagnostic ? diagnostic.relatedInformation.map(o => o.location) : []
let locations = await this.relatedInformation()
if (locations.length == 1) {
await workspace.jumpTo(locations[0].uri, locations[0].range.start)
} else if (locations.length > 1) {
Expand All @@ -443,6 +441,13 @@ class DiagnosticManager implements Disposable {
}
}

public async relatedInformation(): Promise<Location[]> {
let diagnostics = await this.getCurrentDiagnostics()
let diagnostic = diagnostics.find(o => o.relatedInformation != null)
let locations = diagnostic ? diagnostic.relatedInformation.map(o => o.location) : []
return locations
}

public reset(): void {
clearTimeout(this.messageTimer)
this.buffers.reset()
Expand Down
1 change: 0 additions & 1 deletion src/language-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,6 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
private setDiagnostics(uri: string, diagnostics: Diagnostic[] | undefined) {
if (!this._diagnostics) return

// TODO make is async
this._diagnostics.set(uri, diagnostics)
}

Expand Down
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default class Plugin {
this.addAction('diagnosticPrevious', severity => diagnosticManager.jumpPrevious(severity))
this.addAction('diagnosticPreview', () => diagnosticManager.preview())
this.addAction('diagnosticList', () => diagnosticManager.getDiagnosticList())
this.addAction('diagnosticRelatedInformation', () => diagnosticManager.relatedInformation())
this.addAction('findLocations', (id, method, params, openCommand) => this.handler.locations.findLocations(id, method, params, openCommand))
this.addAction('getTagList', () => this.handler.locations.getTagList())
this.addAction('definitions', () => this.handler.locations.definitions())
Expand Down

0 comments on commit 51d54c1

Please sign in to comment.