Skip to content

Commit

Permalink
Merge pull request #204 from uqbar-project/shared-module
Browse files Browse the repository at this point in the history
Shared package
  • Loading branch information
PalumboN authored Jan 25, 2025
2 parents 1d19045 + ecbfb7e commit 2ff1cc9
Show file tree
Hide file tree
Showing 44 changed files with 79 additions and 5,247 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.wlk text eol=lf
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,12 @@
"lint:fix": "cd client && eslint . --fix && cd ../server && eslint . --fix && cd ..",
"test": "yarn compile-tests && yarn lint && yarn test:e2e && yarn test:unit",
"test:e2e": "vscode-test",
"test:unit": "cd packages/client && yarn run test:highlighter && cd .. && yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test",
"test:unit": "yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter,wollok-lsp-ide-client}' run test",
"nyc": "nyc",
"build-coverage-report": "rimraf coverage-total && cpy --flat ./coverage-e2e/coverage-final.json ./coverage-total --rename=coverage-e2e.json && cpy --flat ./coverage-unit/coverage-final.json ./coverage-total --rename=coverage-unit.json && nyc merge ./coverage-total ./coverage-total/coverage.json",
"coverage": "yarn cover:unit && yarn cover:e2e",
"cover:e2e": "vscode-test --coverage --coverage-repoter=text --coverage-reporter=json --coverage-output=coverage-e2e",
"cover:unit": "c8 --reporter=json --report-dir=coverage-unit yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test",
"cover:unit": "c8 --reporter=json --report-dir=coverage-unit yarn test:unit",
"bundle": "yarn compile -- --production",
"package": "yarn bundle && vsce package --no-dependencies",
"vscode:prepublish": "yarn bundle",
Expand Down
3 changes: 2 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"url": "https://github.com/uqbar-project/wollok-lsp-ide"
},
"dependencies": {
"shared": "workspace:^",
"wollok-debug-adapter": "workspace:^"
},
"scripts": {
"test:highlighter": "mocha -u tdd -r ts-node/register/transpile-only --loader=ts-node/esm src/test/highlighter/**.test.ts --timeout 2000"
"test": "mocha -u tdd -r ts-node/register/transpile-only --loader=ts-node/esm src/test/highlighter/**.test.ts --timeout 2000"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import {
window,
workspace,
} from 'vscode'
import { DEFAULT_GAME_PORT, DEFAULT_REPL_PORT } from '../../server/src/settings'
import {
asShellString,
fsToShell,
} from './platform-string-utils'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL, wollokLSPExtensionCode, COMMAND_INIT_PROJECT, COMMAND_DEBUG } from './shared-definitions'
import { DEFAULT_GAME_PORT, DEFAULT_REPL_PORT, COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL, wollokLSPExtensionCode, COMMAND_INIT_PROJECT, COMMAND_DEBUG } from '../../shared/definitions'
import { getLSPMessage } from './messages'

export const subscribeWollokCommands = (context: ExtensionContext): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { WollokDebugAdapterFactory, WollokDebugConfigurationProvider } from '../../debug-adapter/src/index'
import { subscribeWollokCommands } from './commands'
import { getLSPMessage } from './messages'
import { wollokLSPExtensionId } from './shared-definitions'
import { wollokLSPExtensionId } from '../../shared/definitions'
import { allWollokFiles } from './utils'
import { legend, provider, selector } from './highlighter'

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as vscode from 'vscode'
import { tokenModifiers, tokenTypes, WollokNodePlotter, WollokPosition } from './highlighter/definitions'
import { processDocument } from './highlighter/tokenProvider'
import { wollokLSPExtensionCode } from './shared-definitions'
import { wollokLSPExtensionCode } from '../../shared/definitions'

const convertToVSCPosition = (position: WollokPosition) =>
new vscode.Position(position.line, position.column)
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getMessage, LANGUAGES, Messages } from 'wollok-ts'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, wollokLSPExtensionCode } from './shared-definitions'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, wollokLSPExtensionCode } from '../../shared/definitions'
import { workspace } from 'vscode'

