@valtzu/codemirror-lang-el 0.10.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/CONFIGURATION.md +108 -0
- package/README.md +4 -2
- package/dist/index.cjs +18 -3
- package/dist/index.d.cts +39 -17
- package/dist/index.d.ts +39 -17
- package/dist/index.js +18 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
package/CONFIGURATION.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
|
|
2
|
+
## Enum
|
|
3
|
+
|
|
4
|
+
- [ELScalar](#elscalar)
|
|
5
|
+
|
|
6
|
+
### ELScalar
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
| Property | Type | Description |
|
|
11
|
+
| ---------- | ---------- | ---------- |
|
|
12
|
+
| `Bool` | `'bool'` | Equivalent to PHP `bool` |
|
|
13
|
+
| `Number` | `'number'` | Equivalent to PHP `int` or `float` |
|
|
14
|
+
| `String` | `'string'` | Equivalent to PHP `string` |
|
|
15
|
+
| `Null` | `'null'` | Equivalent to PHP `null` |
|
|
16
|
+
| `Any` | `'any'` | Equivalent to PHP `mixed` |
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Interfaces
|
|
20
|
+
|
|
21
|
+
- [ExpressionLanguageConfig](#expressionlanguageconfig)
|
|
22
|
+
- [ELType](#eltype)
|
|
23
|
+
- [ELIdentifier](#elidentifier)
|
|
24
|
+
- [ELFunction](#elfunction)
|
|
25
|
+
- [ELParameter](#elparameter)
|
|
26
|
+
- [ELKeyword](#elkeyword)
|
|
27
|
+
|
|
28
|
+
### ExpressionLanguageConfig
|
|
29
|
+
|
|
30
|
+
The configuration object that is passed to `expressionlanguage` function
|
|
31
|
+
|
|
32
|
+
| Property | Type | Description |
|
|
33
|
+
| ---------- | ---------- | ---------- |
|
|
34
|
+
| `types` | `{ [key: string]: ELType; } or undefined` | Type definitions used in `identifiers` and `functions` |
|
|
35
|
+
| `identifiers` | `ELIdentifier[] or undefined` | Top-level variables |
|
|
36
|
+
| `functions` | `ELFunction[] or undefined` | Top-level functions |
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### ELType
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
| Property | Type | Description |
|
|
44
|
+
| ---------- | ---------- | ---------- |
|
|
45
|
+
| `identifiers` | `ELIdentifier[] or undefined` | Properties of the object |
|
|
46
|
+
| `functions` | `ELFunction[] or undefined` | Methods of the object |
|
|
47
|
+
| `info` | `string or undefined` | |
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### ELIdentifier
|
|
51
|
+
|
|
52
|
+
Represents a variable or a property of an object
|
|
53
|
+
|
|
54
|
+
| Property | Type | Description |
|
|
55
|
+
| ---------- | ---------- | ---------- |
|
|
56
|
+
| `name` | `string` | |
|
|
57
|
+
| `detail` | `string or undefined` | If set, this is shown instead of `type` |
|
|
58
|
+
| `info` | `string or undefined` | Text to show in hover tooltip, autocomplete etc. |
|
|
59
|
+
| `type` | `string[] or undefined` | All possible types for this identifier |
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### ELFunction
|
|
63
|
+
|
|
64
|
+
Represents a function or a method of an object
|
|
65
|
+
|
|
66
|
+
| Property | Type | Description |
|
|
67
|
+
| ---------- | ---------- | ---------- |
|
|
68
|
+
| `name` | `string` | |
|
|
69
|
+
| `args` | `ELParameter[] or undefined` | |
|
|
70
|
+
| `info` | `string or undefined` | |
|
|
71
|
+
| `returnType` | `string[] or undefined` | |
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### ELParameter
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
| Property | Type | Description |
|
|
79
|
+
| ---------- | ---------- | ---------- |
|
|
80
|
+
| `name` | `string` | |
|
|
81
|
+
| `type` | `string[] or undefined` | |
|
|
82
|
+
| `info` | `string or undefined` | |
|
|
83
|
+
| `optional` | `boolean or undefined` | |
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### ELKeyword
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
| Property | Type | Description |
|
|
91
|
+
| ---------- | ---------- | ---------- |
|
|
92
|
+
| `name` | `string` | |
|
|
93
|
+
| `detail` | `string or undefined` | |
|
|
94
|
+
| `info` | `string or undefined` | |
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## Types
|
|
98
|
+
|
|
99
|
+
- [ELTypeName](#eltypename)
|
|
100
|
+
|
|
101
|
+
### ELTypeName
|
|
102
|
+
|
|
103
|
+
One of predefined types (`ELScalar`) or a custom type from `ExpressionLanguageConfig.types`
|
|
104
|
+
|
|
105
|
+
| Type | Type |
|
|
106
|
+
| ---------- | ---------- |
|
|
107
|
+
| `ELTypeName` | `ELScalar or string` |
|
|
108
|
+
|
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
## Symfony Expression Language support for CodeMirror 6
|
|
2
2
|
|
|
3
|
-
> :warning: **This is unstable**: Expect breaking changes until v1 is out.
|
|
4
|
-
|
|
5
3
|
### Features
|
|
6
4
|
|
|
7
5
|
#### Linting
|
|
@@ -58,6 +56,10 @@ yarn add @valtzu/codemirror-lang-el
|
|
|
58
56
|
|
|
59
57
|
---
|
|
60
58
|
|
|
59
|
+
### Configuration
|
|
60
|
+
|
|
61
|
+
See [CONFIGURATION.md](CONFIGURATION.md)
|
|
62
|
+
|
|
61
63
|
### Example
|
|
62
64
|
|
|
63
65
|
[Live demo](https://jsfiddle.net/turse2xq/)
|
package/dist/index.cjs
CHANGED
|
@@ -35,12 +35,18 @@ const parser = lr.LRParser.deserialize({
|
|
|
35
35
|
tokenPrec: 532
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
// generate CONFIGURATION.md from this file by running "tsdoc --src=src/types.ts --dest=CONFIGURATION.md --noemoji --types"
|
|
38
39
|
exports.ELScalar = void 0;
|
|
39
40
|
(function (ELScalar) {
|
|
41
|
+
/** Equivalent to PHP `bool` */
|
|
40
42
|
ELScalar["Bool"] = "bool";
|
|
43
|
+
/** Equivalent to PHP `int` or `float` */
|
|
41
44
|
ELScalar["Number"] = "number";
|
|
45
|
+
/** Equivalent to PHP `string` */
|
|
42
46
|
ELScalar["String"] = "string";
|
|
47
|
+
/** Equivalent to PHP `null` */
|
|
43
48
|
ELScalar["Null"] = "null";
|
|
49
|
+
/** Equivalent to PHP `mixed` */
|
|
44
50
|
ELScalar["Any"] = "any";
|
|
45
51
|
})(exports.ELScalar || (exports.ELScalar = {}));
|
|
46
52
|
|
|
@@ -70,6 +76,11 @@ const createInfoElement = (html) => {
|
|
|
70
76
|
dom.className = 'cm-diagnostic';
|
|
71
77
|
return dom;
|
|
72
78
|
};
|
|
79
|
+
const createCompletionInfoElement = (html) => {
|
|
80
|
+
const dom = document.createElement("div");
|
|
81
|
+
dom.innerHTML = html;
|
|
82
|
+
return dom;
|
|
83
|
+
};
|
|
73
84
|
function resolveFunctionDefinition(node, state, config) {
|
|
74
85
|
var _a;
|
|
75
86
|
if (!node) {
|
|
@@ -192,6 +203,7 @@ const keywords = [
|
|
|
192
203
|
|
|
193
204
|
var utils = /*#__PURE__*/Object.freeze({
|
|
194
205
|
__proto__: null,
|
|
206
|
+
createCompletionInfoElement: createCompletionInfoElement,
|
|
195
207
|
createInfoElement: createInfoElement,
|
|
196
208
|
getExpressionLanguageConfig: getExpressionLanguageConfig,
|
|
197
209
|
keywords: keywords,
|
|
@@ -301,7 +313,7 @@ const autocompleteFunction = (x) => {
|
|
|
301
313
|
view.dispatch(Object.assign(Object.assign({}, autocomplete.insertCompletionText(view.state, `${x.name}()`, from, to)), { selection: { anchor: from + x.name.length + (((_b = (_a = x.args) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? 1 : 2) } }));
|
|
302
314
|
},
|
|
303
315
|
detail: (_c = x.returnType) === null || _c === void 0 ? void 0 : _c.join('|'),
|
|
304
|
-
info: x.info,
|
|
316
|
+
info: () => ({ dom: createCompletionInfoElement(x.info) }),
|
|
305
317
|
type: "function",
|
|
306
318
|
});
|
|
307
319
|
};
|
|
@@ -310,7 +322,7 @@ const autocompleteIdentifier = (x) => {
|
|
|
310
322
|
return ({
|
|
311
323
|
label: x.name,
|
|
312
324
|
apply: x.name,
|
|
313
|
-
info: x.info,
|
|
325
|
+
info: () => ({ dom: createCompletionInfoElement(x.info) }),
|
|
314
326
|
detail: x.detail || ((_a = x.type) === null || _a === void 0 ? void 0 : _a.join('|')),
|
|
315
327
|
type: 'variable',
|
|
316
328
|
});
|
|
@@ -323,7 +335,7 @@ function completeOperatorKeyword(state, config, tree, from, to, explicit) {
|
|
|
323
335
|
options: (_a = keywords.map(({ name, info, detail }) => ({
|
|
324
336
|
label: name,
|
|
325
337
|
apply: `${name} `,
|
|
326
|
-
info: info,
|
|
338
|
+
info: () => ({ dom: createCompletionInfoElement(info) }),
|
|
327
339
|
detail,
|
|
328
340
|
type: "keyword"
|
|
329
341
|
}))) !== null && _a !== void 0 ? _a : [],
|
|
@@ -536,6 +548,9 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
536
548
|
fontSize: ".8em",
|
|
537
549
|
fontStyle: "monospace",
|
|
538
550
|
backgroundColor: "rgba(127, 127, 127, .3)",
|
|
551
|
+
display: 'inline-block',
|
|
552
|
+
padding: '2px 4px',
|
|
553
|
+
borderRadius: '3px',
|
|
539
554
|
},
|
|
540
555
|
});
|
|
541
556
|
|
package/dist/index.d.cts
CHANGED
|
@@ -5,14 +5,37 @@ import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
|
|
5
5
|
import { SyntaxNode } from '@lezer/common';
|
|
6
6
|
import { Tooltip } from '@codemirror/view';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The configuration object that is passed to `expressionlanguage` function
|
|
10
|
+
*/
|
|
11
|
+
interface ExpressionLanguageConfig {
|
|
12
|
+
/** Type definitions used in `identifiers` & `functions` */
|
|
13
|
+
types?: {
|
|
14
|
+
[key: string]: ELType;
|
|
15
|
+
};
|
|
16
|
+
/** Top-level variables */
|
|
17
|
+
identifiers?: ELIdentifier[];
|
|
18
|
+
/** Top-level functions */
|
|
19
|
+
functions?: ELFunction[];
|
|
20
|
+
}
|
|
21
|
+
interface ELType {
|
|
22
|
+
/** Properties of the object */
|
|
23
|
+
identifiers?: ELIdentifier[];
|
|
24
|
+
/** Methods of the object */
|
|
25
|
+
functions?: ELFunction[];
|
|
26
|
+
info?: string;
|
|
27
|
+
}
|
|
8
28
|
/**
|
|
9
29
|
* Represents a variable or a property of an object
|
|
10
30
|
*/
|
|
11
31
|
interface ELIdentifier {
|
|
12
32
|
name: string;
|
|
33
|
+
/** If set, this is shown instead of `type` */
|
|
13
34
|
detail?: string;
|
|
35
|
+
/** Text to show in hover tooltip, autocomplete etc. */
|
|
14
36
|
info?: string;
|
|
15
|
-
|
|
37
|
+
/** All possible types for this identifier */
|
|
38
|
+
type?: ELTypeName[];
|
|
16
39
|
}
|
|
17
40
|
/**
|
|
18
41
|
* Represents a function or a method of an object
|
|
@@ -21,38 +44,35 @@ interface ELFunction {
|
|
|
21
44
|
name: string;
|
|
22
45
|
args?: ELParameter[];
|
|
23
46
|
info?: string;
|
|
24
|
-
returnType?:
|
|
47
|
+
returnType?: ELTypeName[];
|
|
25
48
|
}
|
|
26
49
|
interface ELParameter {
|
|
27
50
|
name: string;
|
|
28
|
-
type?:
|
|
51
|
+
type?: ELTypeName[];
|
|
29
52
|
info?: string;
|
|
30
53
|
optional?: boolean;
|
|
31
54
|
}
|
|
32
|
-
interface ELType {
|
|
33
|
-
identifiers?: ELIdentifier[];
|
|
34
|
-
functions?: ELFunction[];
|
|
35
|
-
info?: string;
|
|
36
|
-
}
|
|
37
|
-
interface ExpressionLanguageConfig {
|
|
38
|
-
types?: {
|
|
39
|
-
[key: string]: ELType;
|
|
40
|
-
};
|
|
41
|
-
identifiers?: ELIdentifier[];
|
|
42
|
-
functions?: ELFunction[];
|
|
43
|
-
}
|
|
44
55
|
interface ELKeyword {
|
|
45
56
|
name: string;
|
|
46
57
|
detail?: string;
|
|
47
58
|
info?: string;
|
|
48
59
|
}
|
|
49
60
|
declare enum ELScalar {
|
|
61
|
+
/** Equivalent to PHP `bool` */
|
|
50
62
|
Bool = "bool",
|
|
63
|
+
/** Equivalent to PHP `int` or `float` */
|
|
51
64
|
Number = "number",
|
|
65
|
+
/** Equivalent to PHP `string` */
|
|
52
66
|
String = "string",
|
|
67
|
+
/** Equivalent to PHP `null` */
|
|
53
68
|
Null = "null",
|
|
69
|
+
/** Equivalent to PHP `mixed` */
|
|
54
70
|
Any = "any"
|
|
55
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* One of predefined types (`ELScalar`) or a custom type from `ExpressionLanguageConfig.types`
|
|
74
|
+
*/
|
|
75
|
+
type ELTypeName = ELScalar | string;
|
|
56
76
|
|
|
57
77
|
declare function expressionLanguageCompletion(context: CompletionContext): CompletionResult | null;
|
|
58
78
|
|
|
@@ -74,6 +94,7 @@ declare const Property: number;
|
|
|
74
94
|
declare const Variable: number;
|
|
75
95
|
|
|
76
96
|
declare const createInfoElement: (html: string) => HTMLDivElement;
|
|
97
|
+
declare const createCompletionInfoElement: (html: string) => HTMLDivElement;
|
|
77
98
|
declare function resolveFunctionDefinition(node: SyntaxNode | null, state: EditorState, config: ExpressionLanguageConfig): ELFunction | undefined;
|
|
78
99
|
declare const resolveIdentifier: (nodeTypeId: typeof Method | typeof Property | typeof Function | typeof Variable, identifier?: string, config?: {
|
|
79
100
|
identifiers?: ELIdentifier[];
|
|
@@ -83,6 +104,7 @@ declare function resolveTypes(state: EditorState, node: SyntaxNode | undefined |
|
|
|
83
104
|
declare function getExpressionLanguageConfig(state: EditorState): ExpressionLanguageConfig;
|
|
84
105
|
declare const keywords: ELKeyword[];
|
|
85
106
|
|
|
107
|
+
declare const utils_d_createCompletionInfoElement: typeof createCompletionInfoElement;
|
|
86
108
|
declare const utils_d_createInfoElement: typeof createInfoElement;
|
|
87
109
|
declare const utils_d_getExpressionLanguageConfig: typeof getExpressionLanguageConfig;
|
|
88
110
|
declare const utils_d_keywords: typeof keywords;
|
|
@@ -90,7 +112,7 @@ declare const utils_d_resolveFunctionDefinition: typeof resolveFunctionDefinitio
|
|
|
90
112
|
declare const utils_d_resolveIdentifier: typeof resolveIdentifier;
|
|
91
113
|
declare const utils_d_resolveTypes: typeof resolveTypes;
|
|
92
114
|
declare namespace utils_d {
|
|
93
|
-
export { utils_d_createInfoElement as createInfoElement, utils_d_getExpressionLanguageConfig as getExpressionLanguageConfig, utils_d_keywords as keywords, utils_d_resolveFunctionDefinition as resolveFunctionDefinition, utils_d_resolveIdentifier as resolveIdentifier, utils_d_resolveTypes as resolveTypes };
|
|
115
|
+
export { utils_d_createCompletionInfoElement as createCompletionInfoElement, utils_d_createInfoElement as createInfoElement, utils_d_getExpressionLanguageConfig as getExpressionLanguageConfig, utils_d_keywords as keywords, utils_d_resolveFunctionDefinition as resolveFunctionDefinition, utils_d_resolveIdentifier as resolveIdentifier, utils_d_resolveTypes as resolveTypes };
|
|
94
116
|
}
|
|
95
117
|
|
|
96
118
|
declare const cursorTooltipField: StateField<readonly Tooltip[]>;
|
|
@@ -107,4 +129,4 @@ declare namespace tooltip_d {
|
|
|
107
129
|
declare const ELLanguage: LRLanguage;
|
|
108
130
|
declare function expressionlanguage(config?: ExpressionLanguageConfig, extensions?: Extension[]): LanguageSupport;
|
|
109
131
|
|
|
110
|
-
export { type ELFunction, type ELIdentifier, type ELKeyword, ELLanguage, type ELParameter, ELScalar, type ELType, type ExpressionLanguageConfig, complete_d as _complete, linter_d as _linter, tooltip_d as _tooltip, utils_d as _utils, expressionlanguage };
|
|
132
|
+
export { type ELFunction, type ELIdentifier, type ELKeyword, ELLanguage, type ELParameter, ELScalar, type ELType, type ELTypeName, type ExpressionLanguageConfig, complete_d as _complete, linter_d as _linter, tooltip_d as _tooltip, utils_d as _utils, expressionlanguage };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,37 @@ import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
|
|
5
5
|
import { SyntaxNode } from '@lezer/common';
|
|
6
6
|
import { Tooltip } from '@codemirror/view';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The configuration object that is passed to `expressionlanguage` function
|
|
10
|
+
*/
|
|
11
|
+
interface ExpressionLanguageConfig {
|
|
12
|
+
/** Type definitions used in `identifiers` & `functions` */
|
|
13
|
+
types?: {
|
|
14
|
+
[key: string]: ELType;
|
|
15
|
+
};
|
|
16
|
+
/** Top-level variables */
|
|
17
|
+
identifiers?: ELIdentifier[];
|
|
18
|
+
/** Top-level functions */
|
|
19
|
+
functions?: ELFunction[];
|
|
20
|
+
}
|
|
21
|
+
interface ELType {
|
|
22
|
+
/** Properties of the object */
|
|
23
|
+
identifiers?: ELIdentifier[];
|
|
24
|
+
/** Methods of the object */
|
|
25
|
+
functions?: ELFunction[];
|
|
26
|
+
info?: string;
|
|
27
|
+
}
|
|
8
28
|
/**
|
|
9
29
|
* Represents a variable or a property of an object
|
|
10
30
|
*/
|
|
11
31
|
interface ELIdentifier {
|
|
12
32
|
name: string;
|
|
33
|
+
/** If set, this is shown instead of `type` */
|
|
13
34
|
detail?: string;
|
|
35
|
+
/** Text to show in hover tooltip, autocomplete etc. */
|
|
14
36
|
info?: string;
|
|
15
|
-
|
|
37
|
+
/** All possible types for this identifier */
|
|
38
|
+
type?: ELTypeName[];
|
|
16
39
|
}
|
|
17
40
|
/**
|
|
18
41
|
* Represents a function or a method of an object
|
|
@@ -21,38 +44,35 @@ interface ELFunction {
|
|
|
21
44
|
name: string;
|
|
22
45
|
args?: ELParameter[];
|
|
23
46
|
info?: string;
|
|
24
|
-
returnType?:
|
|
47
|
+
returnType?: ELTypeName[];
|
|
25
48
|
}
|
|
26
49
|
interface ELParameter {
|
|
27
50
|
name: string;
|
|
28
|
-
type?:
|
|
51
|
+
type?: ELTypeName[];
|
|
29
52
|
info?: string;
|
|
30
53
|
optional?: boolean;
|
|
31
54
|
}
|
|
32
|
-
interface ELType {
|
|
33
|
-
identifiers?: ELIdentifier[];
|
|
34
|
-
functions?: ELFunction[];
|
|
35
|
-
info?: string;
|
|
36
|
-
}
|
|
37
|
-
interface ExpressionLanguageConfig {
|
|
38
|
-
types?: {
|
|
39
|
-
[key: string]: ELType;
|
|
40
|
-
};
|
|
41
|
-
identifiers?: ELIdentifier[];
|
|
42
|
-
functions?: ELFunction[];
|
|
43
|
-
}
|
|
44
55
|
interface ELKeyword {
|
|
45
56
|
name: string;
|
|
46
57
|
detail?: string;
|
|
47
58
|
info?: string;
|
|
48
59
|
}
|
|
49
60
|
declare enum ELScalar {
|
|
61
|
+
/** Equivalent to PHP `bool` */
|
|
50
62
|
Bool = "bool",
|
|
63
|
+
/** Equivalent to PHP `int` or `float` */
|
|
51
64
|
Number = "number",
|
|
65
|
+
/** Equivalent to PHP `string` */
|
|
52
66
|
String = "string",
|
|
67
|
+
/** Equivalent to PHP `null` */
|
|
53
68
|
Null = "null",
|
|
69
|
+
/** Equivalent to PHP `mixed` */
|
|
54
70
|
Any = "any"
|
|
55
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* One of predefined types (`ELScalar`) or a custom type from `ExpressionLanguageConfig.types`
|
|
74
|
+
*/
|
|
75
|
+
type ELTypeName = ELScalar | string;
|
|
56
76
|
|
|
57
77
|
declare function expressionLanguageCompletion(context: CompletionContext): CompletionResult | null;
|
|
58
78
|
|
|
@@ -74,6 +94,7 @@ declare const Property: number;
|
|
|
74
94
|
declare const Variable: number;
|
|
75
95
|
|
|
76
96
|
declare const createInfoElement: (html: string) => HTMLDivElement;
|
|
97
|
+
declare const createCompletionInfoElement: (html: string) => HTMLDivElement;
|
|
77
98
|
declare function resolveFunctionDefinition(node: SyntaxNode | null, state: EditorState, config: ExpressionLanguageConfig): ELFunction | undefined;
|
|
78
99
|
declare const resolveIdentifier: (nodeTypeId: typeof Method | typeof Property | typeof Function | typeof Variable, identifier?: string, config?: {
|
|
79
100
|
identifiers?: ELIdentifier[];
|
|
@@ -83,6 +104,7 @@ declare function resolveTypes(state: EditorState, node: SyntaxNode | undefined |
|
|
|
83
104
|
declare function getExpressionLanguageConfig(state: EditorState): ExpressionLanguageConfig;
|
|
84
105
|
declare const keywords: ELKeyword[];
|
|
85
106
|
|
|
107
|
+
declare const utils_d_createCompletionInfoElement: typeof createCompletionInfoElement;
|
|
86
108
|
declare const utils_d_createInfoElement: typeof createInfoElement;
|
|
87
109
|
declare const utils_d_getExpressionLanguageConfig: typeof getExpressionLanguageConfig;
|
|
88
110
|
declare const utils_d_keywords: typeof keywords;
|
|
@@ -90,7 +112,7 @@ declare const utils_d_resolveFunctionDefinition: typeof resolveFunctionDefinitio
|
|
|
90
112
|
declare const utils_d_resolveIdentifier: typeof resolveIdentifier;
|
|
91
113
|
declare const utils_d_resolveTypes: typeof resolveTypes;
|
|
92
114
|
declare namespace utils_d {
|
|
93
|
-
export { utils_d_createInfoElement as createInfoElement, utils_d_getExpressionLanguageConfig as getExpressionLanguageConfig, utils_d_keywords as keywords, utils_d_resolveFunctionDefinition as resolveFunctionDefinition, utils_d_resolveIdentifier as resolveIdentifier, utils_d_resolveTypes as resolveTypes };
|
|
115
|
+
export { utils_d_createCompletionInfoElement as createCompletionInfoElement, utils_d_createInfoElement as createInfoElement, utils_d_getExpressionLanguageConfig as getExpressionLanguageConfig, utils_d_keywords as keywords, utils_d_resolveFunctionDefinition as resolveFunctionDefinition, utils_d_resolveIdentifier as resolveIdentifier, utils_d_resolveTypes as resolveTypes };
|
|
94
116
|
}
|
|
95
117
|
|
|
96
118
|
declare const cursorTooltipField: StateField<readonly Tooltip[]>;
|
|
@@ -107,4 +129,4 @@ declare namespace tooltip_d {
|
|
|
107
129
|
declare const ELLanguage: LRLanguage;
|
|
108
130
|
declare function expressionlanguage(config?: ExpressionLanguageConfig, extensions?: Extension[]): LanguageSupport;
|
|
109
131
|
|
|
110
|
-
export { type ELFunction, type ELIdentifier, type ELKeyword, ELLanguage, type ELParameter, ELScalar, type ELType, type ExpressionLanguageConfig, complete_d as _complete, linter_d as _linter, tooltip_d as _tooltip, utils_d as _utils, expressionlanguage };
|
|
132
|
+
export { type ELFunction, type ELIdentifier, type ELKeyword, ELLanguage, type ELParameter, ELScalar, type ELType, type ELTypeName, type ExpressionLanguageConfig, complete_d as _complete, linter_d as _linter, tooltip_d as _tooltip, utils_d as _utils, expressionlanguage };
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,17 @@ const parser = /*@__PURE__*/LRParser.deserialize({
|
|
|
33
33
|
tokenPrec: 532
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
// generate CONFIGURATION.md from this file by running "tsdoc --src=src/types.ts --dest=CONFIGURATION.md --noemoji --types"
|
|
36
37
|
var ELScalar = /*@__PURE__*/(function (ELScalar) {
|
|
38
|
+
/** Equivalent to PHP `bool` */
|
|
37
39
|
ELScalar["Bool"] = "bool";
|
|
40
|
+
/** Equivalent to PHP `int` or `float` */
|
|
38
41
|
ELScalar["Number"] = "number";
|
|
42
|
+
/** Equivalent to PHP `string` */
|
|
39
43
|
ELScalar["String"] = "string";
|
|
44
|
+
/** Equivalent to PHP `null` */
|
|
40
45
|
ELScalar["Null"] = "null";
|
|
46
|
+
/** Equivalent to PHP `mixed` */
|
|
41
47
|
ELScalar["Any"] = "any";
|
|
42
48
|
return ELScalar})(ELScalar || (ELScalar = {}));
|
|
43
49
|
|
|
@@ -67,6 +73,11 @@ const createInfoElement = (html) => {
|
|
|
67
73
|
dom.className = 'cm-diagnostic';
|
|
68
74
|
return dom;
|
|
69
75
|
};
|
|
76
|
+
const createCompletionInfoElement = (html) => {
|
|
77
|
+
const dom = document.createElement("div");
|
|
78
|
+
dom.innerHTML = html;
|
|
79
|
+
return dom;
|
|
80
|
+
};
|
|
70
81
|
function resolveFunctionDefinition(node, state, config) {
|
|
71
82
|
var _a;
|
|
72
83
|
if (!node) {
|
|
@@ -189,6 +200,7 @@ const keywords = [
|
|
|
189
200
|
|
|
190
201
|
var utils = /*#__PURE__*//*@__PURE__*/Object.freeze({
|
|
191
202
|
__proto__: null,
|
|
203
|
+
createCompletionInfoElement: createCompletionInfoElement,
|
|
192
204
|
createInfoElement: createInfoElement,
|
|
193
205
|
getExpressionLanguageConfig: getExpressionLanguageConfig,
|
|
194
206
|
keywords: keywords,
|
|
@@ -298,7 +310,7 @@ const autocompleteFunction = (x) => {
|
|
|
298
310
|
view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, `${x.name}()`, from, to)), { selection: { anchor: from + x.name.length + (((_b = (_a = x.args) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? 1 : 2) } }));
|
|
299
311
|
},
|
|
300
312
|
detail: (_c = x.returnType) === null || _c === void 0 ? void 0 : _c.join('|'),
|
|
301
|
-
info: x.info,
|
|
313
|
+
info: () => ({ dom: createCompletionInfoElement(x.info) }),
|
|
302
314
|
type: "function",
|
|
303
315
|
});
|
|
304
316
|
};
|
|
@@ -307,7 +319,7 @@ const autocompleteIdentifier = (x) => {
|
|
|
307
319
|
return ({
|
|
308
320
|
label: x.name,
|
|
309
321
|
apply: x.name,
|
|
310
|
-
info: x.info,
|
|
322
|
+
info: () => ({ dom: createCompletionInfoElement(x.info) }),
|
|
311
323
|
detail: x.detail || ((_a = x.type) === null || _a === void 0 ? void 0 : _a.join('|')),
|
|
312
324
|
type: 'variable',
|
|
313
325
|
});
|
|
@@ -320,7 +332,7 @@ function completeOperatorKeyword(state, config, tree, from, to, explicit) {
|
|
|
320
332
|
options: (_a = keywords.map(({ name, info, detail }) => ({
|
|
321
333
|
label: name,
|
|
322
334
|
apply: `${name} `,
|
|
323
|
-
info: info,
|
|
335
|
+
info: () => ({ dom: createCompletionInfoElement(info) }),
|
|
324
336
|
detail,
|
|
325
337
|
type: "keyword"
|
|
326
338
|
}))) !== null && _a !== void 0 ? _a : [],
|
|
@@ -533,6 +545,9 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
533
545
|
fontSize: ".8em",
|
|
534
546
|
fontStyle: "monospace",
|
|
535
547
|
backgroundColor: "rgba(127, 127, 127, .3)",
|
|
548
|
+
display: 'inline-block',
|
|
549
|
+
padding: '2px 4px',
|
|
550
|
+
borderRadius: '3px',
|
|
536
551
|
},
|
|
537
552
|
});
|
|
538
553
|
|
package/package.json
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@codemirror/buildhelper": "^1.0.0",
|
|
29
29
|
"@types/mocha": "^10.0.10",
|
|
30
|
-
"@types/node": "^22.10.5"
|
|
30
|
+
"@types/node": "^22.10.5",
|
|
31
|
+
"tsdoc-markdown": "^1.1.1"
|
|
31
32
|
},
|
|
32
33
|
"license": "MIT",
|
|
33
34
|
"repository": {
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"access": "public",
|
|
39
40
|
"registry": "https://registry.npmjs.org/"
|
|
40
41
|
},
|
|
41
|
-
"version": "0.
|
|
42
|
+
"version": "1.0.0"
|
|
42
43
|
}
|