-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentScanner.ts
83 lines (75 loc) · 2.35 KB
/
documentScanner.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { type VirtualCode } from "@volar/language-core";
import type * as ts from 'typescript';
//This file is responsible for creating the virtual code for the SuperOffice language plugin.
//It takes care of all the logic for embedded languages and the main language itself.
//Constants for the script tags
// const _SCRIPT_START = '%EJSCRIPT_START%';
// const _SCRIPT_END = '%EJSCRIPT_END%';
// const _SCRIPT_INCLUDE_START = '<%';
// const _SCRIPT_INCLUDE_END = '%>';
export function createSuperOfficeCode(snapshot: ts.IScriptSnapshot): VirtualCode {
//const addCode = `import * as RTL from "@superoffice/webapi"; \n`;
//const newText = addCode + text;
return {
id: 'root',
languageId: 'typescript',
snapshot,
mappings: [{
sourceOffsets: [0],
generatedOffsets: [0],
lengths: [snapshot.getLength()],
data: {
completion: true,
format: true,
navigation: true,
semantic: true,
structure: true,
verification: true,
},
}],
embeddedCodes: []
};
}
// const newText = blankOutNonScriptContent(text);
// //TODO: create logic for the embedded languages. Also extract this logic into its own file..
// return {
// id: 'root',
// languageId: 'crmscript',
// snapshot: {
// getText: (start, end) => newText.substring(start, end),
// getLength: () => newText.length,
// getChangeRange: () => undefined,
// },
// mappings: [{
// sourceOffsets: [0],
// generatedOffsets: [newText.length],
// lengths: [newText.length],
// data: {
// completion: true,
// format: true,
// navigation: true,
// semantic: true,
// structure: true,
// verification: true,
// },
// }],
// embeddedCodes: []
// };
//}
// function blankOutNonScriptContent(text: string): string {
// let result = '';
// let start = 0;
// let end = text.indexOf(_SCRIPT_INCLUDE_START);
// while (end !== -1) {
// result += ' '.repeat(end - start);
// start = text.indexOf(_SCRIPT_INCLUDE_END, end);
// if (start === -1) {
// break;
// }
// start += _SCRIPT_INCLUDE_END.length;
// result += ' '.repeat(_SCRIPT_INCLUDE_START.length) + text.substring(end + _SCRIPT_INCLUDE_START.length, start - _SCRIPT_INCLUDE_END.length) + ' '.repeat(_SCRIPT_INCLUDE_END.length);
// end = text.indexOf(_SCRIPT_INCLUDE_START, start);
// }
// result += ' '.repeat(text.length - start);
// return result;
// }