Skip to content

Completion for object literal#449

Closed
angelozerr wants to merge 3 commits intoternjs:masterfrom
angelozerr:patch-5
Closed

Completion for object literal#449
angelozerr wants to merge 3 commits intoternjs:masterfrom
angelozerr:patch-5

Conversation

@angelozerr
Copy link
Contributor

This PR gives the capability to support completion for object literal properties for known type. This PR includes the update of requirejs plugin to support completion for config properties (baseUrl, paths, etc).

Here a screenshot of completion for requirejs config :

requirejsconfig

The basic idea is to attach to the node of object literal a new property expObjType (expected object type). So the node of object literal have objType and expObjType which comes from !type fn declaration.

expObjType is updated inside the 2 visitors which uses CallExpression.

The completion for object literal uses expObjType. expObjType could be use too to use for 'documentation' for instance or findTypeAt (to fill the type with documentation, url).

Note that it misses some requirejs config properties (tell me if you wish I fill it)

@marijnh
Copy link
Member

marijnh commented Dec 15, 2014

I actually had some code that does work in this area lying around in a branch (remember when you asked me what I'd charge for implementing this, but never got back to me when I made an offer? I did that work as part of the research for that quote.) I've merged it in now, since I guess no one is going to pay for it anyway. Could you take a look at the current master branch and see whether it solves the problems you were trying to address here?

@angelozerr
Copy link
Contributor Author

since I guess no one is going to pay for it anyway

I'm sorry @marijnh I had no news about that, so I hav etried to implement it -(

Many thank's!

Could you take a look at the current master branch and see whether it solves the problems you were trying to address here?

I have tried it and it seems compeltion works only when you know teh property, My initial sample

requirejs.config({
 // here ctrl + space must shows baseUrl, paths, shim, etc properties.
})

I will try to investigate why it doesn't work.

@angelozerr
Copy link
Contributor Author

@marijnh in my case when I execute tests, it fails:

hint-objlit.js, line 13: Completion set failed at hint: undefined
     got: bar, bind, born
  wanted: born
hint-objlit.js, line 28: Completion set failed at hint: undefined
     got:
  wanted: foo, food
hint-objlit.js, line 34: Found no docstring instead of expected docstring
  The food
hint-objlit.js, line 42: Completion set failed at hint: undefined
     got:
  wanted: bar
hint-objlit.js, line 47: Expression has type
  {}
instead of expected type
  bool
Ran 418 tests from 77 files.
5 failures!

@marijnh
Copy link
Member

marijnh commented Dec 17, 2014

Yes, you need to update Acorn to the latest git master branch. Sorry about that. I'll bring out a new Acorn version and bump the dependency version soon.

@marijnh
Copy link
Member

marijnh commented Dec 17, 2014

If you do an npm update you should now get Acorn 0.11, which parses unclosed objects more sanely.

@marijnh marijnh closed this Dec 17, 2014
@angelozerr
Copy link
Contributor Author

Ok I have updated acorn, and it work's great.

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

Successfully merging this pull request may close these issues.

2 participants