Skip to content

Fix analyzer not being called when getHighlightParsingError is off #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 12.22.12
2 changes: 1 addition & 1 deletion server/src/analyser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export default class Analyzer {
): Parser.SyntaxNode | null {
const document = this.uriToTreeSitterTrees[uri]

if (!document.rootNode) {
if (!document?.rootNode) {
// Check for lacking rootNode (due to failed parse?)
return null
}
Expand Down
11 changes: 9 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ export default class BashServer {
this.documents.listen(this.connection)
this.documents.onDidChangeContent(async change => {
const { uri } = change.document

// Load the tree for the modified contents into the analyzer:
const analyzeDiagnostics = this.analyzer.analyze(uri, change.document)

// Run shellcheck diagnostics:
let diagnostics: LSP.Diagnostic[] = []

// FIXME: re-lint on workspace folder change
const folders = await connection.workspace.getWorkspaceFolders()
const lintDiagnostics = await this.linter.lint(change.document, folders || [])
diagnostics = diagnostics.concat(lintDiagnostics)

// Treesitter's diagnostics can be a bit inaccurate, so we only merge the
// analyzer's diagnostics if the setting is enabled:
if (config.getHighlightParsingError()) {
const analyzeDiagnostics = this.analyzer.analyze(uri, change.document)
diagnostics = diagnostics.concat(analyzeDiagnostics)
}

Expand All @@ -100,6 +105,8 @@ export default class BashServer {
connection.onReferences(this.onReferences.bind(this))
connection.onCompletion(this.onCompletion.bind(this))
connection.onCompletionResolve(this.onCompletionResolve.bind(this))

// FIXME: re-lint on workspace folder change
}

/**
Expand Down