Skip to content

Commit fbbc34b

Browse files
committed
fixed base class search
1 parent e0779c3 commit fbbc34b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function Command(cmd) {
190190
}
191191

192192
Command.prototype = Object.create(Argument.prototype);
193-
Command.prototype.constructor = Argument;
193+
Command.prototype.constructor = Command;
194194

195195
/*!
196196
* @brief Event Class
@@ -200,7 +200,7 @@ function Event(event) {
200200
}
201201

202202
Event.prototype = Object.create(Argument.prototype);
203-
Event.prototype.constructor = Argument;
203+
Event.prototype.constructor = Event;
204204
```
205205

206206
Output pseudo code:
@@ -263,7 +263,7 @@ Here some things to notice:
263263
* Base class is determined by next code:
264264
265265
```javascript
266-
Event.prototype.constructor = Argument;
266+
Event.prototype = Object.create(Argument.prototype);
267267
```
268268
269269
Here `Argument` will be used as base class of `Event`.

__tests__/extractToken.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('extractToken', () => {
66
const function_line = 'function foo() {}';
77
const class_constructor_line = 'function Class(args) {}';
88
const class_method_line = 'Class.prototype.foo = function(arg) {}';
9-
const base_class_line = 'Class.prototype.constructor = BaseClass';
9+
const base_class_line = 'Class.prototype = Object.create(BaseClass.prototype)';
1010

1111
it('extracts global variable', () => {
1212
expect(extractToken.extractVariable(variable_line)).toEqual({

src/extractToken.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const extractClass = line => {
4949
};
5050

5151
const extractBaseClass = line => {
52-
const base_class_expr = /^\s*(\w+)\.prototype\.constructor\s*\=\s*(\w+)/;
52+
const base_class_expr = /^\s*(\w+)\.prototype\s*\=\s*Object\.create\((\w+)\.prototype\)/;
5353
const base_class_match = line.match(base_class_expr);
5454

5555
if (base_class_match) {

0 commit comments

Comments
 (0)