Skip to content

Commit

Permalink
[vscode] Run sema on a single file.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfusik committed Mar 21, 2024
1 parent 4e8310e commit 97db288
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion editors/vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/fusion-*.vsix
/node_modules
/out
/src/parser.js
/src/fucheck.js
4 changes: 2 additions & 2 deletions editors/vscode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ VERSION = 3.1.2
run: fusion-$(VERSION).vsix
'$(LOCALAPPDATA)\Programs\Microsoft VS Code\bin\code' --extensionDevelopmentPath=$(abspath .)

fusion-$(VERSION).vsix: package.json fu-logo.png fu-file.svg language-configuration.json tsconfig.json syntaxes/fusion.tmLanguage.json src/extension.ts src/parser.js node_modules
fusion-$(VERSION).vsix: package.json fu-logo.png fu-file.svg language-configuration.json tsconfig.json syntaxes/fusion.tmLanguage.json src/extension.ts src/fucheck.js node_modules
vsce package

src/parser.js: ../../Lexer.fu ../../AST.fu ../../Parser.fu
src/fucheck.js: ../../Lexer.fu ../../AST.fu ../../Parser.fu ../../Sema.fu
fut -o $@ $^

node_modules: package.json
Expand Down
9 changes: 7 additions & 2 deletions editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// along with Fusion Transpiler. If not, see http://www.gnu.org/licenses/

import * as vscode from "vscode";
import { FuParser, FuProgram, FuSystem, FuParserHost } from "./parser.js";
import { FuParser, FuProgram, FuSystem, FuSema, FuSemaHost } from "./fucheck.js";

class VsCodeHost extends FuParserHost
class VsCodeHost extends FuSemaHost
{
#system = FuSystem.new();
#diagnostics: vscode.Diagnostic[] = [];
Expand All @@ -43,6 +43,11 @@ class VsCodeHost extends FuParserHost
parser.program.system = this.#system;
const input = new TextEncoder().encode(document.getText());
parser.parse(document.fileName, input, input.length);
if (this.#diagnostics.length == 0) {
const sema = new FuSema();
sema.setHost(this);
sema.process(parser.program);
}
diagnosticCollection.set(document.uri, this.#diagnostics);
}
}
Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": [
"src/extension.ts",
"src/parser.js"
"src/fucheck.js"
],
"compilerOptions": {
"target": "es2021",
Expand Down

0 comments on commit 97db288

Please sign in to comment.