Skip to content

Commit d56e210

Browse files
committed
Better detection of methods vs properties
1 parent 5de55b4 commit d56e210

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

template/helpers.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ module.exports = {
2121
isBehavior: function(item) {
2222
return ((item && item.type) || this.type) == 'behavior';
2323
},
24-
isJso: function(item) {
25-
return ((item && item.type) || this.type) == 'jso';
26-
},
2724
getNestedBehaviors: function(item, name) {
2825
var _this = this;
2926
var properties = [];
@@ -104,22 +101,27 @@ module.exports = {
104101
if (/^number/i.test(t)) return 'double';
105102
if (/^function/i.test(t)) return 'Function';
106103
var b = this.findBehavior(t);
107-
return b ? this.className(b.name) : "JavaScriptObject";
104+
if (b) {
105+
var c = this.camelCase(t);
106+
return c != t ? c + 'Element' : c;
107+
}
108+
109+
return "JavaScriptObject";
108110
},
109111
sortProperties: function(properties) {
110112

111113
},
112114
getGettersAndSetters: function(properties) {
113-
// Sorting properties so String methods are at end
115+
// Sorting properties so no-typed and String methods are at end
114116
properties.sort(function(a, b) {
115117
var t1 = this.computeType(a.type);
116118
var t2 = this.computeType(b.type);
117-
return t1 == t2 ? 0: t1 == 'String' ? 1 : -1;
119+
return t1 == t2 ? 0: !a.type && b.type ? 1 : a.type && !b.type ? -1: t1 == 'String' ? 1 : -1;
118120
}.bind(this));
119121
var ret = [];
120122
var done = {};
121123
_.forEach(properties, function(item){
122-
if (item.type != 'Function') {
124+
if (item.published || !item.private && item.type && !/function/i.test(item.type)) {
123125
item.getter = item.getter || this.computeGetterWithPrefix(item);
124126
item.setter = item.setter || (this.computeSetterWithPrefix(item) + '(' + this.computeType(item.type) + ' value)');
125127
// JsInterop does not support a property with two signatures
@@ -136,7 +138,7 @@ module.exports = {
136138
var arr = this.getGettersAndSetters(properties);
137139
_.forEach(arr, function(item) {
138140
var itType = this.computeType(item.type) ;
139-
if (item.published && itType != 'String' && itType != 'boolean') {
141+
if (itType != 'String' && itType != 'boolean') {
140142
for (var j = 0; j< arr.length; j++) {
141143
if (arr[j].name == item.name && arr[j].type == 'String') {
142144
return;
@@ -158,7 +160,7 @@ module.exports = {
158160
var ret = [];
159161
var done = {};
160162
_.forEach(properties, function(item){
161-
if (item.type == 'Function') {
163+
if (!item.private && !item.published && /function/i.test(item.type)) {
162164
item.method = item.method || item.name + '(' + this.typedParamsString(item) + ')';
163165
// JsInterop + SDM do not support method overloading if one signature is object
164166
var other = item.method.replace(/String/, 'Object');

0 commit comments

Comments
 (0)