@malloydata/malloy 0.0.99-dev231102173733 → 0.0.99-dev231102201226

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.
@@ -50,7 +50,10 @@ class ModelAnnotation extends ObjectAnnotation {
50
50
  return tagParse.tag;
51
51
  }
52
52
  execute(doc) {
53
- doc.notes = doc.notes.concat(this.notes);
53
+ if (doc.annotation.notes === undefined) {
54
+ doc.annotation.notes = [];
55
+ }
56
+ doc.annotation.notes.push(...this.notes);
54
57
  }
55
58
  }
56
59
  exports.ModelAnnotation = ModelAnnotation;
@@ -1,4 +1,4 @@
1
- import { Annotation, DocumentLocation, DocumentReference, ModelDef, ModelAnnotation, NamedModelObject, Note, Query, SQLBlockStructDef, StructDef } from '../../../model/malloy_types';
1
+ import { Annotation, DocumentLocation, DocumentReference, ModelDef, ModelAnnotation, NamedModelObject, Query, SQLBlockStructDef, StructDef } from '../../../model/malloy_types';
2
2
  import { Tag } from '../../../tags';
3
3
  import { LogSeverity, MessageLogger } from '../../parse-log';
4
4
  import { MalloyTranslation } from '../../parse-malloy';
@@ -120,13 +120,14 @@ export declare class Document extends MalloyElement implements NameSpace {
120
120
  sqlBlocks: SQLBlockStructDef[];
121
121
  statements: DocStatementList;
122
122
  didInitModel: boolean;
123
- notes: Note[];
123
+ annotation: Annotation;
124
124
  experiments: Tag;
125
125
  constructor(statements: (DocStatement | DocStatementList)[]);
126
126
  initModelDef(extendingModelDef: ModelDef | undefined): void;
127
127
  compile(): DocumentCompileResult;
128
128
  private modelAnnotationTodoList;
129
129
  rememberToAddModelAnnotations(sd: StructDef): void;
130
+ hasAnnotation(): boolean;
130
131
  currentModelAnnotation(): ModelAnnotation | undefined;
131
132
  modelDef(): ModelDef;
132
133
  defineSQL(sql: SQLBlockStructDef, name?: string): boolean;
@@ -434,7 +434,7 @@ class Document extends MalloyElement {
434
434
  this.queryList = [];
435
435
  this.sqlBlocks = [];
436
436
  this.didInitModel = false;
437
- this.notes = [];
437
+ this.annotation = {};
438
438
  this.experiments = new tags_1.Tag({});
439
439
  this.modelAnnotationTodoList = [];
440
440
  this.statements = new DocStatementList(statements);
@@ -448,6 +448,9 @@ class Document extends MalloyElement {
448
448
  this.queryList = [];
449
449
  this.sqlBlocks = [];
450
450
  if (extendingModelDef) {
451
+ if (extendingModelDef.annotation) {
452
+ this.annotation.inherits = extendingModelDef.annotation;
453
+ }
451
454
  for (const [nm, orig] of Object.entries(extendingModelDef.contents)) {
452
455
  const entry = (0, cloneDeep_1.default)(orig);
453
456
  if (entry.type === 'struct' ||
@@ -491,16 +494,20 @@ class Document extends MalloyElement {
491
494
  rememberToAddModelAnnotations(sd) {
492
495
  this.modelAnnotationTodoList.push(sd);
493
496
  }
497
+ hasAnnotation() {
498
+ return ((this.annotation.notes && this.annotation.notes.length > 0) ||
499
+ this.annotation.inherits !== undefined);
500
+ }
494
501
  currentModelAnnotation() {
495
- if (this.notes.length > 0) {
496
- const ret = { id: '', notes: this.notes };
502
+ if (this.hasAnnotation()) {
503
+ const ret = { ...this.annotation, id: '' };
497
504
  ret.id = annotationID(ret);
498
505
  return ret;
499
506
  }
500
507
  }
501
508
  modelDef() {
502
509
  const def = { name: '', exports: [], contents: {} };
503
- if (this.notes.length > 0) {
510
+ if (this.hasAnnotation()) {
504
511
  def.annotation = this.currentModelAnnotation();
505
512
  }
506
513
  for (const entry in this.documentModel) {
@@ -86,7 +86,7 @@ declare class HelpContextStep implements TranslationStep {
86
86
  declare class TranslateStep implements TranslationStep {
87
87
  readonly astStep: ASTStep;
88
88
  response?: TranslateResponse;
89
- importedFlags: boolean;
89
+ importedAnnotations: boolean;
90
90
  constructor(astStep: ASTStep);
91
91
  step(that: MalloyTranslation, extendingModel?: ModelDef): TranslateResponse;
92
92
  }
@@ -450,19 +450,19 @@ class HelpContextStep {
450
450
  class TranslateStep {
451
451
  constructor(astStep) {
452
452
  this.astStep = astStep;
453
- this.importedFlags = false;
453
+ this.importedAnnotations = false;
454
454
  }
455
455
  step(that, extendingModel) {
456
456
  if (this.response) {
457
457
  return this.response;
458
458
  }
459
459
  // begin with the compiler flags of the model we are extending
460
- if (extendingModel && !this.importedFlags) {
460
+ if (extendingModel && !this.importedAnnotations) {
461
461
  const tagParse = tags_1.Tag.annotationToTag(extendingModel.annotation, {
462
462
  prefix: /^##! /,
463
463
  });
464
464
  that.compilerFlags = tagParse.tag;
465
- this.importedFlags = true;
465
+ this.importedAnnotations = true;
466
466
  }
467
467
  const astResponse = this.astStep.step(that);
468
468
  if ((0, translate_response_1.isNeedResponse)(astResponse)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.99-dev231102173733",
3
+ "version": "0.0.99-dev231102201226",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",