@malloydata/malloy 0.0.259 → 0.0.260-dev250410011722
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.
|
@@ -9,5 +9,9 @@ export interface ErrorCase {
|
|
|
9
9
|
errorMessage: string;
|
|
10
10
|
lookbackSiblingRuleOptions?: number[];
|
|
11
11
|
predecessorHasAncestorRule?: number;
|
|
12
|
+
alternatives?: {
|
|
13
|
+
replace: string;
|
|
14
|
+
with: string[];
|
|
15
|
+
};
|
|
12
16
|
}
|
|
13
17
|
export declare const checkCustomErrorMessage: (parser: Parser, offendingSymbol: Token | undefined, errorCases: ErrorCase[]) => string;
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.checkCustomErrorMessage = void 0;
|
|
13
|
+
const jaro_winkler_1 = __importDefault(require("jaro-winkler"));
|
|
10
14
|
const checkCustomErrorMessage = (parser, offendingSymbol, errorCases) => {
|
|
11
15
|
var _a, _b;
|
|
12
16
|
const currentRuleName = parser.getRuleInvocationStack()[0];
|
|
@@ -58,16 +62,29 @@ const checkCustomErrorMessage = (parser, offendingSymbol, errorCases) => {
|
|
|
58
62
|
continue;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
65
|
+
const errReplace = (s) => {
|
|
66
|
+
const rs = s
|
|
67
|
+
.replace('${currentToken}', currentToken.text || '')
|
|
68
|
+
.replace('${offendingSymbol}', (offendingSymbol === null || offendingSymbol === void 0 ? void 0 : offendingSymbol.text) || '');
|
|
69
|
+
try {
|
|
70
|
+
const previousToken = parser.inputStream.LT(-1);
|
|
71
|
+
return rs.replace('${previousToken}', previousToken.text || '');
|
|
72
|
+
}
|
|
73
|
+
catch (ex) {
|
|
74
|
+
// This shouldn't ever occur, but if it does, just leave the untokenized message.
|
|
75
|
+
}
|
|
76
|
+
return rs;
|
|
77
|
+
};
|
|
61
78
|
// If all cases match, return the custom error message
|
|
62
|
-
let message = errorCase.errorMessage
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
let message = errReplace(errorCase.errorMessage);
|
|
80
|
+
if (errorCase.alternatives) {
|
|
81
|
+
const badWord = errReplace(errorCase.alternatives.replace);
|
|
82
|
+
const distances = {};
|
|
83
|
+
for (const w of errorCase.alternatives.with) {
|
|
84
|
+
distances[w] = (0, jaro_winkler_1.default)(w, badWord);
|
|
85
|
+
}
|
|
86
|
+
const picks = errorCase.alternatives.with.sort((a, b) => distances[b] - distances[a]);
|
|
87
|
+
message += ` Did you mean '${picks[0]}'?`;
|
|
71
88
|
}
|
|
72
89
|
return message;
|
|
73
90
|
}
|
|
@@ -140,6 +140,36 @@ exports.malloyCustomErrorCases = [
|
|
|
140
140
|
],
|
|
141
141
|
ruleContextOptions: ['queryStatement'],
|
|
142
142
|
},
|
|
143
|
+
{
|
|
144
|
+
errorMessage: "Expected a query statement, '${offendingSymbol}:' is not a keyword.",
|
|
145
|
+
ruleContextOptions: ['queryStatement'],
|
|
146
|
+
offendingSymbol: MalloyParser_1.MalloyParser.IDENTIFIER,
|
|
147
|
+
lookAheadOptions: [[MalloyParser_1.MalloyParser.COLON, MalloyParser_1.MalloyParser.IDENTIFIER]],
|
|
148
|
+
alternatives: {
|
|
149
|
+
replace: '${offendingSymbol}:',
|
|
150
|
+
with: ['group_by:', 'select:', 'aggregate:', 'calculate:', 'nest:'],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
errorMessage: "Expected a source statement, '${offendingSymbol}:' is not a keyword.",
|
|
155
|
+
ruleContextOptions: ['exploreStatement'],
|
|
156
|
+
offendingSymbol: MalloyParser_1.MalloyParser.IDENTIFIER,
|
|
157
|
+
lookAheadOptions: [[MalloyParser_1.MalloyParser.COLON, MalloyParser_1.MalloyParser.IDENTIFIER]],
|
|
158
|
+
alternatives: {
|
|
159
|
+
replace: '${offendingSymbol}:',
|
|
160
|
+
with: ['dimension:', 'measure:', 'primary_key:', 'view:', 'join:'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
errorMessage: "Expected a statement, '${offendingSymbol}:' is not a keyword.",
|
|
165
|
+
ruleContextOptions: ['malloyDocument'],
|
|
166
|
+
offendingSymbol: MalloyParser_1.MalloyParser.IDENTIFIER,
|
|
167
|
+
lookAheadOptions: [[MalloyParser_1.MalloyParser.COLON, MalloyParser_1.MalloyParser.IDENTIFIER]],
|
|
168
|
+
alternatives: {
|
|
169
|
+
replace: '${offendingSymbol}:',
|
|
170
|
+
with: ['run:', 'query:', 'source:'],
|
|
171
|
+
},
|
|
172
|
+
},
|
|
143
173
|
];
|
|
144
174
|
class MalloyParserErrorListener {
|
|
145
175
|
constructor(
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.260";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.260';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.260-dev250410011722",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,17 +41,19 @@
|
|
|
41
41
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "^0.0.
|
|
45
|
-
"@malloydata/malloy-interfaces": "^0.0.
|
|
46
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
44
|
+
"@malloydata/malloy-filter": "^0.0.260-dev250410011722",
|
|
45
|
+
"@malloydata/malloy-interfaces": "^0.0.260-dev250410011722",
|
|
46
|
+
"@malloydata/malloy-tag": "^0.0.260-dev250410011722",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
|
+
"jaro-winkler": "^0.2.8",
|
|
49
50
|
"jest-diff": "^29.6.2",
|
|
50
51
|
"lodash": "^4.17.20",
|
|
51
52
|
"luxon": "^2.4.0",
|
|
52
53
|
"uuid": "^8.3.2"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
56
|
+
"@types/jaro-winkler": "^0.2.3",
|
|
55
57
|
"@types/lodash": "^4.14.165",
|
|
56
58
|
"@types/luxon": "^2.4.0",
|
|
57
59
|
"antlr4ts-cli": "^0.5.0-alpha.4"
|