export const languageDescription: { [key: string]: LANGUAGES } = {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as sinon from 'sinon'
import { ShellExecution, ShellQuotedString, ShellQuoting, Task, Uri, workspace } from 'vscode'
import { initProject, runAllTests, runProgram, runTest, startRepl } from '../commands'
import { activate, getDocumentURI, getFolderURI } from './helper'
import { DEFAULT_GAME_PORT, DEFAULT_REPL_PORT } from '../../../server/src/settings'
import { DEFAULT_GAME_PORT, DEFAULT_REPL_PORT } from '../../../shared/definitions'

suite('Should run commands', () => {
const folderURI = getFolderURI()
Expand Down
2 changes: 1 addition & 1 deletion packages/debug-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/uqbar-project/wollok-lsp-ide"
},
"scripts": {
"test": "mocha --config .mocharc.js"
"test": "mocha --config .mocharc.js --timeout=2000"
},
"dependencies": {
"@vscode/debugadapter": "^1.66.0",
Expand Down
69 changes: 37 additions & 32 deletions packages/debug-adapter/src/test/debug-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,43 +168,48 @@ describe('debug adapter', function () {
})

describe('finished execution', function (){
it('finishing without errors', async function (){
await Promise.all([
it('finishing with errors', function (){
return new Promise((resolve) => {
dc.launch({
"stopOnEntry": false,
"target": {
"file": TEST_FILE,
type: "test",
"describe": "some tests",
"test": "does not break",
},
}),
dc.configurationDoneRequest(),
])
await Promise.all([
dc.assertOutput('stdout', "Finished executing without errors", 1000),
dc.waitForEvent('terminated', 1000),
])
"stopOnEntry": false,
"target": {
"file": TEST_FILE,
type: "test",
"describe": "some tests",
"test": "breaks",
},
}).then(async () => {
await Promise.all([
dc.assertOutput('stderr', "My exception message", 3000),
dc.waitForEvent('terminated', 2000)
])
resolve("Finished")
})
dc.configurationDoneRequest()
})
})

it('finishing with errors', async function (){
await Promise.all([
it('finishing without errors', function (){
return new Promise((resolve) => {
dc.launch({
"stopOnEntry": false,
"target": {
"file": TEST_FILE,
type: "test",
"describe": "some tests",
"test": "breaks",
},
}),
dc.configurationDoneRequest(),
])
await Promise.all([
dc.assertOutput('stderr', "My exception message", 1000),
dc.waitForEvent('terminated', 1000),
])
"stopOnEntry": false,
"target": {
"file": TEST_FILE,
type: "test",
"describe": "some tests",
"test": "does not break",
},
}).then(async () => {
await Promise.all([
dc.assertOutput('stdout', "Finished executing without errors", 1000),
dc.waitForEvent('terminated', 1000)
])
resolve("Finished")
})
dc.configurationDoneRequest()
})
})

})
})

Expand Down
1 change: 1 addition & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"rxjs": "^7.8.1",
"shared": "workspace:^",
"vscode-languageserver": "^9.0.1",
"vscode-languageserver-textdocument": "^1.0.11",
"winston": "^3.11.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/functionalities/code-lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CodeLens, CodeLensParams, Position, Range } from 'vscode-languageserver
import { Describe, Node, Package, Test, Program, Environment, is, PROGRAM_FILE_EXTENSION, TEST_FILE_EXTENSION, WOLLOK_FILE_EXTENSION, Class, Singleton, Entity } from 'wollok-ts'
import { getWollokFileExtension, packageFromURI, toVSCRange } from '../utils/text-documents'
import { removeQuotes } from '../utils/strings'
import { COMMAND_DEBUG, COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL } from '../shared-definitions'
import { COMMAND_DEBUG, COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL } from '../../../shared/definitions'
import { COMMAND_EXECUTE, COMMAND_EXECUTE_DEBUG, getLSPMessage } from './reporter'

export const codeLenses = (environment: Environment) => (params: CodeLensParams): CodeLens[] | null => {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/functionalities/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getMessage, LANGUAGES, Messages, Problem } from 'wollok-ts'
import { lang } from '../settings'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL } from '../shared-definitions'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL } from '../../../shared/definitions'

// ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// CUSTOM MESSAGES DEFINITION
Expand Down
6 changes: 2 additions & 4 deletions packages/server/src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Connection } from 'vscode-languageserver/node'
import { wollokLSPExtensionCode } from './shared-definitions'
import { wollokLSPExtensionCode } from '../../shared/definitions'
import { LANGUAGES } from 'wollok-ts'

export const DEFAULT_REPL_PORT = 3000
export const DEFAULT_GAME_PORT = 4200
import { DEFAULT_REPL_PORT, DEFAULT_GAME_PORT } from '../../shared/definitions'

export interface WollokLSPSettings {
maxNumberOfProblems: number
Expand Down
13 changes: 0 additions & 13 deletions packages/server/src/shared-definitions.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file is linked from both client and server

// IDE
export const wollokLSPExtensionCode = 'wollokLSP'
export const wollokLSPExtensionId = 'wollok-lsp-ide'
export const DEFAULT_REPL_PORT = 3000
export const DEFAULT_GAME_PORT = 4200


// Commands
export const COMMAND_START_REPL = 'wollok.start.repl'
Expand All @@ -11,5 +12,4 @@ export const COMMAND_RUN_PROGRAM = 'wollok.run.program'
export const COMMAND_RUN_ALL_TESTS = 'wollok.run.allTests'
export const COMMAND_RUN_TEST = 'wollok.run.test'
export const COMMAND_INIT_PROJECT = 'wollok.init.project'
//ToDo: Create shared package
export const COMMAND_DEBUG = 'wollok.debug'
export const COMMAND_DEBUG = 'wollok.debug'
12 changes: 12 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "shared",
"author": "Uqbar Foundation",
"license": "LGPL-3.0",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/uqbar-project/wollok-lsp-ide"
}
}
Loading

0 comments on commit 2ff1cc9

Please sign in to comment.