Skip to content

Commit

Permalink
Merge pull request #2 from matheuslenke/develop
Browse files Browse the repository at this point in the history
Feat: Extension with Code Actions, exporting, importing and tests
  • Loading branch information
matheuslenke authored Feb 16, 2023
2 parents ee16fe9 + 2700951 commit 18c6cde
Show file tree
Hide file tree
Showing 131 changed files with 20,913 additions and 6,277 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
53 changes: 51 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
{
"root": true,
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [
"**/{node_modules,lib,bin}"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
// List of [@typescript-eslint rules](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules)
"@typescript-eslint/adjacent-overload-signatures": "error", // grouping same method names
"@typescript-eslint/array-type": ["error", { // string[] instead of Array<string>
"default": "array-simple"
}],
"@typescript-eslint/ban-types": "error", // bans types like String in favor of string
"@typescript-eslint/no-inferrable-types": "off", // don't blame decls like "index: number = 0", esp. in api signatures!
"@typescript-eslint/indent": "off", // consistent indentation
"@typescript-eslint/no-explicit-any": "off", // don't use :any type
"@typescript-eslint/no-misused-new": "error", // no constructors for interfaces or new for classes
"@typescript-eslint/no-namespace": "off", // disallow the use of custom TypeScript modules and namespaces
"@typescript-eslint/no-non-null-assertion": "off", // allow ! operator
"@typescript-eslint/no-parameter-properties": "error", // no property definitions in class constructors
"@typescript-eslint/no-unused-vars": ["warn", { // disallow Unused Variables
"argsIgnorePattern": "^_"
}],
"@typescript-eslint/no-var-requires": "error", // use import instead of require
"@typescript-eslint/prefer-for-of": "error", // prefer for-of loop over arrays
"@typescript-eslint/prefer-namespace-keyword": "error", // prefer namespace over module in TypeScript
"@typescript-eslint/triple-slash-reference": "error", // ban /// <reference />, prefer imports
"@typescript-eslint/type-annotation-spacing": "error" // consistent space around colon ':'
}
}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ lib/
coverage
*.tsbuildinfo

*.vsix
*.vsix

**/generated/*.tonto
**/generated/*.json

.yarn
25 changes: 21 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"debugWebWorkerHost": true
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
]
},
{
"name": "Attach to Language Server",
"type": "node",
"port": 6009,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/node_modules/langium"
],
}
]
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/othneildrew/Best-README-Template">
<a href="https://github.com/matheuslenke/Tonto">
<img src="docs/images/TontoLogo.png" alt="Logo" height="100" alt="Tonto Logo image, a blue background with TONTO written in it">
</a>

Expand Down Expand Up @@ -92,7 +92,7 @@ This is the instructions on setting up your project locally. To get a local copy
This is all the tools you need installed to run the project and the versions that are preferred
* nodejs - v16.9.1 or higher
* npm - 7.21.1 or higher
* Yarn - 1.22.18 (not mandatory, but really recommended)
* Yarn - 1.22.18 (not mandatory, but recommended)


### ⚙️ Initializing
Expand Down
84 changes: 61 additions & 23 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,71 @@
//@ts-check
const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');
const success = watch ? 'Watch build succeeded' : 'Build succeeded';
const watch = process.argv.includes("--watch");
const minify = process.argv.includes("--minify");
const successExtension = watch
? "Watch build Extension succeeded"
: "Build Extension succeeded";
const successCli = watch ? "Watch build CLI succeeded" : "Build CLI succeeded";

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

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

require('esbuild').build({
const esbuild = require("esbuild");

/**
* This is the entry point for building the Extension
*/
esbuild
.build({
// Two entry points, one for the extension, one for the language server
entryPoints: ['src/extension.ts', 'src/language-server/main.ts'],
outdir: 'out',
bundle: true,
loader: { '.ts': 'ts' },
external: ['vscode'], // the vscode-module is created on-the-fly and must be excluded.
platform: 'node', // VSCode extensions run in a node process
sourcemap: true,
watch: watch ? {
onRebuild(error) {
if (error) console.error(`${getTime()}Watch build failed`)
else console.log(`${getTime()}${success}`)
}
} : false,
minify
})
.then(() => console.log(`${getTime()}${success}`))
.catch(() => process.exit(1));
entryPoints: ["src/extension.ts", "src/language-server/main.ts"],
outdir: "out",
bundle: true,
external: ["vscode"], // the vscode-module is created on-the-fly and must be excluded.
platform: "node", // VSCode extensions run in a node process
sourcemap: !minify,
watch: watch
? {
onRebuild(error) {
if (error) console.error("Watch build failed");
else console.log(successExtension);
},
}
: false,
minify,
})
.then(() => console.log(`${getTime()}${successExtension}`))
.catch(() => process.exit(1));

