Skip to content

Commit

Permalink
fixup bound insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
cornytrace committed Feb 7, 2018
1 parent c34d078 commit f2a9a79
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/emit/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,20 +1443,21 @@ function emitMethod(emitter:Emitter, node:Node):void {
let name = node.findChild(NodeKind.NAME);
if (node.kind !== NodeKind.FUNCTION || name.text !== emitter.currentClassName) {
let pathToRoot = ClassList.getLastPathToRoot();
emitter.ensureImportIdentifier("bound", `${pathToRoot}bound`);
emitter.ensureImportIdentifier("bound", `${pathToRoot}bound`);

let mods = node.findChild(NodeKind.MOD_LIST);
if (mods) {
emitter.catchup(mods.start);
} else {
emitter.catchup(name.start);
emitter.catchup(node.start);
}

// insert @bound with equal indentation for the next line
emitter.output = emitter.output.replace(/([^\S\n]*)$/, "$1@bound\n$1");
emitter.output = emitter.output.replace(/([^\S\n]*)$/, "$1@bound\n$1");

emitClassField(emitter, node);
emitter.consume('function', name.start);

emitter.catchup(name.end);
//emitter.insert(" = ");

} else {
let mods = node.findChild(NodeKind.MOD_LIST);
Expand Down

0 comments on commit f2a9a79

Please sign in to comment.