8000 Problem Types, Hiding Individual Errors, Accurate Word Highlighting, TODO Tasks by gurok · Pull Request #51 · eclipsesource/jshint-eclipse · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Problem Types, Hiding Individual Errors, Accurate Word Highlighting, TODO Tasks #51

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

Closed
wants to merge 10 commits into from

Conversation

gurok
Copy link
Contributor
@gurok gurok commented May 11, 2013

Hi there,

I've copied in some changes to support multiple problem types from a fork by ben8p. I improved upon his code so that it now identifies all 3 problem types (warning, info and error). I've also added support for setting a default annotation for all JS files so that you can disable a particular warning number (e.g. W078) through the project properties. Finally, I appended the error number to the error message before it's put in the Problems tab. Makes it easier to identify an error and disable it.

I haven't paid much attention to testing, so you might want to look it over. I basically added extra params where necessary to stop the tests complaining and used sensible defaults, but you might like to add more tests for the new params if you accept this :)

gurok added 5 commits May 11, 2013 15:07
individual warnings), warning numbers on problems and better
identification of problem types (warning, info, error).
character index when scanning a line for tabs. This caused incorrect
positioning of the cursor for some errors
offset -- fixed. Implemented better highlighting of a problem's related
token. Adjusted problem formatting slightly.
@gurok
Copy link
Contributor Author
gurok commented May 11, 2013

I've fixed a bug in the way tabs were being accounted for in the fixPosition function. I also adjusted some of my earlier code that wasn't taking into account the extra annotations line in some places.

With all of the bug fixes out of the way, I've implemented much more comprehensive highlighting of the related term for problems. This means you get a nice little squiggly yellow or red line under the relevant term in your code.

This function in MarkerHandler.java seems wrong to me:

private boolean isValidCharacter( int line, int character ) {
return character >= 0 && character <= code.getLineLength( line - 1 );
}

Given that characters are an index running from 0 to lineLength - 1, it would seem to me that the function should be:

private boolean isValidCharacter( int line, int character ) {
return character > -1 && character < code.getLineLength( line - 1 );
}

Right now, it allows a marker to be on the nth+1 char of a line, which I think puts it on the next line though I haven't confirmed this. I'd like your input.

settings, start of support for grabbing TODO tasks from the central
store.
@gurok
Copy link
Contributor Author
gurok commented May 12, 2013

My fork now recognises TODO tasks, but only the default three (TODO, XXX, FIXME). Couldn't figure out how to read the prefs from the central store, so I'm leaving it for now. Here's a quick visual summary of the changes:
screen

@gurok
Copy link
Contributor Author
gurok commented May 14, 2013

I figured out how to read central preferences for TODO tasks. It's now reading them from the WST preferences store. This could easily be changed to our own, or another, more suitable store. On my machine, I can get to this by right-clicking on the project, choosing Properties and then Task Tags on the left.

@ralfstx
Copy link
Member
ralfstx commented May 15, 2013

Thanks a lot for your contribution, it's very appreciated. However, it may take a couple of weeks until I find the time to look at it.

@gurok
Copy link
Contributor Author
gurok commented May 16, 2013

You're very welcome. This is an excellent project. It was just missing a few key features that I and others needed. Why not take the time to (hopefully) improve it?

In hindsight, it might have been better to offer you separate pull requests for each feature but oh well. Let me know if anything doesn't make sense and I will explain it.

@voelzmo
Copy link
voelzmo commented Sep 30, 2013

Wow, amazing contribution, @gurok, thank you very much! I was thinking about to implement the error/warning differentiation myself - if it fails the build, it should displayed as an error ;)

@paulvi
Copy link
Contributor
paulvi commented Oct 2, 2013

@gurok Could you please update your fork to the latest 0.9.8 changes.
I can release together with Nodeclispe https://github.com/NOdeclipse/jshint-eclipse

@ralfstx
Copy link
Member
ralfstx commented Oct 4, 2013

@gurok Do you agree to contribute your changes under the terms of the EPL? I'd like to start cherry-picking the error/warnings part.

@gurok
Copy link
Contributor Author
gurok commented Oct 4, 2013

Sorry for the delay. I'm really busy right now. My code is so out-of-date now, merging would be nightmare. You're free to cherry pick from it as you see fit. EPL? Public domain, whatever you want :D. I really don't mind. That patch for the bug in fixPosition was actually pretty urgent. I'm surprised it hasn't caused more exceptions.
You will need to do proper unit tests though. My tests are garbage.
I am still here to explain anything if you want.

@ralfstx
Copy link
Member
ralfstx commented Oct 8, 2013

This pull request addresses many different issues, which makes it a bit hard to sort out. Since most issues require some more discussion, it's generally better to open separate issues or pull requests for separate concerns. Discussing different topics in one github issue would become very confusing.

Bugs

fixPosition was using the "tabbed in" index instead of the actual (gurok@7f720c9)

I needed a while to see it, but you're completely right. I cherry-picked your commit with 9ca5109 and refactored the method again in 6de5efc. Thanks!

Off-by-one in MarkerHandler (#51 (comment))

Good catch! Fixed with 5a452b2. Thank you!

Features

Support for error markers

I've included a slightly modified version of @ben8p's change (see #45)

Support for default annotations for JS files

Sorry, I didn't quite get it. Some more explanation would be helpful. In any case, this feature should be discussed in a separate issue. This would also allow others to state their interest.

Support for ranges (squiggly lines)

As far as I understand, you're guessing the ranges from tokens extracted from the error message. That probably opens the door for a lot of follow-up issues (ranges that do not fit, missing ranges, etc.) and probably also differences from one jshint version to another. I'd prefer to ask jshint to provide ranges. If you disagree, again please open a new issue for this feature.

Support for TODO markers

I doubt that TODO markers should be the responsibility of a jshint integration. For me, this sounds like a different plug-in. However, if there's broad interest in this feature, let's discuss this in a new issue.

@ralfstx ralfstx closed this Oct 8, 2013
@gurok
Copy link
Contributor Author
gurok commented Oct 8, 2013

Hey, no problem. These all sound really reasonable. Some of the stuff was a bit half cooked to be honest.

I added default annotations because I was sick of adding annotations to every file to turn off a warning. There's probably a better way to do it. Maybe a jshint.rc or some similar file where you can specify such things, but I was working with what JSHint Eclipse was actively parsing. Yeah, this was pretty bad, honestly.

The ranges stuff wasn't so bad. I don't think my code was guessing, merely searching after the cursor for the first parameter mentioned by the error. If there was none, there was no highlighting. Yeah, I suppose it's better to use what JSHint provides, but what it provides is really incomplete right now.

Most of the other builders accept TODO markers. I don't think it's the role of another plugin unless you expect folks to have multiple builders for a JS project. If this is the only builder, it should really handle TODO. But, that said, there's probably a more standard way of doing it.

I'm just glad the major things got in. If you committed ben8p's stuff, I hope you modified it to allow for all message types (not just error/warning). I seem to remember his wasn't so flexible and I ended up making it a bit spiffier.

@ralfstx
Copy link
Member
ralfstx commented Oct 9, 2013

Hi @gurok, .jshintrc files are already supported, that should help to turn off certain warnings on project level.

I said your ranges code guesses mostly because I've seen that it relies on the a field of the error which seems to be considered legacy and somehow relates this with the reason field, but I didn't really studied it. If you think there's a reliable way to extract the ranges, please open a new issue. That would definitely be a great feature!

TODO markers: Paul already opened a request, let's discuss there.

Currently only errors and warnings are supported, but it's not a big deal to add info once they're needed - design for the moment!

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.

4 participants
0