Skip to content

Commit 4b2aca3

Browse files
fixed crash when class has index on inherited field
1 parent d78c224 commit 4b2aca3

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheClassExplorer",
3-
"version": "1.10.4",
3+
"version": "1.11.0",
44
"description": "Class Explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/js/Lib.js

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/Logic.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,41 @@ Logic.prototype.process = function (data) {
6161

6262
};
6363

64+
/**
65+
* This method inherits all property properties from inherited classes.
66+
* @param {string} className
67+
* @param {string} propertyName
68+
* @returns {boolean} - if property name was taken (exists in inherited classes)
69+
*/
70+
Logic.prototype.takePropertyFromSuper = function (className, propertyName) {
71+
72+
var self = this, cls,
73+
newProperty;
74+
75+
if (!this.data || !this.data.classes || !(cls = this.data.classes[className])) return false;
76+
77+
function getP (cls) {
78+
var sups, prop = {}, p;
79+
cls = cls || {};
80+
sups = (cls.Super || "").split(",");
81+
if (cls.Inheritance === "right") sups.reverse();
82+
sups.forEach(function (sup) {
83+
if (!(p = self.data.classes[sup])) return;
84+
prop = lib.extend(prop, getP(p));
85+
});
86+
if (cls.properties && (p = cls.properties[propertyName])) {
87+
prop = lib.extend(prop, p);
88+
}
89+
return prop;
90+
}
91+
92+
if (!lib.isEmptyObject(newProperty = getP(cls))) {
93+
cls.properties[propertyName] = newProperty;
94+
return true;
95+
} else return false;
96+
97+
};
98+
6499
Logic.prototype.fillIndices = function () {
65100

66101
var className, cls, indexName, j, index, props, propName;
@@ -69,9 +104,10 @@ Logic.prototype.fillIndices = function () {
69104
cls = this.data.classes[className];
70105
for (indexName in cls.indices) {
71106
index = cls.indices[indexName];
72-
props = index["Properties"].split(",");
107+
props = (index["Properties"] || "?").split(",");
73108
for (j in props) {
74-
if (cls.properties[propName = props[j].match(/[^\(]+/)[0]]) {
109+
if (cls.properties[propName = props[j].match(/[^\(]+/)[0]]
110+
|| this.takePropertyFromSuper(className, propName)) {
75111
cls.properties[propName].index = index;
76112
} else {
77113
console.warn(

0 commit comments

Comments
 (0)