@malloydata/malloy 0.0.240-dev250311202829 → 0.0.240-dev250311213218

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.
@@ -0,0 +1,660 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.malloyToQuery = exports.MalloyToQuery = void 0;
33
+ const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisitor");
34
+ const parse = __importStar(require("./lib/Malloy/MalloyParser"));
35
+ const parse_log_1 = require("./parse-log");
36
+ const parse_utils_1 = require("./parse-utils");
37
+ const malloy_types_1 = require("../model/malloy_types");
38
+ const run_malloy_parser_1 = require("./run-malloy-parser");
39
+ const core_1 = require("../api/core");
40
+ const utils_1 = require("./utils");
41
+ const MLQs = 'Malloy query documents';
42
+ /**
43
+ * ANTLR visitor pattern parse tree traversal. Generates a Malloy
44
+ * AST from an ANTLR parse tree.
45
+ */
46
+ class MalloyToQuery extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
47
+ constructor(parseInfo, msgLog) {
48
+ super();
49
+ this.parseInfo = parseInfo;
50
+ this.msgLog = msgLog;
51
+ }
52
+ /**
53
+ * Mostly used to flag a case where the grammar and the type system are
54
+ * no longer in sync. A visitor was written based on a grammar which
55
+ * apparently has changed and now an unexpected element type has appeared.
56
+ * This is a non recoverable error, since the parser and the grammar
57
+ * are not compatible.
58
+ * @return an error object to throw.
59
+ */
60
+ internalError(cx, message) {
61
+ this.contextError(cx, 'internal-translator-error', { message });
62
+ return new Error(`Internal Translator Error: ${message}`);
63
+ }
64
+ getLocation(cx) {
65
+ return {
66
+ url: this.parseInfo.sourceURL,
67
+ range: (0, utils_1.rangeFromContext)(this.parseInfo.sourceInfo, cx),
68
+ };
69
+ }
70
+ /**
71
+ * Log an error message relative to a parse node
72
+ */
73
+ contextError(cx, code, data, options) {
74
+ this.msgLog.log((0, parse_log_1.makeLogMessage)(code, data, {
75
+ at: this.getLocation(cx),
76
+ ...options,
77
+ }));
78
+ }
79
+ getNumber(term) {
80
+ return Number.parseInt(term.text);
81
+ }
82
+ defaultResult() {
83
+ return null;
84
+ }
85
+ /**
86
+ * Get all the possibly missing annotations from this parse rule
87
+ * @param cx Any parse context which has an ANNOTATION* rules
88
+ * @returns Array of texts for the annotations
89
+ */
90
+ getAnnotations(cx) {
91
+ const annotations = cx.ANNOTATION().map(a => {
92
+ return { value: a.text };
93
+ });
94
+ return annotations.length > 0 ? annotations : undefined;
95
+ }
96
+ getIsAnnotations(cx) {
97
+ var _a, _b;
98
+ if (cx === undefined)
99
+ return undefined;
100
+ const before = (_a = this.getAnnotations(cx._beforeIs)) !== null && _a !== void 0 ? _a : [];
101
+ const annotations = before.concat((_b = this.getAnnotations(cx._afterIs)) !== null && _b !== void 0 ? _b : []);
102
+ return annotations.length > 0 ? annotations : undefined;
103
+ }
104
+ notAllowed(pcx, what) {
105
+ this.illegal(pcx, `${what} are not allowed in ${MLQs}`);
106
+ }
107
+ illegal(pcx, what) {
108
+ this.contextError(pcx, 'invalid-malloy-query-document', what);
109
+ }
110
+ visitMalloyDocument(pcx) {
111
+ const statements = pcx.malloyStatement();
112
+ let runStatement = undefined;
113
+ for (const statement of statements) {
114
+ if (statement.defineSourceStatement()) {
115
+ this.notAllowed(statement, 'Source definitions');
116
+ }
117
+ else if (statement.defineQuery()) {
118
+ this.notAllowed(statement, 'Query definitions');
119
+ }
120
+ else if (statement.importStatement()) {
121
+ this.notAllowed(statement, 'Import statements');
122
+ }
123
+ else if (statement.docAnnotations()) {
124
+ this.notAllowed(statement, 'Model annotations');
125
+ }
126
+ else if (statement.ignoredObjectAnnotations()) {
127
+ this.notAllowed(statement, 'Detatched object annotations');
128
+ }
129
+ else if (statement.experimentalStatementForTesting()) {
130
+ this.notAllowed(statement, 'Experimental testing statements');
131
+ }
132
+ else {
133
+ if (runStatement === undefined) {
134
+ runStatement = statement.runStatement();
135
+ }
136
+ else {
137
+ this.illegal(statement, `${MLQs} may only have one run statement`);
138
+ }
139
+ }
140
+ }
141
+ if (runStatement === undefined) {
142
+ this.illegal(pcx, `${MLQs} must have a run statement`);
143
+ return null;
144
+ }
145
+ return this.visitRunStatement(runStatement);
146
+ }
147
+ visitRunStatement(pcx) {
148
+ const defCx = pcx.topLevelAnonQueryDef();
149
+ const definition = this.getQueryDefinition(defCx.sqExpr());
150
+ const annotations = this.getAnnotations(pcx.topLevelAnonQueryDef().tags());
151
+ if (definition !== null) {
152
+ return {
153
+ annotations,
154
+ definition,
155
+ };
156
+ }
157
+ return null;
158
+ }
159
+ getQueryReference(cx) {
160
+ if (cx.sourceArguments()) {
161
+ this.illegal(cx, 'Queries do not support parameters');
162
+ }
163
+ else {
164
+ return {
165
+ name: (0, parse_utils_1.getId)(cx),
166
+ };
167
+ }
168
+ return null;
169
+ }
170
+ getQueryDefinition(cx) {
171
+ if (cx instanceof parse.SQIDContext) {
172
+ const ref = this.getQueryReference(cx);
173
+ if (ref !== null) {
174
+ return {
175
+ kind: 'query_reference',
176
+ ...ref,
177
+ };
178
+ }
179
+ }
180
+ else if (cx instanceof parse.SQParensContext) {
181
+ return this.getQueryDefinition(cx.sqExpr());
182
+ }
183
+ else if (cx instanceof parse.SQComposeContext) {
184
+ this.notAllowed(cx, 'Source compositions');
185
+ }
186
+ else if (cx instanceof parse.SQRefinedQueryContext) {
187
+ const qrefCx = cx.sqExpr();
188
+ const base = this.getQueryDefinition(qrefCx);
189
+ const seg = this.getRefinementSegment(cx.segExpr());
190
+ if (seg === null || base === null)
191
+ return null;
192
+ if (seg.kind === 'arrow') {
193
+ this.notAllowed(cx, 'Queries against refined queries');
194
+ }
195
+ return {
196
+ kind: 'refinement',
197
+ base: base,
198
+ refinement: seg,
199
+ };
200
+ }
201
+ else if (cx instanceof parse.SQExtendedSourceContext) {
202
+ this.notAllowed(cx, 'Source extensions');
203
+ }
204
+ else if (cx instanceof parse.SQIncludeContext) {
205
+ this.notAllowed(cx, 'Source inclusions');
206
+ }
207
+ else if (cx instanceof parse.SQTableContext) {
208
+ this.notAllowed(cx, 'Table statements');
209
+ }
210
+ else if (cx instanceof parse.SQSQLContext) {
211
+ this.notAllowed(cx, 'SQL statements');
212
+ }
213
+ else if (cx instanceof parse.SQArrowContext) {
214
+ const qrefCx = cx.sqExpr();
215
+ const base = this.getQueryDefinition(qrefCx);
216
+ const seg = this.getRefinementSegment(cx.segExpr());
217
+ if (seg === null || base === null)
218
+ return null;
219
+ if (base.kind === 'query_reference') {
220
+ return {
221
+ kind: 'arrow',
222
+ source: {
223
+ ...base,
224
+ kind: 'source_reference',
225
+ },
226
+ view: seg,
227
+ };
228
+ }
229
+ if (base.kind === 'arrow') {
230
+ return {
231
+ kind: 'arrow',
232
+ source: base.source,
233
+ view: {
234
+ kind: 'arrow',
235
+ source: base.view,
236
+ view: seg,
237
+ },
238
+ };
239
+ }
240
+ return {
241
+ kind: 'arrow',
242
+ source: base,
243
+ view: seg,
244
+ };
245
+ }
246
+ return null;
247
+ }
248
+ getRefinementSegment(cx) {
249
+ if (cx instanceof parse.SegOpsContext) {
250
+ const operations = cx
251
+ .queryProperties()
252
+ .queryStatement()
253
+ .flatMap(stmt => this.getSegmentOperation(stmt));
254
+ if (operations.some(o => o === null)) {
255
+ return null;
256
+ }
257
+ return {
258
+ kind: 'segment',
259
+ operations: operations,
260
+ };
261
+ }
262
+ else if (cx instanceof parse.SegFieldContext) {
263
+ const { name, path } = this.getFieldPath(cx.fieldPath());
264
+ return {
265
+ kind: 'view_reference',
266
+ name,
267
+ path,
268
+ };
269
+ }
270
+ else if (cx instanceof parse.SegParenContext) {
271
+ return this.getViewExpression(cx.vExpr());
272
+ }
273
+ else if (cx instanceof parse.SegRefineContext) {
274
+ const l = this.getRefinementSegment(cx._lhs);
275
+ const r = this.getRefinementSegment(cx._rhs);
276
+ if (l === null || r === null)
277
+ return null;
278
+ return {
279
+ kind: 'refinement',
280
+ base: l,
281
+ refinement: r,
282
+ };
283
+ }
284
+ return null;
285
+ }
286
+ getGroupByStatement(gbcx) {
287
+ const groupAnnotations = this.getAnnotations(gbcx.tags());
288
+ const fieldCxs = gbcx.queryFieldList().queryFieldEntry();
289
+ const fields = fieldCxs.map(f => this.getQueryField(f));
290
+ if (fields.some(o => o === null)) {
291
+ return null;
292
+ }
293
+ if (fields === null)
294
+ return null;
295
+ return fields.map(f => {
296
+ var _a;
297
+ const annotations = [
298
+ ...(groupAnnotations !== null && groupAnnotations !== void 0 ? groupAnnotations : []),
299
+ ...((_a = f.field.annotations) !== null && _a !== void 0 ? _a : []),
300
+ ];
301
+ const gb = {
302
+ kind: 'group_by',
303
+ name: f.name,
304
+ field: {
305
+ ...f.field,
306
+ annotations: annotations.length > 0 ? annotations : undefined,
307
+ },
308
+ };
309
+ return gb;
310
+ });
311
+ }
312
+ getAggregateStatement(agcx) {
313
+ const groupAnnotations = this.getAnnotations(agcx.tags());
314
+ const fieldCxs = agcx.queryFieldList().queryFieldEntry();
315
+ const fields = fieldCxs.map(f => this.getQueryField(f));
316
+ if (fields.some(o => o === null)) {
317
+ return null;
318
+ }
319
+ if (fields === null)
320
+ return null;
321
+ return fields.map(f => {
322
+ var _a;
323
+ const annotations = [
324
+ ...(groupAnnotations !== null && groupAnnotations !== void 0 ? groupAnnotations : []),
325
+ ...((_a = f.field.annotations) !== null && _a !== void 0 ? _a : []),
326
+ ];
327
+ const gb = {
328
+ kind: 'aggregate',
329
+ name: f.name,
330
+ field: {
331
+ ...f.field,
332
+ annotations: annotations.length > 0 ? annotations : undefined,
333
+ },
334
+ };
335
+ return gb;
336
+ });
337
+ }
338
+ getOrderByStatement(obcx) {
339
+ const specs = obcx.ordering().orderBySpec();
340
+ const orders = [];
341
+ for (const spec of specs) {
342
+ if (spec.INTEGER_LITERAL()) {
343
+ this.notAllowed(spec, 'Indexed order by statements');
344
+ }
345
+ else if (spec.fieldName()) {
346
+ const fieldName = (0, parse_utils_1.getId)(spec.fieldName());
347
+ const direction = spec.ASC() ? 'asc' : spec.DESC() ? 'desc' : undefined;
348
+ orders.push({
349
+ kind: 'order_by',
350
+ direction,
351
+ field_reference: { name: fieldName },
352
+ });
353
+ }
354
+ else {
355
+ return null;
356
+ }
357
+ }
358
+ return orders;
359
+ }
360
+ getNestStatement(nstcx) {
361
+ const groupAnnotations = this.getAnnotations(nstcx.tags());
362
+ const querylist = nstcx.nestedQueryList().nestEntry();
363
+ const nests = [];
364
+ for (const query of querylist) {
365
+ if (!(query instanceof parse.NestDefContext)) {
366
+ this.internalError(query, 'Expected nestDef');
367
+ return null;
368
+ }
369
+ const annotations1 = this.getAnnotations(query.tags());
370
+ const annotations2 = this.getIsAnnotations(query.isDefine());
371
+ const nameCx = query.queryName();
372
+ const name = nameCx ? (0, parse_utils_1.getId)(nameCx) : undefined;
373
+ const view = this.getViewExpression(query.vExpr());
374
+ if (view === null) {
375
+ return null;
376
+ }
377
+ nests.push({
378
+ kind: 'nest',
379
+ name,
380
+ view: {
381
+ definition: view,
382
+ annotations: this.combineAnnotations(groupAnnotations, annotations1, annotations2),
383
+ },
384
+ });
385
+ }
386
+ return nests;
387
+ }
388
+ getViewExpression(cx) {
389
+ if (cx instanceof parse.VSegContext) {
390
+ return this.getRefinementSegment(cx.segExpr());
391
+ }
392
+ else if (cx instanceof parse.VArrowContext) {
393
+ const l = this.getRefinementSegment(cx);
394
+ const r = this.getViewExpression(cx._rhs);
395
+ if (l === null)
396
+ return null;
397
+ if (r === null)
398
+ return null;
399
+ return {
400
+ kind: 'arrow',
401
+ source: l,
402
+ view: r,
403
+ };
404
+ }
405
+ else {
406
+ this.internalError(cx, 'Unexpected VExpr node');
407
+ return null;
408
+ }
409
+ }
410
+ getLimitStatement(cx) {
411
+ const limit = this.getNumber(cx.INTEGER_LITERAL());
412
+ return {
413
+ kind: 'limit',
414
+ limit,
415
+ };
416
+ }
417
+ getSegmentOperation(cx) {
418
+ if (cx.groupByStatement()) {
419
+ const gbcx = cx.groupByStatement();
420
+ return this.getGroupByStatement(gbcx);
421
+ }
422
+ else if (cx.aggregateStatement()) {
423
+ const agcx = cx.aggregateStatement();
424
+ return this.getAggregateStatement(agcx);
425
+ }
426
+ else if (cx.limitStatement()) {
427
+ const limcx = cx.limitStatement();
428
+ const limit = this.getLimitStatement(limcx);
429
+ if (limit === null)
430
+ return null;
431
+ return [limit];
432
+ }
433
+ else if (cx.declareStatement()) {
434
+ this.notAllowed(cx, 'Declare statements');
435
+ }
436
+ else if (cx.queryJoinStatement()) {
437
+ this.notAllowed(cx, 'Query join statements');
438
+ }
439
+ else if (cx.queryExtend()) {
440
+ this.notAllowed(cx, 'Query extend statements');
441
+ }
442
+ else if (cx.projectStatement()) {
443
+ this.notAllowed(cx, 'Select statements');
444
+ }
445
+ else if (cx.indexStatement()) {
446
+ this.notAllowed(cx, 'Index statements');
447
+ }
448
+ else if (cx.calculateStatement()) {
449
+ this.notAllowed(cx, 'Calculate statements');
450
+ }
451
+ else if (cx.topStatement()) {
452
+ this.notAllowed(cx, 'Top statements');
453
+ }
454
+ else if (cx.orderByStatement()) {
455
+ const obcx = cx.orderByStatement();
456
+ return this.getOrderByStatement(obcx);
457
+ }
458
+ else if (cx.whereStatement()) {
459
+ const whcx = cx.whereStatement();
460
+ const where = this.getWhere(whcx);
461
+ if (where === null)
462
+ return null;
463
+ return where.map(w => ({
464
+ kind: 'where',
465
+ ...w,
466
+ }));
467
+ }
468
+ else if (cx.havingStatement()) {
469
+ this.notAllowed(cx, 'Having statements');
470
+ }
471
+ else if (cx.nestStatement()) {
472
+ const obcx = cx.nestStatement();
473
+ return this.getNestStatement(obcx);
474
+ }
475
+ else if (cx.sampleStatement()) {
476
+ this.notAllowed(cx, 'Sample statements');
477
+ }
478
+ else if (cx.timezoneStatement()) {
479
+ this.notAllowed(cx, 'Timezone statements');
480
+ }
481
+ else if (cx.queryAnnotation() || cx.ignoredModelAnnotations()) {
482
+ this.notAllowed(cx, 'Detached annotation statements');
483
+ }
484
+ return null;
485
+ }
486
+ getFieldPath(pcx) {
487
+ const names = pcx.fieldName().map(nameCx => (0, parse_utils_1.getId)(nameCx));
488
+ const name = names[0];
489
+ const path = names.slice(1);
490
+ return { name, path: path.length > 0 ? path : undefined };
491
+ }
492
+ getTimeframe(cx) {
493
+ const text = cx.text;
494
+ if ((0, malloy_types_1.isTimestampUnit)(text)) {
495
+ return text;
496
+ }
497
+ this.illegal(cx, `Invalid timeframe ${text}`);
498
+ return null;
499
+ }
500
+ getQueryField(cx) {
501
+ if (cx.taggedRef()) {
502
+ const trcx = cx.taggedRef();
503
+ const annotations = this.getAnnotations(trcx.tags());
504
+ const { name, path } = this.getFieldPath(trcx.fieldPath());
505
+ if (trcx.refExpr()) {
506
+ const refexpr = trcx.refExpr();
507
+ if (refexpr.timeframe()) {
508
+ const tf = this.getTimeframe(refexpr.timeframe());
509
+ if (tf === null)
510
+ return null;
511
+ return {
512
+ name: undefined,
513
+ field: {
514
+ annotations,
515
+ expression: {
516
+ kind: 'time_truncation',
517
+ field_reference: {
518
+ name,
519
+ path,
520
+ },
521
+ truncation: tf,
522
+ },
523
+ },
524
+ };
525
+ }
526
+ else if (refexpr.aggregate()) {
527
+ this.notAllowed(refexpr, 'Aggregate expressions');
528
+ }
529
+ }
530
+ else {
531
+ return {
532
+ name: undefined,
533
+ field: {
534
+ annotations,
535
+ expression: {
536
+ kind: 'field_reference',
537
+ name,
538
+ path,
539
+ },
540
+ },
541
+ };
542
+ }
543
+ }
544
+ else if (cx.fieldDef()) {
545
+ const defCx = cx.fieldDef();
546
+ const annotations1 = this.getAnnotations(defCx.tags());
547
+ const annotations2 = this.getIsAnnotations(defCx.isDefine());
548
+ const name = (0, parse_utils_1.getId)(defCx.fieldNameDef());
549
+ const expression = this.getFieldExpression(defCx.fieldExpr());
550
+ if (expression === null) {
551
+ return null;
552
+ }
553
+ return {
554
+ name,
555
+ field: {
556
+ expression,
557
+ annotations: this.combineAnnotations(annotations1, annotations2),
558
+ },
559
+ };
560
+ }
561
+ return null;
562
+ }
563
+ getFieldExpression(cx) {
564
+ if (cx instanceof parse.ExprFieldPathContext) {
565
+ const { name, path } = this.getFieldPath(cx.fieldPath());
566
+ return {
567
+ kind: 'field_reference',
568
+ name,
569
+ path,
570
+ };
571
+ }
572
+ else if (cx instanceof parse.ExprTimeTruncContext) {
573
+ const timeframe = this.getTimeframe(cx.timeframe());
574
+ const exprCx = cx.fieldExpr();
575
+ const expr = this.getFieldExpression(exprCx);
576
+ if (expr === null) {
577
+ return null;
578
+ }
579
+ if (timeframe === null) {
580
+ return null;
581
+ }
582
+ if (expr.kind !== 'field_reference') {
583
+ this.illegal(exprCx, 'Left hand side of time truncation must be a field reference');
584
+ return null;
585
+ }
586
+ return {
587
+ kind: 'time_truncation',
588
+ truncation: timeframe,
589
+ field_reference: {
590
+ name: expr.name,
591
+ path: expr.path,
592
+ parameters: expr.parameters,
593
+ },
594
+ };
595
+ }
596
+ else if (cx instanceof parse.ExprFieldPropsContext) {
597
+ const exprCx = cx.fieldExpr();
598
+ const expr = this.getFieldExpression(exprCx);
599
+ if (expr === null) {
600
+ return null;
601
+ }
602
+ if (expr.kind !== 'field_reference') {
603
+ this.illegal(exprCx, 'Left hand side of filtered field must be a field reference');
604
+ return null;
605
+ }
606
+ const props = cx.fieldProperties().fieldPropertyStatement();
607
+ const where = [];
608
+ for (const prop of props) {
609
+ const whereCx = prop.whereStatement();
610
+ if (whereCx) {
611
+ const it = this.getWhere(whereCx);
612
+ if (it === null)
613
+ return null;
614
+ where.push(...it);
615
+ }
616
+ }
617
+ return {
618
+ kind: 'filtered_field',
619
+ field_reference: {
620
+ name: expr.name,
621
+ path: expr.path,
622
+ parameters: expr.parameters,
623
+ },
624
+ where,
625
+ };
626
+ }
627
+ return null;
628
+ }
629
+ getWhere(_whereCx) {
630
+ // const exprs = whereCx.filterClauseList().fieldExpr();
631
+ // TODO get filter expr...
632
+ return null;
633
+ }
634
+ combineAnnotations(...a) {
635
+ const annotations = a.flatMap(a => a !== null && a !== void 0 ? a : []);
636
+ return annotations.length > 0 ? annotations : undefined;
637
+ }
638
+ }
639
+ exports.MalloyToQuery = MalloyToQuery;
640
+ function malloyToQuery(code) {
641
+ const sourceInfo = (0, utils_1.getSourceInfo)(code);
642
+ const logger = new parse_log_1.BaseMessageLogger(null);
643
+ const url = 'internal://query.malloy';
644
+ const parse = (0, run_malloy_parser_1.runMalloyParser)(code, url, sourceInfo, logger);
645
+ const secondPass = new MalloyToQuery(parse, logger);
646
+ const query = secondPass.visit(parse.root);
647
+ const logs = (0, core_1.mapLogs)(logger.getLog(), url);
648
+ if (query === null) {
649
+ return { logs };
650
+ }
651
+ if (!('definition' in query)) {
652
+ throw new Error('Expected a query');
653
+ }
654
+ return {
655
+ query: query,
656
+ logs,
657
+ };
658
+ }
659
+ exports.malloyToQuery = malloyToQuery;
660
+ //# sourceMappingURL=malloy-to-stable-query.js.map
@@ -362,6 +362,7 @@ type MessageParameterTypes = {
362
362
  'unsupported-path-in-include': string;
363
363
  'wildcard-include-rename': string;
364
364
  'literal-string-newline': string;
365
+ 'invalid-malloy-query-document': string;
365
366
  };
