Skip to content

Commit 2b4be32

Browse files
committed
Merge remote-tracking branch 'origin/main' into 1.35-releases
2 parents 14fee03 + 291a4e9 commit 2b4be32

File tree

62 files changed

+1215
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1215
-636
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **compass**.
2-
This document was automatically generated on Tue Dec 20 2022.
2+
This document was automatically generated on Tue Jan 03 2023.
33

44
## List of dependencies
55

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ Output a compiled string given input and output languages.
4141
- __codeString:__ The code string you would like to be compiled to your
4242
selected output language.
4343

44-
### importsString = transpiler\[inputLang\]\[outputLang\].getImports()
44+
### importsString = transpiler\[inputLang\]\[outputLang\].getImports(mode, driverSyntax)
4545
Output a string containing the set of import statements for the generated code
4646
to compile. These are all the packages that the compiled code could use so that
4747
the transpiler output will be runnable.
48+
- __inputLang:__ Input language of the code string. `shell` and `javascript`
49+
are currently supported.
50+
- __outputLang:__ The language you would like the output to be. `java`,
51+
`python`, `shell`, `javascript`, and `csharp` are currently supported.
52+
- __mode:__ Either 'Query' for the `.find()` method or 'Pipeline' for `.aggregate()`.
53+
- __driverSyntax:__ Whether or not you want to include Driver Syntax into your output string.
4854

4955
### catch (error)
5056
Any transpiler errors that occur will be thrown. To catch them, wrap the

packages/bson-transpilers/codegeneration/CodeGenerationVisitor.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi
8787
* PUBLIC: As code is generated, any classes that require imports are tracked
8888
* in this.Imports. Each class has a "code" defined in the symbol table.
8989
* The imports are then generated based on the output language templates.
90-
*
90+
* @param {String} mode
9191
* @param {Boolean} driverSyntax (optional)
92-
* @return {String} - The list of imports in the target language.
92+
* @return {String} - The list of imports in the target language.
9393
*/
94-
getImports(driverSyntax) {
94+
getImports(mode, driverSyntax) {
9595
const importTemplate = this.Imports.import.template ?
9696
this.Imports.import.template :
9797
(s) => (
@@ -107,18 +107,16 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi
107107
}
108108
});
109109
this.requiredImports.driver = !!driverSyntax;
110-
const imports = Object.keys(this.requiredImports)
111-
.filter((code) => {
112-
return (
113-
this.requiredImports[code] &&
114-
this.Imports[code] &&
115-
this.Imports[code].template
116-
);
117-
})
118-
.reduce((obj, c) => {
119-
obj[c] = this.Imports[c].template(this.requiredImports[c]);
120-
return obj;
121-
}, {});
110+
const imports = {};
111+
for (const code of Object.keys(this.requiredImports)) {
112+
if (
113+
this.requiredImports[code] &&
114+
this.Imports[code] &&
115+
this.Imports[code].template
116+
) {
117+
imports[code] = this.Imports[code].template(this.requiredImports[code], mode);
118+
}
119+
}
122120
return importTemplate(imports);
123121
}
124122

packages/bson-transpilers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ const getTranspiler = (loadTree, visitor, generator, symbols) => {
184184
return transpiler.Syntax.driver.bind(transpiler.getState())(result);
185185
},
186186
compile: compile,
187-
getImports: (driverSyntax) => {
188-
return transpiler.getImports(driverSyntax);
187+
getImports: (mode, driverSyntax) => {
188+
return transpiler.getImports(mode, driverSyntax);
189189
}
190190
};
191191
};

packages/bson-transpilers/lib/symbol-table/javascripttogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/javascripttojava.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/pythontogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/pythontojava.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/shelltogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)