Skip to content

Commit

Permalink
Fixes #322
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano committed Apr 17, 2024
1 parent 4db1231 commit fd37480
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fix issue [#319](https://github.com/intersystems/language-server/issues/319): Outline shows routine labels that don't appear in the first column
- Fix issue [#320](https://github.com/intersystems/language-server/issues/320): Turn routine existence diagnostics on by default
- Fix issue [#321](https://github.com/intersystems/language-server/issues/321): Show detailed descriptions for syntax errors
- Fix issue [#322](https://github.com/intersystems/language-server/issues/322): Add setting to disable undefined variable warning diagnostics
- Parser changes:
- DP-430347: Track variables in routine procedure blocks
- DP-430473: Fix variable tracking with embedded SQL in routine procedure blocks
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is a [LSP](https://microsoft.github.io/language-server-protocol/) compliant
- Expand short class names to include packages (off by default)
- Code linting for ObjectScript and UDL that checks for the following:
- Syntax errors, including for embedded languages.
- References to local variables that are undefined.
- References to local variables that may be undefined.
- Classes and routines that don't exist in the database.
- Invalid UDL Parameter types.
- Mismatches between declared UDL Parameter types and the assigned value.
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@
"type": "boolean",
"default": true,
"markdownDescription": "Controls whether diagnostics are provided when a [SQL reserved word](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_reservedwords) is used in a class or property name of a persistent class."
},
"intersystems.language-server.diagnostics.undefinedVariables": {
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Controls whether diagnostics are provided when a local variable may be undefined."
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion server/src/providers/diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ export async function onDiagnostics(params: DocumentDiagnosticParams): Promise<D
};
diagnostics.push(diagnostic);
}
else if (parsed[i][j].l == ld.cos_langindex && parsed[i][j].s === ld.cos_otw_attrindex) {
else if (
parsed[i][j].l == ld.cos_langindex &&
parsed[i][j].s == ld.cos_otw_attrindex &&
settings.diagnostics.undefinedVariables
) {
// This is an OptionTrackWarning (unset local variable)
const varrange = Range.create(Position.create(i,symbolstart),Position.create(i,symbolend));
let diagnostic: Diagnostic = {
Expand Down
3 changes: 2 additions & 1 deletion server/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export type LanguageServerConfiguration = {
deprecation: boolean,
zutil: boolean,
suppressSyntaxErrors: ("COS" | "SQL" | "CLS" | "HTML" | "PYTHON" | "XML" | "JAVA" | "JAVASCRIPT" | "CSS")[],
sqlReserved: boolean
sqlReserved: boolean,
undefinedVariables: boolean
},
signaturehelp: {
documentation: boolean
Expand Down

0 comments on commit fd37480

Please sign in to comment.