ts-plugin. Works in VS Code, haven't managed to configure Emacs to work with it yet.

This commit is contained in:
Tony Garnock-Jones 2021-12-03 02:06:17 +01:00
parent 7b9f035fa8
commit d8b60ccf76
7 changed files with 47 additions and 24 deletions

View File

@ -2,13 +2,17 @@
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
import { BoxState, SetBox, N } from './protocol.js';
import { Ref } from '@syndicate-lang/core';
boot {
export function boot(ds: Ref) {
spawn named 'box' {
field value: number = 0;
assert BoxState(this.value);
stop on (this.value === N)
field boxValue: number = 0;
at ds {
assert BoxState(boxValue.value);
on message SetBox($v: number) => boxValue.value = v;
}
stop on (boxValue.value === N) {
console.log('terminated box root facet');
on message SetBox($v: number) => this.value = v;
}
}
}

View File

@ -2,10 +2,16 @@
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
import { BoxState, SetBox } from './protocol.js';
import { Ref } from '@syndicate-lang/core';
boot {
export function boot(ds: Ref, doneCallback: () => void) {
spawn named 'client' {
on asserted BoxState($v: number) => send message SetBox(v + 1);
on retracted BoxState(_) => console.log('box gone');
at ds {
on asserted BoxState($v: number) => send message SetBox(v + 1);
on retracted BoxState(_) => {
console.log('box gone');
doneCallback();
}
}
}
}

View File

@ -2,11 +2,14 @@
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
import { N } from './protocol.js';
activate import './box.js';
activate import './client.js';
import * as Box from './box.js';
import * as Client from './client.js';
import { Actor, Dataspace, Turn } from '@syndicate-lang/core';
console.time('box-and-client-' + N.toString());
boot {
thisFacet.actor.dataspace.ground().addStopHandler(() =>
console.timeEnd('box-and-client-' + N.toString()));
}
Actor.boot(() => {
Turn.activeFacet.preventInertCheck();
const ds = create new Dataspace();
Box.boot(ds);
Client.boot(ds, () => console.timeEnd('box-and-client-' + N.toString()));
});

View File

@ -1,7 +1,7 @@
/// SPDX-License-Identifier: GPL-3.0-or-later
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
export assertion type BoxState(value);
export message type SetBox(newValue);
export assertion type BoxState(value: number);
export message type SetBox(newValue: number);
export const N = 100000;

View File

@ -21,9 +21,9 @@
"@syndicate-lang/core": "^0.6.0"
},
"devDependencies": {
"typescript": "^4.1.3"
"typescript": "^4.5"
},
"peerDependencies": {
"typescript": "^4.1.3"
"typescript": "^4.5"
}
}

View File

@ -173,7 +173,7 @@ const boot: tslib.server.PluginModuleFactory = ({ typescript: ts }) => {
return sf;
} catch (e) {
console.error(e);
onError?.(e.message);
onError?.((e as any).message ?? '<no error message available>');
return undefined;
}
} else {
@ -223,6 +223,10 @@ const boot: tslib.server.PluginModuleFactory = ({ typescript: ts }) => {
this.inner = inner;
}
provideInlayHints(fileName: string, span: ts.TextSpan, preferences: ts.UserPreferences | undefined): ts.InlayHint[] {
throw new Error('Method not implemented.');
}
getFileReferences(fileName: string): tslib.ReferenceEntry[] {
throw new Error('Method not implemented.');
}
@ -330,13 +334,19 @@ const boot: tslib.server.PluginModuleFactory = ({ typescript: ts }) => {
});
}
getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined, source: string | undefined, preferences: ts.UserPreferences | undefined): ts.CompletionEntryDetails | undefined {
getCompletionEntryDetails(fileName: string,
position: number,
entryName: string,
formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined,
source: string | undefined,
preferences: ts.UserPreferences | undefined,
data: ts.CompletionEntryData | undefined): ts.CompletionEntryDetails | undefined {
return withPosition(
fileName, position,
() => this.inner.getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences),
() => this.inner.getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data),
() => void 0,
(fixup) => {
const d = this.inner.getCompletionEntryDetails(fileName, fixup.targetStart, entryName, formatOptions, source, preferences);
const d = this.inner.getCompletionEntryDetails(fileName, fixup.targetStart, entryName, formatOptions, source, preferences, data);
if (d !== void 0) {
d.codeActions?.forEach(a =>
a.changes.forEach(c =>

View File

@ -25,9 +25,9 @@
},
"devDependencies": {
"@types/yargs": "^15.0.12",
"typescript": "^4.1.3"
"typescript": "^4.5"
},
"peerDependencies": {
"typescript": "^4.1.3"
"typescript": "^4.5"
}
}