/**
* This is the entry point for building the CLI
*/
esbuild
.build({
entryPoints: ["src/cli/index.ts"],
outdir: "out/cli",
bundle: true,
loader: { ".ts": "ts" },
external: ["vscode"], // the vscode-module is created on-the-fly and must be excluded.
platform: "node", // VSCode extensions run in a node process
sourcemap: true,
minifyIdentifiers: false,
watch: watch
? {
onRebuild(error) {
if (error) console.error(`${getTime()}Watch build failed`);
else console.log(`${getTime()}${successCli}`);
},
}
: false,
minify,
})
.then(() => console.log(`${getTime()}${successCli}`))
.catch(() => process.exit(1));
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
module MarriageModule {
kind Person

relator SocialRelator
category SocialRelator of relators
relator SocialRelatorType specializes SocialRelator
kind MarriageDuty
kind MarriageRight specializes Marriage

role Spouse specializes Person {
-- isBoundBy -- Marriage inverseOf involvesSpouse
}

relator Marriage (instanceOf SocialRelatorType) specializes SocialRelator
ref Marriage -- involvesSpouse -- [2..*] Spouse
ref Marriage <>-- [1..*] MarriageDuty

ref Marriage -- [2..*] Spouse
ref Marriage <>-- [1..*] MarriageDuty
ref Marriage <>-- [1..*] MarriageRight
relation Marriage -- involvesSpouse -- [2..*] Spouse
relation Marriage <>-- [1..*] MarriageDuty
relation Marriage -- [2..*] Spouse
relation Marriage <>-- [1..*] MarriageDuty
relation Marriage <>-- [1..*] MarriageRight
// relation Person (pai {const}) [1] -- temFilhos -- [*] Person (filho)
}

module MarriageModuleCopy {
kind Person

relator SocialRelator
relator SocialRelatorType specializes SocialRelator

role Spouse specializes Person {
[1..*] -- isBoundBy --[2] Marriage inverseOf involvesSpouse
}

kind MarriageDuty
kind MarriageRight


relator Marriage specializes SocialRelatorType

ref Marriage -- involvesSpouse -- [2..*] Spouse
ref Marriage <>-- [1..*] MarriageDuty

ref Marriage -- [2..*] Spouse
ref Marriage <>-- [1..*] MarriageDuty
ref Marriage <>-- [1..*] MarriageRight
relation Marriage -- involvesSpouse -- [2..*] Spouse
relation Marriage <>-- [1..*] MarriageDuty
relation Marriage -- [2..*] Spouse
relation Marriage <>-- [1..*] MarriageDuty
relation Marriage <>-- [1..*] MarriageRight
}

module Teste {

}
File renamed without changes.
8 changes: 8 additions & 0 deletions examples/basicExamples/School.tonto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module School {
kind Pessoa
kind Organizacao
subkind Escola specializes Organizacao
role Estudante specializes Pessoa
relation Organizacao -- temMembro -- Pessoa
relation Estudante -- estudaEm -- Escola
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ module PersonHealth {
phase NonFunctionalBrain specializes Brain

kind Person specializes PhysicalObject {
<>-- hasOneHearth <>-- [1] Hearth
<>-- hasOneBrain <>-- [1] Brain
<>-- hasOneHearth -- [1] Hearth
<>-- hasOneBrain -- [1] Brain
}

ref Person -- hasOneHearth -- [1] Hearth
ref Person -- hasOneBrain -- [1] Brain

phase DeceasedPerson specializes Person
phase LivingPerson specializes Person

Expand Down
Loading

0 comments on commit 18c6cde

Please sign in to comment.