Skip to content

Commit

Permalink
fixed crash when class has index on inherited field
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Nov 8, 2015
1 parent d78c224 commit 4b2aca3
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CacheClassExplorer",
"version": "1.10.4",
"version": "1.11.0",
"description": "Class Explorer for InterSystems Caché",
"directories": {
"test": "test"
Expand Down
31 changes: 31 additions & 0 deletions web/js/Lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 38 additions & 2 deletions web/js/Logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,41 @@ Logic.prototype.process = function (data) {

};

/**
* This method inherits all property properties from inherited classes.
* @param {string} className
* @param {string} propertyName
* @returns {boolean} - if property name was taken (exists in inherited classes)
*/
Logic.prototype.takePropertyFromSuper = function (className, propertyName) {

var self = this, cls,
newProperty;

if (!this.data || !this.data.classes || !(cls = this.data.classes[className])) return false;

function getP (cls) {
var sups, prop = {}, p;
cls = cls || {};
sups = (cls.Super || "").split(",");
if (cls.Inheritance === "right") sups.reverse();
sups.forEach(function (sup) {
if (!(p = self.data.classes[sup])) return;
prop = lib.extend(prop, getP(p));
});
if (cls.properties && (p = cls.properties[propertyName])) {
prop = lib.extend(prop, p);
}
return prop;
}

if (!lib.isEmptyObject(newProperty = getP(cls))) {
cls.properties[propertyName] = newProperty;
return true;
} else return false;

};

Logic.prototype.fillIndices = function () {

var className, cls, indexName, j, index, props, propName;
Expand All @@ -69,9 +104,10 @@ Logic.prototype.fillIndices = function () {
cls = this.data.classes[className];
for (indexName in cls.indices) {
index = cls.indices[indexName];
props = index["Properties"].split(",");
props = (index["Properties"] || "?").split(",");
for (j in props) {
if (cls.properties[propName = props[j].match(/[^\(]+/)[0]]) {
if (cls.properties[propName = props[j].match(/[^\(]+/)[0]]
|| this.takePropertyFromSuper(className, propName)) {
cls.properties[propName].index = index;
} else {
console.warn(
Expand Down

0 comments on commit 4b2aca3

Please sign in to comment.