diff --git a/package-lock.json b/package-lock.json index 30134ef3..a8842f53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22067,12 +22067,14 @@ "@angular/router": "^16.2.0", "@materia-ui/ngx-monaco-editor": "^6.0.0", "@portugol-webstudio/antlr": "*", + "@portugol-webstudio/parser": "*", "@portugol-webstudio/resources": "*", "@portugol-webstudio/runner": "*", "@portugol-webstudio/runtime": "*", "@sentry/angular-ivy": "^7.62.0", "angular-split": "^15.0.0", "angular-svg-icon": "^16.0.0", + "antlr4ts": "^0.5.0-alpha.4", "assert": "^2.0.0", "file-saver": "^2.0.5", "firebase": "^9.23.0", @@ -22106,6 +22108,7 @@ } }, "packages/parser": { + "name": "@portugol-webstudio/parser", "version": "0.0.0", "license": "GPL-3.0", "dependencies": { @@ -22218,7 +22221,6 @@ "license": "GPL-3.0", "dependencies": { "@portugol-webstudio/antlr": "*", - "@portugol-webstudio/parser": "*", "@sentry/core": "^7.62.0", "antlr4ts": "^0.5.0-alpha.4" }, diff --git a/packages/ide/package.json b/packages/ide/package.json index 3a42c7ef..42e578be 100644 --- a/packages/ide/package.json +++ b/packages/ide/package.json @@ -42,12 +42,14 @@ "@angular/router": "^16.2.0", "@materia-ui/ngx-monaco-editor": "^6.0.0", "@portugol-webstudio/antlr": "*", + "@portugol-webstudio/parser": "*", "@portugol-webstudio/resources": "*", "@portugol-webstudio/runner": "*", "@portugol-webstudio/runtime": "*", "@sentry/angular-ivy": "^7.62.0", "angular-split": "^15.0.0", "angular-svg-icon": "^16.0.0", + "antlr4ts": "^0.5.0-alpha.4", "assert": "^2.0.0", "file-saver": "^2.0.5", "firebase": "^9.23.0", diff --git a/packages/ide/src/app/tab-editor/tab-editor.component.scss b/packages/ide/src/app/tab-editor/tab-editor.component.scss index 58aa308f..752cdbf7 100644 --- a/packages/ide/src/app/tab-editor/tab-editor.component.scss +++ b/packages/ide/src/app/tab-editor/tab-editor.component.scss @@ -9,6 +9,13 @@ height: 100%; } +::ng-deep .editor-inner { + .monaco-editor .monaco-hover { + position: fixed; + z-index: 9999; + } +} + .editor-inner { background-color: shade($background-200, 15); flex-grow: 1; diff --git a/packages/ide/src/app/tab-editor/tab-editor.component.ts b/packages/ide/src/app/tab-editor/tab-editor.component.ts index 25b794df..f901b290 100644 --- a/packages/ide/src/app/tab-editor/tab-editor.component.ts +++ b/packages/ide/src/app/tab-editor/tab-editor.component.ts @@ -11,14 +11,16 @@ import { } from "@angular/core"; import { uploadString, ref, Storage } from "@angular/fire/storage"; import { MatSnackBar } from "@angular/material/snack-bar"; -import { PortugolSyntaxError } from "@portugol-webstudio/antlr"; +import { PortugolLexer, PortugolParser, PortugolSyntaxError } from "@portugol-webstudio/antlr"; +import { PortugolNode, ParseError } from "@portugol-webstudio/parser"; import { PortugolExecutor, PortugolWebWorkersRunner } from "@portugol-webstudio/runner"; import { PortugolJsRuntime } from "@portugol-webstudio/runtime"; import { captureException, setExtra } from "@sentry/angular-ivy"; +import { CharStreams, CommonTokenStream } from "antlr4ts"; import { saveAs } from "file-saver"; import { ShortcutInput } from "ng-keyboard-shortcuts"; import { GoogleAnalyticsService } from "ngx-google-analytics"; -import { Subscription } from "rxjs"; +import { Subscription, debounceTime, fromEventPattern } from "rxjs"; import { TextEncoder } from "text-encoding"; @Component({ @@ -27,6 +29,7 @@ import { TextEncoder } from "text-encoding"; styleUrls: ["./tab-editor.component.scss"], }) export class TabEditorComponent implements OnInit, OnDestroy { + private _code$?: Subscription; private _stdOut$?: Subscription; private _events$?: Subscription; @@ -139,8 +142,9 @@ export class TabEditorComponent implements OnInit, OnDestroy { } ngOnDestroy() { - this._stdOut$?.unsubscribe(); + this._code$?.unsubscribe(); this._events$?.unsubscribe(); + this._stdOut$?.unsubscribe(); this.executor.stop(); } @@ -279,6 +283,40 @@ export class TabEditorComponent implements OnInit, OnDestroy { onEditorInit(editor: monaco.editor.IStandaloneCodeEditor) { this.codeEditor = editor; this.initShortcuts(editor); + + this._code$?.unsubscribe(); + + this._code$ = fromEventPattern(editor.onDidChangeModelContent) + .pipe(debounceTime(1000)) + .subscribe(() => { + const code = this.code; + + if (code) { + try { + const inputStream = CharStreams.fromString(code); + const lexer = new PortugolLexer(inputStream); + const tokenStream = new CommonTokenStream(lexer); + const parser = new PortugolParser(tokenStream); + + new PortugolNode().visit(parser.arquivo()); + this.setEditorErrors([]); + } catch (error) { + if (error instanceof ParseError && error.ctx.parent) { + const { _start, _stop } = error.ctx.parent as unknown as { _start: any; _stop: any }; + + this.setEditorErrors([ + new PortugolSyntaxError( + _start._line, + _stop._line, + _start._charPositionInLine + 1, + _stop._charPositionInLine + 1 + error.ctx.text.length, + error.message, + ), + ]); + } + } + } + }); } openHelp() { diff --git a/packages/ide/src/app/tab-start/tab-start.component.html b/packages/ide/src/app/tab-start/tab-start.component.html index 6fdd028d..073ea627 100644 --- a/packages/ide/src/app/tab-start/tab-start.component.html +++ b/packages/ide/src/app/tab-start/tab-start.component.html @@ -77,6 +77,7 @@

šŸ“°  Novidades

+

02/09/2023: VerificaĆ§Ć£o bĆ”sica de erros no editor.

10/08/2023:

@@ -95,7 +96,6 @@

šŸ“°  Novidades

10/12/2022: CorreĆ§Ć£o no comportamento da concatenaĆ§Ć£o.

-

12/11/2022: CorreĆ§Ć£o na verificaĆ§Ć£o de tipos de argumentos de funƧƵes.