@malloydata/malloy 0.0.109-dev231201181643 → 0.0.109-dev231201200035

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.
@@ -48,6 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.walkForDocumentSymbols = void 0;
49
49
  const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
50
50
  const parser = __importStar(require("../lib/Malloy/MalloyParser"));
51
+ const parse_utils_1 = require("../parse-utils");
51
52
  class DocumentSymbolWalker {
52
53
  constructor(translator, tokens, scopes, symbols) {
53
54
  this.translator = translator;
@@ -233,12 +234,43 @@ class DocumentSymbolWalker {
233
234
  const name = pcx.nameSQLBlock().text;
234
235
  const symbol = {
235
236
  range: this.translator.rangeFromContext(pcx),
236
- name: name,
237
+ name,
237
238
  type: 'sql',
238
239
  children: [],
239
240
  };
240
241
  this.symbols.push(symbol);
241
242
  }
243
+ enterImportStatement(pcx) {
244
+ const name = (0, parse_utils_1.getStringIfShort)(pcx.importURL());
245
+ if (name) {
246
+ this.scopes.push({
247
+ range: this.translator.rangeFromContext(pcx),
248
+ name,
249
+ type: 'import',
250
+ children: [],
251
+ });
252
+ }
253
+ }
254
+ exitImportStatement() {
255
+ const scope = this.popScope();
256
+ if (scope) {
257
+ this.symbols.push(scope);
258
+ }
259
+ }
260
+ enterImportSelect(pcx) {
261
+ const parent = this.peekScope();
262
+ if (parent) {
263
+ for (const item of pcx.importItem()) {
264
+ const symbol = {
265
+ range: this.translator.rangeFromContext(pcx),
266
+ name: item.text,
267
+ type: 'import_item',
268
+ children: [],
269
+ };
270
+ parent.children.push(symbol);
271
+ }
272
+ }
273
+ }
242
274
  }
243
275
  function walkForDocumentSymbols(forParse, tokens, parseTree) {
244
276
  const finder = new DocumentSymbolWalker(forParse, tokens, [], []);
package/dist/malloy.d.ts CHANGED
@@ -227,6 +227,12 @@ export declare class Model implements Taggable {
227
227
  * @return An array of `Explore`s contained in the model.
228
228
  */
229
229
  get explores(): Explore[];
230
+ /**
231
+ * Get an array of `NamedQuery`s contained in the model.
232
+ *
233
+ * @return An array of `NamedQuery`s contained in the model.
234
+ */
235
+ get namedQueries(): NamedQuery[];
230
236
  get exportedExplores(): Explore[];
231
237
  get _modelDef(): ModelDef;
232
238
  }
package/dist/malloy.js CHANGED
@@ -467,14 +467,19 @@ class Model {
467
467
  * @return An array of `Explore`s contained in the model.
468
468
  */
469
469
  get explores() {
470
- const explores = [];
471
- for (const me in this.modelDef.contents) {
472
- const ent = this.modelDef.contents[me];
473
- if (ent.type === 'struct') {
474
- explores.push(new Explore(ent));
475
- }
476
- }
477
- return explores;
470
+ const isStructDef = (object) => object.type === 'struct';
471
+ return Object.values(this.modelDef.contents)
472
+ .filter(isStructDef)
473
+ .map(structDef => new Explore(structDef));
474
+ }
475
+ /**
476
+ * Get an array of `NamedQuery`s contained in the model.
477
+ *
478
+ * @return An array of `NamedQuery`s contained in the model.
479
+ */
480
+ get namedQueries() {
481
+ const isNamedQuery = (object) => object.type === 'query';
482
+ return Object.values(this.modelDef.contents).filter(isNamedQuery);
478
483
  }
479
484
  get exportedExplores() {
480
485
  return this.explores.filter(explore => this.modelDef.exports.includes(explore.name));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.109-dev231201181643",
3
+ "version": "0.0.109-dev231201200035",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",