From a3bec922fbf9d4c4759aeeed57a8007f8f985d9e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 12:16:29 -0800 Subject: [PATCH 1/7] When the node contains decorators the actual start of the node is after skipping trivia from decorators end --- src/compiler/emitter.ts | 2 +- .../sourceMapValidationDecorators.js.map | 2 +- ...ourceMapValidationDecorators.sourcemap.txt | 90 +++++++++---------- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 48746d828f..76682dadc5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -851,7 +851,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function recordEmitNodeStartSpan(node: Node) { // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(skipTrivia(currentText, node.pos)); + recordSourceMapSpan(skipTrivia(currentText, node.decorators ? node.decorators.end : node.pos)); } function recordEmitNodeEndSpan(node: Node) { diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 4a8b325865..00de6b40b8 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AAOA;IAGIA,iBAGSA,QAAgBA;QAEvBC,WAEcA;aAFdA,WAEcA,CAFdA,sBAEcA,CAFdA,IAEcA;YAFdA,0BAEcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAFLA;QAGIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAEDH,sBAEIA,8BAASA;aAFbA;YAGII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACvBA,0BAAKA,QAEJA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,UAASA;IAMlBA;QACEA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OAFlBA,uBAAEA,QAKTA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;QAMrBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OANtBA,8BAASA,QAEZA;IAfDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,UAAcA;IAzBnCA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA9CD,IA8CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAV/BA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACvBA,0BAAKA,QAEJA;IAIDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,UAASA;IAMlBA;QACEA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OAFlBA,uBAAEA,QAKTA;IAIDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;QAMrBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OANtBA,8BAASA,QAEZA;IAbDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,UAAcA;IAvBnCA;QAFCA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index d9c8d0cc97..b6d01db06a 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -27,16 +27,16 @@ sourceFile:sourceMapValidationDecorators.ts >declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; > + >@ClassDecorator1 + >@ClassDecorator2(10) > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(10, 1) Source(10, 1) + SourceIndex(0) --- >>> function Greeter(greeting) { 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^ -1->@ClassDecorator1 - >@ClassDecorator2(10) - >class Greeter { +1->class Greeter { > 2 > constructor( > @ParameterDecorator1 @@ -53,11 +53,11 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >, > + > @ParameterDecorator1 + > @ParameterDecorator2(30) > -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1 >Emitted(12, 9) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 > ...b: string[] +1 >Emitted(12, 9) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(12, 20) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> for (var _i = 1; _i < arguments.length; _i++) { @@ -68,32 +68,24 @@ sourceFile:sourceMapValidationDecorators.ts 5 > ^ 6 > ^^^^ 1-> -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] +2 > ...b: string[] 3 > -4 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] +4 > ...b: string[] 5 > -6 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1->Emitted(13, 14) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +6 > ...b: string[] +1->Emitted(13, 14) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(13, 25) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(13, 26) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(13, 26) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 4 >Emitted(13, 48) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(13, 49) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(13, 49) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 6 >Emitted(13, 53) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> b[_i - 1] = arguments[_i]; 1 >^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1 >Emitted(14, 13) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 > ...b: string[] +1 >Emitted(14, 13) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(14, 39) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> } @@ -142,7 +134,7 @@ sourceFile:sourceMapValidationDecorators.ts 3 > 1->Emitted(18, 5) Source(23, 5) + SourceIndex(0) name (Greeter) 2 >Emitted(18, 28) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(18, 31) Source(21, 5) + SourceIndex(0) name (Greeter) +3 >Emitted(18, 31) Source(23, 5) + SourceIndex(0) name (Greeter) --- >>> return "

" + this.greeting + "

"; 1->^^^^^^^^ @@ -156,9 +148,7 @@ sourceFile:sourceMapValidationDecorators.ts 9 > ^^^ 10> ^^^^^^^ 11> ^ -1->@PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { +1->greet() { > 2 > return 3 > @@ -262,12 +252,12 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > + > @PropertyDecorator1 + > @PropertyDecorator2(80) > -2 > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get +2 > get 3 > greetings -1->Emitted(24, 5) Source(42, 5) + SourceIndex(0) name (Greeter) +1->Emitted(24, 5) Source(44, 5) + SourceIndex(0) name (Greeter) 2 >Emitted(24, 27) Source(44, 9) + SourceIndex(0) name (Greeter) 3 >Emitted(24, 57) Source(44, 18) + SourceIndex(0) name (Greeter) --- @@ -275,7 +265,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(25, 14) Source(42, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(25, 14) Source(44, 5) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1->^^^^^^^^^^^^ @@ -285,9 +275,7 @@ sourceFile:sourceMapValidationDecorators.ts 5 > ^ 6 > ^^^^^^^^ 7 > ^ -1->@PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { +1->get greetings() { > 2 > return 3 > @@ -393,13 +381,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(35, 5) Source(21, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(35, 5) Source(23, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1->@ +1-> 2 > PropertyDecorator1 1->Emitted(36, 9) Source(21, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(36, 27) Source(21, 24) + SourceIndex(0) name (Greeter) @@ -442,14 +430,16 @@ sourceFile:sourceMapValidationDecorators.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > + > @PropertyDecorator1 + > @PropertyDecorator2(50) > -1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(39, 5) Source(29, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1->@ +1-> 2 > PropertyDecorator1 1->Emitted(40, 9) Source(27, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(40, 27) Source(27, 24) + SourceIndex(0) name (Greeter) @@ -558,14 +548,16 @@ sourceFile:sourceMapValidationDecorators.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > + > @PropertyDecorator1 + > @PropertyDecorator2(80) > -1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(47, 5) Source(44, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^-> -1->@ +1-> 2 > PropertyDecorator1 1->Emitted(48, 9) Source(42, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(48, 27) Source(42, 24) + SourceIndex(0) name (Greeter) @@ -652,13 +644,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(53, 5) Source(31, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(53, 5) Source(33, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1->@ +1-> 2 > PropertyDecorator1 1->Emitted(54, 9) Source(31, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(54, 27) Source(31, 24) + SourceIndex(0) name (Greeter) @@ -698,13 +690,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(57, 5) Source(8, 1) + SourceIndex(0) name (Greeter) +1 >Emitted(57, 5) Source(10, 1) + SourceIndex(0) name (Greeter) --- >>> ClassDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^ 3 > ^^^^^^-> -1->@ +1-> 2 > ClassDecorator1 1->Emitted(58, 9) Source(8, 2) + SourceIndex(0) name (Greeter) 2 >Emitted(58, 24) Source(8, 17) + SourceIndex(0) name (Greeter) @@ -872,9 +864,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 > 2 >} 3 > -4 > @ClassDecorator1 - > @ClassDecorator2(10) - > class Greeter { +4 > class Greeter { > constructor( > @ParameterDecorator1 > @ParameterDecorator2(20) @@ -921,7 +911,7 @@ sourceFile:sourceMapValidationDecorators.ts > } 1 >Emitted(66, 1) Source(54, 1) + SourceIndex(0) name (Greeter) 2 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) name (Greeter) -3 >Emitted(66, 2) Source(8, 1) + SourceIndex(0) +3 >Emitted(66, 2) Source(10, 1) + SourceIndex(0) 4 >Emitted(66, 6) Source(54, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file From e23b0c65ea7bd2cbc742703c2b2b7e937a7995d7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 15:43:35 -0800 Subject: [PATCH 2/7] Fix the source map emit for decorators Handled #5584 --- src/compiler/emitter.ts | 66 ++-- src/compiler/utilities.ts | 17 - .../sourceMapValidationDecorators.js.map | 2 +- ...ourceMapValidationDecorators.sourcemap.txt | 355 +++++++----------- 4 files changed, 170 insertions(+), 270 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 76682dadc5..4dbdc36e31 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -503,10 +503,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ - let emitStart = function (node: Node) { }; + let emitStart = function (node: Node | TextRange) { }; /** Called once the emit of the node is done */ - let emitEnd = function (node: Node) { }; + let emitEnd = function (node: Node | TextRange) { }; /** Emit the text for the given token that comes after startPos * This by default writes the text provided with the given tokenKind @@ -849,12 +849,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function recordEmitNodeStartSpan(node: Node) { + function recordEmitNodeStartSpan(node: Node | TextRange) { // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(skipTrivia(currentText, node.decorators ? node.decorators.end : node.pos)); + recordSourceMapSpan(skipTrivia(currentText, (node as Node).decorators ? (node as Node).decorators.end : node.pos)); } - function recordEmitNodeEndSpan(node: Node) { + function recordEmitNodeEndSpan(node: Node | TextRange) { recordSourceMapSpan(node.end); } @@ -5656,10 +5656,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitDecoratorsOfConstructor(node: ClassLikeDeclaration) { const decorators = node.decorators; const constructor = getFirstConstructorWithBody(node); - const hasDecoratedParameters = constructor && forEach(constructor.parameters, nodeIsDecorated); + const parameterDecorators = constructor && forEach(constructor.parameters, parameter => parameter.decorators); // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { + if (!decorators && !parameterDecorators) { return; } @@ -5675,28 +5675,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(node); + emitStart(node.decorators || parameterDecorators); emitDeclarationName(node); write(" = __decorate(["); increaseIndent(); writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + decorator => emit(decorator.expression)); + if (parameterDecorators) { + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + } emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); emitDeclarationName(node); - write(");"); - emitEnd(node); + write(")"); + emitEnd(node.decorators || parameterDecorators); + write(";"); writeLine(); } @@ -5712,11 +5711,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi continue; } - // skip a member if it or any of its parameters are not decorated - if (!nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor let decorators: NodeArray; let functionLikeMember: FunctionLikeDeclaration; @@ -5743,6 +5737,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi functionLikeMember = member; } } + const parameterDecorators = functionLikeMember && forEach(functionLikeMember.parameters, parameter => parameter.decorators); + + // skip a member if it or any of its parameters are not decorated + if (!decorators && !parameterDecorators) { + continue; + } // Emit the call to __decorate. Given the following: // @@ -5776,29 +5776,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(member); + emitStart(decorators || parameterDecorators); write("__decorate(["); increaseIndent(); writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + decorator => emit(decorator.expression)); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + if (parameterDecorators) { + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + } emitSerializedTypeMetadata(member, argumentsWritten > 0); decreaseIndent(); writeLine(); write("], "); - emitStart(member.name); emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); - emitEnd(member.name); if (languageVersion > ScriptTarget.ES3) { if (member.kind !== SyntaxKind.PropertyDeclaration) { @@ -5813,8 +5810,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - write(");"); - emitEnd(member); + write(")"); + emitEnd(decorators || parameterDecorators); + write(";"); writeLine(); } } @@ -5827,11 +5825,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (nodeIsDecorated(parameter)) { const decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); write(`__param(${parameterIndex}, `); emit(decorator.expression); write(")"); - emitEnd(decorator); }); leadingComma = true; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index eef6dbe970..3c8e5deb46 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -909,23 +909,6 @@ namespace ts { return false; } - export function childIsDecorated(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.ClassDeclaration: - return forEach((node).members, nodeOrChildIsDecorated); - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.SetAccessor: - return forEach((node).parameters, nodeIsDecorated); - } - - return false; - } - - export function nodeOrChildIsDecorated(node: Node): boolean { - return nodeIsDecorated(node) || childIsDecorated(node); - } - export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { return node.kind === SyntaxKind.PropertyAccessExpression; } diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 00de6b40b8..355cb0cb55 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAV/BA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACvBA,0BAAKA,QAEJA;IAIDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,UAASA;IAMlBA;QACEA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OAFlBA,uBAAEA,QAKTA;IAIDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;QAMrBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OANtBA,8BAASA,QAEZA;IAbDA;QAFCA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,UAAcA;IAvBnCA;QAFCA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ9BA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;wCAAAA;IAKtBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;sCAAAA;IAQpBA;mBAAAA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;qCAAAA;IAKzBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;mBAMpBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;4CAPHA;IAZtBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;6BAAAA;IAxB1BA;QAAAA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;mBAGbA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;mBAGvBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;eARVA;IA6CpBA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index b6d01db06a..face3de621 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -381,7 +381,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(35, 5) Source(23, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(35, 5) Source(21, 6) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -412,28 +412,20 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(37, 31) Source(22, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "greet", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ -1-> - > -2 > greet -3 > () { - > return "

