2014-12-03 02:02:48 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
import Base from './base.js';
|
|
|
|
|
2014-12-10 11:18:55 +00:00
|
|
|
var groupCounter = 1;
|
|
|
|
|
2014-12-03 02:02:48 +00:00
|
|
|
export default _.extend({}, Base, {
|
2014-12-08 02:16:23 +00:00
|
|
|
type: 'subexp',
|
|
|
|
|
|
|
|
labelMap: {
|
|
|
|
'?:': '',
|
|
|
|
'?=': 'positive lookahead',
|
|
|
|
'?!': 'negative lookahead'
|
|
|
|
},
|
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
_render() {
|
2014-12-08 02:16:23 +00:00
|
|
|
var label = this.groupLabel();
|
|
|
|
|
|
|
|
if (label) {
|
2014-12-10 23:27:07 +00:00
|
|
|
this.renderLabeledBox(label);
|
2014-12-08 02:16:23 +00:00
|
|
|
|
2014-12-10 21:57:42 +00:00
|
|
|
this.regexp.setContainer(this.container.group());
|
2014-12-08 02:16:23 +00:00
|
|
|
this.regexp.render();
|
|
|
|
} else {
|
2014-12-11 00:01:57 +00:00
|
|
|
this.proxy(this.regexp);
|
2014-12-08 02:16:23 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
_position() {
|
2014-12-08 02:16:23 +00:00
|
|
|
this.regexp.position();
|
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
this.positionLabeledBox(this.regexp.container, {
|
|
|
|
padding: 10
|
|
|
|
});
|
2014-12-08 02:16:23 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
groupLabel() {
|
|
|
|
if (_.has(this.labelMap, this._capture.textValue)) {
|
|
|
|
return this.labelMap[this._capture.textValue];
|
|
|
|
} else {
|
2014-12-10 11:18:55 +00:00
|
|
|
return 'group #' + (groupCounter++);
|
2014-12-08 02:16:23 +00:00
|
|
|
}
|
2014-12-10 11:18:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
resetCounter() {
|
|
|
|
groupCounter = 1;
|
|
|
|
},
|
2014-12-03 02:02:48 +00:00
|
|
|
});
|