aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/xtext/XtextClient.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-11-16 03:00:45 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-11-16 03:11:00 +0100
commit5810a7eb3b19ef9868db170c9214686bfc613eee (patch)
treeda122997d4ad58f4104d0f84b06a00fe14e7ad02 /language-web/src/main/js/xtext/XtextClient.ts
parentfeat(lang): basic formatting (diff)
downloadrefinery-5810a7eb3b19ef9868db170c9214686bfc613eee.tar.gz
refinery-5810a7eb3b19ef9868db170c9214686bfc613eee.tar.zst
refinery-5810a7eb3b19ef9868db170c9214686bfc613eee.zip
chore(web): json validation with zod
Use the zod library instead of manually written type assertions for validating json messages from the server. This makes it easier to add and handle new messages.
Diffstat (limited to 'language-web/src/main/js/xtext/XtextClient.ts')
-rw-r--r--language-web/src/main/js/xtext/XtextClient.ts7
1 files changed, 2 insertions, 5 deletions
diff --git a/language-web/src/main/js/xtext/XtextClient.ts b/language-web/src/main/js/xtext/XtextClient.ts
index 28f3d0cc..3922b230 100644
--- a/language-web/src/main/js/xtext/XtextClient.ts
+++ b/language-web/src/main/js/xtext/XtextClient.ts
@@ -12,6 +12,7 @@ import { UpdateService } from './UpdateService';
12import { getLogger } from '../utils/logger'; 12import { getLogger } from '../utils/logger';
13import { ValidationService } from './ValidationService'; 13import { ValidationService } from './ValidationService';
14import { XtextWebSocketClient } from './XtextWebSocketClient'; 14import { XtextWebSocketClient } from './XtextWebSocketClient';
15import { XtextWebPushService } from './xtextMessages';
15 16
16const log = getLogger('xtext.XtextClient'); 17const log = getLogger('xtext.XtextClient');
17 18
@@ -52,7 +53,7 @@ export class XtextClient {
52 this.occurrencesService.onTransaction(transaction); 53 this.occurrencesService.onTransaction(transaction);
53 } 54 }
54 55
55 private onPush(resource: string, stateId: string, service: string, push: unknown) { 56 private onPush(resource: string, stateId: string, service: XtextWebPushService, push: unknown) {
56 const { resourceName, xtextStateId } = this.updateService; 57 const { resourceName, xtextStateId } = this.updateService;
57 if (resource !== resourceName) { 58 if (resource !== resourceName) {
58 log.error('Unknown resource name: expected:', resourceName, 'got:', resource); 59 log.error('Unknown resource name: expected:', resourceName, 'got:', resource);
@@ -70,10 +71,6 @@ export class XtextClient {
70 return; 71 return;
71 case 'validate': 72 case 'validate':
72 this.validationService.onPush(push); 73 this.validationService.onPush(push);
73 return;
74 default:
75 log.error('Unknown push service:', service);
76 break;
77 } 74 }
78 } 75 }
79 76