Skip to content

Commit fb53fb3

Browse files
authored
Merge pull request #57 from rdurfee/master
Ignore undefined warnings for Classes and Callables
2 parents 100ddff + 372145f commit fb53fb3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Fixes
1111

1212
* Fix folding for label starting with a dot [#52](https://github.com/LuqueDaniel/vscode-language-renpy/issues/52)
13+
* Fix undefined store warnings for Classes and Callables [#56](https://github.com/LuqueDaniel/vscode-language-renpy/issues/56)
1314

1415
## 2.0.3 (2021/10/31)
1516

src/diagnostics.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,18 @@ function checkInvalidVariableNames(diagnostics: Diagnostic[], line: string, line
217217
function checkStoreVariables(diagnostics: Diagnostic[], line: string, lineIndex: number) {
218218
// check store prefixed variables have been defaulted
219219
const defaults = NavigationData.gameObjects['define_types'];
220+
let classes = [];
221+
let callables = [];
222+
if (NavigationData.data && NavigationData.data.location) {
223+
classes = NavigationData.data.location['class'] || [];
224+
callables = NavigationData.data.location['callable'] || [];
225+
}
226+
220227
if (defaults) {
221228
const filtered = Object.keys(defaults).filter(key => defaults[key].define === 'default');
222229
let matches;
223230
while ((matches = rxStoreCheck.exec(line)) !== null) {
224-
if (!matches[1].startsWith('_') && !filtered.includes(matches[1]) && !renpy_store.includes(matches[1])) {
231+
if (!matches[1].startsWith('_') && !filtered.includes(matches[1]) && !renpy_store.includes(matches[1]) && !classes[matches[1]] && !callables[matches[1]]) {
225232
const offset = matches.index + matches[0].indexOf(matches[1]);
226233
const range = new Range(lineIndex, offset, lineIndex, offset + matches[1].length);
227234
const diagnostic = new Diagnostic(range, `"store.${matches[1]}": Use of a store variable that has not been defaulted.`, DiagnosticSeverity.Warning);

0 commit comments

Comments
 (0)