Skip to content

Commit 6cdad94

Browse files
authored
Merge pull request #708 from bash-lsp/remove-missing-node-diagnostics
Remove sometimes useless missing node diagnostics
2 parents 3a31986 + 25251c7 commit 6cdad94

File tree

5 files changed

+11
-50
lines changed

5 files changed

+11
-50
lines changed

Diff for: server/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Bash Language Server
22

3+
## 4.6.2
4+
5+
- Remove diagnostics for missing nodes that turns out to be unstable (this was introduced in 4.5.3) https://github.com/bash-lsp/bash-language-server/pull/708
6+
37
## 4.6.1
48

59
- Fix the ShellCheck code action feature that for some clients did not return any code actions. https://github.com/bash-lsp/bash-language-server/pull/700

Diff for: server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A language server for Bash",
44
"author": "Mads Hartmann",
55
"license": "MIT",
6-
"version": "4.6.1",
6+
"version": "4.6.2",
77
"main": "./out/server.js",
88
"typings": "./out/server.d.ts",
99
"bin": {

Diff for: server/src/__tests__/analyzer.test.ts

+2-20
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,13 @@ describe('analyze', () => {
6262
expect(loggerWarn).not.toHaveBeenCalled()
6363
})
6464

65-
it('parses files with a missing nodes and return relevant diagnostics', async () => {
65+
it('parses files with a missing nodes', async () => {
6666
const analyzer = await getAnalyzer({})
6767
const diagnostics = analyzer.analyze({
6868
uri: CURRENT_URI,
6969
document: FIXTURE_DOCUMENT.MISSING_NODE,
7070
})
71-
expect(diagnostics).toMatchInlineSnapshot(`
72-
[
73-
{
74-
"message": "Syntax error: "fi" missing",
75-
"range": {
76-
"end": {
77-
"character": 0,
78-
"line": 12,
79-
},
80-
"start": {
81-
"character": 0,
82-
"line": 12,
83-
},
84-
},
85-
"severity": 2,
86-
"source": "bash-language-server",
87-
},
88-
]
89-
`)
71+
expect(diagnostics).toEqual([])
9072
expect(loggerWarn).toHaveBeenCalledWith(
9173
'Error while parsing dummy-uri.sh: syntax error',
9274
)

Diff for: server/src/analyser.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,7 @@ export default class Analyzer {
116116
logger.warn(`Error while parsing ${uri}: syntax error`)
117117
}
118118

119-
const missingNodesDiagnostics = TreeSitterUtil.getDiagnosticsForMissingNodes(
120-
tree.rootNode,
121-
)
122-
123-
return diagnostics.concat(missingNodesDiagnostics)
119+
return diagnostics
124120
}
125121

126122
/**

Diff for: server/src/util/tree-sitter.ts

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver/node'
1+
import * as LSP from 'vscode-languageserver/node'
22
import { SyntaxNode } from 'web-tree-sitter'
33

44
/**
@@ -14,8 +14,8 @@ export function forEach(node: SyntaxNode, callback: (n: SyntaxNode) => void | bo
1414
}
1515
}
1616

17-
export function range(n: SyntaxNode): Range {
18-
return Range.create(
17+
export function range(n: SyntaxNode): LSP.Range {
18+
return LSP.Range.create(
1919
n.startPosition.row,
2020
n.startPosition.column,
2121
n.endPosition.row,
@@ -56,24 +56,3 @@ export function findParent(
5656
}
5757
return null
5858
}
59-
60-
export function getDiagnosticsForMissingNodes(node: SyntaxNode) {
61-
const diagnostics: Diagnostic[] = []
62-
63-
forEach(node, (node) => {
64-
if (node.isMissing()) {
65-
diagnostics.push(
66-
Diagnostic.create(
67-
range(node),
68-
`Syntax error: "${node.type}" missing`,
69-
DiagnosticSeverity.Warning,
70-
undefined,
71-
'bash-language-server',
72-
),
73-
)
74-
}
75-
return node.hasError()
76-
})
77-
78-
return diagnostics
79-
}

0 commit comments

Comments
 (0)