@malloydata/malloy 0.0.3 → 0.0.4
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/dist/lang/ast/ast-expr.d.ts +0 -1
- package/dist/lang/ast/ast-main.d.ts +2 -2
- package/package.json +1 -1
- package/dist/connection_utils.js +0 -56
- package/dist/dialect/dialect.js +0 -77
- package/dist/dialect/dialect_map.js +0 -35
- package/dist/dialect/duckdb.js +0 -347
- package/dist/dialect/index.js +0 -27
- package/dist/dialect/postgres.js +0 -315
- package/dist/dialect/standardsql.js +0 -362
- package/dist/index.js +0 -47
- package/dist/lang/ast/apply-expr.js +0 -231
- package/dist/lang/ast/ast-expr.js +0 -1041
- package/dist/lang/ast/ast-main.js +0 -2087
- package/dist/lang/ast/ast-time-expr.js +0 -549
- package/dist/lang/ast/ast-types.js +0 -215
- package/dist/lang/ast/index.js +0 -34
- package/dist/lang/ast/time-utils.js +0 -94
- package/dist/lang/field-space.js +0 -631
- package/dist/lang/field-utils.js +0 -33
- package/dist/lang/index.js +0 -22
- package/dist/lang/parse-log.js +0 -41
- package/dist/lang/reference-list.js +0 -80
- package/dist/lang/space-field.js +0 -346
- package/dist/lang/test/document-help-context-walker.spec.js +0 -45
- package/dist/lang/test/document-symbol-walker.spec.js +0 -100
- package/dist/lang/test/field-symbols.spec.js +0 -172
- package/dist/lang/test/parse.spec.js +0 -1951
- package/dist/lang/test/test-translator.js +0 -334
- package/dist/lang/zone.js +0 -97
- package/dist/malloy.js +0 -2360
- package/dist/model/index.js +0 -34
- package/dist/model/malloy_query.js +0 -2994
- package/dist/model/malloy_types.js +0 -283
- package/dist/model/sql_block.js +0 -41
- package/dist/model/utils.js +0 -84
- package/dist/runtime_types.js +0 -15
package/dist/lang/parse-log.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.MessageLog = void 0;
|
|
16
|
-
class MessageLog {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.rawLog = [];
|
|
19
|
-
}
|
|
20
|
-
getLog() {
|
|
21
|
-
return this.rawLog;
|
|
22
|
-
}
|
|
23
|
-
log(logMsg) {
|
|
24
|
-
this.rawLog.push(logMsg);
|
|
25
|
-
}
|
|
26
|
-
reset() {
|
|
27
|
-
this.rawLog.length = 0;
|
|
28
|
-
}
|
|
29
|
-
noErrors() {
|
|
30
|
-
return !this.hasErrors();
|
|
31
|
-
}
|
|
32
|
-
hasErrors() {
|
|
33
|
-
const firstError = this.rawLog.find((l) => l.severity !== "warn");
|
|
34
|
-
return firstError !== undefined;
|
|
35
|
-
}
|
|
36
|
-
empty() {
|
|
37
|
-
return this.rawLog.length === 0;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.MessageLog = MessageLog;
|
|
41
|
-
//# sourceMappingURL=parse-log.js.map
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ReferenceList = void 0;
|
|
16
|
-
class ReferenceList {
|
|
17
|
-
constructor(sourceURL) {
|
|
18
|
-
this.sourceURL = sourceURL;
|
|
19
|
-
// These should always be sorted by their end positions
|
|
20
|
-
this.references = [];
|
|
21
|
-
}
|
|
22
|
-
findIndexBefore(position) {
|
|
23
|
-
let low = 0;
|
|
24
|
-
let high = this.references.length;
|
|
25
|
-
while (low < high) {
|
|
26
|
-
const middle = Math.floor((low + high) / 2);
|
|
27
|
-
const compare = this.references[middle].location.range.end;
|
|
28
|
-
if (compare.line < position.line ||
|
|
29
|
-
(compare.line === position.line &&
|
|
30
|
-
compare.character < position.character)) {
|
|
31
|
-
low = middle + 1;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
high = middle;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return low;
|
|
38
|
-
}
|
|
39
|
-
add(reference) {
|
|
40
|
-
// Ignore any reference in another file
|
|
41
|
-
if (reference.location.url !== this.sourceURL) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const insertIndex = this.findIndexBefore(reference.location.range.end);
|
|
45
|
-
// Ignore duplicate references
|
|
46
|
-
if (insertIndex < this.references.length &&
|
|
47
|
-
this.isPositionEqual(reference, this.references[insertIndex])) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.references.splice(insertIndex, 0, reference);
|
|
51
|
-
}
|
|
52
|
-
isPositionEqual(referenceA, referenceB) {
|
|
53
|
-
const rangeA = referenceA.location.range;
|
|
54
|
-
const rangeB = referenceB.location.range;
|
|
55
|
-
return (rangeA.start.line === rangeB.start.line &&
|
|
56
|
-
rangeA.start.character === rangeB.start.character &&
|
|
57
|
-
rangeA.end.line === rangeB.end.line &&
|
|
58
|
-
rangeA.end.character === rangeB.end.character);
|
|
59
|
-
}
|
|
60
|
-
find(position) {
|
|
61
|
-
// Here we assume that references DO NOT overlap. And then we do a binary
|
|
62
|
-
// search to find the one we're looking for.
|
|
63
|
-
const index = this.findIndexBefore(position);
|
|
64
|
-
if (index === this.references.length) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
const reference = this.references[index];
|
|
68
|
-
if (reference.location.range.start.line <= position.line &&
|
|
69
|
-
reference.location.range.end.line >= position.line &&
|
|
70
|
-
(position.line !== reference.location.range.start.line ||
|
|
71
|
-
position.character >= reference.location.range.start.character) &&
|
|
72
|
-
(position.line !== reference.location.range.end.line ||
|
|
73
|
-
position.character <= reference.location.range.end.character)) {
|
|
74
|
-
return reference;
|
|
75
|
-
}
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.ReferenceList = ReferenceList;
|
|
80
|
-
//# sourceMappingURL=reference-list.js.map
|
package/dist/lang/space-field.js
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(o, k2, desc);
|
|
21
|
-
}) : (function(o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
}));
|
|
25
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
-
}) : function(o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.ExpressionFieldFromAst = exports.ReferenceField = exports.FANSPaceField = exports.QueryFieldStruct = exports.QueryFieldAST = exports.QueryField = exports.ColumnSpaceField = exports.JoinSpaceField = exports.StructSpaceField = exports.WildSpaceField = exports.RenameSpaceField = exports.SpaceField = exports.AbstractParameter = exports.DefinedParameter = exports.SpaceParam = exports.SpaceEntry = void 0;
|
|
39
|
-
const model = __importStar(require("../model/malloy_types"));
|
|
40
|
-
const field_space_1 = require("./field-space");
|
|
41
|
-
class SpaceEntry {
|
|
42
|
-
}
|
|
43
|
-
exports.SpaceEntry = SpaceEntry;
|
|
44
|
-
class SpaceParam extends SpaceEntry {
|
|
45
|
-
constructor() {
|
|
46
|
-
super(...arguments);
|
|
47
|
-
this.refType = "parameter";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.SpaceParam = SpaceParam;
|
|
51
|
-
class DefinedParameter extends SpaceParam {
|
|
52
|
-
constructor(paramDef) {
|
|
53
|
-
super();
|
|
54
|
-
this.paramDef = paramDef;
|
|
55
|
-
}
|
|
56
|
-
parameter() {
|
|
57
|
-
return this.paramDef;
|
|
58
|
-
}
|
|
59
|
-
type() {
|
|
60
|
-
return { type: this.paramDef.type };
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.DefinedParameter = DefinedParameter;
|
|
64
|
-
class AbstractParameter extends SpaceParam {
|
|
65
|
-
constructor(astParam) {
|
|
66
|
-
super();
|
|
67
|
-
this.astParam = astParam;
|
|
68
|
-
}
|
|
69
|
-
parameter() {
|
|
70
|
-
return this.astParam.parameter();
|
|
71
|
-
}
|
|
72
|
-
type() {
|
|
73
|
-
const type = this.astParam.type || "unknown";
|
|
74
|
-
return { type };
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.AbstractParameter = AbstractParameter;
|
|
78
|
-
class SpaceField extends SpaceEntry {
|
|
79
|
-
constructor() {
|
|
80
|
-
super(...arguments);
|
|
81
|
-
this.refType = "field";
|
|
82
|
-
}
|
|
83
|
-
fieldTypeFromFieldDef(def) {
|
|
84
|
-
const ref = { type: def.type };
|
|
85
|
-
if (model.isFieldTypeDef(def) && def.aggregate) {
|
|
86
|
-
ref.aggregate = true;
|
|
87
|
-
}
|
|
88
|
-
return ref;
|
|
89
|
-
}
|
|
90
|
-
getQueryFieldDef(_fs) {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
fieldDef() {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.SpaceField = SpaceField;
|
|
98
|
-
class RenameSpaceField extends SpaceField {
|
|
99
|
-
constructor(otherField, newName, location) {
|
|
100
|
-
super();
|
|
101
|
-
this.otherField = otherField;
|
|
102
|
-
this.newName = newName;
|
|
103
|
-
this.location = location;
|
|
104
|
-
}
|
|
105
|
-
fieldDef() {
|
|
106
|
-
const renamedFieldRaw = this.otherField.fieldDef();
|
|
107
|
-
if (renamedFieldRaw === undefined) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
...renamedFieldRaw,
|
|
112
|
-
as: this.newName,
|
|
113
|
-
location: this.location,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
type() {
|
|
117
|
-
return this.otherField.type();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.RenameSpaceField = RenameSpaceField;
|
|
121
|
-
class WildSpaceField extends SpaceField {
|
|
122
|
-
constructor(wildText) {
|
|
123
|
-
super();
|
|
124
|
-
this.wildText = wildText;
|
|
125
|
-
}
|
|
126
|
-
type() {
|
|
127
|
-
throw new Error("should never ask a wild field for its type");
|
|
128
|
-
}
|
|
129
|
-
getQueryFieldDef(_fs) {
|
|
130
|
-
return this.wildText;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.WildSpaceField = WildSpaceField;
|
|
134
|
-
class StructSpaceField extends SpaceField {
|
|
135
|
-
constructor(sourceDef) {
|
|
136
|
-
super();
|
|
137
|
-
this.sourceDef = sourceDef;
|
|
138
|
-
}
|
|
139
|
-
get fieldSpace() {
|
|
140
|
-
if (!this.space) {
|
|
141
|
-
this.space = new field_space_1.StaticSpace(this.sourceDef);
|
|
142
|
-
}
|
|
143
|
-
return this.space;
|
|
144
|
-
}
|
|
145
|
-
fieldDef() {
|
|
146
|
-
return this.sourceDef;
|
|
147
|
-
}
|
|
148
|
-
type() {
|
|
149
|
-
return { type: "struct" };
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.StructSpaceField = StructSpaceField;
|
|
153
|
-
class JoinSpaceField extends StructSpaceField {
|
|
154
|
-
constructor(intoFS, join) {
|
|
155
|
-
super(join.structDef());
|
|
156
|
-
this.intoFS = intoFS;
|
|
157
|
-
this.join = join;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.JoinSpaceField = JoinSpaceField;
|
|
161
|
-
class ColumnSpaceField extends SpaceField {
|
|
162
|
-
constructor(def) {
|
|
163
|
-
super();
|
|
164
|
-
this.def = def;
|
|
165
|
-
}
|
|
166
|
-
fieldDef() {
|
|
167
|
-
return this.def;
|
|
168
|
-
}
|
|
169
|
-
type() {
|
|
170
|
-
return this.fieldTypeFromFieldDef(this.def);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.ColumnSpaceField = ColumnSpaceField;
|
|
174
|
-
class QueryField extends SpaceField {
|
|
175
|
-
constructor(inSpace) {
|
|
176
|
-
super();
|
|
177
|
-
this.inSpace = inSpace;
|
|
178
|
-
}
|
|
179
|
-
type() {
|
|
180
|
-
return { type: "turtle" };
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
exports.QueryField = QueryField;
|
|
184
|
-
class QueryFieldAST extends QueryField {
|
|
185
|
-
constructor(fs, turtle, name) {
|
|
186
|
-
super(fs);
|
|
187
|
-
this.turtle = turtle;
|
|
188
|
-
this.name = name;
|
|
189
|
-
}
|
|
190
|
-
getQueryFieldDef(fs) {
|
|
191
|
-
const def = this.turtle.getFieldDef(fs, this.nestParent);
|
|
192
|
-
if (this.renameAs) {
|
|
193
|
-
def.as = this.renameAs;
|
|
194
|
-
}
|
|
195
|
-
return def;
|
|
196
|
-
}
|
|
197
|
-
fieldDef() {
|
|
198
|
-
const def = this.turtle.getFieldDef(this.inSpace, this.nestParent);
|
|
199
|
-
if (this.renameAs) {
|
|
200
|
-
def.as = this.renameAs;
|
|
201
|
-
}
|
|
202
|
-
return def;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
exports.QueryFieldAST = QueryFieldAST;
|
|
206
|
-
class QueryFieldStruct extends QueryField {
|
|
207
|
-
constructor(fs, turtleDef) {
|
|
208
|
-
super(fs);
|
|
209
|
-
this.turtleDef = turtleDef;
|
|
210
|
-
}
|
|
211
|
-
rename(name) {
|
|
212
|
-
this.turtleDef = {
|
|
213
|
-
...this.turtleDef,
|
|
214
|
-
as: name,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
fieldDef() {
|
|
218
|
-
return this.turtleDef;
|
|
219
|
-
}
|
|
220
|
-
getQueryFieldDef(_fs) {
|
|
221
|
-
return this.fieldDef();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
exports.QueryFieldStruct = QueryFieldStruct;
|
|
225
|
-
/**
|
|
226
|
-
* FilteredAliasedName
|
|
227
|
-
*/
|
|
228
|
-
class FANSPaceField extends SpaceField {
|
|
229
|
-
constructor(ref, inSpace, refInit) {
|
|
230
|
-
super();
|
|
231
|
-
this.ref = ref;
|
|
232
|
-
this.inSpace = inSpace;
|
|
233
|
-
Object.assign(this, refInit);
|
|
234
|
-
}
|
|
235
|
-
name() {
|
|
236
|
-
return this.as || this.ref.refString;
|
|
237
|
-
}
|
|
238
|
-
filtersPresent() {
|
|
239
|
-
return this.filterList && this.filterList.length > 0;
|
|
240
|
-
}
|
|
241
|
-
fieldDef() {
|
|
242
|
-
if (this.as === undefined) {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
const fromField = this.ref.getField(this.inSpace).found;
|
|
246
|
-
if (fromField === undefined) {
|
|
247
|
-
// TODO should errror
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
const fieldTypeInfo = fromField.type();
|
|
251
|
-
const fieldType = fieldTypeInfo.type;
|
|
252
|
-
// TODO starting to feel like this should be a method call on a spaceentry
|
|
253
|
-
if (model.isAtomicFieldType(fieldType)) {
|
|
254
|
-
if (fromField instanceof SpaceParam) {
|
|
255
|
-
return {
|
|
256
|
-
type: fieldType,
|
|
257
|
-
name: this.as,
|
|
258
|
-
e: [{ type: "parameter", path: this.ref.refString }],
|
|
259
|
-
aggregate: false,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
let fieldExpr = [{ type: "field", path: this.ref.refString }];
|
|
263
|
-
if (this.filtersPresent() && this.filterList) {
|
|
264
|
-
const newfieldExpr = [
|
|
265
|
-
{
|
|
266
|
-
type: "filterExpression",
|
|
267
|
-
filterList: this.filterList,
|
|
268
|
-
e: fieldExpr,
|
|
269
|
-
},
|
|
270
|
-
];
|
|
271
|
-
fieldExpr = newfieldExpr;
|
|
272
|
-
}
|
|
273
|
-
return {
|
|
274
|
-
type: fieldType,
|
|
275
|
-
name: this.as,
|
|
276
|
-
e: fieldExpr,
|
|
277
|
-
aggregate: fieldTypeInfo.aggregate,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
return undefined;
|
|
281
|
-
}
|
|
282
|
-
getQueryFieldDef(_fs) {
|
|
283
|
-
// TODO if this reference is to a field which does not exist
|
|
284
|
-
// it needs to be an error SOMEWHERE
|
|
285
|
-
const n = { name: this.ref.refString };
|
|
286
|
-
if (this.filtersPresent()) {
|
|
287
|
-
n.filterList = this.filterList;
|
|
288
|
-
}
|
|
289
|
-
if (this.as) {
|
|
290
|
-
n.as = this.as;
|
|
291
|
-
}
|
|
292
|
-
return n.as || n.filterList ? n : this.ref.refString;
|
|
293
|
-
}
|
|
294
|
-
type() {
|
|
295
|
-
const field = this.ref.getField(this.inSpace).found;
|
|
296
|
-
return (field === null || field === void 0 ? void 0 : field.type()) || { type: "unknown" };
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
exports.FANSPaceField = FANSPaceField;
|
|
300
|
-
class ReferenceField extends SpaceField {
|
|
301
|
-
constructor(fieldRef) {
|
|
302
|
-
super();
|
|
303
|
-
this.fieldRef = fieldRef;
|
|
304
|
-
}
|
|
305
|
-
getQueryFieldDef(fs) {
|
|
306
|
-
// Lookup string and generate error if it isn't defined.
|
|
307
|
-
const check = this.fieldRef.getField(fs);
|
|
308
|
-
if (check.error) {
|
|
309
|
-
this.fieldRef.log(check.error);
|
|
310
|
-
}
|
|
311
|
-
return this.fieldRef.refString;
|
|
312
|
-
}
|
|
313
|
-
type() {
|
|
314
|
-
return { type: "unknown" };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
exports.ReferenceField = ReferenceField;
|
|
318
|
-
class ExpressionFieldFromAst extends SpaceField {
|
|
319
|
-
constructor(space, exprDef) {
|
|
320
|
-
super();
|
|
321
|
-
this.space = space;
|
|
322
|
-
this.exprDef = exprDef;
|
|
323
|
-
this.fieldName = exprDef.defineName;
|
|
324
|
-
}
|
|
325
|
-
get name() {
|
|
326
|
-
return this.fieldName;
|
|
327
|
-
}
|
|
328
|
-
fieldDef() {
|
|
329
|
-
const def = this.exprDef.fieldDef(this.space, this.name);
|
|
330
|
-
this.defType = this.fieldTypeFromFieldDef(def);
|
|
331
|
-
return def;
|
|
332
|
-
}
|
|
333
|
-
getQueryFieldDef(fs) {
|
|
334
|
-
const def = this.exprDef.queryFieldDef(fs, this.name);
|
|
335
|
-
this.defType = this.fieldTypeFromFieldDef(def);
|
|
336
|
-
return def;
|
|
337
|
-
}
|
|
338
|
-
type() {
|
|
339
|
-
if (this.defType) {
|
|
340
|
-
return this.defType;
|
|
341
|
-
}
|
|
342
|
-
return this.fieldTypeFromFieldDef(this.fieldDef());
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
exports.ExpressionFieldFromAst = ExpressionFieldFromAst;
|
|
346
|
-
//# sourceMappingURL=space-field.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const test_translator_1 = require("./test-translator");
|
|
16
|
-
function testHelpContext(source, position, type, token) {
|
|
17
|
-
const doc = new test_translator_1.TestTranslator(source.code);
|
|
18
|
-
expect(doc.logger.hasErrors()).toBeFalsy();
|
|
19
|
-
const helpContext = doc.helpContext(position).helpContext;
|
|
20
|
-
expect(helpContext).toEqual({ type, token });
|
|
21
|
-
}
|
|
22
|
-
const source = `source: foo is table('bar') {
|
|
23
|
-
where: bazz ~ 'biff'
|
|
24
|
-
query: foo is {
|
|
25
|
-
group_by: bazz
|
|
26
|
-
where: bop ~ 'blat'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
query: bar {
|
|
31
|
-
group_by: bazz
|
|
32
|
-
}`;
|
|
33
|
-
test("Supports model properties", () => {
|
|
34
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 0, character: 1 }, "model_property", "source:");
|
|
35
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 8, character: 1 }, "model_property", "query:");
|
|
36
|
-
});
|
|
37
|
-
test("Supports explore properties", () => {
|
|
38
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 1, character: 3 }, "explore_property", "where:");
|
|
39
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 2, character: 3 }, "explore_property", "query:");
|
|
40
|
-
});
|
|
41
|
-
test("Supports query properties", () => {
|
|
42
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 3, character: 5 }, "query_property", "group_by:");
|
|
43
|
-
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 4, character: 5 }, "query_property", "where:");
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=document-help-context-walker.spec.js.map
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const test_translator_1 = require("./test-translator");
|
|
16
|
-
class MalloyExplore extends test_translator_1.TestTranslator {
|
|
17
|
-
constructor(src) {
|
|
18
|
-
super(src);
|
|
19
|
-
}
|
|
20
|
-
get symbols() {
|
|
21
|
-
const md = this.metadata();
|
|
22
|
-
return md.symbols || [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function testSymbol(source, name, type, path) {
|
|
26
|
-
const doc = new MalloyExplore(source.code);
|
|
27
|
-
let current = { children: doc.symbols };
|
|
28
|
-
path.forEach((segment) => {
|
|
29
|
-
current = current.children[segment];
|
|
30
|
-
});
|
|
31
|
-
expect(doc.logger.hasErrors()).toBeFalsy();
|
|
32
|
-
expect(current).toMatchObject({
|
|
33
|
-
name,
|
|
34
|
-
range: source.locations[0].range,
|
|
35
|
-
type,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
test("explore symbols are included", () => {
|
|
39
|
-
testSymbol((0, test_translator_1.markSource) `explore: ${"flights is table('my.table.flights')"}`, "flights", "explore", [0]);
|
|
40
|
-
});
|
|
41
|
-
test("query symbols are included", () => {
|
|
42
|
-
testSymbol((0, test_translator_1.markSource) `query: ${"flights_by_carrier is flights -> by_carrier"}`, "flights_by_carrier", "query", [0]);
|
|
43
|
-
});
|
|
44
|
-
test("expression field defs are included", () => {
|
|
45
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
46
|
-
explore: flights is table('my.table.flights') {
|
|
47
|
-
dimension: ${"one is 1"}
|
|
48
|
-
}
|
|
49
|
-
`, "one", "field", [0, 0]);
|
|
50
|
-
});
|
|
51
|
-
test("renamed fields are included", () => {
|
|
52
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
53
|
-
explore: flights is table('my.table.flights') {
|
|
54
|
-
rename: ${"field_two is field_2"}
|
|
55
|
-
}
|
|
56
|
-
`, "field_two", "field", [0, 0]);
|
|
57
|
-
});
|
|
58
|
-
test("name only fields are included", () => {
|
|
59
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
60
|
-
explore: flights is table('my.table.flights') {
|
|
61
|
-
dimension: ${"field_two is field_2"}
|
|
62
|
-
}
|
|
63
|
-
`, "field_two", "field", [0, 0]);
|
|
64
|
-
});
|
|
65
|
-
test("turtle fields are included", () => {
|
|
66
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
67
|
-
explore: flights is table('my.table.flights') {
|
|
68
|
-
query: ${"my_turtle is { group_by: a }"}
|
|
69
|
-
}
|
|
70
|
-
`, "my_turtle", "query", [0, 0]);
|
|
71
|
-
});
|
|
72
|
-
test("turtle children fields are included", () => {
|
|
73
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
74
|
-
explore: flights is table('my.table.flights') {
|
|
75
|
-
query: my_turtle is { group_by: ${"a"} }
|
|
76
|
-
}
|
|
77
|
-
`, "a", "field", [0, 0, 0]);
|
|
78
|
-
});
|
|
79
|
-
test("turtle children turtles are included", () => {
|
|
80
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
81
|
-
explore: flights is table('my.table.flights') {
|
|
82
|
-
query: my_turtle is { nest: ${"inner_turtle is { group_by: a }"} }
|
|
83
|
-
}
|
|
84
|
-
`, "inner_turtle", "query", [0, 0, 0]);
|
|
85
|
-
});
|
|
86
|
-
test("join withs are included", () => {
|
|
87
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
88
|
-
explore: flights is table('my.table.flights') {
|
|
89
|
-
join_one: ${"a is b with c"}
|
|
90
|
-
}
|
|
91
|
-
`, "a", "join", [0, 0]);
|
|
92
|
-
});
|
|
93
|
-
test("join ons are included", () => {
|
|
94
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
95
|
-
explore: flights is table('my.table.flights') {
|
|
96
|
-
join_one: ${"a is b on c"}
|
|
97
|
-
}
|
|
98
|
-
`, "a", "join", [0, 0]);
|
|
99
|
-
});
|
|
100
|
-
//# sourceMappingURL=document-symbol-walker.spec.js.map
|