This commit is contained in:
2024-12-21 14:29:46 -08:00
parent 567a357dee
commit e396514899
9 changed files with 176 additions and 22 deletions

View File

@@ -17,7 +17,7 @@
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"curly": ["warn", "multi"],
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
@@ -27,4 +27,4 @@
"dist",
"**/*.d.ts"
]
}
}

View File

@@ -37,9 +37,9 @@ export function activate(context: vscode.ExtensionContext) {
{ cwd, maxBuffer: 1024 * 1024 * 10 },
(err, stdout, _stderr) => {
// I think I ignored 1 here because I wanted failure to launch
if (err && err.code !== 1) {
if (err && err.code !== 1)
vscode.window.showErrorMessage(`newt error: ${err}`);
}
// extract errors and messages from stdout
const lines = stdout.split("\n");
@@ -79,9 +79,9 @@ export function activate(context: vscode.ExtensionContext) {
let lnum = Number(line);
let cnum = Number(column);
if (file !== fileName) {
if (file !== fileName)
lnum = cnum = 0;
}
let start = new vscode.Position(lnum, cnum);
// we don't have the full range, so grab the surrounding word
let end = new vscode.Position(lnum, cnum + 1);
@@ -92,17 +92,17 @@ export function activate(context: vscode.ExtensionContext) {
// anything indented
// Context:, or Goal: are part of PRINTME
// unexpected / expecting appear in parse errors
while (lines[i + 1]?.match(/^( )/)) {
while (lines[i + 1]?.match(/^( )/))
message += "\n" + lines[++i];
}
const severity =
kind === "ERROR"
? vscode.DiagnosticSeverity.Error
: vscode.DiagnosticSeverity.Information;
const diag = new vscode.Diagnostic(range, message, severity);
if (kind === "ERROR" || lnum > 0) {
if (kind === "ERROR" || lnum > 0)
diagnostics.push(diag);
}
}
}
diagnosticCollection.set(vscode.Uri.file(fileName), diagnostics);
@@ -116,9 +116,9 @@ export function activate(context: vscode.ExtensionContext) {
const editor = vscode.window.activeTextEditor;
if (editor) {
const document = editor.document;
if (document.fileName.endsWith(".newt")) {
if (document.fileName.endsWith(".newt"))
checkDocument(document);
}
}
}
);
@@ -164,25 +164,25 @@ export function activate(context: vscode.ExtensionContext) {
}
}
)
)
);
context.subscriptions.push(runPiForall);
vscode.workspace.onDidSaveTextDocument((document) => {
if (document.fileName.endsWith(".newt")) {
if (document.fileName.endsWith(".newt"))
vscode.commands.executeCommand("newt-vscode.check");
}
});
vscode.workspace.onDidOpenTextDocument((document) => {
if (document.fileName.endsWith(".newt")) {
if (document.fileName.endsWith(".newt"))
vscode.commands.executeCommand("newt-vscode.check");
}
});
for (let document of vscode.workspace.textDocuments) {
if (document.fileName.endsWith(".newt")) {
for (let document of vscode.workspace.textDocuments)
if (document.fileName.endsWith(".newt"))
checkDocument(document);
}
}
context.subscriptions.push(diagnosticCollection);
}

View File

@@ -16,7 +16,7 @@
},
{
"name": "keyword.newt",
"match": "\\b(λ|=>|<-|->|→|:=|\\$|data|where|do|class|uses|instance|case|of|let|if|then|else|forall|∀|in|U|module|import|ptype|pfunc|infix|infixl|infixr)\\b"
"match": "\\b(λ|=>|<-|->|→|:=|\\$|data|record|where|do|class|uses|instance|case|of|let|if|then|else|forall|∀|in|U|module|import|ptype|pfunc|infix|infixl|infixr)\\b"
},
{
"name": "string.js",