angelozerr / tern.java

Use tern.js in Java context
http://ternjs.net/
Other
249 stars 52 forks source link

local plugin development example doesn't work? #164

Closed gamerson closed 9 years ago

gamerson commented 9 years ago

I installed the latest build of tern.java from master and then tried to follow the steps here:

https://github.com/angelozerr/tern.java/wiki/Tern-Toolings-Server-Plugins

Everything worked as documented until I tried to test out the completions but at I was unable to see anything there.

angelozerr commented 9 years ago

@gamerson at first I suggest you that you try this feature with the last source (I have commited some fixes thoses days).

To understand what is the problem, you should activate tern console (Tern -> Development and check "Trace on console")

You will see on green color how to tern is executed with node. You MUST NOT see --disable-loading-local

gamerson commented 9 years ago

Hey @angelozerr I'm now using the latest version but I still don't see any completions using the generated example "MyConstructor".

Here is the output of the tern console


-----------------------------------
Tern request#completions: 
{"query":{"type":"completions","file":"test.js","end":31,"types":true,"docs":true,"urls":true,"origins":true,"caseInsensitive":true,"lineCharPositions":true,"expandWordForward":false,"file":"test.js"}}
-----------------------------------
{}
Tern response# with 165ms: 
Tern request#: 
{"files":[{"name":"test.js","text":"var a = new MyConstructor();\na.","type":"full"}]}
-----------------------------------
Tern response#completions with 8ms: 
{"start":{"line":1,"ch":2},"end":{"line":1,"ch":2},"isProperty":true,"completions":[]}

Server started at 40252 in 143ms
-----------------------------------
.tern-project: {"ide":{"scriptPaths":[]},"libs":["browser","ecma5"],"plugins":{"senna":{}}}
Nodejs Commnand: "/lrdev/sdks/liferay-ide-2.2.x/plugins/tern.eclipse.ide.server.nodejs.embed.linux.gtk.x86_64_0.7.0.201411050901/node-v0.10.22-linux-x86_64/bin/node" "/lrdev/sdks/liferay-ide-2.2.x/plugins/tern.core_0.7.0.201411050901/node_modules/tern/bin/tern" --no-port-file
Project dir: /lrdev/workspaces/liferay-ide-2.2.x/senna_plugin
gamerson commented 9 years ago

I'll send you the sample project in a followup email.

angelozerr commented 9 years ago

When you try to use your tern plugin named senna in the .tern-project :

plugins":{"senna":{}}

Your tern plugin and your def must used the same name :

  tern.registerPlugin("senna", function(server, options) {

    return {
      defs : defs
    };
  });

  var defs = {
      "!name": "senna",
  }

In your case, you use senna.js and not senna. Change that and it should work.

The wizard of server plugin should disabled the file name field I think to avoid having this problem.

Note that you will able to do the same thing by customizing (or not) a tern repository https://github.com/angelozerr/tern.java/issues/142#issuecomment-60354810

Please not the server plugin wizard will able to generate a tern plugin inside a tern repository. See https://github.com/angelozerr/tern.java/issues/165 for more info.

gamerson commented 9 years ago

Got it, we can close this issue now. thanks.

On Wed, Nov 5, 2014 at 5:20 PM, Angelo notifications@github.com wrote:

When you try to use

plugins":{"senna":{}}

tern.registerPlugin("senna", function(server, options) { ... });

Your problem is because you have named your tern plugin with .js extension.

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/tern.java/issues/164#issuecomment-61779619 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 9 years ago

@gamerson just one question, you wish to write a tern plugin for http://sennajs.com/docs/ ?

Perhaps it should be a better idea to generate it from JS sources, no?

gamerson commented 9 years ago

Yes I agree I was simply trying it as a demo. It would be better to generate from JS sources.

On Wed, Nov 5, 2014 at 11:00 PM, Angelo notifications@github.com wrote:

@gamerson https://github.com/gamerson just one question, you wish to write a tern plugin for http://sennajs.com/docs/ ?

Perhaps it should be a better idea to generate it from JS sources, no?

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/tern.java/issues/164#issuecomment-61819469 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 9 years ago

For your info, Tern.js is able to use JSDoc comments to create internal tern ast. But I think the plugin which manages that should be improved and sometimes JS sources misses somes information.

More with tern plugin, you can manage injection of some modules (likeYUI#use)

More if JS framework is big, the start of tern server can take time.

That's why sometimes it's better to create a tern plugin.

I'm thinking more and more to provide a tern plugin generator capability inside tern.java.

Have you an idea how to is generated Senna API http://sennajs.com/api/senna.App.html ? I have tried to discover taht inside https://github.com/eduardolundgren/sennajs.com but not found how it is generated? My question is which JS tools (JSDoc, YUIDoc?) is used to generate senna API.

gamerson commented 9 years ago

Agree, but for now I want to hold off creating a new plugin until the senna api stablizes.

On Thu, Nov 6, 2014 at 5:31 PM, Angelo notifications@github.com wrote:

For your info, Tern.js is able to use JSDoc comments to create internal tern ast. But I think the plugin which manages that should be improved and sometimes JS sources misses somes information.

More with tern plugin, you can manage injection of some modules (likeYUI#use)

More if JS framework is big, the start of tern server can take time.

That's why sometimes it's better to create a tern plugin.

I'm thinking more and more to provide a tern plugin generator capability inside tern.java.

Have you an idea how to is generated Senna API http://sennajs.com/api/senna.App.html ? I have tried to discover taht inside https://github.com/eduardolundgren/sennajs.com but not found how it is generated? My question is which JS tools (JSDoc, YUIDoc?) is used to generate senna API.

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/tern.java/issues/164#issuecomment-61949306 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com