" + this.greeting + "

"; - > } -1->Emitted(38, 8) Source(23, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(38, 34) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(38, 42) Source(25, 6) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(38, 41) Source(22, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > + > greet() { + > return "

" + this.greeting + "

"; + > } > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > -1 >Emitted(39, 5) Source(29, 5) + SourceIndex(0) name (Greeter) + > @ +1 >Emitted(39, 5) Source(27, 6) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -464,94 +456,66 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "x", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private -2 > x -3 > : string; -1->Emitted(42, 8) Source(29, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(42, 30) Source(29, 14) + SourceIndex(0) name (Greeter) -3 >Emitted(42, 40) Source(29, 23) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(42, 39) Source(28, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > + > private x: string; > > @PropertyDecorator1 > @PropertyDecorator2(60) > private static x1: number = 10; > - > -1 >Emitted(43, 5) Source(35, 5) + SourceIndex(0) name (Greeter) + > private fn( + > @ +1 >Emitted(43, 5) Source(36, 8) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1->private fn( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(44, 9) Source(36, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(44, 40) Source(36, 27) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1-> +2 > ParameterDecorator1 +1->Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(70)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 70 -6 > ) -7 > -1->Emitted(45, 9) Source(37, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(45, 20) Source(37, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(45, 44) Source(37, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 70 +5 > ) +1->Emitted(45, 20) Source(37, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "fn", null); -1 >^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ +1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -2 > fn -3 > ( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } -1 >Emitted(46, 8) Source(35, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(46, 31) Source(35, 15) + SourceIndex(0) name (Greeter) -3 >Emitted(46, 39) Source(40, 6) + SourceIndex(0) name (Greeter) +1 >Emitted(46, 38) Source(37, 31) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +1 > + > x: number) { + > return this.greeting; + > } > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > -1 >Emitted(47, 5) Source(44, 5) + SourceIndex(0) name (Greeter) + > @ +1 >Emitted(47, 5) Source(42, 6) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -582,69 +546,49 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1-> > get greetings() { > return this.greeting; > } > > set greetings( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(50, 9) Source(49, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(50, 20) Source(49, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(50, 40) Source(49, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1->Emitted(50, 20) Source(49, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(90)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -8 > ^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^-> 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 90 -6 > ) -7 > -1->Emitted(51, 9) Source(50, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(51, 20) Source(50, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(51, 44) Source(50, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 90 +5 > ) +1->Emitted(51, 20) Source(50, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "greetings", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -2 > greetings -3 > () { - > return this.greeting; - > } -1->Emitted(52, 8) Source(44, 9) + SourceIndex(0) name (Greeter) -2 >Emitted(52, 38) Source(44, 18) + SourceIndex(0) name (Greeter) -3 >Emitted(52, 46) Source(46, 6) + SourceIndex(0) name (Greeter) +1->Emitted(52, 45) Source(43, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(53, 5) Source(33, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(53, 5) Source(31, 6) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -675,22 +619,15 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter, "x1", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private static -2 > x1 -3 > : number = 10; -1->Emitted(56, 8) Source(33, 20) + SourceIndex(0) name (Greeter) -2 >Emitted(56, 21) Source(33, 22) + SourceIndex(0) name (Greeter) -3 >Emitted(56, 31) Source(33, 36) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(56, 30) Source(32, 28) + SourceIndex(0) name (Greeter) --- >>> Greeter = __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(57, 5) Source(10, 1) + SourceIndex(0) name (Greeter) +1 >Emitted(57, 5) Source(8, 2) + SourceIndex(0) name (Greeter) --- >>> ClassDecorator1, 1->^^^^^^^^ @@ -721,93 +658,83 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^-> 1-> >class Greeter { > constructor( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(60, 9) Source(12, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(60, 20) Source(12, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(60, 40) Source(12, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1->Emitted(60, 20) Source(12, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(20)), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 20 -6 > ) -7 > -1->Emitted(61, 9) Source(13, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(61, 20) Source(13, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(61, 44) Source(13, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 20 +5 > ) +1->Emitted(61, 20) Source(13, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator1), -1 >^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1 > > public greeting: string, > - > -2 > @ -3 > ParameterDecorator1 -4 > -1 >Emitted(62, 9) Source(16, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(62, 40) Source(16, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator2(30)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 30 -6 > ) -7 > -1->Emitted(63, 9) Source(17, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(63, 20) Source(17, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(63, 44) Source(17, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 30 +5 > ) +1->Emitted(63, 20) Source(17, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter); -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^-> -1 > +1 >^^^^^^^^^^^^^^^ +2 > ^^^^^-> +1 > +1 >Emitted(64, 16) Source(9, 21) + SourceIndex(0) name (Greeter) +--- +>>> return Greeter; +1->^^^^ +2 > ^^^^^^^^^^^^^^ +1-> + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) > ...b: string[]) { > } > @@ -844,13 +771,7 @@ sourceFile:sourceMapValidationDecorators.ts > greetings: string) { > this.greeting = greetings; > } - >} -1 >Emitted(64, 17) Source(54, 2) + SourceIndex(0) name (Greeter) ---- ->>> return Greeter; -1->^^^^ -2 > ^^^^^^^^^^^^^^ -1-> + > 2 > } 1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) name (Greeter) 2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) name (Greeter) From c84a9f154b52c6ef15e2386602f78d38cce4e9d6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 15:50:24 -0800 Subject: [PATCH 3/7] Test cases for breakpoints with decorators --- .../reference/bpSpan_decorators.baseline | 539 ++++++++++++++++++ .../breakpointValidationDecorators.ts | 60 ++ 2 files changed, 599 insertions(+) create mode 100644 tests/baselines/reference/bpSpan_decorators.baseline create mode 100644 tests/cases/fourslash/breakpointValidationDecorators.ts diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline new file mode 100644 index 0000000000..dc7a9556d0 --- /dev/null +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -0,0 +1,539 @@ + +1 >declare function ClassDecorator1(target: Function): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (0 to 57) SpanInfo: undefined +-------------------------------- +2 >declare function ClassDecorator2(x: number): (target: Function) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (58 to 130) SpanInfo: undefined +-------------------------------- +3 >declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (131 to 244) SpanInfo: undefined +-------------------------------- +4 >declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (245 to 373) SpanInfo: undefined +-------------------------------- +5 >declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (374 to 475) SpanInfo: undefined +-------------------------------- +6 >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (476 to 592) SpanInfo: undefined +-------------------------------- +7 > + + ~ => Pos: (593 to 593) SpanInfo: undefined +-------------------------------- +8 >@ClassDecorator1 + + ~~~~~~~~~~~~~~~~~ => Pos: (594 to 610) SpanInfo: {"start":594,"length":952} + >@ClassDecorator1 + >@ClassDecorator2(10) + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >} + >:=> (line 8, col 0) to (line 54, col 1) +-------------------------------- +9 >@ClassDecorator2(10) + + ~ => Pos: (611 to 611) SpanInfo: {"start":594,"length":952} + >@ClassDecorator1 + >@ClassDecorator2(10) + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >} + >:=> (line 8, col 0) to (line 54, col 1) +9 >@ClassDecorator2(10) + + ~~~~~~~~~~~~~~~~~~~~ => Pos: (612 to 631) SpanInfo: {"start":612,"length":19} + >ClassDecorator2(10) + >:=> (line 9, col 1) to (line 9, col 20) +-------------------------------- +10 >class Greeter { + + ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":594,"length":952} + >@ClassDecorator1 + >@ClassDecorator2(10) + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >} + >:=> (line 8, col 0) to (line 54, col 1) +-------------------------------- +11 > constructor( + + ~~~~~~~~~~~~~~~~~ => Pos: (648 to 664) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +12 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (665 to 693) SpanInfo: {"start":673,"length":85} + >@ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string + >:=> (line 12, col 8) to (line 14, col 31) +-------------------------------- +13 > @ParameterDecorator2(20) + + ~~~~~~~~~ => Pos: (694 to 702) SpanInfo: {"start":673,"length":85} + >@ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string + >:=> (line 12, col 8) to (line 14, col 31) +13 > @ParameterDecorator2(20) + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (703 to 726) SpanInfo: {"start":703,"length":23} + >ParameterDecorator2(20) + >:=> (line 13, col 9) to (line 13, col 32) +-------------------------------- +14 > public greeting: string, + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":673,"length":85} + >@ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string + >:=> (line 12, col 8) to (line 14, col 31) +-------------------------------- +15 > + + ~ => Pos: (760 to 760) SpanInfo: undefined +-------------------------------- +16 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (761 to 789) SpanInfo: {"start":769,"length":80} + >@ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[] + >:=> (line 16, col 8) to (line 18, col 26) +-------------------------------- +17 > @ParameterDecorator2(30) + + ~~~~~~~~~ => Pos: (790 to 798) SpanInfo: {"start":769,"length":80} + >@ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[] + >:=> (line 16, col 8) to (line 18, col 26) +17 > @ParameterDecorator2(30) + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (799 to 822) SpanInfo: {"start":799,"length":23} + >ParameterDecorator2(30) + >:=> (line 17, col 9) to (line 17, col 32) +-------------------------------- +18 > ...b: string[]) { + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":769,"length":80} + >@ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[] + >:=> (line 16, col 8) to (line 18, col 26) +18 > ...b: string[]) { + + ~~~ => Pos: (850 to 852) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +19 > } + + ~~~~~~ => Pos: (853 to 858) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +20 > + + ~ => Pos: (859 to 859) SpanInfo: undefined +-------------------------------- +21 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (860 to 883) SpanInfo: {"start":864,"length":116} + >@PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + >:=> (line 21, col 4) to (line 25, col 5) +-------------------------------- +22 > @PropertyDecorator2(40) + + ~~~~~ => Pos: (884 to 888) SpanInfo: {"start":864,"length":116} + >@PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + >:=> (line 21, col 4) to (line 25, col 5) +22 > @PropertyDecorator2(40) + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (889 to 911) SpanInfo: {"start":889,"length":22} + >PropertyDecorator2(40) + >:=> (line 22, col 5) to (line 22, col 27) +-------------------------------- +23 > greet() { + + ~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":864,"length":116} + >@PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + >:=> (line 21, col 4) to (line 25, col 5) +23 > greet() { + + ~~~ => Pos: (923 to 925) SpanInfo: {"start":934,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 24, col 8) to (line 24, col 47) +-------------------------------- +24 > return "

" + this.greeting + "

"; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (926 to 974) SpanInfo: {"start":934,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 24, col 8) to (line 24, col 47) +-------------------------------- +25 > } + + ~~~~~~ => Pos: (975 to 980) SpanInfo: {"start":979,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +-------------------------------- +26 > + + ~ => Pos: (981 to 981) SpanInfo: undefined +-------------------------------- +27 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (982 to 1005) SpanInfo: undefined +-------------------------------- +28 > @PropertyDecorator2(50) + + ~~~~~ => Pos: (1006 to 1010) SpanInfo: undefined +28 > @PropertyDecorator2(50) + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1011 to 1033) SpanInfo: {"start":1011,"length":22} + >PropertyDecorator2(50) + >:=> (line 28, col 5) to (line 28, col 27) +-------------------------------- +29 > private x: string; + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1034 to 1056) SpanInfo: undefined +-------------------------------- +30 > + + ~ => Pos: (1057 to 1057) SpanInfo: undefined +-------------------------------- +31 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1058 to 1081) SpanInfo: {"start":1062,"length":83} + >@PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + >:=> (line 31, col 4) to (line 33, col 35) +-------------------------------- +32 > @PropertyDecorator2(60) + + ~~~~~ => Pos: (1082 to 1086) SpanInfo: {"start":1062,"length":83} + >@PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + >:=> (line 31, col 4) to (line 33, col 35) +32 > @PropertyDecorator2(60) + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1087 to 1109) SpanInfo: {"start":1087,"length":22} + >PropertyDecorator2(60) + >:=> (line 32, col 5) to (line 32, col 27) +-------------------------------- +33 > private static x1: number = 10; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1062,"length":83} + >@PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + >:=> (line 31, col 4) to (line 33, col 35) +-------------------------------- +34 > + + ~ => Pos: (1146 to 1146) SpanInfo: undefined +-------------------------------- +35 > private fn( + + ~~~~~~~~~~~~~~~~ => Pos: (1147 to 1162) SpanInfo: {"start":1151,"length":130} + >private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + >:=> (line 35, col 4) to (line 40, col 5) +-------------------------------- +36 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1163 to 1191) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +-------------------------------- +37 > @ParameterDecorator2(70) + + ~~~~~~~~~ => Pos: (1192 to 1200) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +37 > @ParameterDecorator2(70) + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1201 to 1224) SpanInfo: {"start":1201,"length":23} + >ParameterDecorator2(70) + >:=> (line 37, col 9) to (line 37, col 32) +-------------------------------- +38 > x: number) { + + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (1225 to 1245) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +-------------------------------- +39 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1246 to 1275) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +-------------------------------- +40 > } + + ~~~~~~ => Pos: (1276 to 1281) SpanInfo: {"start":1280,"length":1} + >} + >:=> (line 40, col 4) to (line 40, col 5) +-------------------------------- +41 > + + ~ => Pos: (1282 to 1282) SpanInfo: undefined +-------------------------------- +42 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1283 to 1306) SpanInfo: {"start":1287,"length":105} + >@PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + >:=> (line 42, col 4) to (line 46, col 5) +-------------------------------- +43 > @PropertyDecorator2(80) + + ~~~~~ => Pos: (1307 to 1311) SpanInfo: {"start":1287,"length":105} + >@PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + >:=> (line 42, col 4) to (line 46, col 5) +43 > @PropertyDecorator2(80) + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1312 to 1334) SpanInfo: {"start":1312,"length":22} + >PropertyDecorator2(80) + >:=> (line 43, col 5) to (line 43, col 27) +-------------------------------- +44 > get greetings() { + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1287,"length":105} + >@PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + >:=> (line 42, col 4) to (line 46, col 5) +44 > get greetings() { + + ~~~ => Pos: (1354 to 1356) SpanInfo: {"start":1365,"length":20} + >return this.greeting + >:=> (line 45, col 8) to (line 45, col 28) +-------------------------------- +45 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1357 to 1386) SpanInfo: {"start":1365,"length":20} + >return this.greeting + >:=> (line 45, col 8) to (line 45, col 28) +-------------------------------- +46 > } + + ~~~~~~ => Pos: (1387 to 1392) SpanInfo: {"start":1391,"length":1} + >} + >:=> (line 46, col 4) to (line 46, col 5) +-------------------------------- +47 > + + ~ => Pos: (1393 to 1393) SpanInfo: undefined +-------------------------------- +48 > set greetings( + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1394 to 1412) SpanInfo: {"start":1398,"length":146} + >set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >:=> (line 48, col 4) to (line 53, col 5) +-------------------------------- +49 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1413 to 1441) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +-------------------------------- +50 > @ParameterDecorator2(90) + + ~~~~~~~~~ => Pos: (1442 to 1450) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +50 > @ParameterDecorator2(90) + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1451 to 1474) SpanInfo: {"start":1451,"length":23} + >ParameterDecorator2(90) + >:=> (line 50, col 9) to (line 50, col 32) +-------------------------------- +51 > greetings: string) { + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1475 to 1503) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +-------------------------------- +52 > this.greeting = greetings; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1504 to 1538) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +-------------------------------- +53 > } + + ~~~~~~ => Pos: (1539 to 1544) SpanInfo: {"start":1543,"length":1} + >} + >:=> (line 53, col 4) to (line 53, col 5) +-------------------------------- +54 >} + ~ => Pos: (1545 to 1545) SpanInfo: {"start":1545,"length":1} + >} + >:=> (line 54, col 0) to (line 54, col 1) \ No newline at end of file diff --git a/tests/cases/fourslash/breakpointValidationDecorators.ts b/tests/cases/fourslash/breakpointValidationDecorators.ts new file mode 100644 index 0000000000..9eb4463e00 --- /dev/null +++ b/tests/cases/fourslash/breakpointValidationDecorators.ts @@ -0,0 +1,60 @@ +/// + +// @BaselineFile: bpSpan_decorators.baseline +// @Filename: bpSpan_decorators.ts +////declare function ClassDecorator1(target: Function): void; +////declare function ClassDecorator2(x: number): (target: Function) => void; +////declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; +////declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; +////declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; +////declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; +//// +////@ClassDecorator1 +////@ClassDecorator2(10) +////class Greeter { +//// constructor( +//// @ParameterDecorator1 +//// @ParameterDecorator2(20) +//// public greeting: string, +//// +//// @ParameterDecorator1 +//// @ParameterDecorator2(30) +//// ...b: string[]) { +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(40) +//// greet() { +//// return "

" + this.greeting + "

"; +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(50) +//// private x: string; +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(60) +//// private static x1: number = 10; +//// +//// private fn( +//// @ParameterDecorator1 +//// @ParameterDecorator2(70) +//// x: number) { +//// return this.greeting; +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(80) +//// get greetings() { +//// return this.greeting; +//// } +//// +//// set greetings( +//// @ParameterDecorator1 +//// @ParameterDecorator2(90) +//// greetings: string) { +//// this.greeting = greetings; +//// } +////} + +verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file From 858a99b4f198ff265d129d116e540044e6f40aad Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 16:24:13 -0800 Subject: [PATCH 4/7] Setting breakpoint inside decorator expression results in setting breakpoint on all the decorators On resolution, this would be call to __decorate --- src/services/breakpoints.ts | 18 +- .../reference/bpSpan_decorators.baseline | 226 +++++++----------- 2 files changed, 108 insertions(+), 136 deletions(-) diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index e307b21979..dea27d0f8d 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -16,7 +16,7 @@ namespace ts.BreakpointResolver { let tokenAtLocation = getTokenAtPosition(sourceFile, position); let lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line // eg: let x =10; |--- cursor is here // let y = 10; @@ -39,16 +39,20 @@ namespace ts.BreakpointResolver { return spanInNode(tokenAtLocation); function textSpan(startNode: Node, endNode?: Node) { - return createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); + return createTextSpanFromBounds(startNode.getStart(sourceFile), (endNode || startNode).getEnd()); } function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { return spanInNode(node); } return spanInNode(otherwiseOnNode); } + function spanInNodeArray(nodeArray: NodeArray) { + return createTextSpanFromBounds(skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end); + } + function spanInPreviousNode(node: Node): TextSpan { return spanInNode(findPrecedingToken(node.pos, sourceFile)); } @@ -65,6 +69,11 @@ namespace ts.BreakpointResolver { return spanInPreviousNode(node); } + if (node.parent.kind === SyntaxKind.Decorator) { + // Set breakpoint on the decorator emit + return spanInNode(node.parent); + } + if (node.parent.kind === SyntaxKind.ForStatement) { // For now lets set the span on this expression, fix it later return textSpan(node); @@ -207,6 +216,9 @@ namespace ts.BreakpointResolver { // span in statement return spanInNode((node).statement); + case SyntaxKind.Decorator: + return spanInNodeArray(node.parent.decorators); + // No breakpoint in interface, type alias case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline index dc7a9556d0..bba31d1df4 100644 --- a/tests/baselines/reference/bpSpan_decorators.baseline +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -29,7 +29,7 @@ -------------------------------- 8 >@ClassDecorator1 - ~~~~~~~~~~~~~~~~~ => Pos: (594 to 610) SpanInfo: {"start":594,"length":952} + ~ => Pos: (594 to 594) SpanInfo: {"start":594,"length":952} >@ClassDecorator1 >@ClassDecorator2(10) >class Greeter { @@ -78,63 +78,19 @@ > } >} >:=> (line 8, col 0) to (line 54, col 1) +8 >@ClassDecorator1 + + ~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36} + >ClassDecorator1 + >@ClassDecorator2(10) + >:=> (line 8, col 1) to (line 9, col 20) -------------------------------- 9 >@ClassDecorator2(10) - ~ => Pos: (611 to 611) SpanInfo: {"start":594,"length":952} - >@ClassDecorator1 + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":595,"length":36} + >ClassDecorator1 >@ClassDecorator2(10) - >class Greeter { - > constructor( - > @ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string, - > - > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[]) { - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { - > return "

" + this.greeting + "

"; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > private x: string; - > - > @PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - > - > private fn( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { - > return this.greeting; - > } - > - > set greetings( - > @ParameterDecorator1 - > @ParameterDecorator2(90) - > greetings: string) { - > this.greeting = greetings; - > } - >} - >:=> (line 8, col 0) to (line 54, col 1) -9 >@ClassDecorator2(10) - - ~~~~~~~~~~~~~~~~~~~~ => Pos: (612 to 631) SpanInfo: {"start":612,"length":19} - >ClassDecorator2(10) - >:=> (line 9, col 1) to (line 9, col 20) + >:=> (line 8, col 1) to (line 9, col 20) -------------------------------- 10 >class Greeter { @@ -196,24 +152,24 @@ -------------------------------- 12 > @ParameterDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (665 to 693) SpanInfo: {"start":673,"length":85} + ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":673,"length":85} >@ParameterDecorator1 > @ParameterDecorator2(20) > public greeting: string >:=> (line 12, col 8) to (line 14, col 31) +12 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(20) + >:=> (line 12, col 9) to (line 13, col 32) -------------------------------- 13 > @ParameterDecorator2(20) - ~~~~~~~~~ => Pos: (694 to 702) SpanInfo: {"start":673,"length":85} - >@ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":674,"length":52} + >ParameterDecorator1 > @ParameterDecorator2(20) - > public greeting: string - >:=> (line 12, col 8) to (line 14, col 31) -13 > @ParameterDecorator2(20) - - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (703 to 726) SpanInfo: {"start":703,"length":23} - >ParameterDecorator2(20) - >:=> (line 13, col 9) to (line 13, col 32) + >:=> (line 12, col 9) to (line 13, col 32) -------------------------------- 14 > public greeting: string, @@ -229,24 +185,24 @@ -------------------------------- 16 > @ParameterDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (761 to 789) SpanInfo: {"start":769,"length":80} + ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":769,"length":80} >@ParameterDecorator1 > @ParameterDecorator2(30) > ...b: string[] >:=> (line 16, col 8) to (line 18, col 26) +16 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(30) + >:=> (line 16, col 9) to (line 17, col 32) -------------------------------- 17 > @ParameterDecorator2(30) - ~~~~~~~~~ => Pos: (790 to 798) SpanInfo: {"start":769,"length":80} - >@ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":770,"length":52} + >ParameterDecorator1 > @ParameterDecorator2(30) - > ...b: string[] - >:=> (line 16, col 8) to (line 18, col 26) -17 > @ParameterDecorator2(30) - - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (799 to 822) SpanInfo: {"start":799,"length":23} - >ParameterDecorator2(30) - >:=> (line 17, col 9) to (line 17, col 32) + >:=> (line 16, col 9) to (line 17, col 32) -------------------------------- 18 > ...b: string[]) { @@ -273,28 +229,26 @@ -------------------------------- 21 > @PropertyDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (860 to 883) SpanInfo: {"start":864,"length":116} + ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":864,"length":116} >@PropertyDecorator1 > @PropertyDecorator2(40) > greet() { > return "

" + this.greeting + "

"; > } >:=> (line 21, col 4) to (line 25, col 5) +21 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~ => Pos: (865 to 883) SpanInfo: {"start":865,"length":46} + >PropertyDecorator1 + > @PropertyDecorator2(40) + >:=> (line 21, col 5) to (line 22, col 27) -------------------------------- 22 > @PropertyDecorator2(40) - ~~~~~ => Pos: (884 to 888) SpanInfo: {"start":864,"length":116} - >@PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":865,"length":46} + >PropertyDecorator1 > @PropertyDecorator2(40) - > greet() { - > return "

" + this.greeting + "

"; - > } - >:=> (line 21, col 4) to (line 25, col 5) -22 > @PropertyDecorator2(40) - - ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (889 to 911) SpanInfo: {"start":889,"length":22} - >PropertyDecorator2(40) - >:=> (line 22, col 5) to (line 22, col 27) + >:=> (line 21, col 5) to (line 22, col 27) -------------------------------- 23 > greet() { @@ -329,16 +283,20 @@ -------------------------------- 27 > @PropertyDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (982 to 1005) SpanInfo: undefined + ~~~~~ => Pos: (982 to 986) SpanInfo: undefined +27 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~ => Pos: (987 to 1005) SpanInfo: {"start":987,"length":46} + >PropertyDecorator1 + > @PropertyDecorator2(50) + >:=> (line 27, col 5) to (line 28, col 27) -------------------------------- 28 > @PropertyDecorator2(50) - ~~~~~ => Pos: (1006 to 1010) SpanInfo: undefined -28 > @PropertyDecorator2(50) - - ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1011 to 1033) SpanInfo: {"start":1011,"length":22} - >PropertyDecorator2(50) - >:=> (line 28, col 5) to (line 28, col 27) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":987,"length":46} + >PropertyDecorator1 + > @PropertyDecorator2(50) + >:=> (line 27, col 5) to (line 28, col 27) -------------------------------- 29 > private x: string; @@ -350,24 +308,24 @@ -------------------------------- 31 > @PropertyDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1058 to 1081) SpanInfo: {"start":1062,"length":83} + ~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1062,"length":83} >@PropertyDecorator1 > @PropertyDecorator2(60) > private static x1: number = 10; >:=> (line 31, col 4) to (line 33, col 35) +31 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1063 to 1081) SpanInfo: {"start":1063,"length":46} + >PropertyDecorator1 + > @PropertyDecorator2(60) + >:=> (line 31, col 5) to (line 32, col 27) -------------------------------- 32 > @PropertyDecorator2(60) - ~~~~~ => Pos: (1082 to 1086) SpanInfo: {"start":1062,"length":83} - >@PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1063,"length":46} + >PropertyDecorator1 > @PropertyDecorator2(60) - > private static x1: number = 10; - >:=> (line 31, col 4) to (line 33, col 35) -32 > @PropertyDecorator2(60) - - ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1087 to 1109) SpanInfo: {"start":1087,"length":22} - >PropertyDecorator2(60) - >:=> (line 32, col 5) to (line 32, col 27) + >:=> (line 31, col 5) to (line 32, col 27) -------------------------------- 33 > private static x1: number = 10; @@ -394,20 +352,22 @@ -------------------------------- 36 > @ParameterDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1163 to 1191) SpanInfo: {"start":1254,"length":20} + ~~~~~~~~~ => Pos: (1163 to 1171) SpanInfo: {"start":1254,"length":20} >return this.greeting >:=> (line 39, col 8) to (line 39, col 28) +36 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~ => Pos: (1172 to 1191) SpanInfo: {"start":1172,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(70) + >:=> (line 36, col 9) to (line 37, col 32) -------------------------------- 37 > @ParameterDecorator2(70) - ~~~~~~~~~ => Pos: (1192 to 1200) SpanInfo: {"start":1254,"length":20} - >return this.greeting - >:=> (line 39, col 8) to (line 39, col 28) -37 > @ParameterDecorator2(70) - - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1201 to 1224) SpanInfo: {"start":1201,"length":23} - >ParameterDecorator2(70) - >:=> (line 37, col 9) to (line 37, col 32) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1172,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(70) + >:=> (line 36, col 9) to (line 37, col 32) -------------------------------- 38 > x: number) { @@ -433,28 +393,26 @@ -------------------------------- 42 > @PropertyDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1283 to 1306) SpanInfo: {"start":1287,"length":105} + ~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1287,"length":105} >@PropertyDecorator1 > @PropertyDecorator2(80) > get greetings() { > return this.greeting; > } >:=> (line 42, col 4) to (line 46, col 5) +42 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1288 to 1306) SpanInfo: {"start":1288,"length":46} + >PropertyDecorator1 + > @PropertyDecorator2(80) + >:=> (line 42, col 5) to (line 43, col 27) -------------------------------- 43 > @PropertyDecorator2(80) - ~~~~~ => Pos: (1307 to 1311) SpanInfo: {"start":1287,"length":105} - >@PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1288,"length":46} + >PropertyDecorator1 > @PropertyDecorator2(80) - > get greetings() { - > return this.greeting; - > } - >:=> (line 42, col 4) to (line 46, col 5) -43 > @PropertyDecorator2(80) - - ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1312 to 1334) SpanInfo: {"start":1312,"length":22} - >PropertyDecorator2(80) - >:=> (line 43, col 5) to (line 43, col 27) + >:=> (line 42, col 5) to (line 43, col 27) -------------------------------- 44 > get greetings() { @@ -500,20 +458,22 @@ -------------------------------- 49 > @ParameterDecorator1 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1413 to 1441) SpanInfo: {"start":1512,"length":25} + ~~~~~~~~~ => Pos: (1413 to 1421) SpanInfo: {"start":1512,"length":25} >this.greeting = greetings >:=> (line 52, col 8) to (line 52, col 33) +49 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~ => Pos: (1422 to 1441) SpanInfo: {"start":1422,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(90) + >:=> (line 49, col 9) to (line 50, col 32) -------------------------------- 50 > @ParameterDecorator2(90) - ~~~~~~~~~ => Pos: (1442 to 1450) SpanInfo: {"start":1512,"length":25} - >this.greeting = greetings - >:=> (line 52, col 8) to (line 52, col 33) -50 > @ParameterDecorator2(90) - - ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1451 to 1474) SpanInfo: {"start":1451,"length":23} - >ParameterDecorator2(90) - >:=> (line 50, col 9) to (line 50, col 32) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1422,"length":52} + >ParameterDecorator1 + > @ParameterDecorator2(90) + >:=> (line 49, col 9) to (line 50, col 32) -------------------------------- 51 > greetings: string) { From 83e569e6c3f966611624ee6f07d5e9aa128e3674 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 16:34:38 -0800 Subject: [PATCH 5/7] Breakpoints on the node with decorator should start at actual syntax and not from decorators --- src/services/breakpoints.ts | 5 +- .../reference/bpSpan_decorators.baseline | 92 +++++++------------ 2 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index dea27d0f8d..31ab5d2ade 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -39,7 +39,10 @@ namespace ts.BreakpointResolver { return spanInNode(tokenAtLocation); function textSpan(startNode: Node, endNode?: Node) { - return createTextSpanFromBounds(startNode.getStart(sourceFile), (endNode || startNode).getEnd()); + const start = startNode.decorators ? + skipTrivia(sourceFile.text, startNode.decorators.end) : + startNode.getStart(sourceFile); + return createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan { diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline index bba31d1df4..179cdb0890 100644 --- a/tests/baselines/reference/bpSpan_decorators.baseline +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -29,9 +29,7 @@ -------------------------------- 8 >@ClassDecorator1 - ~ => Pos: (594 to 594) SpanInfo: {"start":594,"length":952} - >@ClassDecorator1 - >@ClassDecorator2(10) + ~ => Pos: (594 to 594) SpanInfo: {"start":632,"length":914} >class Greeter { > constructor( > @ParameterDecorator1 @@ -77,7 +75,7 @@ > this.greeting = greetings; > } >} - >:=> (line 8, col 0) to (line 54, col 1) + >:=> (line 10, col 0) to (line 54, col 1) 8 >@ClassDecorator1 ~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36} @@ -94,9 +92,7 @@ -------------------------------- 10 >class Greeter { - ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":594,"length":952} - >@ClassDecorator1 - >@ClassDecorator2(10) + ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":632,"length":914} >class Greeter { > constructor( > @ParameterDecorator1 @@ -142,7 +138,7 @@ > this.greeting = greetings; > } >} - >:=> (line 8, col 0) to (line 54, col 1) + >:=> (line 10, col 0) to (line 54, col 1) -------------------------------- 11 > constructor( @@ -152,11 +148,9 @@ -------------------------------- 12 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":673,"length":85} - >@ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string - >:=> (line 12, col 8) to (line 14, col 31) + ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":735,"length":23} + >public greeting: string + >:=> (line 14, col 8) to (line 14, col 31) 12 > @ParameterDecorator1 ~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52} @@ -173,11 +167,9 @@ -------------------------------- 14 > public greeting: string, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":673,"length":85} - >@ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string - >:=> (line 12, col 8) to (line 14, col 31) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":735,"length":23} + >public greeting: string + >:=> (line 14, col 8) to (line 14, col 31) -------------------------------- 15 > @@ -185,11 +177,9 @@ -------------------------------- 16 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":769,"length":80} - >@ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] - >:=> (line 16, col 8) to (line 18, col 26) + ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":835,"length":14} + >...b: string[] + >:=> (line 18, col 12) to (line 18, col 26) 16 > @ParameterDecorator1 ~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52} @@ -206,11 +196,9 @@ -------------------------------- 18 > ...b: string[]) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":769,"length":80} - >@ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] - >:=> (line 16, col 8) to (line 18, col 26) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":835,"length":14} + >...b: string[] + >:=> (line 18, col 12) to (line 18, col 26) 18 > ...b: string[]) { ~~~ => Pos: (850 to 852) SpanInfo: {"start":857,"length":1} @@ -229,13 +217,11 @@ -------------------------------- 21 > @PropertyDecorator1 - ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":864,"length":116} - >@PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { + ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":916,"length":64} + >greet() { > return "

" + this.greeting + "

"; > } - >:=> (line 21, col 4) to (line 25, col 5) + >:=> (line 23, col 4) to (line 25, col 5) 21 > @PropertyDecorator1 ~~~~~~~~~~~~~~~~~~~ => Pos: (865 to 883) SpanInfo: {"start":865,"length":46} @@ -252,13 +238,11 @@ -------------------------------- 23 > greet() { - ~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":864,"length":116} - >@PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { + ~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":916,"length":64} + >greet() { > return "

" + this.greeting + "

"; > } - >:=> (line 21, col 4) to (line 25, col 5) + >:=> (line 23, col 4) to (line 25, col 5) 23 > greet() { ~~~ => Pos: (923 to 925) SpanInfo: {"start":934,"length":39} @@ -308,11 +292,9 @@ -------------------------------- 31 > @PropertyDecorator1 - ~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1062,"length":83} - >@PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - >:=> (line 31, col 4) to (line 33, col 35) + ~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1114,"length":31} + >private static x1: number = 10; + >:=> (line 33, col 4) to (line 33, col 35) 31 > @PropertyDecorator1 ~~~~~~~~~~~~~~~~~~~ => Pos: (1063 to 1081) SpanInfo: {"start":1063,"length":46} @@ -329,11 +311,9 @@ -------------------------------- 33 > private static x1: number = 10; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1062,"length":83} - >@PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - >:=> (line 31, col 4) to (line 33, col 35) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1114,"length":31} + >private static x1: number = 10; + >:=> (line 33, col 4) to (line 33, col 35) -------------------------------- 34 > @@ -393,13 +373,11 @@ -------------------------------- 42 > @PropertyDecorator1 - ~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1287,"length":105} - >@PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { + ~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1339,"length":53} + >get greetings() { > return this.greeting; > } - >:=> (line 42, col 4) to (line 46, col 5) + >:=> (line 44, col 4) to (line 46, col 5) 42 > @PropertyDecorator1 ~~~~~~~~~~~~~~~~~~~ => Pos: (1288 to 1306) SpanInfo: {"start":1288,"length":46} @@ -416,13 +394,11 @@ -------------------------------- 44 > get greetings() { - ~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1287,"length":105} - >@PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { + ~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1339,"length":53} + >get greetings() { > return this.greeting; > } - >:=> (line 42, col 4) to (line 46, col 5) + >:=> (line 44, col 4) to (line 46, col 5) 44 > get greetings() { ~~~ => Pos: (1354 to 1356) SpanInfo: {"start":1365,"length":20} From ba2238fe583c2e8c7290efd9b61708900f69e2d0 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Nov 2015 16:46:25 -0800 Subject: [PATCH 6/7] Decorators node array should have pos at token @ instead of actual decorator expression --- src/compiler/parser.ts | 2 +- .../reference/bpSpan_decorators.baseline | 199 +++++------------- .../sourceMapValidationDecorators.js.map | 2 +- ...ourceMapValidationDecorators.sourcemap.txt | 30 +-- 4 files changed, 71 insertions(+), 162 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 212594f7b7..fbf84fb6db 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4890,7 +4890,7 @@ namespace ts { if (!decorators) { decorators = >[]; - decorators.pos = scanner.getStartPos(); + decorators.pos = decoratorStart; } const decorator = createNode(SyntaxKind.Decorator, decoratorStart); diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline index 179cdb0890..f6bb700e09 100644 --- a/tests/baselines/reference/bpSpan_decorators.baseline +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -29,66 +29,17 @@ -------------------------------- 8 >@ClassDecorator1 - ~ => Pos: (594 to 594) SpanInfo: {"start":632,"length":914} - >class Greeter { - > constructor( - > @ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string, - > - > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[]) { - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { - > return "

" + this.greeting + "

"; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > private x: string; - > - > @PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - > - > private fn( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { - > return this.greeting; - > } - > - > set greetings( - > @ParameterDecorator1 - > @ParameterDecorator2(90) - > greetings: string) { - > this.greeting = greetings; - > } - >} - >:=> (line 10, col 0) to (line 54, col 1) -8 >@ClassDecorator1 - - ~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36} - >ClassDecorator1 + ~~~~~~~~~~~~~~~~~ => Pos: (594 to 610) SpanInfo: {"start":594,"length":37} + >@ClassDecorator1 >@ClassDecorator2(10) - >:=> (line 8, col 1) to (line 9, col 20) + >:=> (line 8, col 0) to (line 9, col 20) -------------------------------- 9 >@ClassDecorator2(10) - ~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":595,"length":36} - >ClassDecorator1 + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":594,"length":37} + >@ClassDecorator1 >@ClassDecorator2(10) - >:=> (line 8, col 1) to (line 9, col 20) + >:=> (line 8, col 0) to (line 9, col 20) -------------------------------- 10 >class Greeter { @@ -148,22 +99,17 @@ -------------------------------- 12 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":735,"length":23} - >public greeting: string - >:=> (line 14, col 8) to (line 14, col 31) -12 > @ParameterDecorator1 - - ~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (665 to 693) SpanInfo: {"start":673,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(20) - >:=> (line 12, col 9) to (line 13, col 32) + >:=> (line 12, col 8) to (line 13, col 32) -------------------------------- 13 > @ParameterDecorator2(20) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":674,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":673,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(20) - >:=> (line 12, col 9) to (line 13, col 32) + >:=> (line 12, col 8) to (line 13, col 32) -------------------------------- 14 > public greeting: string, @@ -177,22 +123,17 @@ -------------------------------- 16 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":835,"length":14} - >...b: string[] - >:=> (line 18, col 12) to (line 18, col 26) -16 > @ParameterDecorator1 - - ~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (761 to 789) SpanInfo: {"start":769,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(30) - >:=> (line 16, col 9) to (line 17, col 32) + >:=> (line 16, col 8) to (line 17, col 32) -------------------------------- 17 > @ParameterDecorator2(30) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":770,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":769,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(30) - >:=> (line 16, col 9) to (line 17, col 32) + >:=> (line 16, col 8) to (line 17, col 32) -------------------------------- 18 > ...b: string[]) { @@ -217,24 +158,17 @@ -------------------------------- 21 > @PropertyDecorator1 - ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":916,"length":64} - >greet() { - > return "

" + this.greeting + "

"; - > } - >:=> (line 23, col 4) to (line 25, col 5) -21 > @PropertyDecorator1 - - ~~~~~~~~~~~~~~~~~~~ => Pos: (865 to 883) SpanInfo: {"start":865,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (860 to 883) SpanInfo: {"start":864,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(40) - >:=> (line 21, col 5) to (line 22, col 27) + >:=> (line 21, col 4) to (line 22, col 27) -------------------------------- 22 > @PropertyDecorator2(40) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":865,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":864,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(40) - >:=> (line 21, col 5) to (line 22, col 27) + >:=> (line 21, col 4) to (line 22, col 27) -------------------------------- 23 > greet() { @@ -267,20 +201,17 @@ -------------------------------- 27 > @PropertyDecorator1 - ~~~~~ => Pos: (982 to 986) SpanInfo: undefined -27 > @PropertyDecorator1 - - ~~~~~~~~~~~~~~~~~~~ => Pos: (987 to 1005) SpanInfo: {"start":987,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (982 to 1005) SpanInfo: {"start":986,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(50) - >:=> (line 27, col 5) to (line 28, col 27) + >:=> (line 27, col 4) to (line 28, col 27) -------------------------------- 28 > @PropertyDecorator2(50) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":987,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":986,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(50) - >:=> (line 27, col 5) to (line 28, col 27) + >:=> (line 27, col 4) to (line 28, col 27) -------------------------------- 29 > private x: string; @@ -292,22 +223,17 @@ -------------------------------- 31 > @PropertyDecorator1 - ~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1114,"length":31} - >private static x1: number = 10; - >:=> (line 33, col 4) to (line 33, col 35) -31 > @PropertyDecorator1 - - ~~~~~~~~~~~~~~~~~~~ => Pos: (1063 to 1081) SpanInfo: {"start":1063,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1058 to 1081) SpanInfo: {"start":1062,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(60) - >:=> (line 31, col 5) to (line 32, col 27) + >:=> (line 31, col 4) to (line 32, col 27) -------------------------------- 32 > @PropertyDecorator2(60) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1063,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1062,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(60) - >:=> (line 31, col 5) to (line 32, col 27) + >:=> (line 31, col 4) to (line 32, col 27) -------------------------------- 33 > private static x1: number = 10; @@ -332,22 +258,17 @@ -------------------------------- 36 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (1163 to 1171) SpanInfo: {"start":1254,"length":20} - >return this.greeting - >:=> (line 39, col 8) to (line 39, col 28) -36 > @ParameterDecorator1 - - ~~~~~~~~~~~~~~~~~~~~ => Pos: (1172 to 1191) SpanInfo: {"start":1172,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1163 to 1191) SpanInfo: {"start":1171,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(70) - >:=> (line 36, col 9) to (line 37, col 32) + >:=> (line 36, col 8) to (line 37, col 32) -------------------------------- 37 > @ParameterDecorator2(70) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1172,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1171,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(70) - >:=> (line 36, col 9) to (line 37, col 32) + >:=> (line 36, col 8) to (line 37, col 32) -------------------------------- 38 > x: number) { @@ -373,24 +294,17 @@ -------------------------------- 42 > @PropertyDecorator1 - ~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1339,"length":53} - >get greetings() { - > return this.greeting; - > } - >:=> (line 44, col 4) to (line 46, col 5) -42 > @PropertyDecorator1 - - ~~~~~~~~~~~~~~~~~~~ => Pos: (1288 to 1306) SpanInfo: {"start":1288,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1283 to 1306) SpanInfo: {"start":1287,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(80) - >:=> (line 42, col 5) to (line 43, col 27) + >:=> (line 42, col 4) to (line 43, col 27) -------------------------------- 43 > @PropertyDecorator2(80) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1288,"length":46} - >PropertyDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1287,"length":47} + >@PropertyDecorator1 > @PropertyDecorator2(80) - >:=> (line 42, col 5) to (line 43, col 27) + >:=> (line 42, col 4) to (line 43, col 27) -------------------------------- 44 > get greetings() { @@ -434,22 +348,17 @@ -------------------------------- 49 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (1413 to 1421) SpanInfo: {"start":1512,"length":25} - >this.greeting = greetings - >:=> (line 52, col 8) to (line 52, col 33) -49 > @ParameterDecorator1 - - ~~~~~~~~~~~~~~~~~~~~ => Pos: (1422 to 1441) SpanInfo: {"start":1422,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1413 to 1441) SpanInfo: {"start":1421,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(90) - >:=> (line 49, col 9) to (line 50, col 32) + >:=> (line 49, col 8) to (line 50, col 32) -------------------------------- 50 > @ParameterDecorator2(90) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1422,"length":52} - >ParameterDecorator1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1421,"length":53} + >@ParameterDecorator1 > @ParameterDecorator2(90) - >:=> (line 49, col 9) to (line 50, col 32) + >:=> (line 49, col 8) to (line 50, col 32) -------------------------------- 51 > greetings: string) { diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 355cb0cb55..4af925231c 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ9BA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;wCAAAA;IAKtBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;sCAAAA;IAQpBA;mBAAAA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;qCAAAA;IAKzBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;mBAMpBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;4CAPHA;IAZtBA;QAAAA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;6BAAAA;IAxB1BA;QAAAA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;mBAGbA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;mBAGvBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;eARVA;IA6CpBA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;wCAAAA;IAKvBA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;sCAAAA;IAQrBA;mBAACA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;qCAAAA;IAK1BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;mBAMpBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;4CAPHA;IAZvBA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;6BAAAA;IAxB3BA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;mBAGbA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;mBAGvBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;eARVA;IA6CpBA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index face3de621..1e270c4059 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -381,13 +381,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(35, 5) Source(21, 6) + SourceIndex(0) name (Greeter) +1 >Emitted(35, 5) Source(21, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1-> +1->@ 2 > PropertyDecorator1 1->Emitted(36, 9) Source(21, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(36, 27) Source(21, 24) + SourceIndex(0) name (Greeter) @@ -424,14 +424,14 @@ sourceFile:sourceMapValidationDecorators.ts > return "

" + this.greeting + "

"; > } > - > @ -1 >Emitted(39, 5) Source(27, 6) + SourceIndex(0) name (Greeter) + > +1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1-> +1->@ 2 > PropertyDecorator1 1->Emitted(40, 9) Source(27, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(40, 27) Source(27, 24) + SourceIndex(0) name (Greeter) @@ -471,14 +471,14 @@ sourceFile:sourceMapValidationDecorators.ts > private static x1: number = 10; > > private fn( - > @ -1 >Emitted(43, 5) Source(36, 8) + SourceIndex(0) name (Greeter) + > +1 >Emitted(43, 5) Source(36, 7) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), 1->^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^-> -1-> +1->@ 2 > ParameterDecorator1 1->Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) 2 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) @@ -514,14 +514,14 @@ sourceFile:sourceMapValidationDecorators.ts > return this.greeting; > } > - > @ -1 >Emitted(47, 5) Source(42, 6) + SourceIndex(0) name (Greeter) + > +1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^-> -1-> +1->@ 2 > PropertyDecorator1 1->Emitted(48, 9) Source(42, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(48, 27) Source(42, 24) + SourceIndex(0) name (Greeter) @@ -588,13 +588,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(53, 5) Source(31, 6) + SourceIndex(0) name (Greeter) +1 >Emitted(53, 5) Source(31, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^ 3 > ^^^^^-> -1-> +1->@ 2 > PropertyDecorator1 1->Emitted(54, 9) Source(31, 6) + SourceIndex(0) name (Greeter) 2 >Emitted(54, 27) Source(31, 24) + SourceIndex(0) name (Greeter) @@ -627,13 +627,13 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(57, 5) Source(8, 2) + SourceIndex(0) name (Greeter) +1 >Emitted(57, 5) Source(8, 1) + SourceIndex(0) name (Greeter) --- >>> ClassDecorator1, 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^ 3 > ^^^^^^-> -1-> +1->@ 2 > ClassDecorator1 1->Emitted(58, 9) Source(8, 2) + SourceIndex(0) name (Greeter) 2 >Emitted(58, 24) Source(8, 17) + SourceIndex(0) name (Greeter) From ccfa625b32aaa8192eba3aa5a42a92b1da83e10b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 30 Nov 2015 14:03:28 -0800 Subject: [PATCH 7/7] var rename as per PR feedback --- src/compiler/emitter.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 35b5bc9f5e..6a966aee7a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5685,10 +5685,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitDecoratorsOfConstructor(node: ClassLikeDeclaration) { const decorators = node.decorators; const constructor = getFirstConstructorWithBody(node); - const parameterDecorators = constructor && forEach(constructor.parameters, parameter => parameter.decorators); + const firstParameterDecorator = constructor && forEach(constructor.parameters, parameter => parameter.decorators); // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !parameterDecorators) { + if (!decorators && !firstParameterDecorator) { return; } @@ -5704,7 +5704,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(node.decorators || parameterDecorators); + emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); write(" = __decorate(["); increaseIndent(); @@ -5713,7 +5713,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi const decoratorCount = decorators ? decorators.length : 0; let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => emit(decorator.expression)); - if (parameterDecorators) { + if (firstParameterDecorator) { argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); } emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); @@ -5723,7 +5723,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("], "); emitDeclarationName(node); write(")"); - emitEnd(node.decorators || parameterDecorators); + emitEnd(node.decorators || firstParameterDecorator); write(";"); writeLine(); } @@ -5766,10 +5766,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi functionLikeMember = member; } } - const parameterDecorators = functionLikeMember && forEach(functionLikeMember.parameters, parameter => parameter.decorators); + const firstParameterDecorator = functionLikeMember && forEach(functionLikeMember.parameters, parameter => parameter.decorators); // skip a member if it or any of its parameters are not decorated - if (!decorators && !parameterDecorators) { + if (!decorators && !firstParameterDecorator) { continue; } @@ -5805,7 +5805,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(decorators || parameterDecorators); + emitStart(decorators || firstParameterDecorator); write("__decorate(["); increaseIndent(); writeLine(); @@ -5814,7 +5814,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => emit(decorator.expression)); - if (parameterDecorators) { + if (firstParameterDecorator) { argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); } emitSerializedTypeMetadata(member, argumentsWritten > 0); @@ -5840,7 +5840,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } write(")"); - emitEnd(decorators || parameterDecorators); + emitEnd(decorators || firstParameterDecorator); write(";"); writeLine(); }