366
367
  export declare const MESSAGE_FORMATTERS: PartialErrorCodeMessageMap;
367
368
  export type MessageCode = keyof MessageParameterTypes;
@@ -1,5 +1,4 @@
1
- import { ParserRuleContext, Token } from 'antlr4ts';
2
- import { DocumentLocation, DocumentPosition, DocumentRange, DocumentReference, ImportLocation, ModelDef, NamedModelObject, SourceDef, SQLSourceDef, DependencyTree } from '../model/malloy_types';
1
+ import { DocumentLocation, DocumentPosition, DocumentReference, ImportLocation, ModelDef, NamedModelObject, SourceDef, SQLSourceDef, DependencyTree, DocumentRange } from '../model/malloy_types';
3
2
  import { BaseMessageLogger, LogMessage, LogMessageOptions, MessageCode, MessageParameterType } from './parse-log';
4
3
  import { Zone, ZoneData } from './zone';
5
4
  import { ReferenceList } from './reference-list';
@@ -7,6 +6,7 @@ import { ASTResponse, CompletionsResponse, DataRequestResponse, ProblemResponse,
7
6
  import { Tag } from '@malloydata/malloy-tag';
8
7
  import { MalloyParseInfo } from './malloy-parse-info';
9
8
  import { EventStream } from '../runtime_types';
9
+ import { ParserRuleContext } from 'antlr4ts';
10
10
  export type StepResponses = DataRequestResponse | ASTResponse | TranslateResponse | ParseResponse | MetadataResponse | PretranslatedResponse;
11
11
  /**
12
12
  * A Translation is a series of translation steps. Each step can depend
@@ -46,11 +46,6 @@ declare class ParseStep implements TranslationStep {
46
46
  response?: ParseResponse;
47
47
  sourceInfo?: SourceInfo;
48
48
  step(that: MalloyTranslation): ParseResponse;
49
- /**
50
- * Split the source up into lines so we can correctly compute offset
51
- * to the line/char positions favored by LSP and VSCode.
52
- */
53
- private getSourceInfo;
54
49
  private runParser;
55
50
  }
56
51
  declare class ImportsAndTablesStep implements TranslationStep {
@@ -173,8 +168,6 @@ export declare abstract class MalloyTranslation {
173
168
  }): HelpContextResponse;
174
169
  defaultLocation(): DocumentLocation;
175
170
  rangeFromContext(pcx: ParserRuleContext): DocumentRange;
176
- rangeFromTokens(startToken: Token, stopToken: Token): DocumentRange;
177
- rangeFromToken(token: Token): DocumentRange;
178
171
  private dialectAlreadyChecked;
179
172
  firstReferenceToDialect(dialect: string): boolean;
180
173
  allDialectsEnabled: boolean;