@malloydata/malloy 0.0.101-dev231110210501 → 0.0.101-dev231110221413
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.
|
@@ -112,6 +112,7 @@ export declare abstract class MalloyTranslation {
|
|
|
112
112
|
readonly references: ReferenceList;
|
|
113
113
|
constructor(sourceURL: string, importBaseURL?: string | null, grammarRule?: string);
|
|
114
114
|
addChild(url: string): void;
|
|
115
|
+
getDependencies(): string[];
|
|
115
116
|
addReference(reference: DocumentReference): void;
|
|
116
117
|
referenceAt(position: DocumentPosition): DocumentReference | undefined;
|
|
117
118
|
/**
|
|
@@ -134,7 +135,6 @@ export declare abstract class MalloyTranslation {
|
|
|
134
135
|
private finalAnswer?;
|
|
135
136
|
translate(extendingModel?: ModelDef): TranslateResponse;
|
|
136
137
|
importAt(position: DocumentPosition): ImportLocation | undefined;
|
|
137
|
-
private buildImports;
|
|
138
138
|
metadata(): MetadataResponse;
|
|
139
139
|
completions(position: {
|
|
140
140
|
line: number;
|
|
@@ -217,6 +217,10 @@ class ImportsAndTablesStep {
|
|
|
217
217
|
try {
|
|
218
218
|
const ref = decodeURI(new URL(relativeRef, that.importBaseURL || that.sourceURL).toString());
|
|
219
219
|
that.addChild(ref);
|
|
220
|
+
that.imports.push({
|
|
221
|
+
importURL: ref,
|
|
222
|
+
location: { url: that.sourceURL, range: firstRef },
|
|
223
|
+
});
|
|
220
224
|
that.root.importZone.reference(ref, {
|
|
221
225
|
url: that.sourceURL,
|
|
222
226
|
range: firstRef,
|
|
@@ -507,6 +511,7 @@ class TranslateStep {
|
|
|
507
511
|
queryList: that.queryList,
|
|
508
512
|
sqlBlocks: that.sqlBlocks,
|
|
509
513
|
},
|
|
514
|
+
fromSources: that.getDependencies(),
|
|
510
515
|
...that.problemResponse(),
|
|
511
516
|
final: true,
|
|
512
517
|
};
|
|
@@ -550,6 +555,13 @@ class MalloyTranslation {
|
|
|
550
555
|
this.childTranslators.set(url, new MalloyChildTranslator(url, this.root));
|
|
551
556
|
}
|
|
552
557
|
}
|
|
558
|
+
getDependencies() {
|
|
559
|
+
const dependencies = [this.sourceURL];
|
|
560
|
+
for (const [_childURL, child] of this.childTranslators) {
|
|
561
|
+
dependencies.push(...child.getDependencies());
|
|
562
|
+
}
|
|
563
|
+
return dependencies;
|
|
564
|
+
}
|
|
553
565
|
addReference(reference) {
|
|
554
566
|
this.references.add(reference);
|
|
555
567
|
}
|
|
@@ -671,7 +683,6 @@ class MalloyTranslation {
|
|
|
671
683
|
const attempt = this.translateStep.step(this, extendingModel);
|
|
672
684
|
if (attempt.final) {
|
|
673
685
|
this.finalAnswer = attempt;
|
|
674
|
-
this.buildImports();
|
|
675
686
|
}
|
|
676
687
|
return attempt;
|
|
677
688
|
}
|
|
@@ -686,15 +697,6 @@ class MalloyTranslation {
|
|
|
686
697
|
}
|
|
687
698
|
return undefined;
|
|
688
699
|
}
|
|
689
|
-
buildImports() {
|
|
690
|
-
for (const [key, value] of Object.entries(this.root.importZone.location)) {
|
|
691
|
-
// Ignore any import in another file
|
|
692
|
-
if (value.url !== this.sourceURL) {
|
|
693
|
-
continue;
|
|
694
|
-
}
|
|
695
|
-
this.imports.push({ importURL: key, location: value });
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
700
|
metadata() {
|
|
699
701
|
return this.metadataStep.step(this);
|
|
700
702
|
}
|
|
@@ -120,6 +120,16 @@ source: botProjQSrc is botProjQ
|
|
|
120
120
|
const xr = docParse.unresolved();
|
|
121
121
|
expect(docParse).toParse();
|
|
122
122
|
expect(xr).toEqual({ urls: ['internal://test/langtests/grandChild'] });
|
|
123
|
+
docParse.update({
|
|
124
|
+
urls: { 'internal://test/langtests/grandChild': '// empty file' },
|
|
125
|
+
});
|
|
126
|
+
expect(docParse).toTranslate();
|
|
127
|
+
const sources = docParse.translate().fromSources;
|
|
128
|
+
expect(sources).toEqual([
|
|
129
|
+
'internal://test/langtests/root.malloy',
|
|
130
|
+
'internal://test/langtests/child',
|
|
131
|
+
'internal://test/langtests/grandChild',
|
|
132
|
+
]);
|
|
123
133
|
});
|
|
124
134
|
test('relative imports', () => {
|
|
125
135
|
const docParse = new test_translator_1.TestTranslator('import "../parent.malloy"');
|