@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/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.1.
|
|
95
|
+
var version = "2.1.21";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -11706,9 +11706,8 @@ var numberReservedSymbolRecord = {
|
|
|
11706
11706
|
'NaN': Number.NaN,
|
|
11707
11707
|
};
|
|
11708
11708
|
var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11709
|
-
var validReservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11710
11709
|
function isReservedSymbol(symbol) {
|
|
11711
|
-
return symbol in
|
|
11710
|
+
return symbol in reservedSymbolRecord;
|
|
11712
11711
|
}
|
|
11713
11712
|
function isNumberReservedSymbol(symbol) {
|
|
11714
11713
|
return symbol in numberReservedSymbolRecord;
|
|
@@ -14822,18 +14821,25 @@ var Parser = /** @class */ (function () {
|
|
|
14822
14821
|
return Parser;
|
|
14823
14822
|
}());
|
|
14824
14823
|
|
|
14825
|
-
var
|
|
14826
|
-
'Operator',
|
|
14827
|
-
'ReservedSymbol',
|
|
14828
|
-
'Symbol',
|
|
14829
|
-
];
|
|
14830
|
-
var litsCommands = new Set(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false));
|
|
14824
|
+
var litsCommands = new Set(__spreadArray(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false), __read(Object.keys(reservedSymbolRecord)), false));
|
|
14831
14825
|
// TODO: replace with get suggestions function
|
|
14832
14826
|
var AutoCompleter = /** @class */ (function () {
|
|
14833
|
-
function AutoCompleter(
|
|
14834
|
-
this.
|
|
14827
|
+
function AutoCompleter(originalProgram, originalPosition, lits, params) {
|
|
14828
|
+
this.originalProgram = originalProgram;
|
|
14829
|
+
this.originalPosition = originalPosition;
|
|
14830
|
+
this.prefixProgram = '';
|
|
14831
|
+
this.suffixProgram = '';
|
|
14832
|
+
this.searchString = '';
|
|
14835
14833
|
this.suggestions = [];
|
|
14836
14834
|
this.suggestionIndex = null;
|
|
14835
|
+
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
14836
|
+
var tokenStream = null;
|
|
14837
|
+
try {
|
|
14838
|
+
tokenStream = lits.tokenize(partialProgram);
|
|
14839
|
+
}
|
|
14840
|
+
catch (_a) {
|
|
14841
|
+
// do nothing
|
|
14842
|
+
}
|
|
14837
14843
|
if (!tokenStream) {
|
|
14838
14844
|
return;
|
|
14839
14845
|
}
|
|
@@ -14841,14 +14847,28 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14841
14847
|
if (!lastToken) {
|
|
14842
14848
|
return;
|
|
14843
14849
|
}
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
this.
|
|
14849
|
-
this.generateSuggestions(params);
|
|
14850
|
+
this.searchString = lastToken[1];
|
|
14851
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
14852
|
+
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14853
|
+
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14854
|
+
this.suggestions = this.generateSuggestions(params);
|
|
14850
14855
|
}
|
|
14851
14856
|
AutoCompleter.prototype.getNextSuggestion = function () {
|
|
14857
|
+
return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol());
|
|
14858
|
+
};
|
|
14859
|
+
AutoCompleter.prototype.getPreviousSuggestion = function () {
|
|
14860
|
+
return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol());
|
|
14861
|
+
};
|
|
14862
|
+
AutoCompleter.prototype.getAutoCompleteSuggestionResult = function (suggestion) {
|
|
14863
|
+
if (suggestion === null) {
|
|
14864
|
+
return null;
|
|
14865
|
+
}
|
|
14866
|
+
return {
|
|
14867
|
+
program: this.prefixProgram + suggestion + this.suffixProgram,
|
|
14868
|
+
position: this.prefixProgram.length + suggestion.length,
|
|
14869
|
+
};
|
|
14870
|
+
};
|
|
14871
|
+
AutoCompleter.prototype.getNextSuggestionSymbol = function () {
|
|
14852
14872
|
if (this.suggestions.length === 0) {
|
|
14853
14873
|
return null;
|
|
14854
14874
|
}
|
|
@@ -14861,12 +14881,9 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14861
14881
|
this.suggestionIndex = 0;
|
|
14862
14882
|
}
|
|
14863
14883
|
}
|
|
14864
|
-
return
|
|
14865
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14866
|
-
searchPattern: this.searchPrefix,
|
|
14867
|
-
};
|
|
14884
|
+
return this.suggestions[this.suggestionIndex];
|
|
14868
14885
|
};
|
|
14869
|
-
AutoCompleter.prototype.
|
|
14886
|
+
AutoCompleter.prototype.getPreviousSuggestionSymbol = function () {
|
|
14870
14887
|
if (this.suggestions.length === 0) {
|
|
14871
14888
|
return null;
|
|
14872
14889
|
}
|
|
@@ -14879,41 +14896,38 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14879
14896
|
this.suggestionIndex = this.suggestions.length - 1;
|
|
14880
14897
|
}
|
|
14881
14898
|
}
|
|
14882
|
-
return
|
|
14883
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14884
|
-
searchPattern: this.searchPrefix,
|
|
14885
|
-
};
|
|
14899
|
+
return this.suggestions[this.suggestionIndex];
|
|
14886
14900
|
};
|
|
14887
14901
|
AutoCompleter.prototype.getSuggestions = function () {
|
|
14888
14902
|
return __spreadArray([], __read(this.suggestions), false);
|
|
14889
14903
|
};
|
|
14890
|
-
AutoCompleter.prototype.
|
|
14891
|
-
return this.
|
|
14904
|
+
AutoCompleter.prototype.getSearchString = function () {
|
|
14905
|
+
return this.searchString;
|
|
14892
14906
|
};
|
|
14893
14907
|
AutoCompleter.prototype.generateSuggestions = function (params) {
|
|
14894
14908
|
var _this = this;
|
|
14895
14909
|
var _a, _b, _c, _d;
|
|
14896
14910
|
var suggestions = new Set();
|
|
14897
14911
|
litsCommands.forEach(function (name) {
|
|
14898
|
-
if (name.startsWith(_this.
|
|
14912
|
+
if (name.startsWith(_this.searchString)) {
|
|
14899
14913
|
suggestions.add(name);
|
|
14900
14914
|
}
|
|
14901
14915
|
});
|
|
14902
14916
|
Object.keys((_a = params.globalContext) !== null && _a !== void 0 ? _a : {})
|
|
14903
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14917
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14904
14918
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14905
14919
|
(_b = params.contexts) === null || _b === void 0 ? void 0 : _b.forEach(function (context) {
|
|
14906
14920
|
Object.keys(context)
|
|
14907
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14921
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14908
14922
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14909
14923
|
});
|
|
14910
14924
|
Object.keys((_c = params.jsFunctions) !== null && _c !== void 0 ? _c : {})
|
|
14911
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14925
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14912
14926
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14913
14927
|
Object.keys((_d = params.values) !== null && _d !== void 0 ? _d : {})
|
|
14914
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14928
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14915
14929
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14916
|
-
|
|
14930
|
+
return __spreadArray([], __read(suggestions), false).sort(function (a, b) { return a.localeCompare(b); });
|
|
14917
14931
|
};
|
|
14918
14932
|
return AutoCompleter;
|
|
14919
14933
|
}());
|
|
@@ -15093,15 +15107,9 @@ var Lits = /** @class */ (function () {
|
|
|
15093
15107
|
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
15094
15108
|
return ast;
|
|
15095
15109
|
};
|
|
15096
|
-
Lits.prototype.getAutoCompleter = function (
|
|
15110
|
+
Lits.prototype.getAutoCompleter = function (program, position, params) {
|
|
15097
15111
|
if (params === void 0) { params = {}; }
|
|
15098
|
-
|
|
15099
|
-
var tokenStream = this.tokenize(partialProgram);
|
|
15100
|
-
return new AutoCompleter(tokenStream, params);
|
|
15101
|
-
}
|
|
15102
|
-
catch (_a) {
|
|
15103
|
-
return new AutoCompleter(null, params);
|
|
15104
|
-
}
|
|
15112
|
+
return new AutoCompleter(program, position, this, params);
|
|
15105
15113
|
};
|
|
15106
15114
|
return Lits;
|
|
15107
15115
|
}());
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import type { ContextParams } from '../Lits/Lits';
|
|
2
|
-
import type { TokenStream } from '../tokenizer/tokenize';
|
|
1
|
+
import type { ContextParams, Lits } from '../Lits/Lits';
|
|
3
2
|
export type AutoCompleteSuggestion = {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
program: string;
|
|
4
|
+
position: number;
|
|
6
5
|
};
|
|
7
6
|
export declare class AutoCompleter {
|
|
8
|
-
|
|
7
|
+
readonly originalProgram: string;
|
|
8
|
+
readonly originalPosition: number;
|
|
9
|
+
private prefixProgram;
|
|
10
|
+
private suffixProgram;
|
|
11
|
+
private searchString;
|
|
9
12
|
private suggestions;
|
|
10
13
|
private suggestionIndex;
|
|
11
|
-
constructor(
|
|
14
|
+
constructor(originalProgram: string, originalPosition: number, lits: Lits, params: ContextParams);
|
|
12
15
|
getNextSuggestion(): AutoCompleteSuggestion | null;
|
|
13
16
|
getPreviousSuggestion(): AutoCompleteSuggestion | null;
|
|
17
|
+
private getAutoCompleteSuggestionResult;
|
|
18
|
+
private getNextSuggestionSymbol;
|
|
19
|
+
private getPreviousSuggestionSymbol;
|
|
14
20
|
getSuggestions(): string[];
|
|
15
|
-
|
|
21
|
+
getSearchString(): string;
|
|
16
22
|
private generateSuggestions;
|
|
17
23
|
}
|
|
@@ -47,6 +47,6 @@ export declare class Lits {
|
|
|
47
47
|
apply(fn: LitsFunction, fnParams: unknown[], params?: ContextParams): Any;
|
|
48
48
|
private generateApplyFunctionCall;
|
|
49
49
|
private generateAst;
|
|
50
|
-
getAutoCompleter(
|
|
50
|
+
getAutoCompleter(program: string, position: number, params?: ContextParams): AutoCompleter;
|
|
51
51
|
}
|
|
52
52
|
export {};
|
|
@@ -58,44 +58,6 @@ export declare const reservedSymbolRecord: {
|
|
|
58
58
|
readonly as: null;
|
|
59
59
|
readonly _: null;
|
|
60
60
|
};
|
|
61
|
-
export declare const validReservedSymbolRecord: {
|
|
62
|
-
readonly E: number;
|
|
63
|
-
readonly '-E': number;
|
|
64
|
-
readonly ε: number;
|
|
65
|
-
readonly '-\u03B5': number;
|
|
66
|
-
readonly PI: number;
|
|
67
|
-
readonly '-PI': number;
|
|
68
|
-
readonly π: number;
|
|
69
|
-
readonly '-\u03C0': number;
|
|
70
|
-
readonly PHI: number;
|
|
71
|
-
readonly '-PHI': number;
|
|
72
|
-
readonly φ: number;
|
|
73
|
-
readonly '-\u03C6': number;
|
|
74
|
-
readonly POSITIVE_INFINITY: number;
|
|
75
|
-
readonly '\u221E': number;
|
|
76
|
-
readonly NEGATIVE_INFINITY: number;
|
|
77
|
-
readonly '-\u221E': number;
|
|
78
|
-
readonly MAX_SAFE_INTEGER: number;
|
|
79
|
-
readonly MIN_SAFE_INTEGER: number;
|
|
80
|
-
readonly MAX_VALUE: number;
|
|
81
|
-
readonly MIN_VALUE: number;
|
|
82
|
-
readonly NaN: number;
|
|
83
|
-
readonly true: true;
|
|
84
|
-
readonly false: false;
|
|
85
|
-
readonly null: null;
|
|
86
|
-
readonly else: null;
|
|
87
|
-
readonly case: null;
|
|
88
|
-
readonly each: null;
|
|
89
|
-
readonly in: null;
|
|
90
|
-
readonly when: null;
|
|
91
|
-
readonly while: null;
|
|
92
|
-
readonly catch: null;
|
|
93
|
-
readonly function: null;
|
|
94
|
-
readonly export: null;
|
|
95
|
-
readonly as: null;
|
|
96
|
-
readonly _: null;
|
|
97
|
-
};
|
|
98
|
-
export type ValidReservedSymbol = keyof typeof validReservedSymbolRecord;
|
|
99
61
|
export type ReservedSymbol = keyof typeof reservedSymbolRecord;
|
|
100
|
-
export declare function isReservedSymbol(symbol: string): symbol is keyof typeof
|
|
62
|
+
export declare function isReservedSymbol(symbol: string): symbol is keyof typeof reservedSymbolRecord;
|
|
101
63
|
export declare function isNumberReservedSymbol(symbol: string): symbol is keyof typeof numberReservedSymbolRecord;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReservedSymbol } from './reservedNames';
|
|
2
2
|
import { type SymbolicBinaryOperator, type SymbolicOperator } from './operators';
|
|
3
3
|
export declare const tokenTypes: readonly ["LBrace", "LBracket", "RBrace", "RBracket", "LParen", "RParen", "BasePrefixedNumber", "MultiLineComment", "Number", "Operator", "RegexpShorthand", "ReservedSymbol", "SingleLineComment", "String", "Symbol", "Whitespace"];
|
|
4
4
|
export type TokenType = typeof tokenTypes[number];
|
|
@@ -16,7 +16,7 @@ export type MultiLineCommentToken = GenericToken<'MultiLineComment'>;
|
|
|
16
16
|
export type NumberToken = GenericToken<'Number'>;
|
|
17
17
|
export type OperatorToken<T extends SymbolicOperator = SymbolicOperator> = GenericToken<'Operator', T>;
|
|
18
18
|
export type RegexpShorthandToken = GenericToken<'RegexpShorthand'>;
|
|
19
|
-
export type ReservedSymbolToken<T extends
|
|
19
|
+
export type ReservedSymbolToken<T extends ReservedSymbol = ReservedSymbol> = GenericToken<'ReservedSymbol', T>;
|
|
20
20
|
export type SingleLineCommentToken = GenericToken<'SingleLineComment'>;
|
|
21
21
|
export type StringToken = GenericToken<'String'>;
|
|
22
22
|
export type SymbolToken<T extends string = string> = GenericToken<'Symbol', T>;
|
|
@@ -34,9 +34,9 @@ export interface SourceCodeInfo {
|
|
|
34
34
|
export declare function isSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): token is SymbolToken<T>;
|
|
35
35
|
export declare function assertSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): asserts token is SymbolToken<T>;
|
|
36
36
|
export declare function asSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): SymbolToken<T>;
|
|
37
|
-
export declare function isReservedSymbolToken<T extends
|
|
38
|
-
export declare function assertReservedSymbolToken<T extends
|
|
39
|
-
export declare function asReservedSymbolToken<T extends
|
|
37
|
+
export declare function isReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): token is ReservedSymbolToken<T>;
|
|
38
|
+
export declare function assertReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): asserts token is ReservedSymbolToken<T>;
|
|
39
|
+
export declare function asReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): ReservedSymbolToken<T>;
|
|
40
40
|
export declare function isSingleLineCommentToken(token: Token | undefined): token is SingleLineCommentToken;
|
|
41
41
|
export declare function assertSingleLineCommentToken(token: Token | undefined): asserts token is SingleLineCommentToken;
|
|
42
42
|
export declare function asSingleLineCommentToken(token: Token | undefined): SingleLineCommentToken;
|
package/dist/index.esm.js
CHANGED
|
@@ -11628,9 +11628,8 @@ var numberReservedSymbolRecord = {
|
|
|
11628
11628
|
'NaN': Number.NaN,
|
|
11629
11629
|
};
|
|
11630
11630
|
var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11631
|
-
var validReservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
|
|
11632
11631
|
function isReservedSymbol(symbol) {
|
|
11633
|
-
return symbol in
|
|
11632
|
+
return symbol in reservedSymbolRecord;
|
|
11634
11633
|
}
|
|
11635
11634
|
function isNumberReservedSymbol(symbol) {
|
|
11636
11635
|
return symbol in numberReservedSymbolRecord;
|
|
@@ -14859,18 +14858,25 @@ var Parser = /** @class */ (function () {
|
|
|
14859
14858
|
return Parser;
|
|
14860
14859
|
}());
|
|
14861
14860
|
|
|
14862
|
-
var
|
|
14863
|
-
'Operator',
|
|
14864
|
-
'ReservedSymbol',
|
|
14865
|
-
'Symbol',
|
|
14866
|
-
];
|
|
14867
|
-
var litsCommands = new Set(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false));
|
|
14861
|
+
var litsCommands = new Set(__spreadArray(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false), __read(Object.keys(reservedSymbolRecord)), false));
|
|
14868
14862
|
// TODO: replace with get suggestions function
|
|
14869
14863
|
var AutoCompleter = /** @class */ (function () {
|
|
14870
|
-
function AutoCompleter(
|
|
14871
|
-
this.
|
|
14864
|
+
function AutoCompleter(originalProgram, originalPosition, lits, params) {
|
|
14865
|
+
this.originalProgram = originalProgram;
|
|
14866
|
+
this.originalPosition = originalPosition;
|
|
14867
|
+
this.prefixProgram = '';
|
|
14868
|
+
this.suffixProgram = '';
|
|
14869
|
+
this.searchString = '';
|
|
14872
14870
|
this.suggestions = [];
|
|
14873
14871
|
this.suggestionIndex = null;
|
|
14872
|
+
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
14873
|
+
var tokenStream = null;
|
|
14874
|
+
try {
|
|
14875
|
+
tokenStream = lits.tokenize(partialProgram);
|
|
14876
|
+
}
|
|
14877
|
+
catch (_a) {
|
|
14878
|
+
// do nothing
|
|
14879
|
+
}
|
|
14874
14880
|
if (!tokenStream) {
|
|
14875
14881
|
return;
|
|
14876
14882
|
}
|
|
@@ -14878,14 +14884,28 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14878
14884
|
if (!lastToken) {
|
|
14879
14885
|
return;
|
|
14880
14886
|
}
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
this.
|
|
14886
|
-
this.generateSuggestions(params);
|
|
14887
|
+
this.searchString = lastToken[1];
|
|
14888
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
14889
|
+
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14890
|
+
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14891
|
+
this.suggestions = this.generateSuggestions(params);
|
|
14887
14892
|
}
|
|
14888
14893
|
AutoCompleter.prototype.getNextSuggestion = function () {
|
|
14894
|
+
return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol());
|
|
14895
|
+
};
|
|
14896
|
+
AutoCompleter.prototype.getPreviousSuggestion = function () {
|
|
14897
|
+
return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol());
|
|
14898
|
+
};
|
|
14899
|
+
AutoCompleter.prototype.getAutoCompleteSuggestionResult = function (suggestion) {
|
|
14900
|
+
if (suggestion === null) {
|
|
14901
|
+
return null;
|
|
14902
|
+
}
|
|
14903
|
+
return {
|
|
14904
|
+
program: this.prefixProgram + suggestion + this.suffixProgram,
|
|
14905
|
+
position: this.prefixProgram.length + suggestion.length,
|
|
14906
|
+
};
|
|
14907
|
+
};
|
|
14908
|
+
AutoCompleter.prototype.getNextSuggestionSymbol = function () {
|
|
14889
14909
|
if (this.suggestions.length === 0) {
|
|
14890
14910
|
return null;
|
|
14891
14911
|
}
|
|
@@ -14898,12 +14918,9 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14898
14918
|
this.suggestionIndex = 0;
|
|
14899
14919
|
}
|
|
14900
14920
|
}
|
|
14901
|
-
return
|
|
14902
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14903
|
-
searchPattern: this.searchPrefix,
|
|
14904
|
-
};
|
|
14921
|
+
return this.suggestions[this.suggestionIndex];
|
|
14905
14922
|
};
|
|
14906
|
-
AutoCompleter.prototype.
|
|
14923
|
+
AutoCompleter.prototype.getPreviousSuggestionSymbol = function () {
|
|
14907
14924
|
if (this.suggestions.length === 0) {
|
|
14908
14925
|
return null;
|
|
14909
14926
|
}
|
|
@@ -14916,41 +14933,38 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14916
14933
|
this.suggestionIndex = this.suggestions.length - 1;
|
|
14917
14934
|
}
|
|
14918
14935
|
}
|
|
14919
|
-
return
|
|
14920
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14921
|
-
searchPattern: this.searchPrefix,
|
|
14922
|
-
};
|
|
14936
|
+
return this.suggestions[this.suggestionIndex];
|
|
14923
14937
|
};
|
|
14924
14938
|
AutoCompleter.prototype.getSuggestions = function () {
|
|
14925
14939
|
return __spreadArray([], __read(this.suggestions), false);
|
|
14926
14940
|
};
|
|
14927
|
-
AutoCompleter.prototype.
|
|
14928
|
-
return this.
|
|
14941
|
+
AutoCompleter.prototype.getSearchString = function () {
|
|
14942
|
+
return this.searchString;
|
|
14929
14943
|
};
|
|
14930
14944
|
AutoCompleter.prototype.generateSuggestions = function (params) {
|
|
14931
14945
|
var _this = this;
|
|
14932
14946
|
var _a, _b, _c, _d;
|
|
14933
14947
|
var suggestions = new Set();
|
|
14934
14948
|
litsCommands.forEach(function (name) {
|
|
14935
|
-
if (name.startsWith(_this.
|
|
14949
|
+
if (name.startsWith(_this.searchString)) {
|
|
14936
14950
|
suggestions.add(name);
|
|
14937
14951
|
}
|
|
14938
14952
|
});
|
|
14939
14953
|
Object.keys((_a = params.globalContext) !== null && _a !== void 0 ? _a : {})
|
|
14940
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14954
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14941
14955
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14942
14956
|
(_b = params.contexts) === null || _b === void 0 ? void 0 : _b.forEach(function (context) {
|
|
14943
14957
|
Object.keys(context)
|
|
14944
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14958
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14945
14959
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14946
14960
|
});
|
|
14947
14961
|
Object.keys((_c = params.jsFunctions) !== null && _c !== void 0 ? _c : {})
|
|
14948
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14962
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14949
14963
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14950
14964
|
Object.keys((_d = params.values) !== null && _d !== void 0 ? _d : {})
|
|
14951
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14965
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14952
14966
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14953
|
-
|
|
14967
|
+
return __spreadArray([], __read(suggestions), false).sort(function (a, b) { return a.localeCompare(b); });
|
|
14954
14968
|
};
|
|
14955
14969
|
return AutoCompleter;
|
|
14956
14970
|
}());
|
|
@@ -15130,15 +15144,9 @@ var Lits = /** @class */ (function () {
|
|
|
15130
15144
|
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
15131
15145
|
return ast;
|
|
15132
15146
|
};
|
|
15133
|
-
Lits.prototype.getAutoCompleter = function (
|
|
15147
|
+
Lits.prototype.getAutoCompleter = function (program, position, params) {
|
|
15134
15148
|
if (params === void 0) { params = {}; }
|
|
15135
|
-
|
|
15136
|
-
var tokenStream = this.tokenize(partialProgram);
|
|
15137
|
-
return new AutoCompleter(tokenStream, params);
|
|
15138
|
-
}
|
|
15139
|
-
catch (_a) {
|
|
15140
|
-
return new AutoCompleter(null, params);
|
|
15141
|
-
}
|
|
15149
|
+
return new AutoCompleter(program, position, this, params);
|
|
15142
15150
|
};
|
|
15143
15151
|
return Lits;
|
|
15144
15152
|
}());
|