@gooddata/sdk-maql-language-server 0.0.0-stage → 11.65.0-alpha.3
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/LICENSE +7 -0
- package/README.md +118 -2
- package/esm/completions/complete.d.ts +12 -0
- package/esm/completions/complete.d.ts.map +1 -0
- package/esm/completions/complete.js +316 -0
- package/esm/completions/descriptions.d.ts +42 -0
- package/esm/completions/descriptions.d.ts.map +1 -0
- package/esm/completions/descriptions.js +290 -0
- package/esm/completions/findContext.d.ts +19 -0
- package/esm/completions/findContext.d.ts.map +1 -0
- package/esm/completions/findContext.js +172 -0
- package/esm/completions/functionDescriptions.d.ts +3 -0
- package/esm/completions/functionDescriptions.d.ts.map +1 -0
- package/esm/completions/functionDescriptions.js +99 -0
- package/esm/completions/sort.d.ts +4 -0
- package/esm/completions/sort.d.ts.map +1 -0
- package/esm/completions/sort.js +88 -0
- package/esm/constants.d.ts +21 -0
- package/esm/constants.d.ts.map +1 -0
- package/esm/constants.js +22 -0
- package/esm/dateElementFormat.d.ts +9 -0
- package/esm/dateElementFormat.d.ts.map +1 -0
- package/esm/dateElementFormat.js +60 -0
- package/esm/decorations.d.ts +39 -0
- package/esm/decorations.d.ts.map +1 -0
- package/esm/decorations.js +42 -0
- package/esm/diagnostics.d.ts +12 -0
- package/esm/diagnostics.d.ts.map +1 -0
- package/esm/diagnostics.js +260 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/approximate_count.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/approximate_count.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/approximate_count.js +61 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/avg.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/avg.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/avg.js +19 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/count.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/count.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/count.js +72 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/first.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/first.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/first.js +41 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/last.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/last.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/last.js +69 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/max.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/max.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/max.js +61 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/median.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/median.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/median.js +25 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/min.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/min.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/min.js +63 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/sum.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/sum.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/aggregation/sum.js +20 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/case.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/case.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/case.js +73 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/if-then-else.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/if-then-else.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/if-then-else.js +29 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/ifnull.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/ifnull.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/conditionals/ifnull.js +96 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-ranking-filters.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-ranking-filters.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-ranking-filters.js +71 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-having-clause.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-having-clause.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-having-clause.js +65 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-like-clause.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-like-clause.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-like-clause.js +36 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-where-clause.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-where-clause.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/filtering-with-the-where-clause.js +36 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions-except-for-attribute.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions-except-for-attribute.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions-except-for-attribute.js +21 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all-in-all-other-dimensions.js +27 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-all.js +64 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-attribute-all-in-all-other-dimensions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-attribute-all-in-all-other-dimensions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by-attribute-all-in-all-other-dimensions.js +22 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-attribute-filters/by.js +85 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-except.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-except.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-except.js +37 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-filter.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-filter.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/with-parent-filter.js +42 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-except.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-except.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-except.js +94 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-filter.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-filter.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/filters/overriding-parent/without-parent-filter.js +33 -0
- package/esm/docs/en/docs/create-metrics/maql/for-each.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/for-each.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/for-each.js +17 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/and.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/and.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/and.js +37 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/not.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/not.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/not.js +12 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/or.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/or.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/logical-operators/or.js +22 -0
- package/esm/docs/en/docs/create-metrics/maql/maql-and-multidimensionality.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/maql-and-multidimensionality.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/maql-and-multidimensionality.js +59 -0
- package/esm/docs/en/docs/create-metrics/maql/math/abs.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/abs.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/abs.js +23 -0
- package/esm/docs/en/docs/create-metrics/maql/math/arithmetic-operations.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/arithmetic-operations.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/arithmetic-operations.js +29 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ceiling.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ceiling.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ceiling.js +21 -0
- package/esm/docs/en/docs/create-metrics/maql/math/exp.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/exp.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/exp.js +27 -0
- package/esm/docs/en/docs/create-metrics/maql/math/floor.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/floor.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/floor.js +21 -0
- package/esm/docs/en/docs/create-metrics/maql/math/greatest.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/greatest.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/greatest.js +13 -0
- package/esm/docs/en/docs/create-metrics/maql/math/least.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/least.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/least.js +13 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ln.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ln.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/ln.js +33 -0
- package/esm/docs/en/docs/create-metrics/maql/math/log.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/log.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/log.js +29 -0
- package/esm/docs/en/docs/create-metrics/maql/math/power.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/power.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/power.js +33 -0
- package/esm/docs/en/docs/create-metrics/maql/math/round.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/round.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/round.js +34 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sign.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sign.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sign.js +30 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sqrt.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sqrt.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/sqrt.js +32 -0
- package/esm/docs/en/docs/create-metrics/maql/math/trunc.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/math/trunc.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/math/trunc.js +36 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/percentile.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/percentile.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/percentile.js +57 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/rank-variations.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/rank-variations.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/rank-variations.js +90 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-in.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-in.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-in.js +53 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-of.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-of.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/where-top-or-bottom-of.js +29 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/within-clause.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/within-clause.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/ranking/within-clause.js +101 -0
- package/esm/docs/en/docs/create-metrics/maql/relational-operators.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/relational-operators.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/relational-operators.js +50 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/rolling-window.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/rolling-window.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/rolling-window.js +71 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-total-statistical-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-total-statistical-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-total-statistical-functions.js +54 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-totals-for-core-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-totals-for-core-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/runing-totals/running-totals-for-core-functions.js +37 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/correl.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/correl.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/correl.js +47 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/covariance-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/covariance-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/covariance-functions.js +46 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/forecast.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/forecast.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/forecast.js +74 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/least-squares-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/least-squares-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/least-squares-functions.js +44 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/standard-deviation-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/standard-deviation-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/standard-deviation-functions.js +88 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/variance-functions.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/variance-functions.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/statistic/variance-functions.js +54 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-each.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-each.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-each.js +96 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next-period.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next-period.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next-period.js +38 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-next.js +27 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous-period.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous-period.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous-period.js +26 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/for-previous.js +30 -0
- package/esm/docs/en/docs/create-metrics/maql/time/functions-for-referring-to-past-time-periods.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time/functions-for-referring-to-past-time-periods.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time/functions-for-referring-to-past-time-periods.js +36 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-add.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-add.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-add.js +53 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-diff.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-diff.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time-arithmetics/datetime-diff.js +55 -0
- package/esm/docs/en/docs/create-metrics/maql/time-macros.d.ts +2 -0
- package/esm/docs/en/docs/create-metrics/maql/time-macros.d.ts.map +1 -0
- package/esm/docs/en/docs/create-metrics/maql/time-macros.js +79 -0
- package/esm/docs/index.d.ts +77 -0
- package/esm/docs/index.d.ts.map +1 -0
- package/esm/docs/index.js +141 -0
- package/esm/findObjects.d.ts +13 -0
- package/esm/findObjects.d.ts.map +1 -0
- package/esm/findObjects.js +72 -0
- package/esm/format.d.ts +4 -0
- package/esm/format.d.ts.map +1 -0
- package/esm/format.js +581 -0
- package/esm/highlight/convert.d.ts +3 -0
- package/esm/highlight/convert.d.ts.map +1 -0
- package/esm/highlight/convert.js +12 -0
- package/esm/highlight/semanticsHighlight.d.ts +29 -0
- package/esm/highlight/semanticsHighlight.d.ts.map +1 -0
- package/esm/highlight/semanticsHighlight.js +326 -0
- package/esm/highlight/utils.d.ts +3 -0
- package/esm/highlight/utils.d.ts.map +1 -0
- package/esm/highlight/utils.js +14 -0
- package/esm/hover.d.ts +17 -0
- package/esm/hover.d.ts.map +1 -0
- package/esm/hover.js +60 -0
- package/esm/index.d.ts +9 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +7 -0
- package/esm/labelElements.d.ts +22 -0
- package/esm/labelElements.d.ts.map +1 -0
- package/esm/labelElements.js +225 -0
- package/esm/maqlLanguageService.d.ts +51 -0
- package/esm/maqlLanguageService.d.ts.map +1 -0
- package/esm/maqlLanguageService.js +102 -0
- package/esm/maqlObjectTypes.d.ts +15 -0
- package/esm/maqlObjectTypes.d.ts.map +1 -0
- package/esm/maqlObjectTypes.js +28 -0
- package/esm/maqlServer.d.ts +4 -0
- package/esm/maqlServer.d.ts.map +1 -0
- package/esm/maqlServer.js +78 -0
- package/esm/metadata/model.d.ts +116 -0
- package/esm/metadata/model.d.ts.map +1 -0
- package/esm/metadata/model.js +137 -0
- package/esm/metadata/parameters.d.ts +16 -0
- package/esm/metadata/parameters.d.ts.map +1 -0
- package/esm/metadata/parameters.js +38 -0
- package/esm/metadata/types.d.ts +14 -0
- package/esm/metadata/types.d.ts.map +1 -0
- package/esm/metadata/types.js +2 -0
- package/esm/metadataService.d.ts +50 -0
- package/esm/metadataService.d.ts.map +1 -0
- package/esm/metadataService.js +156 -0
- package/esm/node/main.d.ts +2 -0
- package/esm/node/main.d.ts.map +1 -0
- package/esm/node/main.js +18 -0
- package/esm/parameterConstraints.d.ts +5 -0
- package/esm/parameterConstraints.d.ts.map +1 -0
- package/esm/parameterConstraints.js +198 -0
- package/esm/parseMaql.d.ts +43 -0
- package/esm/parseMaql.d.ts.map +1 -0
- package/esm/parseMaql.js +97 -0
- package/esm/renderParameters.d.ts +33 -0
- package/esm/renderParameters.d.ts.map +1 -0
- package/esm/renderParameters.js +72 -0
- package/esm/tests/metadata.test.helpers.d.ts +8 -0
- package/esm/tests/metadata.test.helpers.d.ts.map +1 -0
- package/esm/tests/metadata.test.helpers.js +468 -0
- package/esm/tokenRanges.d.ts +36 -0
- package/esm/tokenRanges.d.ts.map +1 -0
- package/esm/tokenRanges.js +54 -0
- package/esm/types/hierarchy.d.ts +37 -0
- package/esm/types/hierarchy.d.ts.map +1 -0
- package/esm/types/hierarchy.js +165 -0
- package/esm/types/signatures.d.ts +40 -0
- package/esm/types/signatures.d.ts.map +1 -0
- package/esm/types/signatures.js +142 -0
- package/esm/types/typeChecking.d.ts +56 -0
- package/esm/types/typeChecking.d.ts.map +1 -0
- package/esm/types/typeChecking.js +296 -0
- package/esm/types/typeModel.d.ts +18 -0
- package/esm/types/typeModel.d.ts.map +1 -0
- package/esm/types/typeModel.js +84 -0
- package/package.json +89 -3
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// (C) 2021-2026 GoodData Corporation
|
|
2
|
+
import { ParseTreeWalker } from "antlr4ts/tree/index.js";
|
|
3
|
+
import MaqlPkg from "@gooddata/maql-antlr4ts";
|
|
4
|
+
const { AttributeTypeContext, MaqlParser, NumericTypeContext } = MaqlPkg;
|
|
5
|
+
import { isTigerType, tigerIdTypeToObjectType } from "@gooddata/sdk-backend-tiger";
|
|
6
|
+
import { normalizeMaqlObjectType } from "./maqlObjectTypes.js";
|
|
7
|
+
import { MaqlMetric } from "./parseMaql.js";
|
|
8
|
+
import { antlrContextRange } from "./tokenRanges.js";
|
|
9
|
+
export function findAllObjects(metric) {
|
|
10
|
+
const finder = new ObjectFinder();
|
|
11
|
+
ParseTreeWalker.DEFAULT.walk(finder, metric.tree);
|
|
12
|
+
return finder.objects;
|
|
13
|
+
}
|
|
14
|
+
// TODO rewrite using AbstractAstVisitor
|
|
15
|
+
class ObjectFinder {
|
|
16
|
+
objects;
|
|
17
|
+
visitTerminal; // to satisfy TS2559 - weak type detection
|
|
18
|
+
constructor(objects = []) {
|
|
19
|
+
this.objects = objects;
|
|
20
|
+
}
|
|
21
|
+
pushObject(ctx, type) {
|
|
22
|
+
const lbrace = ctx.tryGetToken(MaqlParser.LBRACE, 0);
|
|
23
|
+
const sep = ctx.tryGetToken(MaqlParser.SEP, 0);
|
|
24
|
+
const id = ctx.tryGetToken(MaqlParser.ID, 0);
|
|
25
|
+
const rbrace = ctx.tryGetToken(MaqlParser.RBRACE, 0);
|
|
26
|
+
// check that the object is complete
|
|
27
|
+
if (lbrace === undefined ||
|
|
28
|
+
lbrace.symbol.tokenIndex === -1 ||
|
|
29
|
+
sep === undefined ||
|
|
30
|
+
sep.symbol.tokenIndex === -1 ||
|
|
31
|
+
id === undefined ||
|
|
32
|
+
id.symbol.tokenIndex === -1 ||
|
|
33
|
+
rbrace === undefined ||
|
|
34
|
+
rbrace.symbol.tokenIndex === -1 ||
|
|
35
|
+
type === undefined) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const range = antlrContextRange(ctx.start, ctx.stop);
|
|
39
|
+
// `actualType` keeps the MAQL spelling so diagnostics quote what the author wrote.
|
|
40
|
+
//NOTE: The lexer accepts any casing, so fold it before the type is looked up.
|
|
41
|
+
const tigerType = normalizeMaqlObjectType(type.toLowerCase());
|
|
42
|
+
this.objects.push({
|
|
43
|
+
tigerType: isTigerType(tigerType) ? tigerType : undefined,
|
|
44
|
+
actualType: type,
|
|
45
|
+
id: ctx.ID().text,
|
|
46
|
+
ref: {
|
|
47
|
+
type: tigerIdTypeToObjectType[tigerType],
|
|
48
|
+
identifier: ctx.ID().text,
|
|
49
|
+
},
|
|
50
|
+
range: range,
|
|
51
|
+
offsets: {
|
|
52
|
+
start: MaqlMetric.rawOffset(ctx.start.startIndex),
|
|
53
|
+
end: MaqlMetric.rawOffset((ctx.stop?.stopIndex ?? ctx.start.stopIndex) + 1),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exitAttribute(ctx) {
|
|
58
|
+
this.pushObject(ctx, ctx.tryGetRuleContext(0, AttributeTypeContext)?.text);
|
|
59
|
+
}
|
|
60
|
+
exitNumeric(ctx) {
|
|
61
|
+
this.pushObject(ctx, ctx.tryGetRuleContext(0, NumericTypeContext)?.text);
|
|
62
|
+
}
|
|
63
|
+
exitFact(ctx) {
|
|
64
|
+
this.pushObject(ctx, ctx.tryGetToken(MaqlParser.FACT, 0)?.text);
|
|
65
|
+
}
|
|
66
|
+
exitPrompt(ctx) {
|
|
67
|
+
this.pushObject(ctx, ctx.tryGetToken(MaqlParser.PROMPT, 0)?.text);
|
|
68
|
+
}
|
|
69
|
+
exitParameter(ctx) {
|
|
70
|
+
this.pushObject(ctx, ctx.tryGetToken(MaqlParser.PARAMETER, 0)?.text);
|
|
71
|
+
}
|
|
72
|
+
}
|
package/esm/format.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type FormattingOptions, type Range, TextEdit } from "vscode-languageserver";
|
|
2
|
+
export declare function format(query: string, options: FormattingOptions): TextEdit[];
|
|
3
|
+
export declare function formatRange(query: string, range: Range, options: FormattingOptions): TextEdit[];
|
|
4
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQpG,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,QAAQ,EAAE,CAI5E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,GAAG,QAAQ,EAAE,CAI/F"}
|
package/esm/format.js
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
// (C) 2022-2026 GoodData Corporation
|
|
2
|
+
import { AbstractParseTreeVisitor, } from "antlr4ts/tree/index.js";
|
|
3
|
+
import { TextEdit } from "vscode-languageserver";
|
|
4
|
+
import Maql from "@gooddata/maql-antlr4ts";
|
|
5
|
+
import { TokenTypes, tokenTypeMap } from "./highlight/semanticsHighlight.js";
|
|
6
|
+
import { MaqlMetric } from "./parseMaql.js";
|
|
7
|
+
import { antlrContextRange, tokenRange } from "./tokenRanges.js";
|
|
8
|
+
export function format(query, options) {
|
|
9
|
+
const metric = new MaqlMetric(query);
|
|
10
|
+
const formatter = new MaqlFormatter(options, metric);
|
|
11
|
+
return formatter.visit(metric.tree);
|
|
12
|
+
}
|
|
13
|
+
export function formatRange(query, range, options) {
|
|
14
|
+
const metric = new MaqlMetric(query);
|
|
15
|
+
const formatter = new MaqlFormatter(options, metric, range);
|
|
16
|
+
return formatter.visit(metric.tree);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Automatic formatting for MAQL metrics
|
|
20
|
+
* MaqlFormatter class is a parse tree visitor that analyzes a MAQL metric and finds necessary text edits
|
|
21
|
+
* to transform the metric into the preferred formatting.
|
|
22
|
+
* The found text edits are not sorted. However, they are guaranteed to not be overlapping.
|
|
23
|
+
*
|
|
24
|
+
* The basic principle is to apply a text edit on each token only once. Take this query as an example
|
|
25
|
+
* ```
|
|
26
|
+
* SELECT AVG({fact/budget})
|
|
27
|
+
* WHERE {label/country.code}="US"
|
|
28
|
+
* ```
|
|
29
|
+
* the tokens here would be
|
|
30
|
+
* ```
|
|
31
|
+
* SELECT WS AVG LPAREN <fact tokens> RPAREN WS WHERE WS <label tokens> RELOP STRING
|
|
32
|
+
* ```
|
|
33
|
+
* From the tokens and the MAQL grammar a parse tree is constructed.
|
|
34
|
+
* When traversing the parse tree, edits are added based on the defined rules. If multiple rules should be applied
|
|
35
|
+
* using the same token, the first rule triggered has precedence.
|
|
36
|
+
* Most important are the whitespace (WS) tokens, which are strings of whitespace characters - spaces, new lines, tabs etc.
|
|
37
|
+
*/
|
|
38
|
+
class MaqlFormatter extends AbstractParseTreeVisitor {
|
|
39
|
+
options;
|
|
40
|
+
indentationLevel = 0;
|
|
41
|
+
formattedTokens;
|
|
42
|
+
stream;
|
|
43
|
+
get indentSpaces() {
|
|
44
|
+
return " ".repeat(this.indentationLevel * this.options.tabSize);
|
|
45
|
+
}
|
|
46
|
+
constructor(options, metric, range) {
|
|
47
|
+
super();
|
|
48
|
+
this.options = options;
|
|
49
|
+
this.formattedTokens = new Set();
|
|
50
|
+
this.stream = metric.tokenStream;
|
|
51
|
+
if (range) {
|
|
52
|
+
// if a range is specified do not enter contexts where the intersection with the context range is empty
|
|
53
|
+
this.visit = (tree) => this.visitInRange(tree, range);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
defaultResult() {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
aggregateResult(aggregate, nextResult) {
|
|
60
|
+
return aggregate.concat(nextResult);
|
|
61
|
+
}
|
|
62
|
+
visitInRange(tree, range) {
|
|
63
|
+
const treeRange = antlrContextRange(this.stream.get(tree.sourceInterval.a), this.stream.get(tree.sourceInterval.b)).toRange();
|
|
64
|
+
if (!this.intersects(treeRange, range)) {
|
|
65
|
+
return this.defaultResult();
|
|
66
|
+
}
|
|
67
|
+
return super.visit(tree).filter((edit) => this.intersects(edit.range, range));
|
|
68
|
+
}
|
|
69
|
+
visitChildren(node, firstChild = 0, lastChild = node.childCount - 1) {
|
|
70
|
+
let result = this.defaultResult();
|
|
71
|
+
for (let i = firstChild; i <= lastChild; i++) {
|
|
72
|
+
if (!this.shouldVisitNextChild(node, result)) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
const child = node.getChild(i);
|
|
76
|
+
if (!child)
|
|
77
|
+
continue;
|
|
78
|
+
const childResult = this.visit(child);
|
|
79
|
+
result = this.aggregateResult(result, childResult);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
visitTerminal(node) {
|
|
84
|
+
const token = node.symbol;
|
|
85
|
+
const wsEdits = this.ensureWhitespace(this.getHiddenToLeft(token), undefined, this.indentSpaces);
|
|
86
|
+
const edits = this.formatToken(token);
|
|
87
|
+
return wsEdits.concat(edits);
|
|
88
|
+
}
|
|
89
|
+
visitErrorNode(node) {
|
|
90
|
+
if (node.symbol.tokenIndex === -1)
|
|
91
|
+
return this.defaultResult(); // conjured up symbol -> skip
|
|
92
|
+
return this.visitTerminal(node); // format error nodes anyway if possible
|
|
93
|
+
}
|
|
94
|
+
formatToken(token) {
|
|
95
|
+
if (this.formattedTokens.has(token.tokenIndex))
|
|
96
|
+
return this.defaultResult();
|
|
97
|
+
this.formattedTokens.add(token.tokenIndex);
|
|
98
|
+
const semanticType = tokenTypeMap.get(token.type);
|
|
99
|
+
const edits = [];
|
|
100
|
+
const range = tokenRange(token);
|
|
101
|
+
if (!this.inRange(range) || !token.text)
|
|
102
|
+
return this.defaultResult();
|
|
103
|
+
if (semanticType === TokenTypes.Keyword || semanticType === TokenTypes.Function) {
|
|
104
|
+
const edited = token.text.toUpperCase();
|
|
105
|
+
if (token.text !== edited) {
|
|
106
|
+
edits.push(TextEdit.replace(range, edited));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return edits;
|
|
110
|
+
}
|
|
111
|
+
visitMaqlMeasure = this.visitMaqlQuery;
|
|
112
|
+
visitMaqlComputedAttribute = this.visitMaqlQuery;
|
|
113
|
+
visitMaqlFilter = this.visitMaqlQuery;
|
|
114
|
+
visitMaqlQuery(ctx) {
|
|
115
|
+
const edits = [];
|
|
116
|
+
const eof = ctx.EOF().symbol;
|
|
117
|
+
const eofPosition = tokenRange(eof).start;
|
|
118
|
+
const hidden = this.getHiddenToLeft(eof);
|
|
119
|
+
if (this.options.trimFinalNewlines) {
|
|
120
|
+
const final = this.options.insertFinalNewline ? "\n" : "";
|
|
121
|
+
edits.push(...this.removeWhitespace(hidden, " ", final));
|
|
122
|
+
}
|
|
123
|
+
else if (this.options.insertFinalNewline) {
|
|
124
|
+
edits.push(...this.ensureNewline(hidden, eofPosition));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
edits.push(...this.ensureWhitespace(hidden, "", "", eofPosition));
|
|
128
|
+
}
|
|
129
|
+
edits.push(...this.visitChildren(ctx));
|
|
130
|
+
return edits;
|
|
131
|
+
}
|
|
132
|
+
visitFunctionCall = this.visitFunctionCallCommon;
|
|
133
|
+
visitFunctionCallRun(ctx) {
|
|
134
|
+
const edits = [];
|
|
135
|
+
edits.push(...this.visitFunctionCallCommon(ctx));
|
|
136
|
+
const withinCtx = ctx.within();
|
|
137
|
+
if (withinCtx) {
|
|
138
|
+
edits.push(...this.visitFunctionCallClause(withinCtx));
|
|
139
|
+
}
|
|
140
|
+
const rollWindowCtx = ctx.rollWindow();
|
|
141
|
+
if (rollWindowCtx) {
|
|
142
|
+
edits.push(...this.visitFunctionCallClause(rollWindowCtx));
|
|
143
|
+
}
|
|
144
|
+
return edits;
|
|
145
|
+
}
|
|
146
|
+
visitFunctionCallRank(ctx) {
|
|
147
|
+
const edits = [];
|
|
148
|
+
edits.push(...this.visitFunctionCallCommon(ctx));
|
|
149
|
+
const rankDirCtx = ctx.rankDir();
|
|
150
|
+
if (rankDirCtx) {
|
|
151
|
+
edits.push(...this.visitFunctionCallClause(rankDirCtx));
|
|
152
|
+
}
|
|
153
|
+
const withinCtx = ctx.within();
|
|
154
|
+
if (withinCtx) {
|
|
155
|
+
edits.push(...this.visitFunctionCallClause(withinCtx));
|
|
156
|
+
}
|
|
157
|
+
return edits;
|
|
158
|
+
}
|
|
159
|
+
visitFunctionCallLastFirstValue(ctx) {
|
|
160
|
+
const edits = [];
|
|
161
|
+
edits.push(...this.visitFunctionCallCommon(ctx));
|
|
162
|
+
const orderByCtx = ctx.orderby();
|
|
163
|
+
if (orderByCtx) {
|
|
164
|
+
edits.push(...this.visitFunctionCallClause(orderByCtx));
|
|
165
|
+
}
|
|
166
|
+
const withinCtx = ctx.within();
|
|
167
|
+
if (withinCtx) {
|
|
168
|
+
edits.push(...this.visitFunctionCallClause(withinCtx));
|
|
169
|
+
}
|
|
170
|
+
return edits;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Ensure new line before function modifying clauses e.g. WITHIN
|
|
174
|
+
*/
|
|
175
|
+
visitFunctionCallClause(ctx) {
|
|
176
|
+
const edits = [];
|
|
177
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(ctx.start), tokenRange(ctx.start).start));
|
|
178
|
+
edits.push(...this.visit(ctx));
|
|
179
|
+
return edits;
|
|
180
|
+
}
|
|
181
|
+
visitFunctionCallCommon(ctx) {
|
|
182
|
+
const edits = [];
|
|
183
|
+
edits.push(...this.visit(ctx.getChild(0)));
|
|
184
|
+
const lparen = ctx.tryGetToken(Maql.MaqlParser.LPAREN, 0)?.symbol;
|
|
185
|
+
if (lparen) {
|
|
186
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(lparen)));
|
|
187
|
+
}
|
|
188
|
+
if (lparen) {
|
|
189
|
+
edits.push(...this.ensureWhitespace(this.getHiddenToRight(lparen), "", undefined, tokenRange(lparen).end));
|
|
190
|
+
}
|
|
191
|
+
this.indent();
|
|
192
|
+
const argsCtx = ctx.tryGetRuleContext(0, Maql.ExpressionListContext) ??
|
|
193
|
+
ctx.tryGetRuleContext(0, Maql.MaqlExpressionContext);
|
|
194
|
+
if (argsCtx) {
|
|
195
|
+
edits.push(...this.visit(argsCtx));
|
|
196
|
+
}
|
|
197
|
+
const rparen = ctx.tryGetToken(Maql.MaqlParser.RPAREN, 0)?.symbol;
|
|
198
|
+
if (rparen) {
|
|
199
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(rparen)));
|
|
200
|
+
}
|
|
201
|
+
this.dedent();
|
|
202
|
+
if (rparen) {
|
|
203
|
+
edits.push(...this.visit(ctx.RPAREN()));
|
|
204
|
+
}
|
|
205
|
+
return edits;
|
|
206
|
+
}
|
|
207
|
+
visitTimeMacro(ctx) {
|
|
208
|
+
const edits = [];
|
|
209
|
+
edits.push(...this.visit(ctx.getChild(0)));
|
|
210
|
+
const lparen = ctx.LPAREN().symbol;
|
|
211
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(lparen)));
|
|
212
|
+
edits.push(...this.ensureWhitespace(this.getHiddenToRight(lparen), "", undefined, tokenRange(lparen).end));
|
|
213
|
+
this.indent();
|
|
214
|
+
const rparen = ctx.RPAREN().symbol;
|
|
215
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(rparen)));
|
|
216
|
+
this.dedent();
|
|
217
|
+
edits.push(...this.visit(ctx.RPAREN()));
|
|
218
|
+
const comma = ctx.COMMA()?.symbol;
|
|
219
|
+
if (comma) {
|
|
220
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(comma)));
|
|
221
|
+
const commaRange = tokenRange(comma);
|
|
222
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(comma), commaRange.end));
|
|
223
|
+
}
|
|
224
|
+
edits.push(...this.visit(ctx.granularity()));
|
|
225
|
+
const amountCtx = ctx.integer();
|
|
226
|
+
if (amountCtx) {
|
|
227
|
+
edits.push(...this.visit(amountCtx));
|
|
228
|
+
}
|
|
229
|
+
return edits;
|
|
230
|
+
}
|
|
231
|
+
visitExpressionList(ctx) {
|
|
232
|
+
const edits = [];
|
|
233
|
+
const commaContext = ctx.COMMA();
|
|
234
|
+
const commas = (Array.isArray(commaContext) ? commaContext : [commaContext])
|
|
235
|
+
.map((c) => c?.symbol)
|
|
236
|
+
.filter((c) => c !== undefined);
|
|
237
|
+
for (const comma of commas) {
|
|
238
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(comma)));
|
|
239
|
+
const commaRange = tokenRange(comma);
|
|
240
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(comma), commaRange.end));
|
|
241
|
+
}
|
|
242
|
+
edits.push(...this.visitChildren(ctx));
|
|
243
|
+
return edits;
|
|
244
|
+
}
|
|
245
|
+
visitDisjunction(ctx) {
|
|
246
|
+
return this.visitLogicalOperatorExpression(ctx, () => ctx.OR());
|
|
247
|
+
}
|
|
248
|
+
visitConjunction(ctx) {
|
|
249
|
+
return this.visitLogicalOperatorExpression(ctx, () => ctx.AND());
|
|
250
|
+
}
|
|
251
|
+
visitLogicalOperatorExpression(ctx, ops) {
|
|
252
|
+
const edits = [];
|
|
253
|
+
for (const opNode of ops()) {
|
|
254
|
+
const op = opNode.symbol;
|
|
255
|
+
const opRange = tokenRange(op);
|
|
256
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(op), opRange.start));
|
|
257
|
+
edits.push(...this.removeWhitespace(this.getHiddenToRight(op), " ", " ", opRange.end));
|
|
258
|
+
}
|
|
259
|
+
edits.push(...this.visitChildren(ctx));
|
|
260
|
+
return edits;
|
|
261
|
+
}
|
|
262
|
+
visitAddition(ctx) {
|
|
263
|
+
return this.visitArithmeticOperatorExpression(ctx, () => ctx
|
|
264
|
+
.additiveOperator()
|
|
265
|
+
.map((it) => it.PLUS() ?? it.MINUS())
|
|
266
|
+
.filter((it) => !!it));
|
|
267
|
+
}
|
|
268
|
+
visitMultiplication(ctx) {
|
|
269
|
+
return this.visitArithmeticOperatorExpression(ctx, () => ctx
|
|
270
|
+
.multiplicativeOperator()
|
|
271
|
+
.map((it) => it.MUL() ?? it.DIV())
|
|
272
|
+
.filter((it) => !!it));
|
|
273
|
+
}
|
|
274
|
+
visitArithmeticOperatorExpression(ctx, ops) {
|
|
275
|
+
const edits = [];
|
|
276
|
+
for (const opNode of ops()) {
|
|
277
|
+
const op = opNode.symbol;
|
|
278
|
+
const opRange = tokenRange(op);
|
|
279
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(op), opRange.start));
|
|
280
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(op), opRange.end));
|
|
281
|
+
}
|
|
282
|
+
edits.push(...this.visitChildren(ctx));
|
|
283
|
+
return edits;
|
|
284
|
+
}
|
|
285
|
+
visitRelationRelop(ctx) {
|
|
286
|
+
const edits = [];
|
|
287
|
+
const relop = ctx.RELOP().symbol;
|
|
288
|
+
const relopRange = tokenRange(relop);
|
|
289
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(relop), relopRange.start));
|
|
290
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(relop), relopRange.end));
|
|
291
|
+
edits.push(...this.visitChildren(ctx));
|
|
292
|
+
return edits;
|
|
293
|
+
}
|
|
294
|
+
visitRelationLike(ctx) {
|
|
295
|
+
const edits = [];
|
|
296
|
+
const likeCtx = ctx.like();
|
|
297
|
+
const item = likeCtx.LIKE() || likeCtx.ILIKE();
|
|
298
|
+
const like = item.symbol;
|
|
299
|
+
const likeRange = tokenRange(like);
|
|
300
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(like), likeRange.start));
|
|
301
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(like), likeRange.end));
|
|
302
|
+
edits.push(...this.visit(likeCtx));
|
|
303
|
+
return edits;
|
|
304
|
+
}
|
|
305
|
+
visitRelationBetween(ctx) {
|
|
306
|
+
const edits = [];
|
|
307
|
+
const between = ctx.BETWEEN().symbol;
|
|
308
|
+
const betweenRange = tokenRange(between);
|
|
309
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(between), betweenRange.start));
|
|
310
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(between), betweenRange.end));
|
|
311
|
+
const and = ctx.AND().symbol;
|
|
312
|
+
const andRange = tokenRange(and);
|
|
313
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(and), andRange.start));
|
|
314
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(and), andRange.end));
|
|
315
|
+
edits.push(...this.visitChildren(ctx));
|
|
316
|
+
return edits;
|
|
317
|
+
}
|
|
318
|
+
visitRelationNot(ctx) {
|
|
319
|
+
const not = ctx.NOT();
|
|
320
|
+
const edits = [];
|
|
321
|
+
if (not) {
|
|
322
|
+
const token = not.symbol;
|
|
323
|
+
const range = tokenRange(token);
|
|
324
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(token), range.start));
|
|
325
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(token), range.end));
|
|
326
|
+
edits.push(...this.visit(not));
|
|
327
|
+
}
|
|
328
|
+
edits.push(...this.visit(ctx.relationNegatable()));
|
|
329
|
+
return edits;
|
|
330
|
+
}
|
|
331
|
+
visitRelationIn(ctx) {
|
|
332
|
+
const edits = [];
|
|
333
|
+
const int = ctx.IN().symbol;
|
|
334
|
+
const range = tokenRange(int);
|
|
335
|
+
edits.push(...this.ensureSpace(this.getHiddenToLeft(int), range.start));
|
|
336
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(int), range.end));
|
|
337
|
+
edits.push(...this.visit(ctx.IN()));
|
|
338
|
+
const lparen = ctx.LPAREN().symbol;
|
|
339
|
+
const lparenRange = tokenRange(lparen);
|
|
340
|
+
if (ctx.listLiteral() === undefined) {
|
|
341
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(ctx.RPAREN().symbol)));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
this.indent();
|
|
345
|
+
edits.push(...this.ensureNewline(this.getHiddenToRight(lparen), lparenRange.end));
|
|
346
|
+
edits.push(...this.visitChildren(ctx, 1, ctx.childCount - 2));
|
|
347
|
+
this.dedent();
|
|
348
|
+
}
|
|
349
|
+
edits.push(...this.visit(ctx.RPAREN()));
|
|
350
|
+
return edits;
|
|
351
|
+
}
|
|
352
|
+
visitSelectExpression(ctx) {
|
|
353
|
+
const edits = [];
|
|
354
|
+
const select = ctx.SELECT().symbol;
|
|
355
|
+
const selectRange = tokenRange(select);
|
|
356
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(select), selectRange.start));
|
|
357
|
+
edits.push(...this.visit(ctx.SELECT()));
|
|
358
|
+
this.indent();
|
|
359
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(select), selectRange.end));
|
|
360
|
+
edits.push(...this.visitChildren(ctx, 1));
|
|
361
|
+
this.dedent();
|
|
362
|
+
return edits;
|
|
363
|
+
}
|
|
364
|
+
visitBy(ctx) {
|
|
365
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.BY());
|
|
366
|
+
}
|
|
367
|
+
visitForEach(ctx) {
|
|
368
|
+
const edits = [];
|
|
369
|
+
const forEach = ctx.FOR().symbol;
|
|
370
|
+
const forEachRange = tokenRange(forEach);
|
|
371
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(forEach), forEachRange.start));
|
|
372
|
+
this.indent();
|
|
373
|
+
edits.push(...this.visitChildren(ctx, 1));
|
|
374
|
+
this.dedent();
|
|
375
|
+
return edits;
|
|
376
|
+
}
|
|
377
|
+
visitForTransformation(ctx) {
|
|
378
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.FOR());
|
|
379
|
+
}
|
|
380
|
+
visitWhere(ctx) {
|
|
381
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.WHERE());
|
|
382
|
+
}
|
|
383
|
+
visitHaving(ctx) {
|
|
384
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.HAVING());
|
|
385
|
+
}
|
|
386
|
+
visitUsing(ctx) {
|
|
387
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.USING());
|
|
388
|
+
}
|
|
389
|
+
visitWithPf(ctx) {
|
|
390
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.WITH());
|
|
391
|
+
}
|
|
392
|
+
visitWithoutPf(ctx) {
|
|
393
|
+
return this.visitKeywordOfStatement(ctx, () => ctx.WITHOUT());
|
|
394
|
+
}
|
|
395
|
+
visitKeywordOfStatement(ctx, keyword) {
|
|
396
|
+
const edits = [];
|
|
397
|
+
const kw = keyword().symbol;
|
|
398
|
+
const kwRange = tokenRange(kw);
|
|
399
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(kw), kwRange.start));
|
|
400
|
+
edits.push(...this.ensureSpace(this.getHiddenToRight(kw), kwRange.end));
|
|
401
|
+
edits.push(...this.visit(keyword()));
|
|
402
|
+
edits.push(...this.visitChildren(ctx, 1));
|
|
403
|
+
return edits;
|
|
404
|
+
}
|
|
405
|
+
visitAttributeList(ctx) {
|
|
406
|
+
return this.visitNewlineSeparatedCommaList(ctx);
|
|
407
|
+
}
|
|
408
|
+
// oxlint-disable-next-line sonarjs/no-identical-functions -- distinct ANTLR visitor override with intentionally identical formatting behavior
|
|
409
|
+
visitListLiteral(ctx) {
|
|
410
|
+
return this.visitNewlineSeparatedCommaList(ctx);
|
|
411
|
+
}
|
|
412
|
+
visitNewlineSeparatedCommaList(ctx) {
|
|
413
|
+
const edits = [];
|
|
414
|
+
for (const comma of ctx.COMMA()) {
|
|
415
|
+
const token = comma.symbol;
|
|
416
|
+
edits.push(...this.removeWhitespace(this.getHiddenToLeft(token)));
|
|
417
|
+
edits.push(...this.ensureNewline(this.getHiddenToRight(token), tokenRange(token).end));
|
|
418
|
+
}
|
|
419
|
+
edits.push(...this.visitChildren(ctx));
|
|
420
|
+
return edits;
|
|
421
|
+
}
|
|
422
|
+
visitIf(ctx) {
|
|
423
|
+
const edits = [];
|
|
424
|
+
edits.push(...this.visit(ctx.IF()));
|
|
425
|
+
edits.push(...this.visitElse(ctx));
|
|
426
|
+
return edits;
|
|
427
|
+
}
|
|
428
|
+
visitCase(ctx) {
|
|
429
|
+
const edits = [];
|
|
430
|
+
edits.push(...this.visit(ctx.CASE()));
|
|
431
|
+
edits.push(...this.visitElse(ctx));
|
|
432
|
+
return edits;
|
|
433
|
+
}
|
|
434
|
+
visitElse(ctx) {
|
|
435
|
+
const edits = [];
|
|
436
|
+
this.indent();
|
|
437
|
+
const elseCtx = ctx.ELSE();
|
|
438
|
+
if (elseCtx) {
|
|
439
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(elseCtx.symbol), tokenRange(elseCtx.symbol).start));
|
|
440
|
+
edits.push(...this.visit(elseCtx));
|
|
441
|
+
}
|
|
442
|
+
edits.push(...this.visitChildren(ctx, 1, ctx.childCount - 2));
|
|
443
|
+
this.dedent();
|
|
444
|
+
const end = ctx.END()?.symbol;
|
|
445
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(end), tokenRange(end).start));
|
|
446
|
+
edits.push(...this.visit(ctx.END()));
|
|
447
|
+
return edits;
|
|
448
|
+
}
|
|
449
|
+
visitCaseConditional(ctx) {
|
|
450
|
+
const edits = this.defaultResult();
|
|
451
|
+
for (const when of ctx.WHEN()) {
|
|
452
|
+
const token = when.symbol;
|
|
453
|
+
edits.push(...this.ensureNewline(this.getHiddenToLeft(token), tokenRange(token).start));
|
|
454
|
+
}
|
|
455
|
+
edits.push(...this.visitChildren(ctx));
|
|
456
|
+
return edits;
|
|
457
|
+
}
|
|
458
|
+
visitTransFunction(ctx) {
|
|
459
|
+
const token = ctx.NEXT() ?? ctx.NEXTPERIOD() ?? ctx.PREVIOUS() ?? ctx.PREVIOUSPERIOD();
|
|
460
|
+
const text = token?.text;
|
|
461
|
+
const edited = text ? formatTransFunction(text) : undefined;
|
|
462
|
+
if (!token || !edited || text === edited)
|
|
463
|
+
return this.defaultResult();
|
|
464
|
+
const range = tokenRange(token.symbol);
|
|
465
|
+
if (!this.inRange(range))
|
|
466
|
+
return this.defaultResult();
|
|
467
|
+
return [TextEdit.replace(range, edited)];
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Shortens whitespace, trims trailing spaces, inserts string at the start of the last line
|
|
471
|
+
* @param whitespace - is assumed to be the token text of a MaqlParser.WS token
|
|
472
|
+
* @param finalInline - is the value to be used if there are no line breaks in the whitespace
|
|
473
|
+
* if undefined then by default trim the whitespace to at most one space
|
|
474
|
+
* @param finalNewline - is the value to be after the last line break
|
|
475
|
+
*/
|
|
476
|
+
formatWhitespace(whitespace, finalInline, finalNewline) {
|
|
477
|
+
const lines = whitespace.split("\n");
|
|
478
|
+
if (lines.length === 1)
|
|
479
|
+
return finalInline === undefined ? (whitespace.length > 0 ? " " : "") : finalInline;
|
|
480
|
+
if (this.options.trimTrailingWhitespace) {
|
|
481
|
+
lines.slice(0, -1).forEach((_, idx) => (lines[idx] = ""));
|
|
482
|
+
}
|
|
483
|
+
if (finalNewline !== undefined) {
|
|
484
|
+
lines[lines.length - 1] = finalNewline;
|
|
485
|
+
}
|
|
486
|
+
return lines.join("\n");
|
|
487
|
+
}
|
|
488
|
+
ensureWhitespace(tokens, finalInline, finalNewline, position) {
|
|
489
|
+
if (tokens.length === 0 && finalInline) {
|
|
490
|
+
return [TextEdit.insert(position, finalInline)];
|
|
491
|
+
}
|
|
492
|
+
return tokens
|
|
493
|
+
.map((token) => {
|
|
494
|
+
if (!token.text || this.formattedTokens.has(token.tokenIndex))
|
|
495
|
+
return null;
|
|
496
|
+
if (token.type === Maql.MaqlParser.WS) {
|
|
497
|
+
const range = tokenRange(token);
|
|
498
|
+
const edited = this.formatWhitespace(token.text, finalInline, finalNewline);
|
|
499
|
+
if (token.text !== edited) {
|
|
500
|
+
this.formattedTokens.add(token.tokenIndex);
|
|
501
|
+
return TextEdit.replace(range, edited);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return null;
|
|
505
|
+
})
|
|
506
|
+
.filter((edit) => !!edit);
|
|
507
|
+
}
|
|
508
|
+
ensureSpace(tokens, position) {
|
|
509
|
+
return this.ensureWhitespace(tokens, " ", this.indentSpaces, position);
|
|
510
|
+
}
|
|
511
|
+
ensureNewline(tokens, position) {
|
|
512
|
+
return this.ensureWhitespace(tokens, "\n" + this.indentSpaces, this.indentSpaces, position);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Removes all whitespace if there are no preceding line comments
|
|
516
|
+
*/
|
|
517
|
+
removeWhitespace(tokens, separator = " ", final = "", position) {
|
|
518
|
+
if (tokens.length === 0 && position && final !== "") {
|
|
519
|
+
return [TextEdit.insert(position, final)];
|
|
520
|
+
}
|
|
521
|
+
let prevIsLineComment = false;
|
|
522
|
+
const edits = this.defaultResult();
|
|
523
|
+
tokens.forEach((token, idx) => {
|
|
524
|
+
if (!token.text || this.formattedTokens.has(token.tokenIndex))
|
|
525
|
+
return;
|
|
526
|
+
this.formattedTokens.add(token.tokenIndex);
|
|
527
|
+
if (token.type === Maql.MaqlParser.WS) {
|
|
528
|
+
const range = tokenRange(token);
|
|
529
|
+
const edited = prevIsLineComment
|
|
530
|
+
? "\n" + this.indentSpaces
|
|
531
|
+
: idx < tokens.length - 1
|
|
532
|
+
? separator
|
|
533
|
+
: final;
|
|
534
|
+
if (token.text !== edited) {
|
|
535
|
+
edits.push(TextEdit.replace(range, edited));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
prevIsLineComment = token.type === Maql.MaqlParser.Comment;
|
|
539
|
+
});
|
|
540
|
+
return edits;
|
|
541
|
+
}
|
|
542
|
+
indent() {
|
|
543
|
+
this.indentationLevel += 1;
|
|
544
|
+
}
|
|
545
|
+
dedent() {
|
|
546
|
+
this.indentationLevel -= 1;
|
|
547
|
+
}
|
|
548
|
+
inRange(range) {
|
|
549
|
+
return range.start.line >= 0; // skip "PARSE METRIC\n"
|
|
550
|
+
}
|
|
551
|
+
intersects(a, b) {
|
|
552
|
+
const { start: startA, end: endA } = a;
|
|
553
|
+
const { start: startB, end: endB } = b;
|
|
554
|
+
return ((endA.line > startB.line || (endA.line === startB.line && endA.character > startB.character)) &&
|
|
555
|
+
(startA.line < endB.line || (startA.line === endB.line && startA.character < endB.character)));
|
|
556
|
+
}
|
|
557
|
+
getHiddenToLeft(token) {
|
|
558
|
+
if (token.tokenIndex < 0 || token.tokenIndex >= this.stream.size)
|
|
559
|
+
return [];
|
|
560
|
+
return this.stream.getHiddenTokensToLeft(token.tokenIndex, -1);
|
|
561
|
+
}
|
|
562
|
+
getHiddenToRight(token) {
|
|
563
|
+
if (token.tokenIndex < 0 || token.tokenIndex >= this.stream.size)
|
|
564
|
+
return [];
|
|
565
|
+
return this.stream.getHiddenTokensToRight(token.tokenIndex, -1);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function formatTransFunction(func) {
|
|
569
|
+
switch (func.toUpperCase()) {
|
|
570
|
+
case "NEXT":
|
|
571
|
+
return "Next";
|
|
572
|
+
case "NEXTPERIOD":
|
|
573
|
+
return "NextPeriod";
|
|
574
|
+
case "PREVIOUS":
|
|
575
|
+
return "Previous";
|
|
576
|
+
case "PREVIOUSPERIOD":
|
|
577
|
+
return "PreviousPeriod";
|
|
578
|
+
default:
|
|
579
|
+
return func.charAt(0).toUpperCase() + func.slice(1);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/highlight/convert.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AAGpF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,cAAc,EAAE,kDAa/D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// (C) 2023-2026 GoodData Corporation
|
|
2
|
+
import { SemanticTokensBuilder } from "vscode-languageserver";
|
|
3
|
+
import { semanticTokensLegend } from "./semanticsHighlight.js";
|
|
4
|
+
import { getModifiers, getType } from "./utils.js";
|
|
5
|
+
export function convertToSemanticTokens(tokens) {
|
|
6
|
+
const builder = new SemanticTokensBuilder();
|
|
7
|
+
tokens.forEach(({ position, type, modifiers }) => {
|
|
8
|
+
const length = position.end.character - position.start.character;
|
|
9
|
+
builder.push(position.start.line, position.start.character, length, getType(semanticTokensLegend.tokenTypes, type), getModifiers(semanticTokensLegend.tokenModifiers, modifiers));
|
|
10
|
+
});
|
|
11
|
+
return builder.build();
|
|
12
|
+
}
|