Skip to content

Commit

Permalink
Updated crmscript-langium to now support basic types and some scopes …
Browse files Browse the repository at this point in the history
…for nested.

Updated vscode extension to read client_id from a file, and refactored the authenticationService to be more dependency injection pattern
  • Loading branch information
Eivind Fasting committed Jun 3, 2024
1 parent feaa0c3 commit c7512d9
Show file tree
Hide file tree
Showing 69 changed files with 8,329 additions and 1,386 deletions.
13 changes: 13 additions & 0 deletions packages/langium-crmscript/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
11 changes: 11 additions & 0 deletions packages/langium-crmscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode/*
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/tasks.json
node_modules/
out/
src/language/generated/
static/bundle/
static/monaco-editor-workers/
static/worker/
syntaxes/
11 changes: 11 additions & 0 deletions packages/langium-crmscript/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"langium.langium-vscode",
"ZixuanChen.vitest-explorer",
"kingwl.vscode-vitest-runner"
]
}
36 changes: 36 additions & 0 deletions packages/langium-crmscript/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--folder-uri=${workspaceRoot}/examples"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
]
},
{
"name": "Attach to Language Server",
"type": "node",
"port": 6009,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/node_modules/langium"
]
}
]
}
21 changes: 21 additions & 0 deletions packages/langium-crmscript/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build crmscript",
"command": "npm run langium:generate && npm run build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Langium: Generate grammar and build the crmscript language",
"icon": {
"color": "terminal.ansiGreen",
"id": "server-process"
}
}
]
}
4 changes: 4 additions & 0 deletions packages/langium-crmscript/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
langium-quickstart.md
2 changes: 2 additions & 0 deletions packages/langium-crmscript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# langium-crmscript
Language definition for CRMScript using Langium
54 changes: 54 additions & 0 deletions packages/langium-crmscript/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//@ts-check
import * as esbuild from 'esbuild';

const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');

const success = watch ? 'Watch build succeeded' : 'Build succeeded';

function getTime() {
const date = new Date();
return `[${`${padZeroes(date.getHours())}:${padZeroes(date.getMinutes())}:${padZeroes(date.getSeconds())}`}] `;
}

function padZeroes(i) {
return i.toString().padStart(2, '0');
}

const plugins = [{
name: 'watch-plugin',
setup(build) {
build.onEnd(result => {
if (result.errors.length === 0) {
console.log(getTime() + success);
}
});
},
}];

const ctx = await esbuild.context({
// Entry points for the vscode extension and the language server
entryPoints: ['src/extension/main.ts', 'src/language/main.ts'],
outdir: 'out',
bundle: true,
target: "ES2017",
// VSCode's extension host is still using cjs, so we need to transform the code
format: 'cjs',
// To prevent confusing node, we explicitly use the `.cjs` extension
outExtension: {
'.js': '.cjs'
},
loader: { '.ts': 'ts' },
external: ['vscode'],
platform: 'node',
sourcemap: !minify,
minify,
plugins
});

if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
ctx.dispose();
}
19 changes: 19 additions & 0 deletions packages/langium-crmscript/examples/basic.crmscript-definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
# String

Summary goes here.

I just love **bold text**.

```crmscript

String something = "Hello";

```

*/
class String {
}

String temp = "";

77 changes: 77 additions & 0 deletions packages/langium-crmscript/examples/test.crmscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@


// ///Should be invalid
// Integer invalidSetInteger = "123";
// Integer invalidSetInteger2 = true;
// String invalidSetString = 123;
// String invalidSetString2 = true;
// Bool invalidSetBool = "123";
// Bool invalidSetBool2 = 123;
// Integer invalidSumInteger = 123 + "123";

// String myStringFunction() {
// return 123;
// }

// Integer myIntegerFunction() {
// return "123";
// }
// //--------------------------------------- ---------------------------------------


// /////Should be valid
// "123";
// 13213;
// true;
// Bool validEmptyBool;
// Bool validSetBool = true;
// String validEmptyString;
// String validSetString = "123";
// String validSumString = "123" + "123";
// Integer validEmptyInteger;
// Integer validSetInteger = 123;
// Integer validSumInteger = 123 + 123;

// for(Integer i = 0; i > 20; i++){
// Integer j = i + 20;
// String bla = "123" + 20;
// }

// String myStringFunction() {
// return "123";
// }

// Integer myIntegerFunction() {
// return 123;
// }


// try{}
// catch(exception){}


// /** Hover*/
// //Builtin Class
// Customer c;
// c.firstName = "123";

// //--------------------------------------- ---------------------------------------

// //--------------------------------------- Not working correctly ---------------------------------------
// //Not working correctly
// String invalidSumString = 123 + "123"; // <= This should be invalid, need to look at the validation of number + string
// //TODO: Implement Structs
// // struct myStruct { //Hover returned from the checkStructDeclaration validation method
// // String structString;
// // Integer structInt;
// // Customer cust;
// // String getString(){
// // this.structString = "1232"; // <= this keyword is not recognized as a NamedElement (?)
// // return this.customerString; // Need to validate this is possible after the line above is working
// // }
// // };

// String temp = "123";
// Integer int = 123;

// temp.
21 changes: 17 additions & 4 deletions packages/langium-crmscript/langium-config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"projectName": "Crmscript",
"languages": [{
"id": "crmscript",
"grammar": "src/language/crmscript.langium",
"languages": [ {
"id": "crmscript-definition",
"grammar": "src/language/crmscript-definition.langium",
"fileExtensions": [".crmscript-definition"],
"textMate": {
"out": "syntaxes/crmscript-definition.tmLanguage.json"
},
"monarch": {
"out": "syntaxes/crmscript-definition.monarch.ts"
}
}, {
"id": "crmscript-implementation",
"grammar": "src/language/crmscript-implementation.langium",
"fileExtensions": [".crmscript"],
"textMate": {
"out": "syntaxes/crmscript.tmLanguage.json"
"out": "syntaxes/crmscript-implementation.tmLanguage.json"
},
"monarch": {
"out": "syntaxes/crmscript-implementation.monarch.ts"
}
}],
"out": "src/language/generated"
Expand Down
30 changes: 30 additions & 0 deletions packages/langium-crmscript/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "//",
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
"blockComment": [ "/*", "*/" ]
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
Loading

0 comments on commit c7512d9

Please sign in to comment.