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

Tern.java doesn't respect the [ ] Expand function? preference and always expands #429

Open
vazexqi opened this issue Jun 30, 2016 · 3 comments

Comments

@vazexqi
Copy link

vazexqi commented Jun 30, 2016

screen shot 2016-06-29 at 6 10 29 pm

Using tern.java 1.2.0 from http://oss.opensagres.fr/tern.repository/1.2.0/.
Per my understanding of https://github.com/angelozerr/tern.java/wiki/Tern-Advanced-Completion#expand-function the expand function preference gives multiple entries for the auto-completion. I turned this preference off, but it seems it is not respected.

I turned on trace debugging and see that the completion from tern.js itself doesn't contain duplicate entries, nor do the completion suggest that the methods can have different expansions:

{
  "start": 19,
  "end": 23,
  "isProperty": true,
  "isObjectKey": false,
  "completions": [
    {
      "name": "getData",
      "type": "fn(type: string) -> string",
      "doc": "Retrieves the data for a given type, or an empty string if data for that type does not exist or the data transfer contains no data.",
      "url": "https:\/\/developer.mozilla.org\/en\/docs\/DragDrop\/Drag_Operations",
      "origin": "browser"
    },
    {
      "name": "getDate",
      "type": "fn() -> number",
      "doc": "Returns the day of the month for the specified date according to local time.",
      "url": "https:\/\/developer.mozilla.org\/en-US\/docs\/JavaScript\/Reference\/Global_Objects\/Date\/getDate",
      "origin": "ecma5"
    },
    {
      "name": "getDay",
      "type": "fn() -> number",
      "doc": "Returns the day of the week for the specified date according to local time.",
      "url": "https:\/\/developer.mozilla.org\/en-US\/docs\/JavaScript\/Reference\/Global_Objects\/Date\/getDay",
      "origin": "ecma5"
    }
  ]
}

This seems to be a bug?

@angelozerr
Copy link
Owner

The expand function is done on client side and not by ternjs. The idea is to provide the full signatures of a method. Imagine that ternjs returns. A sample is

String#indexOf(elt: ?, from?: number)

You will have this completion:

  • with expand:
var a = "";
a.index // here Ctrl+Spcae shows indexOf, indexOf(char) and indexOf(char, from)
  • with no expand:
var a = "";
a.index // here Ctrl+Space shows indexOf, and indexOf(char, from)

@vazexqi
Copy link
Author

vazexqi commented Jul 3, 2016

@angelozerr Thanks for the reply. It seems you are saying that the behavior that I see in my example is not due to turning expansion on/off since the method signature doesn't have any ?optional parameters

"name": "getData",
"type": "fn(type: string) -> string"

In that case, what option(s) do I need to do on the client side to turn off the double entries of

getData()
getData(fn)

I know that this is possible since your own example at https://github.com/angelozerr/tern-browser-extension does not have the double entries. See the screenshot below from running the demo.

screen shot 2016-07-03 at 9 01 03 am

@angelozerr
Copy link
Owner

As I said you, the expand is done on client side. With tern.java I have hard coded if I remember the completion to show the fn and fn with signature.

It doens't exist none preferences to disable that. I will do it when I will find time.

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