-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
config: | ||
javaExecutablePath: | ||
type: 'string' | ||
default: '' | ||
title: 'Path to the javac executable' | ||
default: '/usr/bin/javac' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to javac
which will auto-resolve to /usr/bin/javac
in 90% of cases. In the other 10% it will resolve to something else.
Besides that, it looks good to me. It looks like you should be able to expand your Regex to find the file being affected. I've written some code which should work here for another linter: https://github.com/AtomLinter/linter-swiftc/blob/master/lib/provider.coffee#L39 Anything I've missed @steelbrain? |
@k2b6s9j the spawning part could very much use the helpers module. |
Also @daw42, does |
javac definitely doesn't have a JSON output. Java moves very slowly and was created 20 years ago. |
😆 |
@steelbrain Good point about the |
- Default javac executable: javac
Just updated the pull request branch. Thanks for your feedback! By the way, looks like javac doesn't support compiling from standard input, so |
@daw42 I am so sorry this took so much time. You should've pinged us. |
@steelbrain Ok, I've updated so that it uses |
messages = [] | ||
helpers.exec(@javaExecutablePath, args, {throwOnStdErr: false, stream: 'stderr'}) | ||
.then (val) => return @parse(val, textEditor) | ||
.catch (val) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't actually have to catch it here, the last time I checked, atom-linter
throws this and linter
catches
Updated, thanks again. :) |
Beautiful, I'll test it soon. |
I just tried it and it didn't work for me, here's the
|
Here's the patch that fixes that issue diff --git a/.eslintrc b/.eslintrc
diff --git a/lib/init.coffee b/lib/init.coffee
index e2432ad..2d3bd64 100755
--- a/lib/init.coffee
+++ b/lib/init.coffee
@@ -24,12 +24,10 @@ module.exports =
lintOnFly: false # Only lint on save
lint: (textEditor) =>
filePath = textEditor.getPath()
- wd = path.dirname filePath
# Use the text editor's working directory as the classpath.
# TODO: Make the classpath user configurable.
- args = ['-Xlint:all', '-cp', wd, filePath]
- messages = []
- helpers.exec(@javaExecutablePath, args, {stream: 'stderr'})
+ args = ['-Xlint:all', '-cp', '.', path.basename(filePath)]
+ helpers.exec(@javaExecutablePath, args, {stream: 'stderr', cwd: path.dirname(filePath)})
.then (val) => return @parse(val, textEditor)
parse: (javacOutput, textEditor) =>
Also, Your current regex is failing for me as the
|
Looks like the problem is that javac expects a lower-case 'j' for the file extension. Without that, it seems to think that it is a flag or a class name (depending on the classpath). For example, I just tried this in the working directory:
Try a file that has an extension that's all lower case. I like the patch. Better to base everything from the working directory. The regex targets only file syntax type errors, I might need to expand it to handle errors like the one you found. |
The |
cwd is passed directly to child_process. I'll double check later, but On Fri, Jul 31, 2015, 3:38 PM daw42 [email protected] wrote:
|
@k2b6s9j You're correct! All of the options, not just cwd are passed directly, some are however interpreted by |
helpers.exec('pwd', [])
.then (val) => console.log("Current dir: #{val}")
helpers.exec('pwd', [], {cwd: '/tmp'} )
.then (val) => console.log("Current dir (cwd): #{val}") Output:
|
Weird, I'll investigate when I have some time. That is definitely not the expected behavior. |
Sounds like we need a new unit test too. Mind filing an issue on the repo On Sat, Aug 1, 2015, 10:59 AM Steel Brain [email protected] wrote:
|
javac will not accept a file with |
|
||
parse: (javacOutput, textEditor) => | ||
# Regex to match the error/warning line | ||
errRegex = /^(.*\.java):(\d+): (error|warning): (.+)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of (error|warning):
I recommend using (.+):
. This does not limit the type of issue to error and warning. Future-proofing incase some new type of issue is introduced in the future.
|
This pull request ports linter javac to the new Linter API.
It also uses a longer regular expression to extract the column number for errors and warnings.
This pull request relates to issue #20.