Commits

John Peberdy committed 50de719

When classifying a value's class, give lower priority crossing object prototype

  • Participants
  • Parent commits 23504c7

Comments (0)

Files changed (4)

File src/com/nexj/njsdoc/ConstructorClassifier.java

             }
         } else { // Apply the in class flag
             for (Iterator<String> it = d.slotNameIterator(); it.hasNext();) {
-                d.get(it.next()).setInClass(d.getJSClass());
+                String name = it.next();
+                SlotValue target = d.get(name);
+
+                // Give lower priority when walking across object prototype
+                if (target.getJSClass() == null || !SlotValue.OBJECT_PROTO.equals(name)) {
+                    target.setInClass(d.getJSClass());
+                }
             }
         }
 

File src/com/nexj/njsdoc/SlotValue.java

             classification = Type.METHOD;
             this.jsClass = jsClass;
             break;
-        case FIELD:
+        case FIELD: // fall-through
         case METHOD:
             // Heuristic to detect mixins, and prefer being part of mixins
-            if (this.jsClass != null && jsClass != null && this.jsClass.numMembers() > jsClass.numMembers()) {
+            if (this.jsClass == null) {
+               this.jsClass = jsClass;
+            } else if (jsClass != null && this.jsClass.numMembers() > jsClass.numMembers()) {
                 this.jsClass = jsClass;
             }
             break;

File test/com/nexj/njsdoc/Test4.raw

           }
           <ObjectPrototype>: field from MyClass {
              myFun1: method from MyClass @Test4.js:47, Test4.js:42 (Comment) {
-                prototype: field- {
+                prototype: field from MyClass {
                    <ObjectPrototype>: Object.prototype
                 }
                 <ObjectPrototype>: Function.prototype

File test/com/nexj/njsdoc/Test5.raw

        prototype: field from HelloWorld @Test5.js:29 {
           myMember: field from HelloWorld @Test5.js:36 (Comment) 
           myFun: method from HelloWorld @Test5.js:49, Test5.js:38 (Comment) {
-             prototype: field- {
+             prototype: field from HelloWorld {
                 <ObjectPrototype>: Object.prototype
              }
              <ObjectPrototype>: Function.prototype