Open AlexanderOMara opened 9 years ago
@AlexanderOMara yes I would like to support this feature, but before that I must study if it's possible to use directly JSDT Install Path.
I'm considering developing this functionality myself and submitting a pull request. Unfortunately, I'm having some trouble getting setup to develop on the plugin. Any chance of a quick overview on how to develop on an existing plugin?
Also, how do you debug plugin code? Do console.log
statements go anywhere? I tried adding some debug code to the example plugin, but could not find the log statements in the Eclipse console, or anywhere else, with or without Trace on console?
being checked.
Unfortunately, I'm having some trouble getting setup to develop on the plugin.
I suppose you mean developping JavaScript tern plugin like https://github.com/angelozerr/tern-jshint that it is used inside tern.java
If it that, to be honnest with you, it was my first tern plugin that I have developped with node code. The most tern plugin that I develop works without node, so I use Chrome Developer to debug it.
But in the case of tern-jshint tern plugin, node code must be used. At first I suggest you to see how to JSHint client node manages .jshintignore. See https://github.com/jshint/jshint/blob/master/src/cli.js#L193
Ifyou wish to use console.log, you must activate tern console (project properties Tern -> Development) See https://github.com/angelozerr/tern.java/wiki/Tern-Console (screenshot are out of date). Sometimes console.log doesn't work, so I suggest you to use console.error. Tern console will display trace on the Eclipse Console.
But there were a long time, I had played with Nodeclipse to debug step by step the tern plugin. I had written quicly steps to do that https://github.com/angelozerr/tern.java/wiki/Debugging-tern.js-with-Nodeclipse but I don't remember exactly how to do that.
I though managing .jshintignore with Java code, but it seems that it's better to manage that inside tern-jshint (good idea!)
So if you wish to contribute please create PR for https://github.com/angelozerr/tern-jshint please write test https://github.com/angelozerr/tern-jshint/tree/master/test (I must write it liek I had done for https://github.com/angelozerr/tern-lint/tree/master/test)
Hmm, I enabled Trace on console?
and Loading local plugin?
for the project settings, but Tern Console
seems to be missing from my Eclipse console. These are the options I have:
I tried restarting Eclipse a few times, just to be sure. I am seeing the output from console.warn
in the CVS console, so I'm guessing the Tern Console in the screenshot no longer exists?
I have looked over the JSHint .jshintignore
code, it looks like it can be implemented similarly to the .jshintrc
Use config files
option.
I think I'm almost there. I cloned the tern-jshint
repository, ran npm install
, and tried running it in the project, but now I get this error in the console:
Tern error#jshint with 3ms:
tern.TernException: No query type 'jshint' defined
at tern.server.nodejs.NodejsTernHelper.makeRequest(NodejsTernHelper.java:87)
at tern.server.nodejs.NodejsTernServer.makeRequest(NodejsTernServer.java:189)
at tern.server.nodejs.NodejsTernServer.request(NodejsTernServer.java:153)
at tern.server.protocol.TernResultsProcessorsFactory.makeRequestAndProcess(TernResultsProcessorsFactory.java:36)
at tern.eclipse.ide.internal.core.resources.IDETernServerAsyncReqProcessor.processRequest(IDETernServerAsyncReqProcessor.java:49)
at tern.server.AbstractTernServer.request(AbstractTernServer.java:167)
at tern.resources.TernProject.request(TernProject.java:578)
at tern.eclipse.ide.linter.core.validation.TernValidationHelper.validate(TernValidationHelper.java:36)
at tern.eclipse.ide.linter.internal.ui.validation.TernSourceValidator.validate(TernSourceValidator.java:72)
at org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.validate(ReconcileStepForValidator.java:303)
at org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.reconcileModel(ReconcileStepForValidator.java:262)
at org.eclipse.jface.text.reconciler.AbstractReconcileStep.reconcile(AbstractReconcileStep.java:95)
at org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy.reconcile(ValidatorStrategy.java:269)
at org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor.process(DocumentRegionProcessor.java:321)
at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor$BackgroundThread.run(DirtyRegionProcessor.java:691)
-----------------------------------
I assume this is referring to what is defined in section of code:
tern.defineQueryType("jshint", {
...
Is this possibly a collision with the built-in version of tern-jshint
? I added a console.warn
statement, and I know that the initialization mod
function is being executed.
Is this possibly a collision with the built-in version of tern-jshint? I added a console.warn statement, and I know that the initialization mod function is being executed.
If your jshint.js + package.json are on the root of the project and you have checked Loading local plugin?
option it should use your tern plugin.
If it doesn't work (why?) I suggets you that you modify the orginal jshint.js which is hosted inside ECLIPSE_HOME/plugins/ternjs folder.
Unfortunately I seem to be encountering more compatibility issues. Sometimes the JSHint plugin just does not run the code defined in tern.defineQueryType("jshint", {
which makes developing on it difficult.
I was able to create a function to check if a file is ignored by the .jshintignore
file, just put it in the validate
function and pass the file
object to it. Feel free to use it.
function isIgnored(file) {
var gather = cli.gather({
args: [file.name]
});
return gather.indexOf(file.name) < 0;
}
Unfortunately the issues I've been encountering kind-of defeat the usefulness for me. I have hopes for this plugin down the road, but I'm going to have to stick with jshint-eclipse
for now.
@AlexanderOMara the Tern Validator with JSHint is a new feature that I would like to improve it like with your feature.
Thank's for your feedback with your code. I will test it and discover which problem you have (Sometimes the JSHint plugin just does not run the code).
Sometimes the JSHint plugin just does not run the code defined in
tern.defineQueryType("jshint", {
If you activate tern console, you will see that tern.defineQueryType("jshint", {
is called :
Please tell me which case doesn't work. Thanks!
Sometimes the JSHint plugin just does not run the code defined in tern.defineQueryType("jshint", { which makes developing on it difficult.
@AlexanderOMara if you wish that validation is done when you save your JavaScript editor, please read https://github.com/angelozerr/tern.java/wiki/Tern-Linter#wtp-tern-validator
As far as I can tell, the JSHint validation plugin does not support the use of a
.jshintignore
file at the root of the project folder. Is there any way support for this functionality can be added? It should be a core feature of JSHint.This would take care of the one advantage jshint-eclipse has over tern-jshint: