@guihz/trading-vue-editor-tes 0.0.1
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/README.md +30 -0
- package/lib/App.d.ts +3 -0
- package/lib/api/api.d.ts +1 -0
- package/lib/api/server.d.ts +8 -0
- package/lib/assets/parserTccWorker-CFBnUzVu.js +99 -0
- package/lib/assets/scriptsRunWorker-CSDMAOri.js +66 -0
- package/lib/components/editor/config/monarchTokens.d.ts +205 -0
- package/lib/components/editor/constants/contents.d.ts +40 -0
- package/lib/components/editor/constants/locals.d.ts +3 -0
- package/lib/components/editor/index.d.ts +21 -0
- package/lib/components/editor/parseScript/buildInConstants.d.ts +252 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/array.d.ts +144 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/color.d.ts +25 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/errorListener.d.ts +8 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/index.d.ts +12 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/input.d.ts +70 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/map.d.ts +37 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/math.d.ts +47 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/matrix.d.ts +136 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/string.d.ts +43 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/ta.d.ts +116 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/timeframe.d.ts +19 -0
- package/lib/components/editor/parseScript/buildInVariables.d.ts +122 -0
- package/lib/components/editor/parseScript/constants.d.ts +56 -0
- package/lib/components/editor/parseScript/enum.d.ts +248 -0
- package/lib/components/editor/parseScript/parseToJs.d.ts +44 -0
- package/lib/components/editor/parseScript/type.d.ts +27 -0
- package/lib/components/editor/parseScript/userTypeClass.d.ts +12 -0
- package/lib/components/editor/parseScript/utils.d.ts +8 -0
- package/lib/components/editor/parseScript/visitorParser.d.ts +303 -0
- package/lib/components/editor/parseScript/visitorUtils.d.ts +30 -0
- package/lib/components/editor/parseScript/workerStorage.d.ts +12 -0
- package/lib/components/editor/tokenizer/config.d.ts +40 -0
- package/lib/components/editor/tokenizer/utils.d.ts +33 -0
- package/lib/components/editor/type/index.d.ts +70 -0
- package/lib/components/editor/utils/color.d.ts +33 -0
- package/lib/components/editor/utils/completions.d.ts +61 -0
- package/lib/components/editor/utils/decorations.d.ts +23 -0
- package/lib/components/editor/utils/initEditor.d.ts +23 -0
- package/lib/components/editor/utils/overlayWidgets.d.ts +22 -0
- package/lib/components/editor/utils/parse.d.ts +43 -0
- package/lib/components/editor/utils/parserTccWorker.d.ts +25 -0
- package/lib/components/editor/utils/signatureHelp.d.ts +29 -0
- package/lib/components/editor/utils/suggestions.d.ts +18 -0
- package/lib/components/editor/utils/test.d.ts +22 -0
- package/lib/components/editor/utils/tools.d.ts +1 -0
- package/lib/main.d.ts +1 -0
- package/lib/packages/index.d.ts +5 -0
- package/lib/tccParser/LexerBase.d.ts +19 -0
- package/lib/tccParser/tccScriptParserVisitor.d.ts +486 -0
- package/lib/trading-vue-editor.js +64939 -0
- package/lib/trading-vue-editor.umd.cjs +144 -0
- package/package.json +53 -0
@@ -0,0 +1,248 @@
|
|
1
|
+
export declare enum VType {
|
2
|
+
BOOL = "bool",
|
3
|
+
INT = "int",
|
4
|
+
FLOAT = "float",
|
5
|
+
ARRAY = "array",
|
6
|
+
BOX = "box",
|
7
|
+
CHART_POINT = "chart.point",
|
8
|
+
COLOR = "color",
|
9
|
+
CONST = "const",
|
10
|
+
LABEL = "label",
|
11
|
+
LINE = "line",
|
12
|
+
LINEFILL = "linefill",
|
13
|
+
MAP = "map",
|
14
|
+
MATRIX = "matrix",
|
15
|
+
POLYLINE = "polyline",
|
16
|
+
SERIES = "series",
|
17
|
+
SIMPLE = "simple",
|
18
|
+
STRING = "string",
|
19
|
+
TABLE = "table",
|
20
|
+
UNDETERMINED = "undetermined type",
|
21
|
+
INPUT = "input",
|
22
|
+
NA = "na",
|
23
|
+
VOID = "void"
|
24
|
+
}
|
25
|
+
export declare enum VRuleType {
|
26
|
+
FlowStmt = "FlowStmt",
|
27
|
+
DeclareAssign = "DeclareAssign",
|
28
|
+
VarBlockStmt = "VarBlockStmt",
|
29
|
+
VarSingle = "VarSingle",
|
30
|
+
VarMultiple = "VarMultiple",
|
31
|
+
ParenthesizedExpression = "ParenthesizedExpression",
|
32
|
+
AdditiveExpression = "AdditiveExpression",
|
33
|
+
RelationalExpression = "RelationalExpression",
|
34
|
+
EqualityExpression = "EqualityExpression",
|
35
|
+
TernaryExpression = "TernaryExpression",
|
36
|
+
UnaryExpression = "UnaryExpression",
|
37
|
+
NotExpression = "NotExpression",
|
38
|
+
MemberIndexExpression = "MemberIndexExpression",
|
39
|
+
MethodExpression = "MethodExpression",
|
40
|
+
LogicalAndExpression = "LogicalAndExpression",
|
41
|
+
LogicalOrExpression = "LogicalOrExpression",
|
42
|
+
MultiplicativeExpression = "MultiplicativeExpression",
|
43
|
+
Brackethesized = "Brackethesized",
|
44
|
+
IfStatement = "IfStatement",
|
45
|
+
ForToStatement = "ForToStatement",
|
46
|
+
ForInStatement = "ForInStatement",
|
47
|
+
SwitchStatement = "SwitchStatement",
|
48
|
+
CaseClause = "CaseClause",
|
49
|
+
DefaultCaluse = "DefaultCaluse",
|
50
|
+
WhileStatement = "WhileStatement",
|
51
|
+
ImportElement = "ImportElement",
|
52
|
+
Literal = "Literal",
|
53
|
+
ArrowFunction = "ArrowFunction",
|
54
|
+
ArrowMethod = "ArrowMethod",
|
55
|
+
TypeStatement = "TypeStatement",
|
56
|
+
Name = "Name",
|
57
|
+
AgainAssign = "AgainAssign"
|
58
|
+
}
|
59
|
+
export declare enum VAdjustment {
|
60
|
+
dividends = "dividends",
|
61
|
+
none = "none",
|
62
|
+
splits = "splits"
|
63
|
+
}
|
64
|
+
export declare enum VAlert {
|
65
|
+
freqAll = "freq_all",
|
66
|
+
freqOncePerBar = "freq_once_per_bar",
|
67
|
+
freqOncePerBarClose = "freq_once_per_bar_close"
|
68
|
+
}
|
69
|
+
export declare enum VBarmergeGaps {
|
70
|
+
gapsOff = "gaps_off",
|
71
|
+
gapsOn = "gaps_on",
|
72
|
+
lookaheadOff = "lookahead_off",
|
73
|
+
lookaheadOn = "lookahead_on"
|
74
|
+
}
|
75
|
+
export declare enum VPlotDisplay {
|
76
|
+
all = "all",
|
77
|
+
dataWindow = "data_window",
|
78
|
+
none = "none",
|
79
|
+
pane = "pane",
|
80
|
+
priceScale = "price_scale",
|
81
|
+
statusLine = "status_line"
|
82
|
+
}
|
83
|
+
export declare enum VExtend {
|
84
|
+
both = "both",
|
85
|
+
left = "left",
|
86
|
+
none = "none",
|
87
|
+
right = "right"
|
88
|
+
}
|
89
|
+
export declare enum VFormatType {
|
90
|
+
inherit = "inherit",
|
91
|
+
mintick = "mintick",
|
92
|
+
percent = "percent",
|
93
|
+
price = "price",
|
94
|
+
volume = "volume"
|
95
|
+
}
|
96
|
+
export declare enum VHlineStyle {
|
97
|
+
styleDashed = "style_dashed",
|
98
|
+
styleDotted = "style_dotted",
|
99
|
+
styleSolid = "style_solid"
|
100
|
+
}
|
101
|
+
export declare enum VLabelStyle {
|
102
|
+
styleArrowdown = "style_arrowdown",
|
103
|
+
styleArrowup = "style_arrowup",
|
104
|
+
styleCircle = "style_circle",
|
105
|
+
styleCross = "style_cross",
|
106
|
+
styleDiamond = "style_diamond",
|
107
|
+
styleFlag = "style_flag",
|
108
|
+
styleLabelCenter = "style_label_center",
|
109
|
+
styleLabelDown = "style_label_down",
|
110
|
+
styleLabelLeft = "style_label_left",
|
111
|
+
styleLabelLowerLeft = "style_label_lower_left",
|
112
|
+
styleLabelLowerRight = "style_label_lower_right",
|
113
|
+
styleLabelRight = "style_label_right",
|
114
|
+
styleLabelUp = "style_label_up",
|
115
|
+
styleLabelUpperLeft = "style_label_upper_left",
|
116
|
+
styleLabelUpperRight = "style_label_upper_right",
|
117
|
+
styleNone = "style_none",
|
118
|
+
styleSquare = "style_square",
|
119
|
+
styleTextOutline = "style_text_outline",
|
120
|
+
styleTriangledown = "style_triangledown",
|
121
|
+
styleTriangleup = "style_triangleup",
|
122
|
+
styleXcross = "style_xcross"
|
123
|
+
}
|
124
|
+
export declare enum VLineStyle {
|
125
|
+
styleArrowBoth = "style_arrow_both",
|
126
|
+
styleArrowLeft = "style_arrow_left",
|
127
|
+
styleArrowRight = "style_arrow_right",
|
128
|
+
styleDashed = "style_dashed",
|
129
|
+
styleDotted = "style_dotted",
|
130
|
+
styleSolid = "style_solid"
|
131
|
+
}
|
132
|
+
export declare enum VLocation {
|
133
|
+
abovebar = "abovebar",
|
134
|
+
absolute = "absolute",
|
135
|
+
belowbar = "belowbar",
|
136
|
+
bottom = "bottom",
|
137
|
+
top = "top"
|
138
|
+
}
|
139
|
+
export declare enum VSortOrder {
|
140
|
+
ascending = "ascending",// 从小到大
|
141
|
+
descending = "descending"
|
142
|
+
}
|
143
|
+
export declare enum VPlotStyle {
|
144
|
+
styleArea = "Area",
|
145
|
+
styleAreabr = "Area With Breaks",
|
146
|
+
styleCircles = "Circles",
|
147
|
+
styleColumns = "Columns",
|
148
|
+
styleCross = "Cross",
|
149
|
+
styleHistogram = "Histogram",
|
150
|
+
styleLine = "Line",
|
151
|
+
styleLinebr = "Line With Breaks",
|
152
|
+
styleStepline = "Step Line",
|
153
|
+
styleSteplineDiamond = "Step Line With Diamonds",
|
154
|
+
styleSteplinebr = "Step line with Breaks"
|
155
|
+
}
|
156
|
+
export declare enum VPosition {
|
157
|
+
bottomCenter = "bottom_center",
|
158
|
+
bottomLeft = "bottom_left",
|
159
|
+
bottomRight = "bottom_right",
|
160
|
+
middleCenter = "middle_center",
|
161
|
+
middleLeft = "middle_left",
|
162
|
+
middleRight = "middle_right",
|
163
|
+
topCenter = "top_center",
|
164
|
+
topLeft = "top_left",
|
165
|
+
topRight = "top_right"
|
166
|
+
}
|
167
|
+
export declare enum VScale {
|
168
|
+
left = "left",
|
169
|
+
none = "none",
|
170
|
+
right = "right"
|
171
|
+
}
|
172
|
+
export declare enum VSession {
|
173
|
+
extended = "extended",
|
174
|
+
regular = "regular"
|
175
|
+
}
|
176
|
+
export declare enum VShape {
|
177
|
+
arrowdown = "arrowdown",
|
178
|
+
arrowup = "arrowup",
|
179
|
+
circle = "circle",
|
180
|
+
cross = "cross",
|
181
|
+
diamond = "diamond",
|
182
|
+
flag = "flag",
|
183
|
+
labeldown = "labeldown",
|
184
|
+
labelup = "labelup",
|
185
|
+
square = "square",
|
186
|
+
triangledown = "triangledown",
|
187
|
+
triangleup = "triangleup",
|
188
|
+
xcross = "xcross"
|
189
|
+
}
|
190
|
+
export declare enum VSize {
|
191
|
+
auto = "auto",
|
192
|
+
huge = "huge",
|
193
|
+
large = "large",
|
194
|
+
normal = "normal",
|
195
|
+
small = "small",
|
196
|
+
tiny = "tiny"
|
197
|
+
}
|
198
|
+
export declare enum VStrategy {
|
199
|
+
cash = "cash",
|
200
|
+
fixed = "fixed",
|
201
|
+
percentOfEquity = "percent_of_equity"
|
202
|
+
}
|
203
|
+
export declare enum VCommission {
|
204
|
+
cashPerContract = "cash_per_contract",
|
205
|
+
cashPerOrder = "cash_per_order",
|
206
|
+
percent = "percent"
|
207
|
+
}
|
208
|
+
export declare enum VDirection {
|
209
|
+
all = "all",
|
210
|
+
long = "long",
|
211
|
+
short = "short"
|
212
|
+
}
|
213
|
+
export declare enum VOca {
|
214
|
+
cancel = "cancel",
|
215
|
+
none = "none",
|
216
|
+
reduce = "reduce"
|
217
|
+
}
|
218
|
+
export declare enum VText {
|
219
|
+
alignBottom = "align_bottom",
|
220
|
+
alignCenter = "align_center",
|
221
|
+
alignLeft = "align_left",
|
222
|
+
alignRight = "align_right",
|
223
|
+
alignTop = "align_top",
|
224
|
+
wrapAuto = "wrap_auto",
|
225
|
+
wrapNone = "wrap_none"
|
226
|
+
}
|
227
|
+
export declare enum VXloc {
|
228
|
+
bar_index = "bar_index",
|
229
|
+
bar_time = "bar_time"
|
230
|
+
}
|
231
|
+
export declare enum VYloc {
|
232
|
+
abovebar = "abovebar",
|
233
|
+
belowbar = "belowbar",
|
234
|
+
price = "price"
|
235
|
+
}
|
236
|
+
export declare enum VEarnings {
|
237
|
+
actual = "actual",
|
238
|
+
estimate = "estimate",
|
239
|
+
standardized = "standardized"
|
240
|
+
}
|
241
|
+
export declare enum VPivotType {
|
242
|
+
traditional = "Traditional",
|
243
|
+
fibonacci = "Fibonacci",
|
244
|
+
woodie = "Woodie",
|
245
|
+
classic = "Classic",
|
246
|
+
dm = "DM",
|
247
|
+
camarilla = "Camarilla"
|
248
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { IKeyObjectValue } from "../type";
|
2
|
+
export default class ParseToJs {
|
3
|
+
private _nameMap;
|
4
|
+
private _prefixNameVar;
|
5
|
+
private _prefixNameFunc;
|
6
|
+
private _prefixNameConst;
|
7
|
+
private _userTypes;
|
8
|
+
private _memberIndexCache;
|
9
|
+
private _isInFunc;
|
10
|
+
constructor(prefix: string);
|
11
|
+
preParser(values: IKeyObjectValue[]): string | undefined;
|
12
|
+
parser(values: IKeyObjectValue[]): string | undefined;
|
13
|
+
private _parserStmt;
|
14
|
+
private _parserTypeStatement;
|
15
|
+
private _parserVarBlockStmt;
|
16
|
+
private _parserForToStatement;
|
17
|
+
private _parserForInStatement;
|
18
|
+
private _parserAgainAssign;
|
19
|
+
private _parserSwitchStatement;
|
20
|
+
private _parserCases;
|
21
|
+
private _parserDefaultCase;
|
22
|
+
private _parserCase;
|
23
|
+
private _parserWhileStatement;
|
24
|
+
private _parserIfStatement;
|
25
|
+
private _parserBlockLine;
|
26
|
+
private _parserReturnBlock;
|
27
|
+
private _parserArrowMethod;
|
28
|
+
private _parserArrowFunction;
|
29
|
+
private _parserParameters;
|
30
|
+
private _parserBlock;
|
31
|
+
private _parserDeclareAssign;
|
32
|
+
private _parserDeclareAssignNames;
|
33
|
+
private _parserSingleExpression;
|
34
|
+
private _parserAdditiveExpression;
|
35
|
+
private _parserMemberIndexExpression;
|
36
|
+
private _parseLiteral;
|
37
|
+
private _colorToRgba;
|
38
|
+
private _parserName;
|
39
|
+
private _parserMethodExpression;
|
40
|
+
private _parserMethodElement;
|
41
|
+
private _parserArguments;
|
42
|
+
private _parserBrackethesized;
|
43
|
+
private _functionalProcess;
|
44
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
interface IBase {
|
2
|
+
startColumn: number;
|
3
|
+
startLineNumber: number;
|
4
|
+
endColumn: number;
|
5
|
+
endLineNumber: number;
|
6
|
+
}
|
7
|
+
export declare enum VMarkerSeverity {
|
8
|
+
Hint = 1,
|
9
|
+
Info = 2,
|
10
|
+
Warning = 4,
|
11
|
+
Error = 8
|
12
|
+
}
|
13
|
+
export interface IPosition {
|
14
|
+
readonly lineNumber: number;
|
15
|
+
readonly column: number;
|
16
|
+
}
|
17
|
+
export interface IRange {
|
18
|
+
readonly startLineNumber: number;
|
19
|
+
readonly startColumn: number;
|
20
|
+
readonly endLineNumber: number;
|
21
|
+
readonly endColumn: number;
|
22
|
+
}
|
23
|
+
export interface IError extends IBase {
|
24
|
+
message: string;
|
25
|
+
type?: VMarkerSeverity;
|
26
|
+
}
|
27
|
+
export {};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { IKeyObjectValue } from "../type";
|
2
|
+
declare class UserTypeClass {
|
3
|
+
private _defaultParams;
|
4
|
+
private _UserTypeFileds;
|
5
|
+
private _varipKeys;
|
6
|
+
constructor(params: IKeyObjectValue, keys: string[]);
|
7
|
+
copy(typeObject: IKeyObjectValue): IKeyObjectValue;
|
8
|
+
new(params?: IKeyObjectValue): any;
|
9
|
+
addNewMethod(name: string, func: any): void;
|
10
|
+
private _createDynamicClass;
|
11
|
+
}
|
12
|
+
export default UserTypeClass;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { IKeyValue } from "../type";
|
2
|
+
import dayjs from "dayjs";
|
3
|
+
export declare function replaceTemplate(template: string, replacements: IKeyValue): string;
|
4
|
+
export declare function parsePerid(period: string): (string | number)[];
|
5
|
+
export declare function generateRandomId(length?: number): string;
|
6
|
+
export declare function parseTimezoneOffset(timezone: string): number;
|
7
|
+
export declare function parserTimezone(time?: number, timezone?: string): dayjs.Dayjs;
|
8
|
+
export declare function periodConvert(period: string): number;
|
@@ -0,0 +1,303 @@
|
|
1
|
+
import { IKeyObjectValue, IDocValue, IKeyValue } from '../type';
|
2
|
+
import { VRuleType } from './enum';
|
3
|
+
import { ParserUtils } from './visitorUtils';
|
4
|
+
import { IError, IPosition } from "./type";
|
5
|
+
export default class ParserVisitor extends ParserUtils {
|
6
|
+
private _loopCount;
|
7
|
+
private _errors;
|
8
|
+
private _variables;
|
9
|
+
private _functions;
|
10
|
+
private _methods;
|
11
|
+
private _types;
|
12
|
+
private _currentBlockVars;
|
13
|
+
private _currentFuncParams;
|
14
|
+
private _isNeedCalc;
|
15
|
+
private _blockCount;
|
16
|
+
private _isInFunc;
|
17
|
+
private _onlyStatementsCount;
|
18
|
+
private _blockRanges;
|
19
|
+
private _overloadsFuncs;
|
20
|
+
private _hasMemberIndex;
|
21
|
+
private _isInLocalScop;
|
22
|
+
constructor(props: IKeyObjectValue);
|
23
|
+
get overloadsFuncs(): IKeyValue[];
|
24
|
+
get errors(): IError[];
|
25
|
+
get userTypes(): Map<string, IDocValue[]>;
|
26
|
+
get userFunctions(): Map<string, IDocValue[]>;
|
27
|
+
get userVariables(): Map<string, IDocValue[]>;
|
28
|
+
get userMethods(): Map<string, IDocValue[]>;
|
29
|
+
visitProgram: (ctx: IKeyObjectValue) => any[];
|
30
|
+
visitGlobalStmt: (ctx: IKeyObjectValue) => any;
|
31
|
+
visitBlockStmt: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
32
|
+
visitStmt: (ctx: IKeyObjectValue) => any;
|
33
|
+
visitSimpleStmt: (ctx: IKeyObjectValue) => any;
|
34
|
+
visitFlowStmt: (ctx: IKeyObjectValue) => {
|
35
|
+
ruleType: VRuleType;
|
36
|
+
value: any;
|
37
|
+
};
|
38
|
+
visitBlock: (ctx: IKeyObjectValue) => any;
|
39
|
+
visitBlockLine: (ctx: IKeyObjectValue) => any[] | null;
|
40
|
+
visitDeclareAssign: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
41
|
+
visitAgainAssign: (ctx: IKeyObjectValue) => {
|
42
|
+
ruleType: VRuleType;
|
43
|
+
name: IKeyObjectValue;
|
44
|
+
operator: string;
|
45
|
+
type: string;
|
46
|
+
value: IKeyObjectValue;
|
47
|
+
} | null;
|
48
|
+
visitVarModifier: (ctx: IKeyObjectValue) => any;
|
49
|
+
visitExpressionSequence: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
50
|
+
visitExpressionBlockSequence: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
51
|
+
visitBlockSequence: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
52
|
+
visitVariableDeclarationStmt: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
53
|
+
visitVarBlockStmt: (ctx: IKeyObjectValue) => IKeyObjectValue | {
|
54
|
+
ruleType: VRuleType;
|
55
|
+
name: IKeyObjectValue;
|
56
|
+
operator: string;
|
57
|
+
type: string;
|
58
|
+
value: IKeyObjectValue;
|
59
|
+
};
|
60
|
+
visitVarSingle: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
61
|
+
visitVarMultiple: (ctx: IKeyObjectValue) => {
|
62
|
+
ruleType: VRuleType;
|
63
|
+
names: IKeyObjectValue[];
|
64
|
+
posList: IPosition[];
|
65
|
+
};
|
66
|
+
visitBlockExpression: (ctx: IKeyObjectValue) => any;
|
67
|
+
visitParenthesizedExpression: (ctx: IKeyObjectValue) => {
|
68
|
+
ruleType: VRuleType;
|
69
|
+
type: any;
|
70
|
+
ctx: IKeyObjectValue;
|
71
|
+
exprs: any;
|
72
|
+
};
|
73
|
+
visitAdditiveExpression: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
74
|
+
visitRelationalExpression: (ctx: IKeyObjectValue) => {
|
75
|
+
ruleType: VRuleType;
|
76
|
+
operator: string;
|
77
|
+
ctx: IKeyObjectValue;
|
78
|
+
type: string;
|
79
|
+
exprs: IKeyObjectValue[];
|
80
|
+
};
|
81
|
+
visitEqualityExpression: (ctx: IKeyObjectValue) => {
|
82
|
+
ruleType: VRuleType;
|
83
|
+
operator: string;
|
84
|
+
ctx: IKeyObjectValue;
|
85
|
+
type: string;
|
86
|
+
exprs: IKeyObjectValue[];
|
87
|
+
};
|
88
|
+
visitTernaryExpression: (ctx: IKeyObjectValue) => {
|
89
|
+
ruleType: VRuleType;
|
90
|
+
type: string;
|
91
|
+
ctx: IKeyObjectValue;
|
92
|
+
exprs: IKeyObjectValue[];
|
93
|
+
};
|
94
|
+
visitNameExpression: (ctx: IKeyObjectValue) => any;
|
95
|
+
visitLiteralExpression: (ctx: IKeyObjectValue) => any;
|
96
|
+
visitUnaryExpression: (ctx: IKeyObjectValue) => {
|
97
|
+
ruleType: VRuleType;
|
98
|
+
operator: any;
|
99
|
+
type: any;
|
100
|
+
ctx: IKeyObjectValue;
|
101
|
+
exprs: IKeyObjectValue[];
|
102
|
+
};
|
103
|
+
visitNotExpression: (ctx: IKeyObjectValue) => {
|
104
|
+
ruleType: VRuleType;
|
105
|
+
ctx: IKeyObjectValue;
|
106
|
+
type: string;
|
107
|
+
exprs: IKeyObjectValue[];
|
108
|
+
};
|
109
|
+
visitMemberIndexExpression: (ctx: IKeyObjectValue) => {
|
110
|
+
ruleType: VRuleType;
|
111
|
+
type: any;
|
112
|
+
ctx: IKeyObjectValue;
|
113
|
+
isInFunc: boolean;
|
114
|
+
exprs: IKeyObjectValue[];
|
115
|
+
};
|
116
|
+
visitMethodStmt: (ctx: IKeyObjectValue) => {
|
117
|
+
ruleType: VRuleType;
|
118
|
+
types: any;
|
119
|
+
ctx: IKeyObjectValue;
|
120
|
+
type: any;
|
121
|
+
exprs: any[];
|
122
|
+
};
|
123
|
+
visitMethodExpression: (ctx: IKeyObjectValue) => any;
|
124
|
+
visitLogicalAndExpression: (ctx: IKeyObjectValue) => {
|
125
|
+
ruleType: VRuleType;
|
126
|
+
type: string;
|
127
|
+
operator: string;
|
128
|
+
ctx: IKeyObjectValue;
|
129
|
+
exprs: IKeyObjectValue[];
|
130
|
+
};
|
131
|
+
visitLogicalOrExpression: (ctx: IKeyObjectValue) => {
|
132
|
+
ruleType: VRuleType;
|
133
|
+
operator: string;
|
134
|
+
ctx: IKeyObjectValue;
|
135
|
+
type: string;
|
136
|
+
exprs: IKeyObjectValue[];
|
137
|
+
};
|
138
|
+
visitMultiplicativeExpression: (ctx: IKeyObjectValue) => {
|
139
|
+
ruleType: VRuleType;
|
140
|
+
operator: string;
|
141
|
+
ctx: IKeyObjectValue;
|
142
|
+
type: string;
|
143
|
+
exprs: IKeyObjectValue[];
|
144
|
+
};
|
145
|
+
visitBrackethesized: (ctx: IKeyObjectValue) => {
|
146
|
+
ruleType: VRuleType;
|
147
|
+
ctx: IKeyObjectValue;
|
148
|
+
exprs: any;
|
149
|
+
};
|
150
|
+
visitArguments: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
151
|
+
visitArgument: (ctx: IKeyObjectValue) => any;
|
152
|
+
visitIfStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
153
|
+
visitForToStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
154
|
+
visitForInStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
155
|
+
visitSwitchStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
156
|
+
visitCaseClause: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
157
|
+
visitDefaultCaluse: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
158
|
+
visitWhileStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
159
|
+
visitImportStmt: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
160
|
+
visitImportElement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
161
|
+
visitLiteral: (ctx: IKeyObjectValue) => {
|
162
|
+
ruleType: VRuleType;
|
163
|
+
ctx: IKeyObjectValue;
|
164
|
+
type: string;
|
165
|
+
value: any;
|
166
|
+
};
|
167
|
+
visitMethodElement: (ctx: IKeyObjectValue) => {
|
168
|
+
name: any;
|
169
|
+
type: any;
|
170
|
+
args: any;
|
171
|
+
expr: any;
|
172
|
+
};
|
173
|
+
visitMethodName: (ctx: IKeyObjectValue) => any[];
|
174
|
+
visitArrowFunction: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
175
|
+
visitArrowFunctionParameters: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
176
|
+
visitFormalParameterList: (ctx: IKeyObjectValue) => IKeyObjectValue[];
|
177
|
+
visitFormalParameterArg: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
178
|
+
visitArrowMethod: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
179
|
+
visitArrowMethodParameters: (ctx: IKeyObjectValue) => any[];
|
180
|
+
visitTypeStatement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
181
|
+
visitTypeElement: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
182
|
+
visitAssignmentOperator: (ctx: IKeyObjectValue) => any;
|
183
|
+
visitTypeMap: (ctx: IKeyObjectValue) => string;
|
184
|
+
visitTypeSeries: (ctx: IKeyObjectValue) => string;
|
185
|
+
visitTypeArray: (ctx: IKeyObjectValue) => string;
|
186
|
+
visitTypeGather: (ctx: IKeyObjectValue) => any;
|
187
|
+
visitIdentifier: (ctx: IKeyObjectValue) => any;
|
188
|
+
visitTypeName: (ctx: IKeyObjectValue) => string;
|
189
|
+
visitName: (ctx: IKeyObjectValue) => IKeyObjectValue;
|
190
|
+
private _typeElementVerify;
|
191
|
+
private _memberIndexVerify;
|
192
|
+
private _setFuncParams;
|
193
|
+
private _pushBlockRanges;
|
194
|
+
private _setUserType;
|
195
|
+
private _againAssignHandle;
|
196
|
+
private _typeCheck;
|
197
|
+
private _verifyName;
|
198
|
+
private _nameCheck;
|
199
|
+
private _inBlock;
|
200
|
+
private _errorHandle;
|
201
|
+
private _boolTypeJudge;
|
202
|
+
private _calcTypeJudge;
|
203
|
+
private _typeJudge;
|
204
|
+
/**
|
205
|
+
* 判断数组中的对象类型是否一致,支持根据操作符和指定的类型集合对类型进行动态判断和调整。
|
206
|
+
* @param arr - 用于判断类型的对象数组
|
207
|
+
* @param children - 与 arr 对应的子对象数组,用于在类型不匹配时进行错误处理
|
208
|
+
* @param operator - 当前操作符,影响类型判断的逻辑
|
209
|
+
* @param supportTypes - 支持的类型数组,会根据操作符动态调整
|
210
|
+
* @returns 返回一个数组,包含每个对象根据判断逻辑确定的类型
|
211
|
+
*/
|
212
|
+
private _sameTypeJudge;
|
213
|
+
private _getUserVar;
|
214
|
+
private _repeatVarJudge;
|
215
|
+
private _judgeVarBuildIn;
|
216
|
+
private _updateUserVar;
|
217
|
+
private _variablesHandle;
|
218
|
+
private _checkVarMultiple;
|
219
|
+
private _addVarToMap;
|
220
|
+
private _setVariablesMap;
|
221
|
+
private _varTypeJudge;
|
222
|
+
private _getAllowTypes;
|
223
|
+
private _setNewFunc;
|
224
|
+
private _setCopyFunc;
|
225
|
+
private _setCopyMethod;
|
226
|
+
private _setFunc;
|
227
|
+
private _setMethod;
|
228
|
+
private _getMethodTypes;
|
229
|
+
private _globalFuncVerify;
|
230
|
+
private _hasMemberIndexVerify;
|
231
|
+
private _tempFuncNameHandle;
|
232
|
+
private _getOtherNamesMethodType;
|
233
|
+
private _expandMethodHandle;
|
234
|
+
/**
|
235
|
+
* 根据函数参数和上下文获取内置返回类型。
|
236
|
+
* @param res 函数匹配结果数组,包含返回类型、语法和参数信息。
|
237
|
+
* @param args 函数调用时的实际参数对象。
|
238
|
+
* @param name 函数名,用于错误处理时的提示。
|
239
|
+
* @param ctx 函数调用的上下文对象。
|
240
|
+
* @param fArg 函数的首个特定参数,可选,用于某些特殊场景下的类型检查。
|
241
|
+
* @param type 预期的返回类型数组,可选,用于进一步筛选返回类型。
|
242
|
+
* @returns 返回可能的返回类型数组。可能是一个确定的类型数组,或者在类型不匹配时返回[VType.UNDETERMINED]。
|
243
|
+
*/
|
244
|
+
private _getBuildInReturnTypes;
|
245
|
+
/**
|
246
|
+
* 根据提供的函数列表和当前参数,获取匹配的函数返回类型。
|
247
|
+
* @param funcs 函数列表,每个函数包含参数信息、返回类型、函数名和this类型。
|
248
|
+
* @param currentArgs 当前调用的参数对象。
|
249
|
+
* @param ctx 当前上下文对象,包含代码位置等信息。
|
250
|
+
* @param fArg 可选,指定的首个参数,用于重载判断。
|
251
|
+
* @returns 匹配的函数返回类型,如果没有匹配则返回'UNDETERMINED'。
|
252
|
+
*/
|
253
|
+
private _overloadsFuncGetTypes;
|
254
|
+
private _funcArgsAddOriginName;
|
255
|
+
/**
|
256
|
+
* 检查函数参数数量和类型是否符合预期
|
257
|
+
* @param args 提供的参数对象,包含实际参数和参数对象
|
258
|
+
* @param originArgs 预期的参数列表
|
259
|
+
* @param name 函数名称
|
260
|
+
* @param ctx 上下文信息,用于错误定位
|
261
|
+
* @param firstArg 第一个参数的对象,用于某些特定的参数检查
|
262
|
+
* @returns 返回一个对象,包含错误信息和警告信息
|
263
|
+
*/
|
264
|
+
private _overloadsCheckArgs;
|
265
|
+
/**
|
266
|
+
* 检查传入参数的数量和类型是否符合预期
|
267
|
+
* @param args 包含所有参数的对象
|
268
|
+
* @param originArgs 原始参数列表
|
269
|
+
* @param name 函数或方法的名称
|
270
|
+
* @param ctx 上下文信息,用于错误处理
|
271
|
+
* @param returnType 函数预期的返回类型
|
272
|
+
* @param firstArg 第一个参数的详细信息,可选
|
273
|
+
* @returns 返回一个对象,包含是否有错误和可能的类型信息
|
274
|
+
*/
|
275
|
+
private _checkArgs;
|
276
|
+
/**
|
277
|
+
* 校验参数是否符合给定的规则。
|
278
|
+
* @param arg 需要校验的参数对象,包含参数的规则类型、表达式和名称等信息。
|
279
|
+
* @param originArg 原始参数对象,包含参数的允许类型ID、显示类型和名称等信息。
|
280
|
+
* @param name 参数的当前名称。
|
281
|
+
* @param firstArg 如果是重载函数,第一个参数的对象。
|
282
|
+
* @param ctx 参数的上下文信息,可选。
|
283
|
+
* @param isOverloads 是否为重载函数的标志,可选。
|
284
|
+
* @returns 如果参数校验通过,返回true;否则返回false。
|
285
|
+
*/
|
286
|
+
private _checkArg;
|
287
|
+
/**
|
288
|
+
* 将键值对对象转换为检查对象,用于验证参数类型是否匹配
|
289
|
+
* @param arg 要检查的键值对对象,包含规则类型和表达式数组
|
290
|
+
* @param originArg 原始参数对象,包含参数名和允许的类型ID
|
291
|
+
* @param needType 需要检查的类型数组
|
292
|
+
* @param name 操作符名称
|
293
|
+
* @param type 当前参数的类型
|
294
|
+
* @returns 如果类型不匹配,返回错误提示字符串;否则,返回undefined
|
295
|
+
*/
|
296
|
+
private _tupleToCheck;
|
297
|
+
/**
|
298
|
+
* 获取块的返回类型
|
299
|
+
* @param block 可以是单个对象或者对象数组,代表一个代码块
|
300
|
+
* @returns 返回一个类型数组,表示该代码块可能的返回类型
|
301
|
+
*/
|
302
|
+
private _getBlockReturnTypes;
|
303
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { IDocValue, IKeyObjectValue } from "../type";
|
2
|
+
import TccScriptParserVisitor from '../../../tccParser/tccScriptParserVisitor';
|
3
|
+
export declare class ParserUtils extends TccScriptParserVisitor<any> {
|
4
|
+
protected _buildinVariables: Map<string, IDocValue[]>;
|
5
|
+
protected _buildinTypes: Map<string, IDocValue[]>;
|
6
|
+
protected _buildinConstants: Map<string, IDocValue[]>;
|
7
|
+
protected _buildinMethods: Map<string, IDocValue[]>;
|
8
|
+
protected _buildinFunctions: Map<string, IDocValue[]>;
|
9
|
+
constructor(buildinObj: IKeyObjectValue);
|
10
|
+
private _buildinHandle;
|
11
|
+
protected _typeHandle(types?: string[], rType?: string): string;
|
12
|
+
protected _returnTypesOtherHandle(firstArg: IKeyObjectValue, returnType: string, returnTypes: string[], name: string): string[];
|
13
|
+
protected _checkMethodThisType(thisType: string[], type: string): boolean;
|
14
|
+
protected _priorityComparison(currentType: string, targetType: string): boolean;
|
15
|
+
protected _compareType(currentType: string, targetType: string): boolean;
|
16
|
+
protected _typeAddSeries(type: string): string;
|
17
|
+
protected _typeAddConst(type: string): string;
|
18
|
+
protected _getOriginMethodName(type: string, lastName: string): string;
|
19
|
+
protected _returnedTypesParse(returnedTypes?: string[]): string[];
|
20
|
+
protected _removePrefix(type?: string): string;
|
21
|
+
protected _getPrefix(type: string): string;
|
22
|
+
protected _getArrayType(name: string): string | undefined;
|
23
|
+
protected _getMapType(name: string): "" | string[] | undefined;
|
24
|
+
protected _isMatrixType(type: string): boolean;
|
25
|
+
protected _isArrayType(type: string): boolean;
|
26
|
+
protected _isMapType(type: string): boolean;
|
27
|
+
protected _arrayTypeConvert(type: string): string;
|
28
|
+
protected _getMethodTypeName(type: string): string;
|
29
|
+
protected _typeReplace(returnType: string, type: string): string;
|
30
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { IKeyObjectValue } from "../type";
|
2
|
+
export declare class WorkerStorage {
|
3
|
+
private _cache;
|
4
|
+
constructor();
|
5
|
+
set(key: string, value: IKeyObjectValue): void;
|
6
|
+
setValue(mapKey: string, valKey: string, value: IKeyObjectValue): void;
|
7
|
+
updateValue(mapKey: string, valKey: string, value: IKeyObjectValue): void;
|
8
|
+
get(key: string): IKeyObjectValue | undefined;
|
9
|
+
has(key: string): boolean;
|
10
|
+
delete(key: string): void;
|
11
|
+
clear(): void;
|
12
|
+
}
|