Skip to content

Commit 459fa50

Browse files
committed
Remove sometimes useless missing node diagnostics
1 parent 3a31986 commit 459fa50

File tree

3 files changed

+3
-46
lines changed

3 files changed

+3
-46
lines changed

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

-21
Original file line numberDiff line numberDiff line change
@@ -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)