@mojir/lits 2.1.19 → 2.1.21
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/cli/cli.js +50 -42
- package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +13 -7
- package/dist/cli/src/Lits/Lits.d.ts +1 -1
- package/dist/cli/src/tokenizer/reservedNames.d.ts +1 -39
- package/dist/cli/src/tokenizer/token.d.ts +5 -5
- package/dist/index.esm.js +49 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -41
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +49 -41
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/AutoCompleter/AutoCompleter.d.ts +13 -7
- package/dist/src/Lits/Lits.d.ts +1 -1
- package/dist/src/tokenizer/reservedNames.d.ts +1 -39
- package/dist/src/tokenizer/token.d.ts +5 -5
- package/dist/testFramework.esm.js +49 -41
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +49 -41
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11630,9 +11630,8 @@ var numberReservedSymbolRecord = {
|
|
|
11630
11630
|
'NaN': Number.NaN,
|
|
11631
11631
|
};
|
|
11632
11632
|
var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11633
|
-
var validReservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11634
11633
|
function isReservedSymbol(symbol) {
|
|
11635
|
-
return symbol in
|
|
11634
|
+
return symbol in reservedSymbolRecord;
|
|
11636
11635
|
}
|
|
11637
11636
|
function isNumberReservedSymbol(symbol) {
|
|
11638
11637
|
return symbol in numberReservedSymbolRecord;
|
|
@@ -14861,18 +14860,25 @@ var Parser = /** @class */ (function () {
|
|
|
14861
14860
|
return Parser;
|
|
14862
14861
|
}());
|
|
14863
14862
|
|
|
14864
|
-
var
|
|
14865
|
-
'Operator',
|
|
14866
|
-
'ReservedSymbol',
|
|
14867
|
-
'Symbol',
|
|
14868
|
-
];
|
|
14869
|
-
var litsCommands = new Set(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false));
|
|
14863
|
+
var litsCommands = new Set(__spreadArray(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false), __read(Object.keys(reservedSymbolRecord)), false));
|
|
14870
14864
|
// TODO: replace with get suggestions function
|
|
14871
14865
|
var AutoCompleter = /** @class */ (function () {
|
|
14872
|
-
function AutoCompleter(
|
|
14873
|
-
this.
|
|
14866
|
+
function AutoCompleter(originalProgram, originalPosition, lits, params) {
|
|
14867
|
+
this.originalProgram = originalProgram;
|
|
14868
|
+
this.originalPosition = originalPosition;
|
|
14869
|
+
this.prefixProgram = '';
|
|
14870
|
+
this.suffixProgram = '';
|
|
14871
|
+
this.searchString = '';
|
|
14874
14872
|
this.suggestions = [];
|
|
14875
14873
|
this.suggestionIndex = null;
|
|
14874
|
+
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
14875
|
+
var tokenStream = null;
|
|
14876
|
+
try {
|
|
14877
|
+
tokenStream = lits.tokenize(partialProgram);
|
|
14878
|
+
}
|
|
14879
|
+
catch (_a) {
|
|
14880
|
+
// do nothing
|
|
14881
|
+
}
|
|
14876
14882
|
if (!tokenStream) {
|
|
14877
14883
|
return;
|
|
14878
14884
|
}
|
|
@@ -14880,14 +14886,28 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14880
14886
|
if (!lastToken) {
|
|
14881
14887
|
return;
|
|
14882
14888
|
}
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
this.
|
|
14888
|
-
this.generateSuggestions(params);
|
|
14889
|
+
this.searchString = lastToken[1];
|
|
14890
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
14891
|
+
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14892
|
+
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14893
|
+
this.suggestions = this.generateSuggestions(params);
|
|
14889
14894
|
}
|
|
14890
14895
|
AutoCompleter.prototype.getNextSuggestion = function () {
|
|
14896
|
+
return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol());
|
|
14897
|
+
};
|
|
14898
|
+
AutoCompleter.prototype.getPreviousSuggestion = function () {
|
|
14899
|
+
return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol());
|
|
14900
|
+
};
|
|
14901
|
+
AutoCompleter.prototype.getAutoCompleteSuggestionResult = function (suggestion) {
|
|
14902
|
+
if (suggestion === null) {
|
|
14903
|
+
return null;
|
|
14904
|
+
}
|
|
14905
|
+
return {
|
|
14906
|
+
program: this.prefixProgram + suggestion + this.suffixProgram,
|
|
14907
|
+
position: this.prefixProgram.length + suggestion.length,
|
|
14908
|
+
};
|
|
14909
|
+
};
|
|
14910
|
+
AutoCompleter.prototype.getNextSuggestionSymbol = function () {
|
|
14891
14911
|
if (this.suggestions.length === 0) {
|
|
14892
14912
|
return null;
|
|
14893
14913
|
}
|
|
@@ -14900,12 +14920,9 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14900
14920
|
this.suggestionIndex = 0;
|
|
14901
14921
|
}
|
|
14902
14922
|
}
|
|
14903
|
-
return
|
|
14904
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14905
|
-
searchPattern: this.searchPrefix,
|
|
14906
|
-
};
|
|
14923
|
+
return this.suggestions[this.suggestionIndex];
|
|
14907
14924
|
};
|
|
14908
|
-
AutoCompleter.prototype.
|
|
14925
|
+
AutoCompleter.prototype.getPreviousSuggestionSymbol = function () {
|
|
14909
14926
|
if (this.suggestions.length === 0) {
|
|
14910
14927
|
return null;
|
|
14911
14928
|
}
|
|
@@ -14918,41 +14935,38 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14918
14935
|
this.suggestionIndex = this.suggestions.length - 1;
|
|
14919
14936
|
}
|
|
14920
14937
|
}
|
|
14921
|
-
return
|
|
14922
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14923
|
-
searchPattern: this.searchPrefix,
|
|
14924
|
-
};
|
|
14938
|
+
return this.suggestions[this.suggestionIndex];
|
|
14925
14939
|
};
|
|
14926
14940
|
AutoCompleter.prototype.getSuggestions = function () {
|
|
14927
14941
|
return __spreadArray([], __read(this.suggestions), false);
|
|
14928
14942
|
};
|
|
14929
|
-
AutoCompleter.prototype.
|
|
14930
|
-
return this.
|
|
14943
|
+
AutoCompleter.prototype.getSearchString = function () {
|
|
14944
|
+
return this.searchString;
|
|
14931
14945
|
};
|
|
14932
14946
|
AutoCompleter.prototype.generateSuggestions = function (params) {
|
|
14933
14947
|
var _this = this;
|
|
14934
14948
|
var _a, _b, _c, _d;
|
|
14935
14949
|
var suggestions = new Set();
|
|
14936
14950
|
litsCommands.forEach(function (name) {
|
|
14937
|
-
if (name.startsWith(_this.
|
|
14951
|
+
if (name.startsWith(_this.searchString)) {
|
|
14938
14952
|
suggestions.add(name);
|
|
14939
14953
|
}
|
|
14940
14954
|
});
|
|
14941
14955
|
Object.keys((_a = params.globalContext) !== null && _a !== void 0 ? _a : {})
|
|
14942
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14956
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14943
14957
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14944
14958
|
(_b = params.contexts) === null || _b === void 0 ? void 0 : _b.forEach(function (context) {
|
|
14945
14959
|
Object.keys(context)
|
|
14946
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14960
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14947
14961
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14948
14962
|
});
|
|
14949
14963
|
Object.keys((_c = params.jsFunctions) !== null && _c !== void 0 ? _c : {})
|
|
14950
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14964
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14951
14965
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14952
14966
|
Object.keys((_d = params.values) !== null && _d !== void 0 ? _d : {})
|
|
14953
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14967
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14954
14968
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14955
|
-
|
|
14969
|
+
return __spreadArray([], __read(suggestions), false).sort(function (a, b) { return a.localeCompare(b); });
|
|
14956
14970
|
};
|
|
14957
14971
|
return AutoCompleter;
|
|
14958
14972
|
}());
|
|
@@ -15132,15 +15146,9 @@ var Lits = /** @class */ (function () {
|
|
|
15132
15146
|
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
15133
15147
|
return ast;
|
|
15134
15148
|
};
|
|
15135
|
-
Lits.prototype.getAutoCompleter = function (
|
|
15149
|
+
Lits.prototype.getAutoCompleter = function (program, position, params) {
|
|
15136
15150
|
if (params === void 0) { params = {}; }
|
|
15137
|
-
|
|
15138
|
-
var tokenStream = this.tokenize(partialProgram);
|
|
15139
|
-
return new AutoCompleter(tokenStream, params);
|
|
15140
|
-
}
|
|
15141
|
-
catch (_a) {
|
|
15142
|
-
return new AutoCompleter(null, params);
|
|
15143
|
-
}
|
|
15151
|
+
return new AutoCompleter(program, position, this, params);
|
|
15144
15152
|
};
|
|
15145
15153
|
return Lits;
|
|
15146
15154
|
}());
|