mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
Fixing #700. Block comment for constructor now appears above the constructor declaration.
This commit is contained in:
10
lib/nodes.js
10
lib/nodes.js
@@ -906,7 +906,7 @@
|
||||
applied = new Value(this.parent, [new Accessor(new Literal('apply'))]);
|
||||
constructor = new Code([], new Expressions([new Call(applied, [new Literal('this'), new Literal('arguments')])]));
|
||||
} else {
|
||||
constructor = new Code;
|
||||
constructor = new Code([], new Expressions([new Return(new Literal('this'))]));
|
||||
}
|
||||
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; _i++) {
|
||||
prop = _ref2[_i];
|
||||
@@ -928,6 +928,9 @@
|
||||
variable = new Value(variable);
|
||||
variable.namespaced = 0 < className.indexOf('.');
|
||||
constructor = func;
|
||||
if (props.expressions[props.expressions.length - 1] instanceof Comment) {
|
||||
constructor.comment = props.expressions.pop();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (func instanceof Code && func.bound) {
|
||||
@@ -1117,7 +1120,7 @@
|
||||
__extends(Code, Base);
|
||||
Code.prototype.children = ['params', 'body'];
|
||||
Code.prototype.compileNode = function(o) {
|
||||
var _i, _len, _len2, _ref2, _ref3, _result, close, code, empty, func, i, open, param, params, sharedScope, splat, top, value;
|
||||
var _i, _len, _len2, _ref2, _ref3, _result, close, code, comm, empty, func, i, open, param, params, sharedScope, splat, top, value;
|
||||
sharedScope = del(o, 'sharedScope');
|
||||
top = del(o, 'top');
|
||||
o.scope = sharedScope || new Scope(o.scope, this.body, this);
|
||||
@@ -1169,11 +1172,12 @@
|
||||
param = params[_i];
|
||||
(o.scope.parameter(param));
|
||||
}
|
||||
comm = this.comment ? this.comment.compile(o) + '\n' : '';
|
||||
if (this.className) {
|
||||
o.indent = this.idt(2);
|
||||
}
|
||||
code = this.body.expressions.length ? ("\n" + (this.body.compileWithDeclarations(o)) + "\n") : '';
|
||||
open = this.className ? ("(function() {\n" + (this.idt(1)) + "function " + (this.className) + "(") : "function(";
|
||||
open = this.className ? ("(function() {\n" + comm + (this.idt(1)) + "function " + (this.className) + "(") : "function(";
|
||||
close = this.className ? ("" + (code && this.idt(1)) + "};\n" + (this.idt(1)) + "return " + (this.className) + ";\n" + (this.tab) + "})()") : ("" + (code && this.tab) + "}");
|
||||
func = ("" + open + (params.join(', ')) + ") {" + code + close);
|
||||
o.scope.endLevel();
|
||||
|
||||
Reference in New Issue
Block a user