regexper-static/src/js/parser/javascript/subexp.js

50 lines
1.0 KiB
JavaScript
Raw Normal View History

import _ from 'lodash';
export default {
2014-12-08 02:16:23 +00:00
type: 'subexp',
2014-12-17 21:04:55 +00:00
definedProperties: {
_anchor: {
get: function() {
var anchor = this.regexp.anchor,
matrix = this.transform().localMatrix;
2014-12-24 04:27:09 +00:00
return {
2014-12-17 21:04:55 +00:00
ax: matrix.x(anchor.ax, anchor.ay),
ax2: matrix.x(anchor.ax2, anchor.ay),
ay: matrix.y(anchor.ax, anchor.ay)
2014-12-24 04:27:09 +00:00
};
2014-12-17 21:04:55 +00:00
}
}
},
2014-12-08 02:16:23 +00:00
labelMap: {
'?:': '',
'?=': 'positive lookahead',
'?!': 'negative lookahead'
},
_render() {
2014-12-17 20:12:04 +00:00
return this.regexp.render(this.container.group())
2014-12-21 17:05:55 +00:00
.then(() => {
return this.renderLabeledBox(this.label, this.regexp, {
padding: 10
});
});
2014-12-08 02:16:23 +00:00
},
setup() {
if (_.has(this.labelMap, this.properties.capture.textValue)) {
this.label = this.labelMap[this.properties.capture.textValue];
} else {
this.label = 'group #' + (this.state.groupCounter++);
}
this.regexp = this.properties.regexp;
2014-12-17 20:12:04 +00:00
if (!this.label) {
this.proxy = this.regexp;
}
2014-12-15 00:08:14 +00:00
}
};