Skip to content

Commit

Permalink
moved showcase to langium ast helper
Browse files Browse the repository at this point in the history
  • Loading branch information
emilkrebs authored and spoenemann committed Nov 21, 2023
1 parent dc84df4 commit 7e13580
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 161 deletions.
6 changes: 5 additions & 1 deletion hugo/assets/scripts/arithmetics/arithmetics-tools.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { monaco } from "langium-website-core/bundle";
import { Pos } from "../langium-utils/langium-ast";

type Pos = {
character: number;
line: number;
}

export interface Evaluation {
range: {
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/arithmetics/arithmetics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { addMonacoStyles, createUserConfig, MonacoEditorReactComp, UserConfig }
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
import { Diagnostic, DocumentChangeResponse } from "../langium-utils/langium-ast";
import { Evaluation, examples, syntaxHighlighting } from "./arithmetics-tools";
import { Diagnostic, DocumentChangeResponse } from "langium-ast-helper";

addMonacoStyles('monaco-styles-helper');

Expand Down
3 changes: 1 addition & 2 deletions hugo/assets/scripts/domainmodel/domainmodel-tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import { AstNode } from "../langium-utils/langium-ast";
import { AstNode } from "langium-ast-helper";
import { TreeNode } from "./d3tree";


Expand Down
4 changes: 2 additions & 2 deletions hugo/assets/scripts/domainmodel/domainmodel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { addMonacoStyles, createUserConfig, MonacoEditorReactComp, UserConfig }
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
import { Diagnostic, DocumentChangeResponse, LangiumAST } from "../langium-utils/langium-ast";
import { DomainModelAstNode, example, getMainTreeNode, syntaxHighlighting } from "./domainmodel-tools";
import { deserializeAST, Diagnostic, DocumentChangeResponse } from 'langium-ast-helper';

import D3Tree from "./d3tree";

Expand Down Expand Up @@ -70,7 +70,7 @@ class App extends React.Component<{}, AppState> {
*/
onDocumentChange(resp: DocumentChangeResponse) {
// get the AST from the response and deserialize it
const ast = new LangiumAST().deserializeAST(resp.content) as DomainModelAstNode;
const ast = deserializeAST(resp.content) as DomainModelAstNode;

this.setState({
ast: ast,
Expand Down
151 changes: 0 additions & 151 deletions hugo/assets/scripts/langium-utils/langium-ast.ts

This file was deleted.

2 changes: 1 addition & 1 deletion hugo/assets/scripts/statemachine/statemachine-tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AstNode } from "../langium-utils/langium-ast";
import { AstNode } from "langium-ast-helper";

export class StateMachineTools {
currentState: StateMachineState;
Expand Down
4 changes: 2 additions & 2 deletions hugo/assets/scripts/statemachine/statemachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { addMonacoStyles, createUserConfig, MonacoEditorReactComp, UserConfig }
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
import { Diagnostic, DocumentChangeResponse, LangiumAST } from "../langium-utils/langium-ast";
import { defaultText, StateMachineAstNode, StateMachineState, StateMachineTools } from "./statemachine-tools";
import statemachineGrammar from 'langium-statemachine-dsl/syntaxes/statemachine.tmLanguage.json';
import { deserializeAST, Diagnostic, DocumentChangeResponse } from "langium-ast-helper";

addMonacoStyles('monaco-styles-helper');

Expand Down Expand Up @@ -249,7 +249,7 @@ class StateMachineComponent extends React.Component<{
*/
onDocumentChange(resp: DocumentChangeResponse) {
// decode the received Ast
const statemachineAst = new LangiumAST().deserializeAST(resp.content) as StateMachineAstNode;
const statemachineAst = deserializeAST(resp.content) as StateMachineAstNode;
this.preview.current?.startPreview(statemachineAst, resp.diagnostics);
}

Expand Down
3 changes: 2 additions & 1 deletion hugo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"monaco-editor-workers": "~0.44.0",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"vscode-languageserver": "~8.0.2"
"vscode-languageserver": "~8.0.2",
"langium-ast-helper": "0.1.2"
},
"volta": {
"node": "18.18.1",
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e13580

Please sign in to comment.