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

Use tern def for JSON completion? #311

Closed
angelozerr opened this issue Mar 31, 2014 · 7 comments
Closed

Use tern def for JSON completion? #311

angelozerr opened this issue Mar 31, 2014 · 7 comments

Comments

@angelozerr
Copy link
Contributor

In many JS framework, JSON is used to configure it. Ex for angularjs directive, it returns a JSON like this :

.directive('myCustomer', function() {
    return {
      restrict: 'E',
      templateUrl: 'my-customer.html'
    };
  });

It should be really cool if we could manage completion for JSON (restrict, templateUrl, etc).

For YUI http://yuilibrary.com/yui/docs/yui/create.html#config :

YUI.GlobalConfig = {
    modules: {
        module1: '/path/to/my/module1.js',
        module2: '/path/to/my/module2.js',
        module3: {
            fullpath: '/path/to/my/module3.js',
            requires: [ 'node', 'event', 'dd', 'yql']
        }
    }
};

It should be cool if we could manage completion for JSON (modules, fullpath, requires, compeltion, etc).

@marijnh do you think we could manage that with tern def like?

@angelozerr
Copy link
Contributor Author

For the angular directive case, I have tried to modify angular.js tern plugin like this :

  var defs = {
    "!name": "angular",
    "!define": {
    ...
    DirectiveFactory: {
      restrict: "string"
    },
    Module: {
        ...
        directive: {
            "!type": "fn(name: string, directiveFactory: fn() -> DirectiveFactory) -> !this",

But it doesn't work.

@marijnh
Copy link
Member

marijnh commented Apr 16, 2014

Tern doesn't complete object literal properties. It doesn't know anything about the type of expressions that are not variables or member expressions (except for what is contained in the expression itself), so it can't help in such a case.

@marijnh marijnh closed this as completed Apr 16, 2014
@angelozerr
Copy link
Contributor Author

Tha's really shame. I would like to provide same features than VJET http://wiki.eclipse.org/VJET/Code_Assistance_Features#Object_Literals but it seems that it's not possible with tern.

@angelozerr
Copy link
Contributor Author

@angelozerr
Copy link
Contributor Author

@marijnh do you think that it's possible to support object litteral or it's too hard to implement it?

If it's possible,could you give some help to implement it. Thank's!

I would like to provide this feature for YUI/AUI config.

@marijnh
Copy link
Member

marijnh commented Apr 24, 2014

As I said, the system currently does not provide a way to do this. And I have no design that would make this possible without a lot of invasive changes.

@angelozerr
Copy link
Contributor Author

Ok @marijnh I stop to spam with this topic. I hope one day, tern will implement this feature.

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