@malloydata/malloy 0.0.22-dev230207144036 → 0.0.22-dev230207180844
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.
- package/dist/connection_utils.d.ts +1 -0
- package/dist/connection_utils.js +66 -0
- package/dist/dialect/dialect.d.ts +66 -0
- package/dist/dialect/dialect.js +85 -0
- package/dist/dialect/dialect_map.d.ts +3 -0
- package/dist/dialect/dialect_map.js +45 -0
- package/dist/dialect/duckdb.d.ts +52 -0
- package/dist/dialect/duckdb.js +364 -0
- package/dist/dialect/index.d.ts +6 -0
- package/dist/dialect/index.js +37 -0
- package/dist/dialect/postgres.d.ts +52 -0
- package/dist/dialect/postgres.js +330 -0
- package/dist/dialect/standardsql.d.ts +49 -0
- package/dist/dialect/standardsql.js +381 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +59 -0
- package/dist/lang/ast/ast-utils.d.ts +10 -0
- package/dist/lang/ast/ast-utils.js +42 -0
- package/dist/lang/ast/elements/define-query.d.ts +14 -0
- package/dist/lang/ast/elements/define-query.js +56 -0
- package/dist/lang/ast/elements/define-source.d.ts +17 -0
- package/dist/lang/ast/elements/define-source.js +79 -0
- package/dist/lang/ast/elements/import-statement.d.ts +9 -0
- package/dist/lang/ast/elements/import-statement.js +78 -0
- package/dist/lang/ast/elements/pipeline-desc.d.ts +30 -0
- package/dist/lang/ast/elements/pipeline-desc.js +102 -0
- package/dist/lang/ast/elements/refined-source.d.ts +15 -0
- package/dist/lang/ast/elements/refined-source.js +121 -0
- package/dist/lang/ast/elements/source.d.ts +12 -0
- package/dist/lang/ast/elements/source.js +53 -0
- package/dist/lang/ast/error-factory.d.ts +9 -0
- package/dist/lang/ast/error-factory.js +61 -0
- package/dist/lang/ast/executors/index-executor.d.ts +18 -0
- package/dist/lang/ast/executors/index-executor.js +96 -0
- package/dist/lang/ast/executors/project-executor.d.ts +10 -0
- package/dist/lang/ast/executors/project-executor.js +68 -0
- package/dist/lang/ast/executors/reduce-executor.d.ts +21 -0
- package/dist/lang/ast/executors/reduce-executor.js +149 -0
- package/dist/lang/ast/expressions/apply.d.ts +8 -0
- package/dist/lang/ast/expressions/apply.js +37 -0
- package/dist/lang/ast/expressions/binary-boolean.d.ts +12 -0
- package/dist/lang/ast/expressions/binary-boolean.js +54 -0
- package/dist/lang/ast/expressions/binary-numeric.d.ts +11 -0
- package/dist/lang/ast/expressions/binary-numeric.js +42 -0
- package/dist/lang/ast/expressions/boolean.d.ts +8 -0
- package/dist/lang/ast/expressions/boolean.js +39 -0
- package/dist/lang/ast/expressions/constant-sub-expression.d.ts +16 -0
- package/dist/lang/ast/expressions/constant-sub-expression.js +98 -0
- package/dist/lang/ast/expressions/expr-add-sub.d.ts +4 -0
- package/dist/lang/ast/expressions/expr-add-sub.js +34 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +15 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.js +99 -0
- package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-alternation-tree.js +54 -0
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-asymmetric.js +27 -0
- package/dist/lang/ast/expressions/expr-avg.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-avg.js +34 -0
- package/dist/lang/ast/expressions/expr-cast.d.ts +13 -0
- package/dist/lang/ast/expressions/expr-cast.js +29 -0
- package/dist/lang/ast/expressions/expr-compare.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-compare.js +58 -0
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-count-distinct.js +35 -0
- package/dist/lang/ast/expressions/expr-count.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-count.js +57 -0
- package/dist/lang/ast/expressions/expr-filter.d.ts +12 -0
- package/dist/lang/ast/expressions/expr-filter.js +69 -0
- package/dist/lang/ast/expressions/expr-func.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-func.js +63 -0
- package/dist/lang/ast/expressions/expr-granular-time.d.ts +24 -0
- package/dist/lang/ast/expressions/expr-granular-time.js +117 -0
- package/dist/lang/ast/expressions/expr-id-reference.d.ts +12 -0
- package/dist/lang/ast/expressions/expr-id-reference.js +75 -0
- package/dist/lang/ast/expressions/expr-logical-op.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-logical-op.js +36 -0
- package/dist/lang/ast/expressions/expr-max.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-max.js +16 -0
- package/dist/lang/ast/expressions/expr-min.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-min.js +16 -0
- package/dist/lang/ast/expressions/expr-minus.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-minus.js +48 -0
- package/dist/lang/ast/expressions/expr-mul-div.d.ts +4 -0
- package/dist/lang/ast/expressions/expr-mul-div.js +34 -0
- package/dist/lang/ast/expressions/expr-not.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-not.js +49 -0
- package/dist/lang/ast/expressions/expr-now.d.ts +7 -0
- package/dist/lang/ast/expressions/expr-now.js +46 -0
- package/dist/lang/ast/expressions/expr-null.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-null.js +41 -0
- package/dist/lang/ast/expressions/expr-number.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-number.js +42 -0
- package/dist/lang/ast/expressions/expr-parens.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-parens.js +42 -0
- package/dist/lang/ast/expressions/expr-regex.d.ts +8 -0
- package/dist/lang/ast/expressions/expr-regex.js +42 -0
- package/dist/lang/ast/expressions/expr-string.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-string.js +50 -0
- package/dist/lang/ast/expressions/expr-sum.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-sum.js +12 -0
- package/dist/lang/ast/expressions/expr-time-extract.d.ts +13 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +117 -0
- package/dist/lang/ast/expressions/expr-time.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-time.js +62 -0
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +14 -0
- package/dist/lang/ast/expressions/expr-ungroup.js +83 -0
- package/dist/lang/ast/expressions/for-range.d.ts +19 -0
- package/dist/lang/ast/expressions/for-range.js +101 -0
- package/dist/lang/ast/expressions/granular-literal.d.ts +20 -0
- package/dist/lang/ast/expressions/granular-literal.js +148 -0
- package/dist/lang/ast/expressions/partial-compare.d.ts +14 -0
- package/dist/lang/ast/expressions/partial-compare.js +50 -0
- package/dist/lang/ast/expressions/pick-when.d.ts +19 -0
- package/dist/lang/ast/expressions/pick-when.js +156 -0
- package/dist/lang/ast/expressions/range.d.ts +12 -0
- package/dist/lang/ast/expressions/range.js +80 -0
- package/dist/lang/ast/expressions/time-frame.d.ts +7 -0
- package/dist/lang/ast/expressions/time-frame.js +40 -0
- package/dist/lang/ast/expressions/top-by.d.ts +10 -0
- package/dist/lang/ast/expressions/top-by.js +51 -0
- package/dist/lang/ast/expressions/unary.d.ts +5 -0
- package/dist/lang/ast/expressions/unary.js +34 -0
- package/dist/lang/ast/expressions/utils.d.ts +12 -0
- package/dist/lang/ast/expressions/utils.js +87 -0
- package/dist/lang/ast/field-space/column-space-field.d.ts +9 -0
- package/dist/lang/ast/field-space/column-space-field.js +40 -0
- package/dist/lang/ast/field-space/dynamic-space.d.ts +22 -0
- package/dist/lang/ast/field-space/dynamic-space.js +140 -0
- package/dist/lang/ast/field-space/field-definition-value.d.ts +16 -0
- package/dist/lang/ast/field-space/field-definition-value.js +55 -0
- package/dist/lang/ast/field-space/index-field-space.d.ts +10 -0
- package/dist/lang/ast/field-space/index-field-space.js +57 -0
- package/dist/lang/ast/field-space/join-space-field.d.ts +8 -0
- package/dist/lang/ast/field-space/join-space-field.js +35 -0
- package/dist/lang/ast/field-space/project-field-space.d.ts +6 -0
- package/dist/lang/ast/field-space/project-field-space.js +51 -0
- package/dist/lang/ast/field-space/query-field-struct.d.ts +10 -0
- package/dist/lang/ast/field-space/query-field-struct.js +46 -0
- package/dist/lang/ast/field-space/query-space-field.d.ts +11 -0
- package/dist/lang/ast/field-space/query-space-field.js +37 -0
- package/dist/lang/ast/field-space/query-spaces.d.ts +50 -0
- package/dist/lang/ast/field-space/query-spaces.js +233 -0
- package/dist/lang/ast/field-space/reference-field.d.ts +11 -0
- package/dist/lang/ast/field-space/reference-field.js +45 -0
- package/dist/lang/ast/field-space/refined-space.d.ts +13 -0
- package/dist/lang/ast/field-space/refined-space.js +100 -0
- package/dist/lang/ast/field-space/rename-space-field.d.ts +11 -0
- package/dist/lang/ast/field-space/rename-space-field.js +50 -0
- package/dist/lang/ast/field-space/static-space.d.ts +29 -0
- package/dist/lang/ast/field-space/static-space.js +156 -0
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +11 -0
- package/dist/lang/ast/field-space/struct-space-field-base.js +40 -0
- package/dist/lang/ast/field-space/wild-space-field.d.ts +10 -0
- package/dist/lang/ast/field-space/wild-space-field.js +40 -0
- package/dist/lang/ast/fragtype-utils.d.ts +39 -0
- package/dist/lang/ast/fragtype-utils.js +100 -0
- package/dist/lang/ast/index.d.ts +90 -0
- package/dist/lang/ast/index.js +129 -0
- package/dist/lang/ast/parameters/constant-parameter.d.ts +8 -0
- package/dist/lang/ast/parameters/constant-parameter.js +54 -0
- package/dist/lang/ast/parameters/has-parameter.d.ts +19 -0
- package/dist/lang/ast/parameters/has-parameter.js +64 -0
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +9 -0
- package/dist/lang/ast/query-elements/anonymous-query.js +41 -0
- package/dist/lang/ast/query-elements/existing-query.d.ts +11 -0
- package/dist/lang/ast/query-elements/existing-query.js +79 -0
- package/dist/lang/ast/query-elements/full-query.d.ts +10 -0
- package/dist/lang/ast/query-elements/full-query.js +85 -0
- package/dist/lang/ast/query-elements/query-head-struct.d.ts +9 -0
- package/dist/lang/ast/query-elements/query-head-struct.js +48 -0
- package/dist/lang/ast/query-items/field-declaration.d.ts +31 -0
- package/dist/lang/ast/query-items/field-declaration.js +137 -0
- package/dist/lang/ast/query-items/field-references.d.ts +25 -0
- package/dist/lang/ast/query-items/field-references.js +80 -0
- package/dist/lang/ast/query-properties/aggregate.d.ts +5 -0
- package/dist/lang/ast/query-properties/aggregate.js +39 -0
- package/dist/lang/ast/query-properties/declare-fields.d.ts +5 -0
- package/dist/lang/ast/query-properties/declare-fields.js +33 -0
- package/dist/lang/ast/query-properties/dimmensions.d.ts +5 -0
- package/dist/lang/ast/query-properties/dimmensions.js +36 -0
- package/dist/lang/ast/query-properties/filters.d.ts +18 -0
- package/dist/lang/ast/query-properties/filters.js +89 -0
- package/dist/lang/ast/query-properties/group-by.d.ts +5 -0
- package/dist/lang/ast/query-properties/group-by.js +39 -0
- package/dist/lang/ast/query-properties/indexing.d.ts +10 -0
- package/dist/lang/ast/query-properties/indexing.js +39 -0
- package/dist/lang/ast/query-properties/joins.d.ts +36 -0
- package/dist/lang/ast/query-properties/joins.js +143 -0
- package/dist/lang/ast/query-properties/limit.d.ts +6 -0
- package/dist/lang/ast/query-properties/limit.js +35 -0
- package/dist/lang/ast/query-properties/measures.d.ts +5 -0
- package/dist/lang/ast/query-properties/measures.js +36 -0
- package/dist/lang/ast/query-properties/nest-reference.d.ts +7 -0
- package/dist/lang/ast/query-properties/nest-reference.js +35 -0
- package/dist/lang/ast/query-properties/nest.d.ts +31 -0
- package/dist/lang/ast/query-properties/nest.js +133 -0
- package/dist/lang/ast/query-properties/nests.d.ts +5 -0
- package/dist/lang/ast/query-properties/nests.js +33 -0
- package/dist/lang/ast/query-properties/ordering.d.ts +15 -0
- package/dist/lang/ast/query-properties/ordering.js +66 -0
- package/dist/lang/ast/query-properties/project-statement.d.ts +5 -0
- package/dist/lang/ast/query-properties/project-statement.js +33 -0
- package/dist/lang/ast/query-properties/qop-desc.d.ts +17 -0
- package/dist/lang/ast/query-properties/qop-desc.js +124 -0
- package/dist/lang/ast/query-properties/sampling.d.ts +8 -0
- package/dist/lang/ast/query-properties/sampling.js +38 -0
- package/dist/lang/ast/query-properties/top.d.ts +13 -0
- package/dist/lang/ast/query-properties/top.js +60 -0
- package/dist/lang/ast/source-properties/field-list-edit.d.ts +8 -0
- package/dist/lang/ast/source-properties/field-list-edit.js +36 -0
- package/dist/lang/ast/source-properties/primary-key.d.ts +7 -0
- package/dist/lang/ast/source-properties/primary-key.js +35 -0
- package/dist/lang/ast/source-properties/renames.d.ts +11 -0
- package/dist/lang/ast/source-properties/renames.js +43 -0
- package/dist/lang/ast/source-properties/turtles.d.ts +5 -0
- package/dist/lang/ast/source-properties/turtles.js +33 -0
- package/dist/lang/ast/sources/named-source.d.ts +19 -0
- package/dist/lang/ast/sources/named-source.js +147 -0
- package/dist/lang/ast/sources/query-source.d.ts +9 -0
- package/dist/lang/ast/sources/query-source.js +41 -0
- package/dist/lang/ast/sources/sql-source.d.ts +7 -0
- package/dist/lang/ast/sources/sql-source.js +54 -0
- package/dist/lang/ast/sources/table-source.d.ts +8 -0
- package/dist/lang/ast/sources/table-source.js +60 -0
- package/dist/lang/ast/space-seed.d.ts +16 -0
- package/dist/lang/ast/space-seed.js +59 -0
- package/dist/lang/ast/sql-elements/sql-statement.d.ts +19 -0
- package/dist/lang/ast/sql-elements/sql-statement.js +80 -0
- package/dist/lang/ast/sql-elements/sql-string.d.ts +12 -0
- package/dist/lang/ast/sql-elements/sql-string.js +60 -0
- package/dist/lang/ast/struct-utils.d.ts +4 -0
- package/dist/lang/ast/struct-utils.js +48 -0
- package/dist/lang/ast/time-utils.d.ts +12 -0
- package/dist/lang/ast/time-utils.js +140 -0
- package/dist/lang/ast/types/comparison.d.ts +11 -0
- package/dist/lang/ast/types/comparison.js +41 -0
- package/dist/lang/ast/types/document-compile-result.d.ts +8 -0
- package/dist/lang/ast/types/document-compile-result.js +25 -0
- package/dist/lang/ast/types/equality.d.ts +7 -0
- package/dist/lang/ast/types/equality.js +37 -0
- package/dist/lang/ast/types/executor.d.ts +9 -0
- package/dist/lang/ast/types/executor.js +25 -0
- package/dist/lang/ast/types/explore-desc.d.ts +5 -0
- package/dist/lang/ast/types/explore-desc.js +33 -0
- package/dist/lang/ast/types/explore-field.d.ts +5 -0
- package/dist/lang/ast/types/explore-field.js +32 -0
- package/dist/lang/ast/types/expr-result.d.ts +5 -0
- package/dist/lang/ast/types/expr-result.js +25 -0
- package/dist/lang/ast/types/expr-value.d.ts +3 -0
- package/dist/lang/ast/types/expr-value.js +25 -0
- package/dist/lang/ast/types/expression-def.d.ts +69 -0
- package/dist/lang/ast/types/expression-def.js +346 -0
- package/dist/lang/ast/types/field-collection-member.d.ts +5 -0
- package/dist/lang/ast/types/field-collection-member.js +34 -0
- package/dist/lang/ast/types/field-decl.d.ts +7 -0
- package/dist/lang/ast/types/field-decl.js +37 -0
- package/dist/lang/ast/types/field-space.d.ts +24 -0
- package/dist/lang/ast/types/field-space.js +44 -0
- package/dist/lang/ast/types/granular-result.d.ts +7 -0
- package/dist/lang/ast/types/granular-result.js +11 -0
- package/dist/lang/ast/types/lookup-result.d.ts +10 -0
- package/dist/lang/ast/types/lookup-result.js +25 -0
- package/dist/lang/ast/types/malloy-element.d.ts +106 -0
- package/dist/lang/ast/types/malloy-element.js +398 -0
- package/dist/lang/ast/types/model-entry.d.ts +6 -0
- package/dist/lang/ast/types/model-entry.js +25 -0
- package/dist/lang/ast/types/name-space.d.ts +5 -0
- package/dist/lang/ast/types/name-space.js +25 -0
- package/dist/lang/ast/types/nested-query.d.ts +3 -0
- package/dist/lang/ast/types/nested-query.js +25 -0
- package/dist/lang/ast/types/op-desc.d.ts +6 -0
- package/dist/lang/ast/types/op-desc.js +25 -0
- package/dist/lang/ast/types/query-comp.d.ts +5 -0
- package/dist/lang/ast/types/query-comp.js +25 -0
- package/dist/lang/ast/types/query-element.d.ts +5 -0
- package/dist/lang/ast/types/query-element.js +32 -0
- package/dist/lang/ast/types/query-item.d.ts +5 -0
- package/dist/lang/ast/types/query-item.js +25 -0
- package/dist/lang/ast/types/query-property.d.ts +17 -0
- package/dist/lang/ast/types/query-property.js +55 -0
- package/dist/lang/ast/types/source-property.d.ts +10 -0
- package/dist/lang/ast/types/source-property.js +43 -0
- package/dist/lang/ast/types/space-entry.d.ts +5 -0
- package/dist/lang/ast/types/space-entry.js +29 -0
- package/dist/lang/ast/types/space-field.d.ts +10 -0
- package/dist/lang/ast/types/space-field.js +48 -0
- package/dist/lang/ast/types/space-param.d.ts +20 -0
- package/dist/lang/ast/types/space-param.js +61 -0
- package/dist/lang/ast/types/time-result.d.ts +6 -0
- package/dist/lang/ast/types/time-result.js +25 -0
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +7 -0
- package/dist/lang/ast/types/turtle-headed-pipe.js +37 -0
- package/dist/lang/ast/types/type-desc.d.ts +7 -0
- package/dist/lang/ast/types/type-desc.js +25 -0
- package/dist/lang/field-utils.d.ts +5 -0
- package/dist/lang/field-utils.js +43 -0
- package/dist/lang/index.d.ts +10 -0
- package/dist/lang/index.js +32 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +165 -0
- package/dist/lang/lib/Malloy/MalloyLexer.js +1232 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1947 -0
- package/dist/lang/lib/Malloy/MalloyParser.js +11909 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2022 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1274 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
- package/dist/lang/malloy-to-ast.d.ts +155 -0
- package/dist/lang/malloy-to-ast.js +990 -0
- package/dist/lang/parse-error-handler.d.ts +9 -0
- package/dist/lang/parse-error-handler.js +44 -0
- package/dist/lang/parse-log.d.ts +27 -0
- package/dist/lang/parse-log.js +51 -0
- package/dist/lang/parse-malloy.d.ts +182 -0
- package/dist/lang/parse-malloy.js +728 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +148 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +107 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +385 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +182 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +74 -0
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/find-external-references.js +61 -0
- package/dist/lang/reference-list.d.ts +10 -0
- package/dist/lang/reference-list.js +90 -0
- package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-help-context-walker.spec.js +55 -0
- package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-symbol-walker.spec.js +110 -0
- package/dist/lang/test/field-symbols.spec.d.ts +1 -0
- package/dist/lang/test/field-symbols.spec.js +184 -0
- package/dist/lang/test/parse.spec.d.ts +14 -0
- package/dist/lang/test/parse.spec.js +2135 -0
- package/dist/lang/test/test-translator.d.ts +41 -0
- package/dist/lang/test/test-translator.js +344 -0
- package/dist/lang/translate-response.d.ts +59 -0
- package/dist/lang/translate-response.js +30 -0
- package/dist/lang/zone.d.ts +57 -0
- package/dist/lang/zone.js +107 -0
- package/dist/malloy.d.ts +1146 -0
- package/dist/malloy.js +2413 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +45 -0
- package/dist/model/malloy_query.d.ts +351 -0
- package/dist/model/malloy_query.js +3174 -0
- package/dist/model/malloy_types.d.ts +551 -0
- package/dist/model/malloy_types.js +378 -0
- package/dist/model/sql_block.d.ts +7 -0
- package/dist/model/sql_block.js +56 -0
- package/dist/model/utils.d.ts +22 -0
- package/dist/model/utils.js +102 -0
- package/dist/run_sql_options.d.ts +3 -0
- package/dist/run_sql_options.js +25 -0
- package/dist/runtime_types.d.ts +105 -0
- package/dist/runtime_types.js +25 -0
- package/package.json +2 -2
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.sortHighlights = exports.walkForDocumentHighlights = exports.passForHighlights = exports.HighlightType = void 0;
|
|
26
|
+
const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
|
|
27
|
+
const MalloyParser_1 = require("../lib/Malloy/MalloyParser");
|
|
28
|
+
// TODO maybe this could be an enum like Definition__Field, etc.
|
|
29
|
+
exports.HighlightType = {
|
|
30
|
+
Identifier: "identifier",
|
|
31
|
+
Type: "type",
|
|
32
|
+
Literal: {
|
|
33
|
+
Date: "literal.date",
|
|
34
|
+
Number: "literal.number",
|
|
35
|
+
String: "literal.string",
|
|
36
|
+
RegularExpression: "literal.regular_expression",
|
|
37
|
+
Boolean: "literal.boolean",
|
|
38
|
+
Null: "literal.null",
|
|
39
|
+
},
|
|
40
|
+
Call: {
|
|
41
|
+
Aggregate: "call.aggregate",
|
|
42
|
+
TimeFrame: "call.time_frame",
|
|
43
|
+
Cast: "call.cast",
|
|
44
|
+
Table: "call.table",
|
|
45
|
+
From: "call.from",
|
|
46
|
+
Function: "call.function",
|
|
47
|
+
FromSQL: "call.from_sql",
|
|
48
|
+
},
|
|
49
|
+
// TODO many of these should probably be categorized further
|
|
50
|
+
Keyword: {
|
|
51
|
+
AggregateModifier: {
|
|
52
|
+
Distinct: "keyword.aggregate_modifier.distinct",
|
|
53
|
+
},
|
|
54
|
+
CastModifier: {
|
|
55
|
+
As: "keyword.cast_modifier.as",
|
|
56
|
+
},
|
|
57
|
+
Is: "keyword.is",
|
|
58
|
+
On: "keyword.on",
|
|
59
|
+
Desc: "keyword.desc",
|
|
60
|
+
Asc: "keyword.asc",
|
|
61
|
+
Pick: "keyword.pick",
|
|
62
|
+
When: "keyword.when",
|
|
63
|
+
Else: "keyword.else",
|
|
64
|
+
With: "keyword.with",
|
|
65
|
+
// TODO or is this a meta type?
|
|
66
|
+
JSON: "keyword.json",
|
|
67
|
+
// TODO or is this a meta type?
|
|
68
|
+
Turtle: "keyword.turtle",
|
|
69
|
+
Import: "keyword.import",
|
|
70
|
+
},
|
|
71
|
+
Operator: {
|
|
72
|
+
Comparison: "operator.comparison",
|
|
73
|
+
Boolean: "operator.boolean",
|
|
74
|
+
Date: "operator.date",
|
|
75
|
+
},
|
|
76
|
+
Comment: {
|
|
77
|
+
Line: "comment.line",
|
|
78
|
+
Block: "comment.block",
|
|
79
|
+
},
|
|
80
|
+
Property: {
|
|
81
|
+
Accept: "property.accept",
|
|
82
|
+
Aggregate: "property.aggregate",
|
|
83
|
+
Dimension: "property.dimension",
|
|
84
|
+
Except: "property.except",
|
|
85
|
+
Source: "property.source",
|
|
86
|
+
GroupBy: "property.group_by",
|
|
87
|
+
Having: "property.having",
|
|
88
|
+
Index: "property.index",
|
|
89
|
+
JoinOne: "keyword.join_one",
|
|
90
|
+
JoinMany: "keyword.join_many",
|
|
91
|
+
JoinCross: "keyword.join_cross",
|
|
92
|
+
Limit: "property.limit",
|
|
93
|
+
Measure: "property.measure",
|
|
94
|
+
Nest: "property.nest",
|
|
95
|
+
OrderBy: "property.order_by",
|
|
96
|
+
PrimaryKey: "property.primary_key",
|
|
97
|
+
Project: "property.project",
|
|
98
|
+
Query: "property.query",
|
|
99
|
+
Rename: "property.rename",
|
|
100
|
+
Top: "property.top",
|
|
101
|
+
Where: "property.where",
|
|
102
|
+
SQL: "property.sql",
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
function passForHighlights(tokens) {
|
|
106
|
+
const highlights = [];
|
|
107
|
+
const register = (token, type, removeColon = false) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const offset = token.startIndex - token.charPositionInLine;
|
|
110
|
+
const tokenLines = ((_a = token.text) === null || _a === void 0 ? void 0 : _a.split("\n")) || [];
|
|
111
|
+
const numberOfLines = tokenLines.length;
|
|
112
|
+
const lengthOfAllButLastLine = tokenLines
|
|
113
|
+
.slice(0, -1)
|
|
114
|
+
.reduce((a, l) => a + l.length, 0);
|
|
115
|
+
const colonAdjustment = removeColon ? 1 : 0;
|
|
116
|
+
highlights.push({
|
|
117
|
+
type,
|
|
118
|
+
range: {
|
|
119
|
+
start: { line: token.line - 1, character: token.startIndex - offset },
|
|
120
|
+
end: {
|
|
121
|
+
line: token.line - 1 + numberOfLines - 1,
|
|
122
|
+
character: token.stopIndex +
|
|
123
|
+
2 -
|
|
124
|
+
(numberOfLines > 1 ? token.startIndex : offset) -
|
|
125
|
+
lengthOfAllButLastLine -
|
|
126
|
+
numberOfLines -
|
|
127
|
+
colonAdjustment,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
for (let i = 0; i < tokens.size; i++) {
|
|
133
|
+
const token = tokens.get(i);
|
|
134
|
+
switch (token.type) {
|
|
135
|
+
case MalloyParser_1.MalloyParser.ACCEPT:
|
|
136
|
+
register(token, exports.HighlightType.Property.Accept, true);
|
|
137
|
+
break;
|
|
138
|
+
case MalloyParser_1.MalloyParser.AGGREGATE:
|
|
139
|
+
register(token, exports.HighlightType.Property.Aggregate, true);
|
|
140
|
+
break;
|
|
141
|
+
case MalloyParser_1.MalloyParser.DIMENSION:
|
|
142
|
+
register(token, exports.HighlightType.Property.Dimension, true);
|
|
143
|
+
break;
|
|
144
|
+
case MalloyParser_1.MalloyParser.EXCEPT:
|
|
145
|
+
register(token, exports.HighlightType.Property.Except, true);
|
|
146
|
+
break;
|
|
147
|
+
case MalloyParser_1.MalloyParser.GROUP_BY:
|
|
148
|
+
register(token, exports.HighlightType.Property.GroupBy, true);
|
|
149
|
+
break;
|
|
150
|
+
case MalloyParser_1.MalloyParser.HAVING:
|
|
151
|
+
register(token, exports.HighlightType.Property.Having, true);
|
|
152
|
+
break;
|
|
153
|
+
case MalloyParser_1.MalloyParser.INDEX:
|
|
154
|
+
register(token, exports.HighlightType.Property.Index, true);
|
|
155
|
+
break;
|
|
156
|
+
case MalloyParser_1.MalloyParser.JOIN_CROSS:
|
|
157
|
+
register(token, exports.HighlightType.Property.JoinOne, true);
|
|
158
|
+
break;
|
|
159
|
+
case MalloyParser_1.MalloyParser.JOIN_ONE:
|
|
160
|
+
register(token, exports.HighlightType.Property.JoinMany, true);
|
|
161
|
+
break;
|
|
162
|
+
case MalloyParser_1.MalloyParser.JOIN_MANY:
|
|
163
|
+
register(token, exports.HighlightType.Property.JoinCross, true);
|
|
164
|
+
break;
|
|
165
|
+
case MalloyParser_1.MalloyParser.LIMIT:
|
|
166
|
+
register(token, exports.HighlightType.Property.Limit, true);
|
|
167
|
+
break;
|
|
168
|
+
case MalloyParser_1.MalloyParser.MEASURE:
|
|
169
|
+
register(token, exports.HighlightType.Property.Measure, true);
|
|
170
|
+
break;
|
|
171
|
+
case MalloyParser_1.MalloyParser.NEST:
|
|
172
|
+
register(token, exports.HighlightType.Property.Nest, true);
|
|
173
|
+
break;
|
|
174
|
+
case MalloyParser_1.MalloyParser.ORDER_BY:
|
|
175
|
+
register(token, exports.HighlightType.Property.OrderBy, true);
|
|
176
|
+
break;
|
|
177
|
+
case MalloyParser_1.MalloyParser.PRIMARY_KEY:
|
|
178
|
+
register(token, exports.HighlightType.Property.PrimaryKey, true);
|
|
179
|
+
break;
|
|
180
|
+
case MalloyParser_1.MalloyParser.PROJECT:
|
|
181
|
+
register(token, exports.HighlightType.Property.Project, true);
|
|
182
|
+
break;
|
|
183
|
+
case MalloyParser_1.MalloyParser.QUERY:
|
|
184
|
+
register(token, exports.HighlightType.Property.Query, true);
|
|
185
|
+
break;
|
|
186
|
+
case MalloyParser_1.MalloyParser.RENAME:
|
|
187
|
+
register(token, exports.HighlightType.Property.Rename, true);
|
|
188
|
+
break;
|
|
189
|
+
case MalloyParser_1.MalloyParser.SOURCE:
|
|
190
|
+
register(token, exports.HighlightType.Property.Source, true);
|
|
191
|
+
break;
|
|
192
|
+
case MalloyParser_1.MalloyParser.TOP:
|
|
193
|
+
register(token, exports.HighlightType.Property.Top, true);
|
|
194
|
+
break;
|
|
195
|
+
case MalloyParser_1.MalloyParser.WHERE:
|
|
196
|
+
register(token, exports.HighlightType.Property.Where, true);
|
|
197
|
+
break;
|
|
198
|
+
case MalloyParser_1.MalloyParser.SQL:
|
|
199
|
+
register(token, exports.HighlightType.Property.SQL, true);
|
|
200
|
+
break;
|
|
201
|
+
case MalloyParser_1.MalloyParser.TABLE:
|
|
202
|
+
register(token, exports.HighlightType.Call.Table);
|
|
203
|
+
break;
|
|
204
|
+
case MalloyParser_1.MalloyParser.FROM:
|
|
205
|
+
register(token, exports.HighlightType.Call.From);
|
|
206
|
+
break;
|
|
207
|
+
case MalloyParser_1.MalloyParser.FROM_SQL:
|
|
208
|
+
register(token, exports.HighlightType.Call.FromSQL);
|
|
209
|
+
break;
|
|
210
|
+
case MalloyParser_1.MalloyParser.STRING_LITERAL:
|
|
211
|
+
case MalloyParser_1.MalloyParser.JSON_STRING:
|
|
212
|
+
register(token, exports.HighlightType.Literal.String);
|
|
213
|
+
break;
|
|
214
|
+
case MalloyParser_1.MalloyParser.NUMERIC_LITERAL:
|
|
215
|
+
case MalloyParser_1.MalloyParser.INTEGER_LITERAL:
|
|
216
|
+
register(token, exports.HighlightType.Literal.Number);
|
|
217
|
+
break;
|
|
218
|
+
case MalloyParser_1.MalloyParser.HACKY_REGEX:
|
|
219
|
+
register(token, exports.HighlightType.Literal.RegularExpression);
|
|
220
|
+
break;
|
|
221
|
+
case MalloyParser_1.MalloyParser.IS:
|
|
222
|
+
register(token, exports.HighlightType.Keyword.Is);
|
|
223
|
+
break;
|
|
224
|
+
case MalloyParser_1.MalloyParser.DISTINCT:
|
|
225
|
+
register(token, exports.HighlightType.Keyword.AggregateModifier.Distinct);
|
|
226
|
+
break;
|
|
227
|
+
case MalloyParser_1.MalloyParser.ON:
|
|
228
|
+
register(token, exports.HighlightType.Keyword.On);
|
|
229
|
+
break;
|
|
230
|
+
case MalloyParser_1.MalloyParser.DESC:
|
|
231
|
+
register(token, exports.HighlightType.Keyword.Desc);
|
|
232
|
+
break;
|
|
233
|
+
case MalloyParser_1.MalloyParser.ASC:
|
|
234
|
+
register(token, exports.HighlightType.Keyword.Asc);
|
|
235
|
+
break;
|
|
236
|
+
case MalloyParser_1.MalloyParser.CAST:
|
|
237
|
+
register(token, exports.HighlightType.Call.Cast);
|
|
238
|
+
break;
|
|
239
|
+
case MalloyParser_1.MalloyParser.AS:
|
|
240
|
+
register(token, exports.HighlightType.Keyword.CastModifier.As);
|
|
241
|
+
break;
|
|
242
|
+
case MalloyParser_1.MalloyParser.PICK:
|
|
243
|
+
register(token, exports.HighlightType.Keyword.Pick);
|
|
244
|
+
break;
|
|
245
|
+
case MalloyParser_1.MalloyParser.WHEN:
|
|
246
|
+
register(token, exports.HighlightType.Keyword.When);
|
|
247
|
+
break;
|
|
248
|
+
case MalloyParser_1.MalloyParser.WITH:
|
|
249
|
+
register(token, exports.HighlightType.Keyword.With);
|
|
250
|
+
break;
|
|
251
|
+
case MalloyParser_1.MalloyParser.ELSE:
|
|
252
|
+
register(token, exports.HighlightType.Keyword.Else);
|
|
253
|
+
break;
|
|
254
|
+
case MalloyParser_1.MalloyParser.JSON:
|
|
255
|
+
register(token, exports.HighlightType.Keyword.JSON);
|
|
256
|
+
break;
|
|
257
|
+
case MalloyParser_1.MalloyParser.TURTLE:
|
|
258
|
+
register(token, exports.HighlightType.Keyword.Turtle);
|
|
259
|
+
break;
|
|
260
|
+
case MalloyParser_1.MalloyParser.TRUE:
|
|
261
|
+
case MalloyParser_1.MalloyParser.FALSE:
|
|
262
|
+
register(token, exports.HighlightType.Literal.Boolean);
|
|
263
|
+
break;
|
|
264
|
+
case MalloyParser_1.MalloyParser.NOW:
|
|
265
|
+
case MalloyParser_1.MalloyParser.LITERAL_TIMESTAMP:
|
|
266
|
+
case MalloyParser_1.MalloyParser.LITERAL_QUARTER:
|
|
267
|
+
case MalloyParser_1.MalloyParser.LITERAL_MONTH:
|
|
268
|
+
case MalloyParser_1.MalloyParser.LITERAL_DAY:
|
|
269
|
+
case MalloyParser_1.MalloyParser.LITERAL_WEEK:
|
|
270
|
+
case MalloyParser_1.MalloyParser.LITERAL_YEAR:
|
|
271
|
+
register(token, exports.HighlightType.Literal.Date);
|
|
272
|
+
break;
|
|
273
|
+
case MalloyParser_1.MalloyParser.NULL:
|
|
274
|
+
register(token, exports.HighlightType.Literal.Null);
|
|
275
|
+
break;
|
|
276
|
+
case MalloyParser_1.MalloyParser.AND:
|
|
277
|
+
case MalloyParser_1.MalloyParser.OR:
|
|
278
|
+
case MalloyParser_1.MalloyParser.NOT:
|
|
279
|
+
register(token, exports.HighlightType.Operator.Boolean);
|
|
280
|
+
break;
|
|
281
|
+
case MalloyParser_1.MalloyParser.FOR:
|
|
282
|
+
register(token, exports.HighlightType.Operator.Date);
|
|
283
|
+
break;
|
|
284
|
+
case MalloyParser_1.MalloyParser.COMMENT_TO_EOL:
|
|
285
|
+
register(token, exports.HighlightType.Comment.Line);
|
|
286
|
+
break;
|
|
287
|
+
case MalloyParser_1.MalloyParser.BLOCK_COMMENT:
|
|
288
|
+
register(token, exports.HighlightType.Comment.Block);
|
|
289
|
+
break;
|
|
290
|
+
case MalloyParser_1.MalloyParser.SUM:
|
|
291
|
+
case MalloyParser_1.MalloyParser.COUNT:
|
|
292
|
+
case MalloyParser_1.MalloyParser.AVG:
|
|
293
|
+
case MalloyParser_1.MalloyParser.MIN:
|
|
294
|
+
case MalloyParser_1.MalloyParser.MAX:
|
|
295
|
+
register(token, exports.HighlightType.Call.Aggregate);
|
|
296
|
+
break;
|
|
297
|
+
case MalloyParser_1.MalloyParser.IDENTIFIER:
|
|
298
|
+
case MalloyParser_1.MalloyParser.OBJECT_NAME_LITERAL:
|
|
299
|
+
register(token, exports.HighlightType.Identifier);
|
|
300
|
+
break;
|
|
301
|
+
case MalloyParser_1.MalloyParser.STRING:
|
|
302
|
+
case MalloyParser_1.MalloyParser.NUMBER:
|
|
303
|
+
case MalloyParser_1.MalloyParser.BOOLEAN:
|
|
304
|
+
case MalloyParser_1.MalloyParser.DATE:
|
|
305
|
+
case MalloyParser_1.MalloyParser.TIMESTAMP:
|
|
306
|
+
register(token, exports.HighlightType.Type);
|
|
307
|
+
break;
|
|
308
|
+
case MalloyParser_1.MalloyParser.SECOND:
|
|
309
|
+
case MalloyParser_1.MalloyParser.MINUTE:
|
|
310
|
+
case MalloyParser_1.MalloyParser.HOUR:
|
|
311
|
+
case MalloyParser_1.MalloyParser.DAY:
|
|
312
|
+
case MalloyParser_1.MalloyParser.WEEK:
|
|
313
|
+
case MalloyParser_1.MalloyParser.MONTH:
|
|
314
|
+
case MalloyParser_1.MalloyParser.QUARTER:
|
|
315
|
+
case MalloyParser_1.MalloyParser.YEAR:
|
|
316
|
+
register(token, exports.HighlightType.Call.TimeFrame);
|
|
317
|
+
break;
|
|
318
|
+
case MalloyParser_1.MalloyParser.IMPORT:
|
|
319
|
+
register(token, exports.HighlightType.Keyword.Import);
|
|
320
|
+
break;
|
|
321
|
+
// TODO durations? How should we highlight `3 days` or
|
|
322
|
+
// `(1 + 2) days` or `n days`?
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return highlights;
|
|
326
|
+
}
|
|
327
|
+
exports.passForHighlights = passForHighlights;
|
|
328
|
+
class DocumentHighlightWalker {
|
|
329
|
+
constructor(tokens, highlights) {
|
|
330
|
+
this.tokens = tokens;
|
|
331
|
+
this.highlights = highlights;
|
|
332
|
+
}
|
|
333
|
+
rangeOf(pcx) {
|
|
334
|
+
const stopToken = pcx.stop || pcx.start;
|
|
335
|
+
return {
|
|
336
|
+
start: {
|
|
337
|
+
line: pcx.start.line - 1,
|
|
338
|
+
character: pcx.start.charPositionInLine,
|
|
339
|
+
},
|
|
340
|
+
end: {
|
|
341
|
+
line: stopToken.line - 1,
|
|
342
|
+
character: stopToken.stopIndex -
|
|
343
|
+
(stopToken.startIndex - stopToken.charPositionInLine) +
|
|
344
|
+
1,
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
enterExprFunc(pcx) {
|
|
349
|
+
const id = pcx.id() || pcx.timeframe();
|
|
350
|
+
if (id) {
|
|
351
|
+
this.highlights.push({
|
|
352
|
+
range: this.rangeOf(id),
|
|
353
|
+
type: exports.HighlightType.Call.Function,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function walkForDocumentHighlights(tokens, parseTree) {
|
|
359
|
+
const finder = new DocumentHighlightWalker(tokens, []);
|
|
360
|
+
const listener = finder;
|
|
361
|
+
ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, parseTree);
|
|
362
|
+
return finder.highlights;
|
|
363
|
+
}
|
|
364
|
+
exports.walkForDocumentHighlights = walkForDocumentHighlights;
|
|
365
|
+
function sortHighlights(highlights) {
|
|
366
|
+
return highlights.sort((a, b) => {
|
|
367
|
+
if (a.range.start.line < b.range.start.line) {
|
|
368
|
+
return -1;
|
|
369
|
+
}
|
|
370
|
+
else if (a.range.start.line > b.range.start.line) {
|
|
371
|
+
return 1;
|
|
372
|
+
}
|
|
373
|
+
else if (a.range.start.character < b.range.start.character) {
|
|
374
|
+
return -1;
|
|
375
|
+
}
|
|
376
|
+
else if (a.range.start.character > b.range.start.character) {
|
|
377
|
+
return 1;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
return 0;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
exports.sortHighlights = sortHighlights;
|
|
385
|
+
//# sourceMappingURL=document-highlight-walker.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CommonTokenStream } from "antlr4ts";
|
|
2
|
+
import { ParseTree } from "antlr4ts/tree";
|
|
3
|
+
import { DocumentRange } from "../../model/malloy_types";
|
|
4
|
+
import { MalloyTranslation } from "../parse-malloy";
|
|
5
|
+
export interface DocumentSymbol {
|
|
6
|
+
range: DocumentRange;
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
children: DocumentSymbol[];
|
|
10
|
+
}
|
|
11
|
+
export declare function walkForDocumentSymbols(forParse: MalloyTranslation, tokens: CommonTokenStream, parseTree: ParseTree): DocumentSymbol[];
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.walkForDocumentSymbols = void 0;
|
|
26
|
+
const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
|
|
27
|
+
class DocumentSymbolWalker {
|
|
28
|
+
constructor(translator, tokens, scopes, symbols) {
|
|
29
|
+
this.translator = translator;
|
|
30
|
+
this.tokens = tokens;
|
|
31
|
+
this.scopes = scopes;
|
|
32
|
+
this.symbols = symbols;
|
|
33
|
+
}
|
|
34
|
+
popScope() {
|
|
35
|
+
return this.scopes.pop();
|
|
36
|
+
}
|
|
37
|
+
peekScope() {
|
|
38
|
+
return this.scopes[this.scopes.length - 1];
|
|
39
|
+
}
|
|
40
|
+
enterTopLevelQueryDef(pcx) {
|
|
41
|
+
this.symbols.push({
|
|
42
|
+
range: this.translator.rangeFromContext(pcx),
|
|
43
|
+
name: pcx.queryName().text,
|
|
44
|
+
type: "query",
|
|
45
|
+
children: [],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
enterTopLevelAnonQueryDef(pcx) {
|
|
49
|
+
this.symbols.push({
|
|
50
|
+
range: this.translator.rangeFromContext(pcx),
|
|
51
|
+
name: "unnamed_query",
|
|
52
|
+
type: "unnamed_query",
|
|
53
|
+
children: [],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
enterSourceDefinition(pcx) {
|
|
57
|
+
this.scopes.push({
|
|
58
|
+
range: this.translator.rangeFromContext(pcx),
|
|
59
|
+
name: pcx.sourceNameDef().id().text,
|
|
60
|
+
type: "explore",
|
|
61
|
+
children: [],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exitSourceDefinition(_pcx) {
|
|
65
|
+
const scope = this.popScope();
|
|
66
|
+
if (scope) {
|
|
67
|
+
this.symbols.push(scope);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
enterExploreQueryDef(pcx) {
|
|
71
|
+
const symbol = {
|
|
72
|
+
range: this.translator.rangeFromContext(pcx),
|
|
73
|
+
name: pcx.exploreQueryNameDef().id().text,
|
|
74
|
+
type: "query",
|
|
75
|
+
children: [],
|
|
76
|
+
};
|
|
77
|
+
const parent = this.peekScope();
|
|
78
|
+
if (parent) {
|
|
79
|
+
parent.children.push(symbol);
|
|
80
|
+
}
|
|
81
|
+
this.scopes.push(symbol);
|
|
82
|
+
}
|
|
83
|
+
exitExploreQueryDef(_pcx) {
|
|
84
|
+
this.popScope();
|
|
85
|
+
}
|
|
86
|
+
handleNestEntry(pcx) {
|
|
87
|
+
const symbol = {
|
|
88
|
+
range: this.translator.rangeFromContext(pcx),
|
|
89
|
+
name: pcx.queryName().id().text,
|
|
90
|
+
type: "query",
|
|
91
|
+
children: [],
|
|
92
|
+
};
|
|
93
|
+
const parent = this.peekScope();
|
|
94
|
+
if (parent) {
|
|
95
|
+
parent.children.push(symbol);
|
|
96
|
+
}
|
|
97
|
+
return symbol;
|
|
98
|
+
}
|
|
99
|
+
enterNestExisting(pcx) {
|
|
100
|
+
this.handleNestEntry(pcx);
|
|
101
|
+
}
|
|
102
|
+
enterNestDef(pcx) {
|
|
103
|
+
const symbol = this.handleNestEntry(pcx);
|
|
104
|
+
this.scopes.push(symbol);
|
|
105
|
+
}
|
|
106
|
+
exitNestDef(_pcx) {
|
|
107
|
+
this.popScope();
|
|
108
|
+
}
|
|
109
|
+
enterFieldDef(pcx) {
|
|
110
|
+
const symbol = {
|
|
111
|
+
range: this.translator.rangeFromContext(pcx),
|
|
112
|
+
name: pcx.fieldNameDef().id().text,
|
|
113
|
+
type: "field",
|
|
114
|
+
children: [],
|
|
115
|
+
};
|
|
116
|
+
const parent = this.peekScope();
|
|
117
|
+
if (parent) {
|
|
118
|
+
parent.children.push(symbol);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
enterQueryFieldRef(pcx) {
|
|
122
|
+
const symbol = {
|
|
123
|
+
range: this.translator.rangeFromContext(pcx),
|
|
124
|
+
name: pcx.fieldPath().text,
|
|
125
|
+
type: "field",
|
|
126
|
+
children: [],
|
|
127
|
+
};
|
|
128
|
+
const parent = this.peekScope();
|
|
129
|
+
if (parent) {
|
|
130
|
+
parent.children.push(symbol);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
enterExploreRenameDef(pcx) {
|
|
134
|
+
const symbol = {
|
|
135
|
+
range: this.translator.rangeFromContext(pcx),
|
|
136
|
+
name: pcx.fieldName()[0].text,
|
|
137
|
+
type: "field",
|
|
138
|
+
children: [],
|
|
139
|
+
};
|
|
140
|
+
const parent = this.peekScope();
|
|
141
|
+
if (parent) {
|
|
142
|
+
parent.children.push(symbol);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
enterJoinWith(pcx) {
|
|
146
|
+
this.handleJoinDef(pcx);
|
|
147
|
+
}
|
|
148
|
+
enterJoinOn(pcx) {
|
|
149
|
+
this.handleJoinDef(pcx);
|
|
150
|
+
}
|
|
151
|
+
handleJoinDef(pcx) {
|
|
152
|
+
const symbol = {
|
|
153
|
+
range: this.translator.rangeFromContext(pcx),
|
|
154
|
+
name: pcx.joinNameDef().id().text,
|
|
155
|
+
type: "join",
|
|
156
|
+
children: [],
|
|
157
|
+
};
|
|
158
|
+
const parent = this.peekScope();
|
|
159
|
+
if (parent) {
|
|
160
|
+
parent.children.push(symbol);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
enterDefineSQLStatement(pcx) {
|
|
164
|
+
var _a;
|
|
165
|
+
const name = (_a = pcx.nameSQLBlock()) === null || _a === void 0 ? void 0 : _a.text;
|
|
166
|
+
const symbol = {
|
|
167
|
+
range: this.translator.rangeFromContext(pcx),
|
|
168
|
+
name: name || "unnamed_sql",
|
|
169
|
+
type: name === undefined ? "unnamed_sql" : "sql",
|
|
170
|
+
children: [],
|
|
171
|
+
};
|
|
172
|
+
this.symbols.push(symbol);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function walkForDocumentSymbols(forParse, tokens, parseTree) {
|
|
176
|
+
const finder = new DocumentSymbolWalker(forParse, tokens, [], []);
|
|
177
|
+
const listener = finder;
|
|
178
|
+
ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, parseTree);
|
|
179
|
+
return finder.symbols;
|
|
180
|
+
}
|
|
181
|
+
exports.walkForDocumentSymbols = walkForDocumentSymbols;
|
|
182
|
+
//# sourceMappingURL=document-symbol-walker.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CommonTokenStream } from "antlr4ts";
|
|
2
|
+
import { ParseTree } from "antlr4ts/tree";
|
|
3
|
+
import { MalloyParserListener } from "../lib/Malloy/MalloyParserListener";
|
|
4
|
+
declare type SimpleRange = [number | undefined, number | undefined];
|
|
5
|
+
export interface FilterRef {
|
|
6
|
+
text: string;
|
|
7
|
+
range: SimpleRange;
|
|
8
|
+
}
|
|
9
|
+
export interface FilterList {
|
|
10
|
+
range: SimpleRange;
|
|
11
|
+
}
|
|
12
|
+
export interface ExploreRef {
|
|
13
|
+
text: string;
|
|
14
|
+
range: SimpleRange;
|
|
15
|
+
}
|
|
16
|
+
export interface ExploreClauseRef {
|
|
17
|
+
exploreRef: ExploreRef;
|
|
18
|
+
filterRefs: FilterRef[];
|
|
19
|
+
filterLists: FilterList[];
|
|
20
|
+
range: SimpleRange;
|
|
21
|
+
}
|
|
22
|
+
export declare class ExploreQueryWalker implements MalloyParserListener {
|
|
23
|
+
tokens: CommonTokenStream;
|
|
24
|
+
exploreClauseRefs: ExploreClauseRef[];
|
|
25
|
+
currentExploreClauseRef: ExploreClauseRef | undefined;
|
|
26
|
+
constructor(tokens: CommonTokenStream);
|
|
27
|
+
exploreQueryAtOffset(offset: number): ExploreClauseRef | undefined;
|
|
28
|
+
filterAtOffset(offset: number): FilterRef | undefined;
|
|
29
|
+
hasFilterListAtOffset(offset: number): boolean;
|
|
30
|
+
inDocument: boolean;
|
|
31
|
+
enterMalloyDocument(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare function exploreQueryWalkerBuilder(tokens: CommonTokenStream, parseTree: ParseTree): ExploreQueryWalker;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.exploreQueryWalkerBuilder = exports.ExploreQueryWalker = void 0;
|
|
26
|
+
const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
|
|
27
|
+
class ExploreQueryWalker {
|
|
28
|
+
constructor(tokens) {
|
|
29
|
+
// just to make this compile, no need for this
|
|
30
|
+
this.inDocument = false;
|
|
31
|
+
this.exploreClauseRefs = [];
|
|
32
|
+
this.tokens = tokens;
|
|
33
|
+
}
|
|
34
|
+
exploreQueryAtOffset(offset) {
|
|
35
|
+
return this.exploreClauseRefs.find((ex) => {
|
|
36
|
+
if (ex.range[0] === undefined || ex.range[1] === undefined)
|
|
37
|
+
return false;
|
|
38
|
+
return ex.range[0] <= offset && ex.range[1] >= offset;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
filterAtOffset(offset) {
|
|
42
|
+
const exploreRef = this.exploreQueryAtOffset(offset);
|
|
43
|
+
if (!exploreRef)
|
|
44
|
+
return;
|
|
45
|
+
return exploreRef.filterRefs.find((filterRef) => {
|
|
46
|
+
if (filterRef.range[0] === undefined || filterRef.range[1] === undefined)
|
|
47
|
+
return false;
|
|
48
|
+
return filterRef.range[0] <= offset && filterRef.range[1] >= offset;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
hasFilterListAtOffset(offset) {
|
|
52
|
+
const exploreRef = this.exploreQueryAtOffset(offset);
|
|
53
|
+
if (!exploreRef)
|
|
54
|
+
return false;
|
|
55
|
+
return !!exploreRef.filterLists.find((filterList) => {
|
|
56
|
+
if (filterList.range[0] === undefined ||
|
|
57
|
+
filterList.range[1] === undefined)
|
|
58
|
+
return false;
|
|
59
|
+
return filterList.range[0] <= offset && filterList.range[1] >= offset;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
enterMalloyDocument() {
|
|
63
|
+
this.inDocument = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ExploreQueryWalker = ExploreQueryWalker;
|
|
67
|
+
function exploreQueryWalkerBuilder(tokens, parseTree) {
|
|
68
|
+
const finder = new ExploreQueryWalker(tokens);
|
|
69
|
+
const listener = finder;
|
|
70
|
+
ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, parseTree);
|
|
71
|
+
return finder;
|
|
72
|
+
}
|
|
73
|
+
exports.exploreQueryWalkerBuilder = exploreQueryWalkerBuilder;
|
|
74
|
+
//# sourceMappingURL=explore-query-walker.js.map
|