@capillarytech/blaze-ui 5.4.1 → 5.6.0
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/CapAskAira/index.js +312 -341
- package/CapAskAira/index.js.map +1 -1
- package/CapExpressionEditor/README.md +32 -0
- package/CapExpressionEditor/index.d.ts +1654 -0
- package/CapExpressionEditor/index.d.ts.map +1 -0
- package/CapExpressionEditor/index.js +312 -349
- package/CapExpressionEditor/index.js.map +1 -1
- package/CapExpressionEditor/js/fixGrammar.d.ts +3 -0
- package/CapExpressionEditor/js/fixGrammar.d.ts.map +1 -0
- package/CapExpressionEditor/js/grammar.d.ts +1628 -0
- package/CapExpressionEditor/js/grammar.d.ts.map +1 -0
- package/CapExpressionEditor/types.d.ts +18 -0
- package/CapExpressionEditor/types.d.ts.map +1 -0
- package/CapLevelGraphRenderer/index.js +130 -127
- package/CapLevelGraphRenderer/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +4352 -1108
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/.npmrc +0 -2
- package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +0 -50
- package/CapLevelGraphRenderer/README.md +0 -123
- package/CapLevelGraphRenderer/Tooltip.d.ts +0 -24
- package/CapLevelGraphRenderer/Tooltip.d.ts.map +0 -1
- package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +0 -120
- package/CapLevelGraphRenderer/index.d.ts +0 -16
- package/CapLevelGraphRenderer/index.d.ts.map +0 -1
- package/CapLevelGraphRenderer/types.d.ts +0 -151
- package/CapLevelGraphRenderer/types.d.ts.map +0 -1
package/CapAskAira/index.js
CHANGED
|
@@ -8510,26 +8510,23 @@ var _default = exports["default"] = CapDivider;
|
|
|
8510
8510
|
|
|
8511
8511
|
exports.__esModule = true;
|
|
8512
8512
|
exports["default"] = void 0;
|
|
8513
|
+
var _classnames = _interopRequireDefault(__webpack_require__(46942));
|
|
8513
8514
|
var _jquery = _interopRequireDefault(__webpack_require__(42812));
|
|
8514
|
-
var _propTypes = _interopRequireDefault(__webpack_require__(43363));
|
|
8515
8515
|
var _react = _interopRequireDefault(__webpack_require__(9206));
|
|
8516
8516
|
var _CapInput = _interopRequireDefault(__webpack_require__(15773));
|
|
8517
8517
|
var _fixGrammar = _interopRequireDefault(__webpack_require__(29666));
|
|
8518
8518
|
var _grammar2 = _interopRequireDefault(__webpack_require__(22193));
|
|
8519
|
-
__webpack_require__(77792);
|
|
8519
|
+
var _styles = _interopRequireDefault(__webpack_require__(77792));
|
|
8520
8520
|
var _jsxRuntime = __webpack_require__(74848);
|
|
8521
|
-
const _excluded = ["className", "onChange", "grammar", "
|
|
8521
|
+
const _excluded = ["className", "onChange", "grammar", "expected", "typeSource", "delims", "expression"];
|
|
8522
8522
|
/**
|
|
8523
|
-
*
|
|
8524
|
-
* ExpressionEditor
|
|
8525
|
-
*
|
|
8523
|
+
* CapExpressionEditor - Expression editor with grammar validation and autocomplete
|
|
8526
8524
|
*/
|
|
8527
|
-
|
|
8525
|
+
/* global JQuery */
|
|
8528
8526
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8529
8527
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
8530
8528
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
8531
8529
|
__webpack_require__(29925);
|
|
8532
|
-
const classNames = __webpack_require__(46942);
|
|
8533
8530
|
const {
|
|
8534
8531
|
TextArea
|
|
8535
8532
|
} = _CapInput.default;
|
|
@@ -8537,19 +8534,19 @@ let idCounter = 0;
|
|
|
8537
8534
|
class CapExpressionEditor extends _react.default.Component {
|
|
8538
8535
|
constructor(props) {
|
|
8539
8536
|
super(props);
|
|
8537
|
+
this.$expressionEditorContainer = null;
|
|
8538
|
+
this.$expressionEditor = null;
|
|
8540
8539
|
this.onChange = () => {
|
|
8540
|
+
var _this$$expressionEdit, _this$$expressionEdit2, _this$$expressionEdit3, _this$$expressionEdit4;
|
|
8541
8541
|
const {
|
|
8542
8542
|
onChange
|
|
8543
8543
|
} = this.props;
|
|
8544
8544
|
this.setState({
|
|
8545
|
-
expressionJSON: this.$expressionEditor.data('json'),
|
|
8546
|
-
expression: this.$expressionEditor.val(),
|
|
8547
|
-
isError: this.$expressionEditorContainer.find('span.has_errors').length > 0
|
|
8545
|
+
expressionJSON: (_this$$expressionEdit = this.$expressionEditor) == null ? void 0 : _this$$expressionEdit.data('json'),
|
|
8546
|
+
expression: (_this$$expressionEdit2 = this.$expressionEditor) == null ? void 0 : _this$$expressionEdit2.val(),
|
|
8547
|
+
isError: ((_this$$expressionEdit3 = (_this$$expressionEdit4 = this.$expressionEditorContainer) == null ? void 0 : _this$$expressionEdit4.find('span.has_errors').length) != null ? _this$$expressionEdit3 : 0) > 0
|
|
8548
8548
|
}, () => onChange && onChange(this.state.expressionJSON, this.state.expression, this.state.isError));
|
|
8549
8549
|
};
|
|
8550
|
-
this.setRef = textArea => {
|
|
8551
|
-
this.expressionEditorContainer = textArea;
|
|
8552
|
-
};
|
|
8553
8550
|
this.state = {
|
|
8554
8551
|
expressionJSON: {},
|
|
8555
8552
|
expression: props.expression || '',
|
|
@@ -8562,10 +8559,6 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
8562
8559
|
return "expression-editor-" + idCounter;
|
|
8563
8560
|
}
|
|
8564
8561
|
componentDidMount() {
|
|
8565
|
-
/**
|
|
8566
|
-
* this.$expressionEditorContainer => This is the Jquery ref for entire expressionJSON container, will help us traverse through all the DOM node using jquery
|
|
8567
|
-
* this.$expressionEditor => this refers to the textArea of the expressionEditor
|
|
8568
|
-
*/
|
|
8569
8562
|
const {
|
|
8570
8563
|
grammar,
|
|
8571
8564
|
expected,
|
|
@@ -8575,15 +8568,18 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
8575
8568
|
disabled
|
|
8576
8569
|
} = this.props;
|
|
8577
8570
|
if (!disabled) {
|
|
8578
|
-
|
|
8571
|
+
const containerEl = document.querySelector("." + this.state.refTargetId);
|
|
8572
|
+
if (!containerEl) return;
|
|
8573
|
+
this.$expressionEditorContainer = (0, _jquery.default)(containerEl);
|
|
8579
8574
|
this.$expressionEditor = this.$expressionEditorContainer.find('textarea');
|
|
8575
|
+
if (!this.$expressionEditor.length) return;
|
|
8580
8576
|
this.$expressionEditor.expredit((0, _fixGrammar.default)(grammar), {
|
|
8581
8577
|
expected,
|
|
8582
8578
|
typeSource,
|
|
8583
8579
|
delims
|
|
8584
8580
|
}).on('change', () => this.onChange());
|
|
8585
8581
|
|
|
8586
|
-
//If we are already passing the expression then trigger a onchange to keep the JSON updated in the state
|
|
8582
|
+
// If we are already passing the expression then trigger a onchange to keep the JSON updated in the state
|
|
8587
8583
|
if (expression) {
|
|
8588
8584
|
this.$expressionEditor.trigger('change');
|
|
8589
8585
|
}
|
|
@@ -8599,26 +8595,19 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
8599
8595
|
expression: value
|
|
8600
8596
|
} = this.state;
|
|
8601
8597
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextArea, _extends({
|
|
8602
|
-
className:
|
|
8598
|
+
className: (0, _classnames.default)(_styles.default.root, 'cap-expression-editor', this.state.refTargetId, className)
|
|
8603
8599
|
}, rest, {
|
|
8604
|
-
ref: this.setRef,
|
|
8605
8600
|
value: value,
|
|
8606
8601
|
onChange: this.onChange
|
|
8607
8602
|
}));
|
|
8608
8603
|
}
|
|
8609
8604
|
}
|
|
8605
|
+
CapExpressionEditor.displayName = 'CapExpressionEditor';
|
|
8610
8606
|
CapExpressionEditor.defaultProps = {
|
|
8611
8607
|
grammar: _grammar2.default,
|
|
8612
8608
|
expected: ['boolean'],
|
|
8613
8609
|
delims: ['{{', '}}']
|
|
8614
8610
|
};
|
|
8615
|
-
CapExpressionEditor.propTypes = {
|
|
8616
|
-
grammar: _propTypes.default.object,
|
|
8617
|
-
expected: _propTypes.default.array,
|
|
8618
|
-
typeSource: _propTypes.default.string,
|
|
8619
|
-
delims: _propTypes.default.array,
|
|
8620
|
-
expression: _propTypes.default.string
|
|
8621
|
-
};
|
|
8622
8611
|
var _default = exports["default"] = CapExpressionEditor;
|
|
8623
8612
|
|
|
8624
8613
|
/***/ }),
|
|
@@ -9828,6 +9817,7 @@ var _default = exports["default"] = SvgPoints;
|
|
|
9828
9817
|
exports.__esModule = true;
|
|
9829
9818
|
exports["default"] = void 0;
|
|
9830
9819
|
/* eslint-disable */
|
|
9820
|
+
// @ts-nocheck - Legacy grammar fix utility; types would require extensive interface definitions
|
|
9831
9821
|
/*
|
|
9832
9822
|
Please use this fix function.
|
|
9833
9823
|
|
|
@@ -10001,7 +9991,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
10001
9991
|
/* eslint-disable */
|
|
10002
9992
|
|
|
10003
9993
|
_jquery.default.fn.expredit = function (grammar, options) {
|
|
10004
|
-
|
|
9994
|
+
'use strict';
|
|
10005
9995
|
|
|
10006
9996
|
//pickers.js
|
|
10007
9997
|
var pickers = {};
|
|
@@ -10013,7 +10003,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10013
10003
|
|
|
10014
10004
|
function makeRegex(str, atBegin, atEnd) {
|
|
10015
10005
|
try {
|
|
10016
|
-
return new RegExp((atBegin ?
|
|
10006
|
+
return new RegExp((atBegin ? '^' : '') + str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + (atEnd ? '$' : ''), 'i');
|
|
10017
10007
|
} catch (e) {
|
|
10018
10008
|
return null;
|
|
10019
10009
|
}
|
|
@@ -10037,21 +10027,21 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10037
10027
|
};
|
|
10038
10028
|
//
|
|
10039
10029
|
//pickers.datetime = function(value, type, setValue, onKey) {
|
|
10040
|
-
//
|
|
10030
|
+
//
|
|
10041
10031
|
// return getCalender();;//$("<div>").addClass("info").html("Date picker will come here.");
|
|
10042
10032
|
//},
|
|
10043
10033
|
|
|
10044
10034
|
pickers.interval = function (value, type, setValue, onKey) {
|
|
10045
|
-
return (0, _jquery.default)(
|
|
10035
|
+
return (0, _jquery.default)('<div>').addClass('info').html('Time interval picker will come here.');
|
|
10046
10036
|
}, pickers.enumset = function (value, type, setValue, onKey) {
|
|
10047
10037
|
var list = pickers.enum(value, type.valueType);
|
|
10048
|
-
return (0, _jquery.default)(
|
|
10038
|
+
return (0, _jquery.default)('<div>').addClass('info').html('Multiselect box with options ' + node.getType(type.valueType).values.join(', '));
|
|
10049
10039
|
},
|
|
10050
10040
|
// ----- Calltips from the current scope -----
|
|
10051
10041
|
|
|
10052
10042
|
pickers.any = function (node, sort) {
|
|
10053
10043
|
// This populates calltips.
|
|
10054
|
-
if (typeof sort ===
|
|
10044
|
+
if (typeof sort === 'undefined') sort = false;
|
|
10055
10045
|
var r = [],
|
|
10056
10046
|
calltipDiv,
|
|
10057
10047
|
scope = node.scope,
|
|
@@ -10062,7 +10052,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10062
10052
|
m,
|
|
10063
10053
|
t,
|
|
10064
10054
|
root,
|
|
10065
|
-
prefix =
|
|
10055
|
+
prefix = '';
|
|
10066
10056
|
|
|
10067
10057
|
// turn the name into a regex for matching.
|
|
10068
10058
|
try {
|
|
@@ -10090,7 +10080,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10090
10080
|
// return calltipDiv;
|
|
10091
10081
|
// }
|
|
10092
10082
|
}
|
|
10093
|
-
prefix +=
|
|
10083
|
+
prefix += 'outer.';
|
|
10094
10084
|
scope = scope.outer;
|
|
10095
10085
|
}
|
|
10096
10086
|
return r.length && (r.length > 1 || node.text != r[0]) ? calltipDiv : false;
|
|
@@ -10102,7 +10092,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10102
10092
|
// Aravind R S, Capillary Technologies, 2012-02-09
|
|
10103
10093
|
|
|
10104
10094
|
var tokenize = function (str) {
|
|
10105
|
-
|
|
10095
|
+
'use strict';
|
|
10106
10096
|
|
|
10107
10097
|
var rex = {
|
|
10108
10098
|
space: /^\s+/,
|
|
@@ -10116,31 +10106,31 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10116
10106
|
tok,
|
|
10117
10107
|
pos = 0,
|
|
10118
10108
|
r;
|
|
10119
|
-
while (str !=
|
|
10109
|
+
while (str != '') {
|
|
10120
10110
|
tok = null;
|
|
10121
10111
|
for (r in rex) {
|
|
10122
10112
|
str = str.replace(rex[r], function (m) {
|
|
10123
10113
|
var len = m.length,
|
|
10124
10114
|
val;
|
|
10125
|
-
if (r ==
|
|
10115
|
+
if (r == 'space') {
|
|
10126
10116
|
pos += len;
|
|
10127
|
-
return
|
|
10128
|
-
} else if (r ==
|
|
10117
|
+
return '';
|
|
10118
|
+
} else if (r == 'number') {
|
|
10129
10119
|
val = parseFloat(m);
|
|
10130
|
-
} else if (r ==
|
|
10120
|
+
} else if (r == 'date') {
|
|
10131
10121
|
val = new Date(m.substring(2, m.length - 2));
|
|
10132
|
-
} else if (r ==
|
|
10133
|
-
case
|
|
10122
|
+
} else if (r == 'name') switch (m) {
|
|
10123
|
+
case 'true':
|
|
10134
10124
|
val = true;
|
|
10135
|
-
r =
|
|
10125
|
+
r = 'boolean';
|
|
10136
10126
|
break;
|
|
10137
|
-
case
|
|
10127
|
+
case 'false':
|
|
10138
10128
|
val = false;
|
|
10139
|
-
r =
|
|
10129
|
+
r = 'boolean';
|
|
10140
10130
|
break;
|
|
10141
10131
|
default:
|
|
10142
10132
|
val = m;
|
|
10143
|
-
} else if (r ==
|
|
10133
|
+
} else if (r == 'string') {
|
|
10144
10134
|
val = m.substr(1, len - 2);
|
|
10145
10135
|
} else {
|
|
10146
10136
|
val = m;
|
|
@@ -10153,7 +10143,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10153
10143
|
len: len
|
|
10154
10144
|
};
|
|
10155
10145
|
pos += len;
|
|
10156
|
-
return
|
|
10146
|
+
return '';
|
|
10157
10147
|
});
|
|
10158
10148
|
if (tok) break;
|
|
10159
10149
|
}
|
|
@@ -10174,13 +10164,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10174
10164
|
|
|
10175
10165
|
var protonode = {};
|
|
10176
10166
|
var parse = function () {
|
|
10177
|
-
|
|
10167
|
+
'use strict';
|
|
10178
10168
|
|
|
10179
10169
|
var symbol_table = {},
|
|
10180
10170
|
token,
|
|
10181
10171
|
tokens,
|
|
10182
10172
|
token_nr,
|
|
10183
|
-
terminators = [
|
|
10173
|
+
terminators = ['(end)'],
|
|
10184
10174
|
has_errors;
|
|
10185
10175
|
var itself = function () {
|
|
10186
10176
|
return this;
|
|
@@ -10194,7 +10184,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10194
10184
|
e = "Expected '" + id + "'";
|
|
10195
10185
|
}
|
|
10196
10186
|
if (token_nr >= tokens.length) {
|
|
10197
|
-
token = symbol_table[
|
|
10187
|
+
token = symbol_table['(end)'];
|
|
10198
10188
|
t = tokens[tokens.length - 1];
|
|
10199
10189
|
token.pos = t ? t.pos + t.len : 0;
|
|
10200
10190
|
token.len = 0;
|
|
@@ -10204,30 +10194,30 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10204
10194
|
token_nr += 1;
|
|
10205
10195
|
v = t.value;
|
|
10206
10196
|
a = t.arity;
|
|
10207
|
-
if (a ===
|
|
10208
|
-
o = symbol_table[
|
|
10209
|
-
} else if (a ===
|
|
10197
|
+
if (a === 'name') {
|
|
10198
|
+
o = symbol_table['(name)'];
|
|
10199
|
+
} else if (a === 'operator') {
|
|
10210
10200
|
o = symbol_table[v];
|
|
10211
10201
|
if (!o) {
|
|
10212
|
-
e =
|
|
10202
|
+
e = 'Unknown operator.';
|
|
10213
10203
|
}
|
|
10214
|
-
} else if (a ===
|
|
10215
|
-
o = symbol_table[
|
|
10204
|
+
} else if (a === 'string' || a === 'number' || a === 'boolean' || a === 'datetime') {
|
|
10205
|
+
o = symbol_table['(literal)'];
|
|
10216
10206
|
type = a;
|
|
10217
|
-
a =
|
|
10207
|
+
a = 'literal';
|
|
10218
10208
|
} else {
|
|
10219
|
-
e =
|
|
10209
|
+
e = 'Unexpected token.';
|
|
10220
10210
|
}
|
|
10221
10211
|
if (o) {
|
|
10222
10212
|
token = Object.create(o);
|
|
10223
10213
|
} else {
|
|
10224
10214
|
token = missing();
|
|
10225
|
-
a =
|
|
10215
|
+
a = 'missing';
|
|
10226
10216
|
}
|
|
10227
10217
|
token.value = v;
|
|
10228
10218
|
token.arity = a;
|
|
10229
10219
|
token.type = type;
|
|
10230
|
-
token.text = t.text ||
|
|
10220
|
+
token.text = t.text || '';
|
|
10231
10221
|
token.pos = t.pos;
|
|
10232
10222
|
token.len = t.len;
|
|
10233
10223
|
if (e) {
|
|
@@ -10255,14 +10245,14 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10255
10245
|
return left;
|
|
10256
10246
|
};
|
|
10257
10247
|
protonode.nud = function () {
|
|
10258
|
-
this.arity =
|
|
10259
|
-
this.error(
|
|
10248
|
+
this.arity = 'missing';
|
|
10249
|
+
this.error('Unknown operator.');
|
|
10260
10250
|
return this;
|
|
10261
10251
|
};
|
|
10262
10252
|
protonode.led = function (left) {
|
|
10263
10253
|
var n = missing();
|
|
10264
|
-
this.arity =
|
|
10265
|
-
this.error(
|
|
10254
|
+
this.arity = 'group';
|
|
10255
|
+
this.error('Unknown operator.');
|
|
10266
10256
|
n.children = [left, this];
|
|
10267
10257
|
return n;
|
|
10268
10258
|
};
|
|
@@ -10284,7 +10274,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10284
10274
|
var group = function (e) {
|
|
10285
10275
|
var g = Object.create(protonode);
|
|
10286
10276
|
g.value = undefined;
|
|
10287
|
-
g.arity =
|
|
10277
|
+
g.arity = 'group';
|
|
10288
10278
|
g.children = [];
|
|
10289
10279
|
if (e) g.error(e);
|
|
10290
10280
|
return g;
|
|
@@ -10292,18 +10282,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10292
10282
|
var missing = function (e) {
|
|
10293
10283
|
var m = Object.create(protonode);
|
|
10294
10284
|
m.value = undefined;
|
|
10295
|
-
m.arity =
|
|
10285
|
+
m.arity = 'missing';
|
|
10296
10286
|
if (e) {
|
|
10297
10287
|
m.error(e);
|
|
10298
10288
|
} else if (e !== false) {
|
|
10299
|
-
m.error(
|
|
10289
|
+
m.error('Missing value.');
|
|
10300
10290
|
}
|
|
10301
10291
|
return m;
|
|
10302
10292
|
};
|
|
10303
10293
|
var pos_missing = function (node, pos) {
|
|
10304
|
-
if (node.arity !==
|
|
10305
|
-
if (typeof node.pos ===
|
|
10306
|
-
if (typeof node.len ===
|
|
10294
|
+
if (node.arity !== 'missing') return node;
|
|
10295
|
+
if (typeof node.pos === 'undefined') node.pos = pos;
|
|
10296
|
+
if (typeof node.len === 'undefined') node.len = node.text ? node.text.length : 1;
|
|
10307
10297
|
return node;
|
|
10308
10298
|
};
|
|
10309
10299
|
var infix = function (id, bp, led) {
|
|
@@ -10312,7 +10302,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10312
10302
|
this.children = [left, expression(bp)];
|
|
10313
10303
|
pos_missing(this.children[0], this.pos);
|
|
10314
10304
|
pos_missing(this.children[1], this.pos + this.len);
|
|
10315
|
-
this.arity =
|
|
10305
|
+
this.arity = 'binary_operation';
|
|
10316
10306
|
return this;
|
|
10317
10307
|
};
|
|
10318
10308
|
return s;
|
|
@@ -10323,7 +10313,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10323
10313
|
this.children = [left, expression(bp - 1)];
|
|
10324
10314
|
pos_missing(this.children[0], this.pos);
|
|
10325
10315
|
pos_missing(this.children[1], this.pos + this.len);
|
|
10326
|
-
this.arity =
|
|
10316
|
+
this.arity = 'binary_operation';
|
|
10327
10317
|
return this;
|
|
10328
10318
|
};
|
|
10329
10319
|
return s;
|
|
@@ -10333,61 +10323,61 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10333
10323
|
s.nud = nud || function () {
|
|
10334
10324
|
this.children = [expression(70)];
|
|
10335
10325
|
pos_missing(this.children[0], this.pos + this.len);
|
|
10336
|
-
this.arity =
|
|
10326
|
+
this.arity = 'unary_operation';
|
|
10337
10327
|
return this;
|
|
10338
10328
|
};
|
|
10339
10329
|
return s;
|
|
10340
10330
|
};
|
|
10341
|
-
symbol(
|
|
10342
|
-
symbol(
|
|
10343
|
-
symbol(
|
|
10331
|
+
symbol('(end)').nud = nothing;
|
|
10332
|
+
symbol('(name)').nud = itself;
|
|
10333
|
+
symbol(')');
|
|
10344
10334
|
// symbol("]");
|
|
10345
|
-
symbol(
|
|
10346
|
-
symbol(
|
|
10347
|
-
symbol(
|
|
10348
|
-
infix(
|
|
10335
|
+
symbol(':');
|
|
10336
|
+
symbol(',');
|
|
10337
|
+
symbol('(literal)').nud = itself;
|
|
10338
|
+
infix('?', 20, function (left) {
|
|
10349
10339
|
var s_tok;
|
|
10350
10340
|
this.children = [left];
|
|
10351
10341
|
pos_missing(this.children[0], this.pos);
|
|
10352
|
-
terminators.push(
|
|
10342
|
+
terminators.push(':');
|
|
10353
10343
|
this.children[1] = expression(0);
|
|
10354
10344
|
pos_missing(this.children[1], this.pos + this.len);
|
|
10355
10345
|
s_tok = token;
|
|
10356
|
-
if (terminators[terminators.length - 1] ==
|
|
10357
|
-
advance(
|
|
10346
|
+
if (terminators[terminators.length - 1] == ':') terminators.pop();
|
|
10347
|
+
advance(':');
|
|
10358
10348
|
this.children[2] = expression(0);
|
|
10359
10349
|
pos_missing(this.children[2], s_tok.pos + s_tok.len);
|
|
10360
|
-
this.arity =
|
|
10350
|
+
this.arity = 'ternary_operation';
|
|
10361
10351
|
return this;
|
|
10362
10352
|
});
|
|
10363
|
-
infixr(
|
|
10364
|
-
infixr(
|
|
10365
|
-
infixr(
|
|
10366
|
-
infixr(
|
|
10367
|
-
infixr(
|
|
10368
|
-
infixr(
|
|
10369
|
-
infixr(
|
|
10370
|
-
infixr(
|
|
10371
|
-
infix(
|
|
10372
|
-
infix(
|
|
10373
|
-
infix(
|
|
10374
|
-
infix(
|
|
10375
|
-
infix(
|
|
10376
|
-
infix(
|
|
10353
|
+
infixr('&&', 30);
|
|
10354
|
+
infixr('||', 30);
|
|
10355
|
+
infixr('==', 40);
|
|
10356
|
+
infixr('!=', 40);
|
|
10357
|
+
infixr('<', 40);
|
|
10358
|
+
infixr('<=', 40);
|
|
10359
|
+
infixr('>', 40);
|
|
10360
|
+
infixr('>=', 40);
|
|
10361
|
+
infix('+', 50);
|
|
10362
|
+
infix('-', 50);
|
|
10363
|
+
infix('*', 60);
|
|
10364
|
+
infix('/', 60);
|
|
10365
|
+
infix('%', 60);
|
|
10366
|
+
infix('.', 80, function (left) {
|
|
10377
10367
|
var n;
|
|
10378
10368
|
this.children = [left];
|
|
10379
|
-
this.arity =
|
|
10369
|
+
this.arity = 'object_dereference';
|
|
10380
10370
|
this.value = undefined;
|
|
10381
|
-
if (token.arity ===
|
|
10371
|
+
if (token.arity === 'name') {
|
|
10382
10372
|
this.children[1] = token;
|
|
10383
10373
|
advance();
|
|
10384
|
-
} else if (token.id ===
|
|
10385
|
-
token.arity =
|
|
10386
|
-
token.error(
|
|
10374
|
+
} else if (token.id === '(literal)') {
|
|
10375
|
+
token.arity = 'missing';
|
|
10376
|
+
token.error('Expected a property name.');
|
|
10387
10377
|
this.children[1] = token;
|
|
10388
10378
|
advance();
|
|
10389
10379
|
} else {
|
|
10390
|
-
this.children[1] = missing(
|
|
10380
|
+
this.children[1] = missing('Expected a property name.');
|
|
10391
10381
|
}
|
|
10392
10382
|
pos_missing(this.children[0], this.pos);
|
|
10393
10383
|
pos_missing(this.children[1], this.pos + this.len);
|
|
@@ -10395,59 +10385,56 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10395
10385
|
});
|
|
10396
10386
|
|
|
10397
10387
|
/* infix("[", 80, function (left) {
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
});*/
|
|
10428
|
-
|
|
10429
|
-
infix("(", 80, function (left) {
|
|
10388
|
+
var g, n, e;
|
|
10389
|
+
if(left.id === "(literal)") {
|
|
10390
|
+
left.error("Expected a collection.");
|
|
10391
|
+
}
|
|
10392
|
+
terminators.push("]");
|
|
10393
|
+
this.children = [left];
|
|
10394
|
+
pos_missing(this.children[0], this.pos);
|
|
10395
|
+
n = expression(0);
|
|
10396
|
+
e = [n];
|
|
10397
|
+
while(token.id !== "]" && token.id !== "(end)") {
|
|
10398
|
+
e.push(expression(0));
|
|
10399
|
+
}
|
|
10400
|
+
if(e.length > 1) {
|
|
10401
|
+
g = group();
|
|
10402
|
+
g.paren = false;
|
|
10403
|
+
g.children = e;
|
|
10404
|
+
this.children.push(g);
|
|
10405
|
+
} else {
|
|
10406
|
+
this.children.push(n);
|
|
10407
|
+
}
|
|
10408
|
+
pos_missing(this.children[1], this.pos + this.len);
|
|
10409
|
+
this.arity = "array_lookup";
|
|
10410
|
+
this.value = undefined;
|
|
10411
|
+
if(terminators[terminators.length-1]=="]") terminators.pop();
|
|
10412
|
+
advance("]");
|
|
10413
|
+
return this;
|
|
10414
|
+
});*/
|
|
10415
|
+
|
|
10416
|
+
infix('(', 80, function (left) {
|
|
10430
10417
|
var g, n, e;
|
|
10431
|
-
if (left.arity ===
|
|
10432
|
-
this.arity =
|
|
10418
|
+
if (left.arity === 'object_dereference') {
|
|
10419
|
+
this.arity = 'method_call';
|
|
10433
10420
|
this.value = undefined;
|
|
10434
10421
|
this.children = left.children;
|
|
10435
|
-
if (left.children[1].arity !==
|
|
10436
|
-
left.children[1].error(
|
|
10422
|
+
if (left.children[1].arity !== 'name') {
|
|
10423
|
+
left.children[1].error('Expected a method name.');
|
|
10437
10424
|
}
|
|
10438
10425
|
} else {
|
|
10439
|
-
this.arity =
|
|
10426
|
+
this.arity = 'function_call';
|
|
10440
10427
|
this.value = undefined;
|
|
10441
10428
|
this.children = [left];
|
|
10442
|
-
if (left.arity !==
|
|
10443
|
-
left.error(
|
|
10429
|
+
if (left.arity !== 'name') {
|
|
10430
|
+
left.error('Expected a function name.');
|
|
10444
10431
|
}
|
|
10445
10432
|
}
|
|
10446
|
-
terminators.push(
|
|
10433
|
+
terminators.push(')');
|
|
10447
10434
|
n = missing(false);
|
|
10448
10435
|
pos_missing(n, token.pos);
|
|
10449
|
-
while (token.id !==
|
|
10450
|
-
if (token.id ===
|
|
10436
|
+
while (token.id !== ')' && token.id !== '(end)') {
|
|
10437
|
+
if (token.id === ',') {
|
|
10451
10438
|
n = missing();
|
|
10452
10439
|
} else {
|
|
10453
10440
|
n = expression(0);
|
|
@@ -10456,7 +10443,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10456
10443
|
e = [n];
|
|
10457
10444
|
|
|
10458
10445
|
// Gather any malformed tokens from here to the next ) or ,
|
|
10459
|
-
while (token.id !==
|
|
10446
|
+
while (token.id !== ',' && token.id !== ')' && token.id !== '(end)') {
|
|
10460
10447
|
e.push(expression(0));
|
|
10461
10448
|
}
|
|
10462
10449
|
if (e.length > 1) {
|
|
@@ -10468,35 +10455,35 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10468
10455
|
this.children.push(n);
|
|
10469
10456
|
}
|
|
10470
10457
|
n = null;
|
|
10471
|
-
if (token.id ===
|
|
10458
|
+
if (token.id === ',') {
|
|
10472
10459
|
n = missing();
|
|
10473
10460
|
pos_missing(n, token.pos + token.len);
|
|
10474
|
-
advance(
|
|
10461
|
+
advance(',');
|
|
10475
10462
|
}
|
|
10476
10463
|
}
|
|
10477
10464
|
if (n) {
|
|
10478
10465
|
this.children.push(n);
|
|
10479
10466
|
}
|
|
10480
|
-
if (terminators[terminators.length - 1] ==
|
|
10481
|
-
advance(
|
|
10467
|
+
if (terminators[terminators.length - 1] == ')') terminators.pop();
|
|
10468
|
+
advance(')');
|
|
10482
10469
|
return this;
|
|
10483
10470
|
});
|
|
10484
|
-
prefix(
|
|
10485
|
-
prefix(
|
|
10486
|
-
prefix(
|
|
10487
|
-
prefix(
|
|
10471
|
+
prefix('!');
|
|
10472
|
+
prefix('-');
|
|
10473
|
+
prefix('+');
|
|
10474
|
+
prefix('(', function () {
|
|
10488
10475
|
var e;
|
|
10489
|
-
this.arity =
|
|
10476
|
+
this.arity = 'group';
|
|
10490
10477
|
this.value = undefined;
|
|
10491
|
-
this.text =
|
|
10478
|
+
this.text = '';
|
|
10492
10479
|
this.children = [];
|
|
10493
|
-
terminators.push(
|
|
10494
|
-
if (token.id ===
|
|
10480
|
+
terminators.push(')');
|
|
10481
|
+
if (token.id === ')' || token.id === '(end)') {
|
|
10495
10482
|
e = missing();
|
|
10496
10483
|
pos_missing(e, token.pos);
|
|
10497
10484
|
this.children.push(e);
|
|
10498
10485
|
} else {
|
|
10499
|
-
while (token.id !==
|
|
10486
|
+
while (token.id !== ')' && token.id !== '(end)') {
|
|
10500
10487
|
e = expression(0);
|
|
10501
10488
|
pos_missing(e, token.pos);
|
|
10502
10489
|
if (this.children.length > 0) {
|
|
@@ -10505,8 +10492,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10505
10492
|
this.children.push(e);
|
|
10506
10493
|
}
|
|
10507
10494
|
}
|
|
10508
|
-
if (terminators[terminators.length - 1] ==
|
|
10509
|
-
advance(
|
|
10495
|
+
if (terminators[terminators.length - 1] == ')') terminators.pop();
|
|
10496
|
+
advance(')');
|
|
10510
10497
|
return this;
|
|
10511
10498
|
});
|
|
10512
10499
|
protonode.error = function (e) {
|
|
@@ -10525,15 +10512,15 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10525
10512
|
token_nr = 0;
|
|
10526
10513
|
advance();
|
|
10527
10514
|
do {
|
|
10528
|
-
terminators = [
|
|
10515
|
+
terminators = ['(end)'];
|
|
10529
10516
|
tree = expression(0);
|
|
10530
|
-
if (token.id !==
|
|
10531
|
-
token.error(
|
|
10517
|
+
if (token.id !== '(end)') {
|
|
10518
|
+
token.error('Expected an operator.');
|
|
10532
10519
|
}
|
|
10533
|
-
if (!(tree.arity ==
|
|
10520
|
+
if (!(tree.arity == 'missing' && (tree.value == ')' || tree.value == ']'))) {
|
|
10534
10521
|
trees.push(tree);
|
|
10535
10522
|
}
|
|
10536
|
-
} while (token.id !==
|
|
10523
|
+
} while (token.id !== '(end)');
|
|
10537
10524
|
if (trees.length == 1) {
|
|
10538
10525
|
tree = trees[0];
|
|
10539
10526
|
} else {
|
|
@@ -10552,7 +10539,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10552
10539
|
*/
|
|
10553
10540
|
protonode.crosslink = function (parent) {
|
|
10554
10541
|
var i, l, subtree;
|
|
10555
|
-
if (this.arity ===
|
|
10542
|
+
if (this.arity === 'group' && this.children && this.children.length === 1) {
|
|
10556
10543
|
this.operands = this.children;
|
|
10557
10544
|
return this.children[0].crosslink(parent);
|
|
10558
10545
|
}
|
|
@@ -10573,7 +10560,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10573
10560
|
// this is the prototype of the primitive types
|
|
10574
10561
|
|
|
10575
10562
|
var primitive = {
|
|
10576
|
-
ancestry:
|
|
10563
|
+
ancestry: 'primitive',
|
|
10577
10564
|
prepared: true,
|
|
10578
10565
|
//Adding isStrict to match the exact type and not any super type.(Author:Susi)
|
|
10579
10566
|
is: function (type, isStrict) {
|
|
@@ -10583,9 +10570,9 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10583
10570
|
if (type.ancestry && !/\banonymous\b/.test(type.ancestry)) {
|
|
10584
10571
|
type = type.ancestry;
|
|
10585
10572
|
}
|
|
10586
|
-
if (typeof type ===
|
|
10573
|
+
if (typeof type === 'string') {
|
|
10587
10574
|
if (this.ancestry) {
|
|
10588
|
-
if (isStrict === true) return this.ancestry === type;else return new RegExp(
|
|
10575
|
+
if (isStrict === true) return this.ancestry === type;else return new RegExp('\\b' + type + '\\b').test(this.ancestry);
|
|
10589
10576
|
} else {
|
|
10590
10577
|
return false;
|
|
10591
10578
|
}
|
|
@@ -10599,9 +10586,9 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10599
10586
|
|
|
10600
10587
|
var traverse = function (root, path) {
|
|
10601
10588
|
var res;
|
|
10602
|
-
path = path.replace(/\$/g,
|
|
10589
|
+
path = path.replace(/\$/g, 'this');
|
|
10603
10590
|
try {
|
|
10604
|
-
res = new Function(
|
|
10591
|
+
res = new Function('return ' + path).call(root);
|
|
10605
10592
|
} catch (e) {}
|
|
10606
10593
|
return res;
|
|
10607
10594
|
};
|
|
@@ -10627,7 +10614,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10627
10614
|
if (currentScope && currentScope.idents) {
|
|
10628
10615
|
scope.idents.outer = {
|
|
10629
10616
|
type: this.getType({
|
|
10630
|
-
form:
|
|
10617
|
+
form: 'object',
|
|
10631
10618
|
memberScope: currentScope,
|
|
10632
10619
|
members: currentScope.idents
|
|
10633
10620
|
})
|
|
@@ -10691,12 +10678,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10691
10678
|
};
|
|
10692
10679
|
protonode.getType = function (p) {
|
|
10693
10680
|
var type, t, typeName, i, pp, inherit, scope;
|
|
10694
|
-
if (p ===
|
|
10681
|
+
if (p === 'any') {
|
|
10695
10682
|
return primitive;
|
|
10696
10683
|
}
|
|
10697
|
-
if (typeof p ===
|
|
10698
|
-
if (typeof p ===
|
|
10699
|
-
if (p.indexOf(
|
|
10684
|
+
if (typeof p === 'undefined') p = this.type;
|
|
10685
|
+
if (typeof p === 'string') {
|
|
10686
|
+
if (p.indexOf('$') === -1) {
|
|
10700
10687
|
type = grammar.types[p];
|
|
10701
10688
|
if (!type) {
|
|
10702
10689
|
if (type !== false) {
|
|
@@ -10714,12 +10701,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10714
10701
|
}
|
|
10715
10702
|
if (pp) {
|
|
10716
10703
|
type = this.getType(pp);
|
|
10717
|
-
typeName =
|
|
10704
|
+
typeName = 'anonymous';
|
|
10718
10705
|
}
|
|
10719
10706
|
}
|
|
10720
10707
|
} else {
|
|
10721
10708
|
type = p;
|
|
10722
|
-
typeName =
|
|
10709
|
+
typeName = 'anonymous';
|
|
10723
10710
|
}
|
|
10724
10711
|
if (!type) {
|
|
10725
10712
|
return null;
|
|
@@ -10734,7 +10721,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10734
10721
|
var i,
|
|
10735
10722
|
newObj = Object.create(oldObj);
|
|
10736
10723
|
for (i in props) {
|
|
10737
|
-
if (typeof oldObj[i] ===
|
|
10724
|
+
if (typeof oldObj[i] === 'object' && typeof props[i] === 'object' && oldObj[i] !== null && props[i] !== null) {
|
|
10738
10725
|
newObj[i] = inherit(oldObj[i], props[i]);
|
|
10739
10726
|
} else {
|
|
10740
10727
|
newObj[i] = props[i];
|
|
@@ -10742,7 +10729,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10742
10729
|
}
|
|
10743
10730
|
return newObj;
|
|
10744
10731
|
};
|
|
10745
|
-
if (type.form ===
|
|
10732
|
+
if (type.form === 'primitive') {
|
|
10746
10733
|
t = inherit(primitive, type);
|
|
10747
10734
|
} else {
|
|
10748
10735
|
p = this.getType(type.form);
|
|
@@ -10752,7 +10739,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10752
10739
|
return;
|
|
10753
10740
|
}
|
|
10754
10741
|
}
|
|
10755
|
-
t.ancestry = typeName +
|
|
10742
|
+
t.ancestry = typeName + ':' + t.ancestry;
|
|
10756
10743
|
t.prepared = true;
|
|
10757
10744
|
return t;
|
|
10758
10745
|
};
|
|
@@ -10766,13 +10753,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10766
10753
|
i,
|
|
10767
10754
|
l = node.operands.length - offset;
|
|
10768
10755
|
fnType = node.operands[offset - 1].type;
|
|
10769
|
-
if (!fnType || !fnType.is(
|
|
10756
|
+
if (!fnType || !fnType.is('function')) {
|
|
10770
10757
|
return;
|
|
10771
10758
|
}
|
|
10772
10759
|
node.type = fnType.type;
|
|
10773
10760
|
if (fnType.params && fnType.params.length !== l) {
|
|
10774
10761
|
//Handling wherever the function doesnt have parameters.Not an error.
|
|
10775
|
-
if (fnType.params.length != 0) node.error(
|
|
10762
|
+
if (fnType.params.length != 0) node.error('Expected ' + fnType.params.length + ' arguments.');
|
|
10776
10763
|
l = Math.min(l, fnType.params.length);
|
|
10777
10764
|
}
|
|
10778
10765
|
for (i = 0; i < l; i += 1) {
|
|
@@ -10789,11 +10776,11 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10789
10776
|
};
|
|
10790
10777
|
this.scope = scope;
|
|
10791
10778
|
switch (this.arity) {
|
|
10792
|
-
case
|
|
10779
|
+
case 'literal':
|
|
10793
10780
|
break;
|
|
10794
|
-
case
|
|
10781
|
+
case 'missing':
|
|
10795
10782
|
break;
|
|
10796
|
-
case
|
|
10783
|
+
case 'name':
|
|
10797
10784
|
while (scope) {
|
|
10798
10785
|
this.ident = scope.find(this.value);
|
|
10799
10786
|
if (this.ident) break;
|
|
@@ -10803,12 +10790,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10803
10790
|
this.type = this.ident.type;
|
|
10804
10791
|
this.scope = scope;
|
|
10805
10792
|
} else {
|
|
10806
|
-
this.error(
|
|
10793
|
+
this.error('Unknown identifier.');
|
|
10807
10794
|
}
|
|
10808
10795
|
break;
|
|
10809
|
-
case
|
|
10810
|
-
case
|
|
10811
|
-
case
|
|
10796
|
+
case 'unary_operation':
|
|
10797
|
+
case 'binary_operation':
|
|
10798
|
+
case 'ternary_operation':
|
|
10812
10799
|
for (i = 0, l = this.operands.length; i < l; i += 1) {
|
|
10813
10800
|
this.operands[i].setType(scope);
|
|
10814
10801
|
}
|
|
@@ -10823,24 +10810,24 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10823
10810
|
for (i = 0, l = this.operands.length; i < l; i += 1) {
|
|
10824
10811
|
e.push(getTypeName(this.operands[i]));
|
|
10825
10812
|
}
|
|
10826
|
-
this.error(
|
|
10813
|
+
this.error('Invalid ' + this.value + ' between ' + e.join(', '));
|
|
10827
10814
|
}
|
|
10828
10815
|
break;
|
|
10829
|
-
case
|
|
10816
|
+
case 'object_dereference':
|
|
10830
10817
|
this.operands[0].setType(scope);
|
|
10831
10818
|
if (this.operands[0].type) {
|
|
10832
10819
|
this.operands[1].setType(this.operands[0].type.memberScope || this.getScope(this.operands[0].type.members, null));
|
|
10833
10820
|
}
|
|
10834
10821
|
this.type = this.operands[1].type;
|
|
10835
|
-
this.operands[0].setExpectedTypes([
|
|
10822
|
+
this.operands[0].setExpectedTypes(['object']);
|
|
10836
10823
|
break;
|
|
10837
|
-
case
|
|
10824
|
+
case 'function_call':
|
|
10838
10825
|
this.operands[0].setType(scope);
|
|
10839
10826
|
setParamTypes(this, 1, scope);
|
|
10840
|
-
this.operands[0].setExpectedTypes([
|
|
10827
|
+
this.operands[0].setExpectedTypes(['function']);
|
|
10841
10828
|
break;
|
|
10842
|
-
case
|
|
10843
|
-
//TODO : auto braces with number of arguments
|
|
10829
|
+
case 'method_call':
|
|
10830
|
+
//TODO : auto braces with number of arguments
|
|
10844
10831
|
//might have to make some changes here for inserting braces automatically
|
|
10845
10832
|
//console.log(this);
|
|
10846
10833
|
this.operands[0].setType(scope);
|
|
@@ -10848,8 +10835,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10848
10835
|
this.operands[1].setType(this.operands[0].type.memberScope || this.getScope(this.operands[0].type.members, null));
|
|
10849
10836
|
}
|
|
10850
10837
|
setParamTypes(this, 2, scope);
|
|
10851
|
-
this.operands[0].setExpectedTypes([
|
|
10852
|
-
this.operands[1].setExpectedTypes([
|
|
10838
|
+
this.operands[0].setExpectedTypes(['object']);
|
|
10839
|
+
this.operands[1].setExpectedTypes(['function']);
|
|
10853
10840
|
|
|
10854
10841
|
//Handling wherever the function doesnt have parameters. Remove the last node.
|
|
10855
10842
|
if (this.operands[1] && this.operands[1].type && this.operands[1].type.params == 0) {
|
|
@@ -10857,7 +10844,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10857
10844
|
this.operands.length = 2;
|
|
10858
10845
|
}
|
|
10859
10846
|
break;
|
|
10860
|
-
case
|
|
10847
|
+
case 'array_lookup':
|
|
10861
10848
|
this.operands[0].setType(scope);
|
|
10862
10849
|
this.operands[1].setType(scope);
|
|
10863
10850
|
if (this.operands[0].type) {
|
|
@@ -10894,8 +10881,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10894
10881
|
for (j = 0; j < l; j++) {
|
|
10895
10882
|
if (i !== j && types[j] && types[i].is(types[j]) && (!types[j].is(types[i]) || i < j)
|
|
10896
10883
|
/* Don't push types[i] if it is a proper subtype
|
|
10897
|
-
|
|
10898
|
-
|
|
10884
|
+
of types[j]; However if both are the same type,
|
|
10885
|
+
push one of them (the last one). */) {
|
|
10899
10886
|
break;
|
|
10900
10887
|
}
|
|
10901
10888
|
}
|
|
@@ -10911,21 +10898,21 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10911
10898
|
}
|
|
10912
10899
|
this.expectedTypes = types;
|
|
10913
10900
|
for (i = 0; i < l; i += 1) {
|
|
10914
|
-
typeNames[i] = types[i].ancestry.split(
|
|
10901
|
+
typeNames[i] = types[i].ancestry.split(':')[0];
|
|
10915
10902
|
}
|
|
10916
10903
|
|
|
10917
10904
|
// Check if the current type is one of the expected ones.
|
|
10918
10905
|
if (this.type) {
|
|
10919
10906
|
for (i = 0; i < l; i += 1) {
|
|
10920
10907
|
expectedType = types[i];
|
|
10921
|
-
if (this.arity ===
|
|
10908
|
+
if (this.arity === 'literal') {
|
|
10922
10909
|
//brackets are a must!
|
|
10923
10910
|
//console.log(expectedType, this.type);
|
|
10924
10911
|
}
|
|
10925
10912
|
if (this.type.is(expectedType)) {
|
|
10926
10913
|
break;
|
|
10927
10914
|
}
|
|
10928
|
-
if (this.arity ===
|
|
10915
|
+
if (this.arity === 'literal' && expectedType.is(this.type)) {
|
|
10929
10916
|
// Auto-cast literals to subtypes.
|
|
10930
10917
|
// This is done to handle enums, etc.
|
|
10931
10918
|
this.type = expectedType;
|
|
@@ -10936,18 +10923,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10936
10923
|
|
|
10937
10924
|
// Put type mismatch errors
|
|
10938
10925
|
if (i === l) {
|
|
10939
|
-
e =
|
|
10926
|
+
e = 'Expected: ' + typeNames.join('/');
|
|
10940
10927
|
if (this.type && this.type.ancestry) {
|
|
10941
|
-
e +=
|
|
10928
|
+
e += ', not ' + this.type.ancestry.split(':')[0];
|
|
10942
10929
|
}
|
|
10943
10930
|
this.error(e);
|
|
10944
10931
|
}
|
|
10945
10932
|
};
|
|
10946
10933
|
|
|
10947
10934
|
/*
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10935
|
+
* Type annotates nodes with "type" and "expectedType" attributes
|
|
10936
|
+
* and adds error messages if needed.
|
|
10937
|
+
*/
|
|
10951
10938
|
var loadType;
|
|
10952
10939
|
return function (tree, expected, loader) {
|
|
10953
10940
|
loadType = loader;
|
|
@@ -10965,13 +10952,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10965
10952
|
pos: pos
|
|
10966
10953
|
};
|
|
10967
10954
|
}
|
|
10968
|
-
t = node.textContent || node.innerText ||
|
|
10955
|
+
t = node.textContent || node.innerText || '';
|
|
10969
10956
|
if (pos > t.length) {
|
|
10970
10957
|
pos = t.length;
|
|
10971
10958
|
}
|
|
10972
10959
|
for (i = 0, l = node.childNodes.length; i < l; i += 1) {
|
|
10973
10960
|
n = node.childNodes[i];
|
|
10974
|
-
t = n.textContent || n.innerText ||
|
|
10961
|
+
t = n.textContent || n.innerText || '';
|
|
10975
10962
|
if (t.length < pos) {
|
|
10976
10963
|
pos -= t.length;
|
|
10977
10964
|
} else {
|
|
@@ -10984,7 +10971,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
10984
10971
|
};
|
|
10985
10972
|
},
|
|
10986
10973
|
getCursor: function (editor) {
|
|
10987
|
-
|
|
10974
|
+
'use strict';
|
|
10988
10975
|
|
|
10989
10976
|
var range = _rangy.default.createRange(),
|
|
10990
10977
|
select = _rangy.default.getSelection(),
|
|
@@ -11003,7 +10990,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11003
10990
|
};
|
|
11004
10991
|
},
|
|
11005
10992
|
putCursor: function (start, end, reverse) {
|
|
11006
|
-
|
|
10993
|
+
'use strict';
|
|
11007
10994
|
|
|
11008
10995
|
var range = _rangy.default.createRange(),
|
|
11009
10996
|
select = _rangy.default.getSelection();
|
|
@@ -11013,16 +11000,16 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11013
11000
|
select.addRange(range, reverse);
|
|
11014
11001
|
},
|
|
11015
11002
|
expr: function (d) {
|
|
11016
|
-
|
|
11003
|
+
'use strict';
|
|
11017
11004
|
|
|
11018
11005
|
var t = (0, _jquery.default)(d);
|
|
11019
|
-
t.find(
|
|
11006
|
+
t.find('br').remove();
|
|
11020
11007
|
return t.text();
|
|
11021
11008
|
},
|
|
11022
11009
|
balloon: function (node) {
|
|
11023
|
-
|
|
11010
|
+
'use strict';
|
|
11024
11011
|
|
|
11025
|
-
var popup = (0, _jquery.default)(
|
|
11012
|
+
var popup = (0, _jquery.default)('.balloon'),
|
|
11026
11013
|
editor,
|
|
11027
11014
|
t,
|
|
11028
11015
|
i,
|
|
@@ -11035,31 +11022,38 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11035
11022
|
show = false,
|
|
11036
11023
|
calltipDiv,
|
|
11037
11024
|
calltipEls;
|
|
11038
|
-
if (!node.dom || node.dom.hasClass(
|
|
11039
|
-
editor = node.dom.closest(
|
|
11040
|
-
if (!editor.is(
|
|
11025
|
+
if (!node.dom || node.dom.hasClass('selected')) return;
|
|
11026
|
+
editor = node.dom.closest('.expredit').eq(0);
|
|
11027
|
+
if (!editor.is(':focus')) return;
|
|
11041
11028
|
if (popup.length) {
|
|
11042
11029
|
io.removeBalloon();
|
|
11043
11030
|
}
|
|
11044
|
-
editor.find(
|
|
11045
|
-
node.dom.addClass(
|
|
11046
|
-
var
|
|
11047
|
-
|
|
11048
|
-
|
|
11031
|
+
editor.find('.selected').removeClass('selected');
|
|
11032
|
+
node.dom.addClass('selected');
|
|
11033
|
+
var rect = node.dom[0].getBoundingClientRect();
|
|
11034
|
+
popup = (0, _jquery.default)('<div>').addClass('balloon').data('node', node).css({
|
|
11035
|
+
position: 'fixed',
|
|
11036
|
+
top: rect.bottom + 8 + 'px',
|
|
11037
|
+
left: rect.left + 'px',
|
|
11038
|
+
zIndex: 2147483647,
|
|
11039
|
+
background: '#fff',
|
|
11040
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
11041
|
+
border: '1px solid #d9d9d9'
|
|
11042
|
+
});
|
|
11049
11043
|
var setValue = function (value) {
|
|
11050
11044
|
var range;
|
|
11051
11045
|
node.dom.html(value);
|
|
11052
11046
|
range = _rangy.default.createRange();
|
|
11053
11047
|
range.collapseAfter(node.dom[0]);
|
|
11054
11048
|
_rangy.default.getSelection().setSingleRange(range);
|
|
11055
|
-
node.dom.trigger(
|
|
11049
|
+
node.dom.trigger('keyup');
|
|
11056
11050
|
};
|
|
11057
11051
|
var calltipHover = function (e) {
|
|
11058
|
-
if ((0, _jquery.default)(this).hasClass(
|
|
11052
|
+
if ((0, _jquery.default)(this).hasClass('sel')) {
|
|
11059
11053
|
return;
|
|
11060
11054
|
}
|
|
11061
|
-
(0, _jquery.default)(
|
|
11062
|
-
(0, _jquery.default)(this).addClass(
|
|
11055
|
+
(0, _jquery.default)('.calltip.sel').removeClass('sel');
|
|
11056
|
+
(0, _jquery.default)(this).addClass('sel');
|
|
11063
11057
|
};
|
|
11064
11058
|
var calltipClick = function (e) {
|
|
11065
11059
|
setValue((0, _jquery.default)(this).html());
|
|
@@ -11073,18 +11067,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11073
11067
|
selection,
|
|
11074
11068
|
numTips;
|
|
11075
11069
|
if (e.which === UP || e.which === DOWN || e.which === ENTER || e.which === ESC) {
|
|
11076
|
-
selection = (0, _jquery.default)(
|
|
11077
|
-
var callTipDiv = (0, _jquery.default)(
|
|
11070
|
+
selection = (0, _jquery.default)('.calltip.sel');
|
|
11071
|
+
var callTipDiv = (0, _jquery.default)('.calltips');
|
|
11078
11072
|
numTips = calltipEls.length;
|
|
11079
11073
|
if (selection.length) {
|
|
11080
11074
|
if (e.which === UP) {
|
|
11081
|
-
(0, _jquery.default)(
|
|
11075
|
+
(0, _jquery.default)('.balloon').removeClass('hide');
|
|
11082
11076
|
selection = calltipEls.eq((calltipEls.index(selection) + numTips - 1) % numTips);
|
|
11083
11077
|
callTipDiv.animate({
|
|
11084
11078
|
scrollTop: calltipEls.index(selection) * selection.outerHeight()
|
|
11085
11079
|
}, 100);
|
|
11086
11080
|
} else if (e.which === DOWN) {
|
|
11087
|
-
(0, _jquery.default)(
|
|
11081
|
+
(0, _jquery.default)('.balloon').removeClass('hide');
|
|
11088
11082
|
selection = calltipEls.eq((calltipEls.index(selection) + 1) % numTips);
|
|
11089
11083
|
callTipDiv.animate({
|
|
11090
11084
|
scrollTop: calltipEls.index(selection) * selection.outerHeight()
|
|
@@ -11093,7 +11087,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11093
11087
|
//console.log(grammar);
|
|
11094
11088
|
setValue(selection.html());
|
|
11095
11089
|
} else if (e.which === ESC) {
|
|
11096
|
-
(0, _jquery.default)(
|
|
11090
|
+
(0, _jquery.default)('.balloon').addClass('hide');
|
|
11097
11091
|
}
|
|
11098
11092
|
} else {
|
|
11099
11093
|
if (e.which === UP) {
|
|
@@ -11103,8 +11097,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11103
11097
|
}
|
|
11104
11098
|
}
|
|
11105
11099
|
if (selection.length) {
|
|
11106
|
-
(0, _jquery.default)(
|
|
11107
|
-
selection.addClass(
|
|
11100
|
+
(0, _jquery.default)('.calltip.sel').removeClass('sel');
|
|
11101
|
+
selection.addClass('sel');
|
|
11108
11102
|
}
|
|
11109
11103
|
e.preventDefault();
|
|
11110
11104
|
e.stopPropagation();
|
|
@@ -11115,16 +11109,16 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11115
11109
|
|
|
11116
11110
|
/* Add error messages */
|
|
11117
11111
|
if (node.err) {
|
|
11118
|
-
popup.append((0, _jquery.default)(
|
|
11112
|
+
popup.append((0, _jquery.default)('<div>').addClass('expressionError').html(node.err.join('<br />')));
|
|
11119
11113
|
show = true;
|
|
11120
11114
|
}
|
|
11121
11115
|
|
|
11122
11116
|
/* Add info messages */
|
|
11123
|
-
var info =
|
|
11117
|
+
var info = '',
|
|
11124
11118
|
expDescs = [],
|
|
11125
|
-
expinfo =
|
|
11119
|
+
expinfo = '';
|
|
11126
11120
|
if (node.param && node.param.desc) {
|
|
11127
|
-
expinfo +=
|
|
11121
|
+
expinfo += 'argument: ' + node.param.desc + ' ';
|
|
11128
11122
|
}
|
|
11129
11123
|
if (node.expectedTypes) {
|
|
11130
11124
|
for (i = 0, l = node.expectedTypes.length; i < l; i += 1) {
|
|
@@ -11132,20 +11126,20 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11132
11126
|
expDescs.push(node.expectedTypes[i].desc);
|
|
11133
11127
|
}
|
|
11134
11128
|
}
|
|
11135
|
-
expinfo += expDescs.length ? (expinfo ?
|
|
11129
|
+
expinfo += expDescs.length ? (expinfo ? '(' : '') + expDescs.join(', ') + (expinfo ? ')' : '') : '';
|
|
11136
11130
|
}
|
|
11137
11131
|
if (node.ident && node.ident.desc) {
|
|
11138
|
-
info += node.ident.desc +
|
|
11132
|
+
info += node.ident.desc + ' ';
|
|
11139
11133
|
}
|
|
11140
11134
|
if (node.type && node.type.desc) {
|
|
11141
|
-
info += (info ?
|
|
11135
|
+
info += (info ? '(' : 'Found: ') + node.type.desc + (info ? ')' : '');
|
|
11142
11136
|
}
|
|
11143
11137
|
if (expinfo) {
|
|
11144
|
-
popup.append((0, _jquery.default)(
|
|
11138
|
+
popup.append((0, _jquery.default)('<div>').addClass('info').html('Expected ' + expinfo));
|
|
11145
11139
|
show = true;
|
|
11146
11140
|
}
|
|
11147
11141
|
if (info) {
|
|
11148
|
-
popup.append((0, _jquery.default)(
|
|
11142
|
+
popup.append((0, _jquery.default)('<div>').addClass('info').html(info));
|
|
11149
11143
|
show = true;
|
|
11150
11144
|
}
|
|
11151
11145
|
|
|
@@ -11154,7 +11148,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11154
11148
|
for (j = 0; j < m; j += 1) {
|
|
11155
11149
|
expected = node.getType(node.expectedTypes[j]);
|
|
11156
11150
|
if (expected && expected.ancestry) {
|
|
11157
|
-
t = expected.ancestry.split(
|
|
11151
|
+
t = expected.ancestry.split(':');
|
|
11158
11152
|
for (i = 0, l = t.length; i < l; i += 1) {
|
|
11159
11153
|
if (pickers[t[i]]) {
|
|
11160
11154
|
picker = pickers[t[i]](node.value, expected, setValue);
|
|
@@ -11176,44 +11170,45 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11176
11170
|
show = true;
|
|
11177
11171
|
}
|
|
11178
11172
|
if (show) {
|
|
11179
|
-
popup.data(
|
|
11180
|
-
editor.on(
|
|
11181
|
-
|
|
11182
|
-
|
|
11173
|
+
popup.data('editor', editor);
|
|
11174
|
+
editor.on('keydown.balloon', calltipKey);
|
|
11175
|
+
var targetBody = editor[0] && editor[0].ownerDocument ? editor[0].ownerDocument.body : document.body;
|
|
11176
|
+
popup.on('mousedown', function () {
|
|
11177
|
+
editor.trigger('focus');
|
|
11183
11178
|
ignoreBlur = true;
|
|
11184
|
-
}).appendTo(
|
|
11185
|
-
(0, _jquery.default)(
|
|
11179
|
+
}).appendTo(targetBody);
|
|
11180
|
+
(0, _jquery.default)('.calltip').on('mousemove', calltipHover).on('click', calltipClick);
|
|
11186
11181
|
}
|
|
11187
|
-
calltipEls = (0, _jquery.default)(
|
|
11188
|
-
calltipEls.eq(0).addClass(
|
|
11182
|
+
calltipEls = (0, _jquery.default)('.calltip');
|
|
11183
|
+
calltipEls.eq(0).addClass('sel');
|
|
11189
11184
|
},
|
|
11190
11185
|
removeBalloon: function () {
|
|
11191
11186
|
var editor;
|
|
11192
|
-
editor = (0, _jquery.default)(
|
|
11187
|
+
editor = (0, _jquery.default)('.balloon').data('editor');
|
|
11193
11188
|
if (editor) {
|
|
11194
|
-
editor.off(
|
|
11189
|
+
editor.off('keydown.balloon');
|
|
11195
11190
|
}
|
|
11196
|
-
(0, _jquery.default)(
|
|
11197
|
-
(0, _jquery.default)(
|
|
11191
|
+
(0, _jquery.default)('.balloon').remove();
|
|
11192
|
+
(0, _jquery.default)('.selected').removeClass('selected');
|
|
11198
11193
|
}
|
|
11199
11194
|
};
|
|
11200
11195
|
|
|
11201
11196
|
/*
|
|
11202
|
-
|
|
11197
|
+
selectNode could be rewritten as protonode.findSelectedLeaf(cursor)
|
|
11203
11198
|
*/
|
|
11204
11199
|
|
|
11205
11200
|
var selectNode = function (tree, cursor) {
|
|
11206
|
-
|
|
11201
|
+
'use strict';
|
|
11207
11202
|
|
|
11208
11203
|
var selDist = 99999,
|
|
11209
11204
|
selNode,
|
|
11210
11205
|
t;
|
|
11211
11206
|
var affinity = function (node) {
|
|
11212
11207
|
switch (node.arity) {
|
|
11213
|
-
case
|
|
11208
|
+
case 'missing':
|
|
11214
11209
|
return 2;
|
|
11215
|
-
case
|
|
11216
|
-
case
|
|
11210
|
+
case 'literal':
|
|
11211
|
+
case 'name':
|
|
11217
11212
|
return 1;
|
|
11218
11213
|
default:
|
|
11219
11214
|
return 0;
|
|
@@ -11239,13 +11234,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11239
11234
|
if (selNode) {
|
|
11240
11235
|
if (selNode.dom) {
|
|
11241
11236
|
t = selNode.dom[0];
|
|
11242
|
-
t = (t.textContent || t.innerText ||
|
|
11237
|
+
t = (t.textContent || t.innerText || '').length;
|
|
11243
11238
|
}
|
|
11244
11239
|
return {
|
|
11245
11240
|
node: selNode,
|
|
11246
11241
|
pos: Math.min(t, cursor - selNode.pos)
|
|
11247
11242
|
};
|
|
11248
|
-
} else if (tree.arity ===
|
|
11243
|
+
} else if (tree.arity === 'missing') {
|
|
11249
11244
|
return {
|
|
11250
11245
|
node: tree,
|
|
11251
11246
|
pos: 0
|
|
@@ -11257,7 +11252,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11257
11252
|
var getTypeName = function (node, full) {
|
|
11258
11253
|
var type = node.type;
|
|
11259
11254
|
if (type) {
|
|
11260
|
-
if (typeof type ===
|
|
11255
|
+
if (typeof type === 'string') {
|
|
11261
11256
|
if (full) {
|
|
11262
11257
|
return node.getType(type).ancestry;
|
|
11263
11258
|
}
|
|
@@ -11267,13 +11262,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11267
11262
|
if (full) {
|
|
11268
11263
|
return type.ancestry;
|
|
11269
11264
|
}
|
|
11270
|
-
return type.ancestry.replace(/anonymous\:/g,
|
|
11265
|
+
return type.ancestry.replace(/anonymous\:/g, '').split(':')[0];
|
|
11271
11266
|
}
|
|
11272
11267
|
}
|
|
11273
|
-
return
|
|
11268
|
+
return 'unknown';
|
|
11274
11269
|
};
|
|
11275
11270
|
protonode.toJson = function (prefix, indent) {
|
|
11276
|
-
|
|
11271
|
+
'use strict';
|
|
11277
11272
|
|
|
11278
11273
|
var i, l, str, delim;
|
|
11279
11274
|
str = prefix + '{';
|
|
@@ -11299,12 +11294,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11299
11294
|
return str;
|
|
11300
11295
|
};
|
|
11301
11296
|
protonode.toDom = function (pos) {
|
|
11302
|
-
|
|
11297
|
+
'use strict';
|
|
11303
11298
|
|
|
11304
11299
|
var i,
|
|
11305
11300
|
l,
|
|
11306
11301
|
el,
|
|
11307
|
-
className =
|
|
11302
|
+
className = 'node',
|
|
11308
11303
|
node = this,
|
|
11309
11304
|
typeName;
|
|
11310
11305
|
pos = pos || 0;
|
|
@@ -11321,29 +11316,29 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11321
11316
|
if (delim) d = delim.clone(false);
|
|
11322
11317
|
}
|
|
11323
11318
|
};
|
|
11324
|
-
this.dom = el = (0, _jquery.default)(
|
|
11325
|
-
className +=
|
|
11326
|
-
className += this.err ?
|
|
11327
|
-
typeName =
|
|
11328
|
-
className += typeName ?
|
|
11319
|
+
this.dom = el = (0, _jquery.default)('<span>');
|
|
11320
|
+
className += ' ' + this.arity;
|
|
11321
|
+
className += this.err ? ' has_errors' : '';
|
|
11322
|
+
typeName = 'expredit_' + getTypeName(this, true);
|
|
11323
|
+
className += typeName ? ' ' + typeName.replace(/anonymous/g, '').replace(/\:+/g, ' ') : '';
|
|
11329
11324
|
el.addClass(className);
|
|
11330
11325
|
switch (this.arity) {
|
|
11331
|
-
case
|
|
11332
|
-
case
|
|
11333
|
-
addChildren(this, 0, (0, _jquery.default)("<span class='operator'>" + this.text +
|
|
11326
|
+
case 'binary_operation':
|
|
11327
|
+
case 'object_dereference':
|
|
11328
|
+
addChildren(this, 0, (0, _jquery.default)("<span class='operator'>" + this.text + '</span>'));
|
|
11334
11329
|
break;
|
|
11335
|
-
case
|
|
11336
|
-
el.append((0, _jquery.default)("<span class='operator'>" + this.text +
|
|
11330
|
+
case 'unary_operation':
|
|
11331
|
+
el.append((0, _jquery.default)("<span class='operator'>" + this.text + '</span>'));
|
|
11337
11332
|
el.append(this.children[0].toDom(pos));
|
|
11338
11333
|
break;
|
|
11339
|
-
case
|
|
11334
|
+
case 'ternary_operation':
|
|
11340
11335
|
el.append(this.children[0].toDom(pos));
|
|
11341
11336
|
el.append((0, _jquery.default)("<span class='operator'>?</span>"));
|
|
11342
11337
|
el.append(this.children[1].toDom(pos));
|
|
11343
11338
|
el.append((0, _jquery.default)("<span class='operator'>:</span>"));
|
|
11344
11339
|
el.append(this.children[2].toDom(pos));
|
|
11345
11340
|
break;
|
|
11346
|
-
case
|
|
11341
|
+
case 'method_call':
|
|
11347
11342
|
el.append(this.children[0].toDom(pos));
|
|
11348
11343
|
el.append((0, _jquery.default)("<span class='operator'>.</span>"));
|
|
11349
11344
|
el.append(this.children[1].toDom(pos));
|
|
@@ -11351,19 +11346,19 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11351
11346
|
addChildren(this, 2, (0, _jquery.default)("<span class='operator'>,</span>"));
|
|
11352
11347
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
11353
11348
|
break;
|
|
11354
|
-
case
|
|
11349
|
+
case 'function_call':
|
|
11355
11350
|
el.append(this.children[0].toDom(pos));
|
|
11356
11351
|
el.append((0, _jquery.default)("<span class='operator paren'>(</span>"));
|
|
11357
11352
|
addChildren(this, 1, (0, _jquery.default)("<span class='operator'>,</span>"));
|
|
11358
11353
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
11359
11354
|
break;
|
|
11360
|
-
case
|
|
11355
|
+
case 'array_lookup':
|
|
11361
11356
|
el.append(this.children[0].toDom(pos));
|
|
11362
11357
|
el.append((0, _jquery.default)("<span class='operator paren'>[</span>"));
|
|
11363
11358
|
addChildren(this, 1, (0, _jquery.default)("<span class='operator'> </span>"));
|
|
11364
11359
|
el.append((0, _jquery.default)("<span class='operator paren'>]</span>"));
|
|
11365
11360
|
break;
|
|
11366
|
-
case
|
|
11361
|
+
case 'group':
|
|
11367
11362
|
if (this.paren !== false) {
|
|
11368
11363
|
el.append((0, _jquery.default)("<span class='operator paren'>(</span>"));
|
|
11369
11364
|
}
|
|
@@ -11372,18 +11367,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11372
11367
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
11373
11368
|
}
|
|
11374
11369
|
break;
|
|
11375
|
-
case
|
|
11370
|
+
case 'missing':
|
|
11376
11371
|
if (this.text) {
|
|
11377
11372
|
el.html(this.text);
|
|
11378
11373
|
} else {
|
|
11379
|
-
el.html(
|
|
11374
|
+
el.html(' ');
|
|
11380
11375
|
}
|
|
11381
11376
|
break;
|
|
11382
11377
|
default:
|
|
11383
|
-
el.html(this.text ||
|
|
11378
|
+
el.html(this.text || '');
|
|
11384
11379
|
break;
|
|
11385
11380
|
}
|
|
11386
|
-
el.on(
|
|
11381
|
+
el.on('mousemove', function (e) {
|
|
11387
11382
|
io.balloon(node);
|
|
11388
11383
|
e.stopPropagation();
|
|
11389
11384
|
});
|
|
@@ -11398,7 +11393,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11398
11393
|
missingPos;
|
|
11399
11394
|
var loadType = function (typeName) {
|
|
11400
11395
|
if (!options.typeSource) return;
|
|
11401
|
-
var notif = (0, _jquery.default)(
|
|
11396
|
+
var notif = (0, _jquery.default)('<div>').addClass('notification').insertAfter(xedit).html('Loading ' + typeName + '...').fadeIn(200);
|
|
11402
11397
|
_jquery.default.getJSON(options.typeSource, {
|
|
11403
11398
|
t: typeName
|
|
11404
11399
|
}).done(function (data) {
|
|
@@ -11411,7 +11406,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11411
11406
|
if (!options.offline) handleCursor();
|
|
11412
11407
|
}).fail(function () {
|
|
11413
11408
|
//console.log(this);
|
|
11414
|
-
notif.html(
|
|
11409
|
+
notif.html('Error loading ' + typeName);
|
|
11415
11410
|
grammar.types[typeName] = false;
|
|
11416
11411
|
setTimeout(function () {
|
|
11417
11412
|
notif.fadeOut(500);
|
|
@@ -11425,19 +11420,19 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11425
11420
|
typify(tree, options.expected, loadType);
|
|
11426
11421
|
xedit.empty().append(tree.toDom());
|
|
11427
11422
|
//console.log(tree);
|
|
11428
|
-
input.val(io.expr(xedit)).data(
|
|
11423
|
+
input.val(io.expr(xedit)).data('json', tree.toJson('\n', ' ')).trigger('change');
|
|
11429
11424
|
}
|
|
11430
11425
|
};
|
|
11431
11426
|
var handleCursor = function () {
|
|
11432
11427
|
var reverse = cursor.reverse;
|
|
11433
11428
|
var node_s = selectNode(tree, cursor.start);
|
|
11434
11429
|
var node_e = selectNode(tree, cursor.end);
|
|
11435
|
-
var cur_s = node_s && node_s.node.dom && node_s.node.arity ===
|
|
11436
|
-
var cur_e = node_e && node_s.node.dom && node_e.node.arity ===
|
|
11430
|
+
var cur_s = node_s && node_s.node.dom && node_s.node.arity === 'missing' ? io.charOffset(node_s.node.dom[0], node_s.pos) : io.charOffset(xedit[0], cursor.start);
|
|
11431
|
+
var cur_e = node_e && node_s.node.dom && node_e.node.arity === 'missing' ? io.charOffset(node_e.node.dom[0], node_e.pos) : io.charOffset(xedit[0], cursor.end);
|
|
11437
11432
|
onMissing = false;
|
|
11438
11433
|
if (node_e && node_s && node_e.node === node_s.node) {
|
|
11439
11434
|
selectedNode = node_s.node;
|
|
11440
|
-
if (selectedNode.arity ===
|
|
11435
|
+
if (selectedNode.arity === 'missing' && !selectedNode.text) {
|
|
11441
11436
|
cur_s.pos = 0;
|
|
11442
11437
|
cur_e.pos = 1;
|
|
11443
11438
|
missingPos = node_s.pos;
|
|
@@ -11462,34 +11457,34 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
11462
11457
|
(0, _jquery.default)(document.body).attr({
|
|
11463
11458
|
spellcheck: false
|
|
11464
11459
|
});
|
|
11465
|
-
var xedit = (0, _jquery.default)(
|
|
11460
|
+
var xedit = (0, _jquery.default)('<div>').attr({
|
|
11466
11461
|
contenteditable: true,
|
|
11467
11462
|
spellcheck: false,
|
|
11468
|
-
|
|
11469
|
-
style: input.attr(
|
|
11463
|
+
class: 'expredit ' + input[0].className,
|
|
11464
|
+
style: input.attr('style')
|
|
11470
11465
|
}).css({
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
}).on(
|
|
11466
|
+
width: input.width(),
|
|
11467
|
+
height: 'auto',
|
|
11468
|
+
display: input.is(':visible') ? 'inline-block' : 'none'
|
|
11469
|
+
}).on('keyup', function (e) {
|
|
11475
11470
|
if (onMissing && selectedNode != tree && (e.which == 8 || e.which == 46 || e.which == 37 && missingPos == 0 || e.which == 39 && missingPos == 1)) {
|
|
11476
11471
|
onMissing = false;
|
|
11477
11472
|
}
|
|
11478
11473
|
if (!options.offline) cursor = io.getCursor(xedit[0]);
|
|
11479
11474
|
handleText();
|
|
11480
11475
|
if (!options.offline) handleCursor();
|
|
11481
|
-
}).on(
|
|
11476
|
+
}).on('mouseup', function () {
|
|
11482
11477
|
if (!options.offline) {
|
|
11483
11478
|
cursor = io.getCursor(xedit[0]);
|
|
11484
11479
|
handleCursor();
|
|
11485
11480
|
}
|
|
11486
|
-
}).on(
|
|
11481
|
+
}).on('blur', handleBlur).insertAfter(input);
|
|
11487
11482
|
|
|
11488
11483
|
//TODO: Do it in a better way. Escaping the special characters.
|
|
11489
|
-
var initVal1 = initVal.replace(/</g,
|
|
11490
|
-
initVal1 = initVal1.replace(/>/g,
|
|
11491
|
-
initVal1 = initVal1.replace(/&&/g,
|
|
11492
|
-
initVal1 = initVal1.replace(/'/g,
|
|
11484
|
+
var initVal1 = initVal.replace(/</g, '<');
|
|
11485
|
+
initVal1 = initVal1.replace(/>/g, '>');
|
|
11486
|
+
initVal1 = initVal1.replace(/&&/g, '&&');
|
|
11487
|
+
initVal1 = initVal1.replace(/'/g, '"');
|
|
11493
11488
|
xedit.html(initVal1);
|
|
11494
11489
|
input.hide();
|
|
11495
11490
|
handleText(true);
|
|
@@ -25439,34 +25434,10 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
|
|
|
25439
25434
|
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
|
|
25440
25435
|
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
|
|
25441
25436
|
// Module
|
|
25442
|
-
___CSS_LOADER_EXPORT___.push([module.id, `.
|
|
25437
|
+
___CSS_LOADER_EXPORT___.push([module.id, `.root .expredit-container{background:#fff;border-radius:2px;border:1px solid #dcdee2;padding:2px;width:200px;cursor:text;overflow:hidden;font:1 monospace}.root .expredit-container.input{white-space:nowrap;vertical-align:baseline}.root .expredit-container.textarea{vertical-align:bottom;white-space:pre;height:100px}.root .expredit-field{box-shadow:0 1px 0 0 #e9f0fc}.root .operator:after,.root .operator:before{content:" ";font-size:0}.root .expredit{background:#fff;border-radius:2px;border:1px solid #dcdee2;padding:8px 12px;cursor:text;font-size:.857rem;font-family:"Roboto",sans-serif;line-height:1.5;overflow:auto;white-space:pre-wrap;word-wrap:break-word;min-height:32px;box-sizing:border-box}.root .expredit:focus{outline:none;border-color:#47af46}.root .expredit:hover{border-color:#47af46}.root .node{color:#2a2a2a;background:rgba(0,0,0,0);border-bottom:1px solid rgba(0,0,0,0)}.root .operator{display:inline;color:#97a0af}.root .node.selected{background:#e9f0fc !important}.root .node.has_errors>.operator{color:#f5222d}.root .node.has_errors{border-bottom:1px solid #f5222d;margin-bottom:-1px}.root .name{color:#2a2a2a;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_number,.root .name.expredit_number{color:#2466eb;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_string,.root .name.expredit_string{color:#42b040;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_boolean,.root .name.expredit_boolean{color:#f79600;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_date,.root .name.expredit_date,.root .expredit_date{color:#2466eb;background:rgba(0,0,0,0);box-shadow:none}.root .operator.paren{display:inline}.root .node.selected>.arglist{border-color:#97a0af}.root .node.missing>.operator{color:#f5222d}.balloon,.notification{font:1 "Roboto",sans-serif}.balloon{position:absolute;color:#fff;line-height:1em;background:#fff;box-shadow:inset 0 1px 1px 1px rgba(0,0,0,.56);z-index:2147483002;min-width:200px;max-width:400px}.balloon:after{content:"";display:block;position:absolute;top:-8px;left:8px;width:0;border-width:0 8px 8px 0;border-style:solid;border-color:#dcdee2 rgba(0,0,0,0)}.expressionError{color:#f5222d;padding:0 .571rem;margin:.571rem 0}.info{color:#97a0af;padding:0 .571rem;margin:.571rem 0}.picker{margin:0;padding:0}.calltips{text-align:left;padding:0 .571rem;margin:.571rem 0 0 0;max-height:180px;overflow-y:auto;overflow-x:auto}a.calltip{display:block;color:#5e6c84;text-decoration:none;cursor:pointer;margin:0 -0.571rem;padding:.571rem}.calltip.sel{background:#5e6c84;color:#fff}.notification{position:absolute;background:#2a2a2a;color:#fff;padding:.571rem}`, ""]);
|
|
25443
25438
|
// Exports
|
|
25444
25439
|
___CSS_LOADER_EXPORT___.locals = {
|
|
25445
|
-
"
|
|
25446
|
-
"notification": `notification`,
|
|
25447
|
-
"expredit-container": `expredit-container`,
|
|
25448
|
-
"input": `input`,
|
|
25449
|
-
"textarea": `textarea`,
|
|
25450
|
-
"expredit-field": `expredit-field`,
|
|
25451
|
-
"operator": `operator`,
|
|
25452
|
-
"expredit": `expredit`,
|
|
25453
|
-
"node": `node`,
|
|
25454
|
-
"selected": `selected`,
|
|
25455
|
-
"has_errors": `has_errors`,
|
|
25456
|
-
"name": `name`,
|
|
25457
|
-
"literal": `literal`,
|
|
25458
|
-
"expredit_number": `expredit_number`,
|
|
25459
|
-
"expredit_string": `expredit_string`,
|
|
25460
|
-
"expredit_boolean": `expredit_boolean`,
|
|
25461
|
-
"expredit_date": `expredit_date`,
|
|
25462
|
-
"arglist": `arglist`,
|
|
25463
|
-
"missing": `missing`,
|
|
25464
|
-
"expressionError": `expressionError`,
|
|
25465
|
-
"info": `info`,
|
|
25466
|
-
"picker": `picker`,
|
|
25467
|
-
"calltips": `calltips`,
|
|
25468
|
-
"calltip": `calltip`,
|
|
25469
|
-
"sel": `sel`
|
|
25440
|
+
"root": `root`
|
|
25470
25441
|
};
|
|
25471
25442
|
module.exports = ___CSS_LOADER_EXPORT___;
|
|
25472
25443
|
|