Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not complete prototype properties when superclass unknown #296

Open
dangoor opened this issue Feb 25, 2014 · 2 comments
Open

Does not complete prototype properties when superclass unknown #296

dangoor opened this issue Feb 25, 2014 · 2 comments

Comments

@dangoor
Copy link

dangoor commented Feb 25, 2014

This is copied over from Brackets#6929. This is reproducible on the Tern demo page.

Start with this code:

define(function (require, exports, module) {
    "use strict";

    function MyClass() {
    }
    MyClass.prototype = Object.create(Superclass.prototype);
    MyClass.prototype.constructor = MyClass;
    MyClass.prototype.parentClass = Superclass.prototype;

    MyClass.prototype.func1 = function () {
    };
    MyClass.prototype.func2 = function () {
    };
    MyClass.prototype.func3 = function () {
    };
});
  1. Put the cursor in any of the function bodies
  2. Type this.

Result: hints have no suggestions other than generic italic ones

Expected: even if the superclass is unknown, it should at least be able to hint the three known members func1 through func3. Because of the prototype chaining order, there's no way the nature of the superclass prototype could affect those properties.

This has been true as long as the Tern-based code hints have existed, afaict.

One real-world use case is writing extensions that subclass a core Brackets class (e.g. InlineWidget) -- because we don't grok brackets.getModule() references, the superclass will always be unknown.

@marijnh
Copy link
Member

marijnh commented Feb 25, 2014

Logically, the tool could deduce the fact that those properties will be there, yes. But this is not a logic engine--it has its algorithmic approach to creating a type graph, which requires a type to track properties. In this case, Object.create is waiting for some kind of type to flow into its argument, so that it can create an object based on it.

I've seen similar cases (without Object.create) where a missing type would prevent propagations that would, on the surface, seem trivial. I'll see if I can find a hack to make this work better. The main problem is that, if a later file does introduce SuperClass, we don't end up confused.

@dangoor
Copy link
Author

dangoor commented Feb 25, 2014

Because of limitations in how Brackets' code hints deals with large numbers of files, this case comes up fairly often. We're looking to improve how Brackets deals with the files, but it would be great if there was a hack to make this better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants