Skip to content

Commit 4b942e9

Browse files
committed
Add error checking
1 parent b401fe7 commit 4b942e9

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the "restructuredpython" extension will be documented in this file. Versions older than 1.2.0 will not be documented.
44

5+
# 2.1.0
6+
7+
- Error Checking
8+
59
# 2.0.0
610

711
- INTELLISENSE!

errorChecker.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

errorChecker.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export function updateDiagnostics(doc: vscode.TextDocument, declaredVariables: S
66
const diagnostics: vscode.Diagnostic[] = [];
77
const text = doc.getText();
88
const lines = text.split(/\r?\n/);
9-
109
lines.forEach((line, i) => {
1110
const lineText = line.trim();
1211

@@ -15,6 +14,20 @@ export function updateDiagnostics(doc: vscode.TextDocument, declaredVariables: S
1514
const range = new vscode.Range(i, line.length - 2, i, line.length);
1615
diagnostics.push(new vscode.Diagnostic(range, "Unexpected ';' at end of line", vscode.DiagnosticSeverity.Error));
1716
}
17+
const trimmedLine = line.trim();
18+
19+
// Direct string matching (like Python)
20+
if (trimmedLine.startsWith("} else") ||
21+
trimmedLine.startsWith("} elif") ||
22+
trimmedLine.startsWith("} except") ||
23+
trimmedLine.startsWith("} def") ||
24+
trimmedLine.startsWith("} class") ||
25+
trimmedLine.startsWith("} case")) {
26+
27+
const range = new vscode.Range(i, 0, i, line.length);
28+
diagnostics.push(new vscode.Diagnostic(range, `Misplaced '${trimmedLine}' statement.`, vscode.DiagnosticSeverity.Error));
29+
}
30+
1831
});
1932

2033
collection.set(doc.uri, diagnostics);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "restructuredpython",
33
"displayName": "reStructuredPython",
44
"description": "Support for the language reStructuredPython",
5-
"version": "2.0.0",
5+
"version": "2.1.0",
66
"publisher": "RihaanMeher",
77
"icon": "icons/icon.png",
88
"repository": {

0 commit comments

Comments
 (0)