From 716562135c6df17a99bc90e648ec29994c922c2f Mon Sep 17 00:00:00 2001 From: tekreme73 Date: Tue, 3 Feb 2015 21:42:52 +0100 Subject: [PATCH 1/3] [ADD] Automatic generation abstract methods and interface methods [FIX] Error with "abstract" modifier detection --- JavaCodeGenerator.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/JavaCodeGenerator.js b/JavaCodeGenerator.js index 339a625..a88c2f4 100644 --- a/JavaCodeGenerator.js +++ b/JavaCodeGenerator.js @@ -464,7 +464,7 @@ define(function (require, exports, module) { // Modifiers var _modifiers = this.getModifiers(elem); - if (_modifiers.indexOf("abstract") !== -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { + if (_modifiers.indexOf("abstract") === -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { _modifiers.push("abstract"); } if (_modifiers.length > 0) { @@ -522,6 +522,25 @@ define(function (require, exports, module) { codeWriter.writeLine(); } + // Extends methods + if (_extends.length > 0) { + for (i = 0, len = _extends[0].operations.length; i < len; i++) { + _modifiers = this.getModifiers(_extends[0].operations[i]); + if( _modifiers.indexOf("abstract") !== -1 ) { + this.writeMethod(codeWriter, _extends[0].operations[i], options, false, false); + codeWriter.writeLine(); + } + } + } + + // Interface methods + for (var j = 0; j < _implements.length; j++) { + for (i = 0, len = _implements[j].operations.length; i < len; i++) { + this.writeMethod(codeWriter, _implements[j].operations[i], options, false, false); + codeWriter.writeLine(); + } + } + // Inner Definitions for (i = 0, len = elem.ownedElements.length; i < len; i++) { var def = elem.ownedElements[i]; @@ -679,7 +698,7 @@ define(function (require, exports, module) { // Modifiers var _modifiers = this.getModifiers(elem); - if (_modifiers.indexOf("abstract") !== -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { + if (_modifiers.indexOf("abstract") === -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { _modifiers.push("abstract"); } if (_modifiers.length > 0) { @@ -706,6 +725,17 @@ define(function (require, exports, module) { codeWriter.writeLine(); } + // Extends methods + if (_extends.length > 0) { + for (i = 0, len = _extends[0].operations.length; i < len; i++) { + _modifiers = this.getModifiers(_extends[0].operations[i]); + if( _modifiers.indexOf("abstract") !== -1 ) { + this.writeMethod(codeWriter, _extends[0].operations[i], options, false, false); + codeWriter.writeLine(); + } + } + } + // Inner Definitions for (i = 0, len = elem.ownedElements.length; i < len; i++) { var def = elem.ownedElements[i]; From 7ce5ea693c545e0992b82ff68f604d25fb992bef Mon Sep 17 00:00:00 2001 From: tekreme73 Date: Tue, 3 Feb 2015 21:50:03 +0100 Subject: [PATCH 2/3] Tab to Spaces --- JavaCodeGenerator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaCodeGenerator.js b/JavaCodeGenerator.js index a88c2f4..b530137 100644 --- a/JavaCodeGenerator.js +++ b/JavaCodeGenerator.js @@ -534,7 +534,7 @@ define(function (require, exports, module) { } // Interface methods - for (var j = 0; j < _implements.length; j++) { + for (var j = 0; j < _implements.length; j++) { for (i = 0, len = _implements[j].operations.length; i < len; i++) { this.writeMethod(codeWriter, _implements[j].operations[i], options, false, false); codeWriter.writeLine(); From b7277a8c094c218e00f9c8e24bc568ef6a2cf93d Mon Sep 17 00:00:00 2001 From: tekreme73 Date: Tue, 3 Feb 2015 23:49:19 +0100 Subject: [PATCH 3/3] To Underscore.js support --- JavaCodeGenerator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JavaCodeGenerator.js b/JavaCodeGenerator.js index b530137..914ad4b 100644 --- a/JavaCodeGenerator.js +++ b/JavaCodeGenerator.js @@ -464,7 +464,7 @@ define(function (require, exports, module) { // Modifiers var _modifiers = this.getModifiers(elem); - if (_modifiers.indexOf("abstract") === -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { + if ( _.contains(_modifiers, "abstract") !== true && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { _modifiers.push("abstract"); } if (_modifiers.length > 0) { @@ -526,7 +526,7 @@ define(function (require, exports, module) { if (_extends.length > 0) { for (i = 0, len = _extends[0].operations.length; i < len; i++) { _modifiers = this.getModifiers(_extends[0].operations[i]); - if( _modifiers.indexOf("abstract") !== -1 ) { + if( _.contains(_modifiers, "abstract") === true ) { this.writeMethod(codeWriter, _extends[0].operations[i], options, false, false); codeWriter.writeLine(); } @@ -698,7 +698,7 @@ define(function (require, exports, module) { // Modifiers var _modifiers = this.getModifiers(elem); - if (_modifiers.indexOf("abstract") === -1 && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { + if (_.contains(_modifiers, "abstract") !== true && _.some(elem.operations, function (op) { return op.isAbstract === true; })) { _modifiers.push("abstract"); } if (_modifiers.length > 0) { @@ -729,7 +729,7 @@ define(function (require, exports, module) { if (_extends.length > 0) { for (i = 0, len = _extends[0].operations.length; i < len; i++) { _modifiers = this.getModifiers(_extends[0].operations[i]); - if( _modifiers.indexOf("abstract") !== -1 ) { + if(_.contains(_modifiers, "abstract") === true) { this.writeMethod(codeWriter, _extends[0].operations[i], options, false, false); codeWriter.writeLine(); }