AtomLinter / linter-javac

Lint Java on save, with javac
https://atom.io/packages/linter-javac
MIT License
23 stars 17 forks source link

Does not lint #36

Closed kentwongg closed 8 years ago

kentwongg commented 8 years ago

I have a fresh atom install with JDK ( Java SE Development Kit 8u66 ). Nothing will lint, I have tried uninstalling/reinstalling/deleting my ~.atom for a fresh config/etc.

Here is my config.cson. I have tried a few things

config attempt 1:

"*":
  "exception-reporting":
    userId: "1f5fb4e1-474f-6fb5-9164-efb318e9ac10"
  welcome:
    showOnStartup: false
  core:
    themes: [
      "one-dark-ui"
      "fruits-syntax"
    ]
  editor:
    invisibles: {}
  linter: {}
  "linter-javac":
    javaExecutablePath: "C:\\Program Files\\Java\\jdk1.8.0_66\\bin"

Config attempt 2:

"*":
  "exception-reporting":
    userId: "1f5fb4e1-474f-6fb5-9164-efb318e9ac10"
  welcome:
    showOnStartup: false
  core:
    themes: [
      "one-dark-ui"
      "fruits-syntax"
    ]
  editor:
    invisibles: {}
  linter:
    path: "C:\Users\SupRa\.atom\packages\linter"
  "linter-javac":
    path:"C:\Users\SupRa\.atom\packages\linter-javac"
    javaExecutablePath: "C:\\Program Files\\Java\\jdk1.8.0_66\\bin"

Config attempt 3 (DEFAULT, AFTER INSTALLING PACKAGES):

"*":
  "exception-reporting":
    userId: "1f5fb4e1-474f-6fb5-9164-efb318e9ac10"
  welcome:
    showOnStartup: false
  core:
    themes: [
      "one-dark-ui"
      "fruits-syntax"
    ]
  editor:
    invisibles: {}
  linter: {}
kentwongg commented 8 years ago

Ok so I tried another fresh install ( i .atom and reinstalled the atomio linter and linter-javac)

Here is my config now

"*":
  "exception-reporting":
    userId: "e4f5993e-0ba1-2f57-2495-830ca138ba1d"
  welcome:
    showOnStartup: false
  core:
    themes: [
      "one-dark-ui"
      "fruits-syntax"
    ]
  linter: {}
  editor:
    invisibles: {}
  "linter-javac":
    javaExecutablePath: "C:\\Program Files\\Java\\jdk1.8.0_66\\bin\\javac.exe"

Ok and upon trying to save a .java file, I received this error https://gyazo.com/813c8a8e69b5c26787599693a0d4a777

But upon rebooting atom and reinstalling, the error seems to have disappeared. However it is still not linting java grammar.

i.e.

sc.nextLine();
sc.nextLine

in atom show nothing and nothing like the linter GIFS on https://atom.io/packages/linter

keskiju commented 8 years ago

I have the same problem on my Mac (OS X 10.11.1, Atom 1.2.0 and Java 8u51). It does lint however, but errors are shown on the project tab only. For current file it always says "no issues" and therefore also inline messages are not shown at all.

Arcanemagus commented 8 years ago

This project doesn't seem to have an active maintainer, we would welcome somebody to take this over and a good first step would be diagnosing issues like this and submitting a PR :wink:

My guess is that the file path the linter is outputting doesn't match the full path to the file as Atom sees it (textEditor.getPath()), messages only show on the file tab when their path matches the currently open file.

steelbrain commented 8 years ago

@Arcanemagus This project does actually have a maintainer, Ping @kepler0 :stuck_out_tongue:

keskiju commented 8 years ago

In my case the problem was caused by a symlink. I keep all my active projects side by side in the same directory but some of them are actually symlinks that point elsewhere. In this case the project root directory was actually a symlink.

noseglid commented 8 years ago

This can also happen if you have multiple root projects open and the project your currently working on is not the first one (cause: https://github.com/AtomLinter/linter-javac/blob/master/lib/init.coffee#L92)

Ehekatl commented 8 years ago

I have the same problem, other linters perform well except this, I'm on windows 10, atom 1.3.1, javac is runable in my path, but ctrl + alt + i shows that linter-javac didn't load (while *.java file open)

florianb commented 8 years ago

Are there any updates on this?

daiwenxiamen commented 8 years ago

I have the same problem Cry cry cry

Arcanemagus commented 8 years ago

@daiwenxiamen Do you have other linters installed that are working? Or not? Do you see any errors in the console? Does javac exist in your $PATH? Does manually specifying the full path to it in the settings change anything?

daiwenxiamen commented 8 years ago

@Arcanemagus NO NO YES I can run javac & java in cmd YES but still not working

florianb commented 8 years ago

If the issue won't be taken by anyone i'll take it over after i finished the test-suite. I beg for patience. :cookie:

Arcanemagus commented 8 years ago

@florianb You are the only current maintainer of this linter :stuck_out_tongue:.

florianb commented 8 years ago

@Arcanemagus - :scream_cat: i somehow try to avoid that cognition..

florianb commented 8 years ago

@daiwenxiamen @supahkutdiamnds: This error seems to belong to a symbolic linked directory can you verify that in your project-folder (including the project-folder itself) is a symbolic linked/symlinked/softlinked folder?

Thank you very much for your support & patience! :gift:

florianb commented 8 years ago

Ping. :bell:

TAXUEZJU commented 8 years ago

The same issue. I am on openSUSE Leap, linter-gcc works well while linter-javac never works. Javac exist in my $PATH, I also tried manually input full path in the settings but it still does not work. My project-folder is not a linked folder. Thanks for your effort. @florianb

florianb commented 8 years ago

Hey @TAXUEZJU - welcome and thank you very much for your support. :tada:

This bug is currently hard to catch, mainly because of missing diagnostic information and a plenty diversity of assumptions in this thread.

I summarize:

Proposal for solution:

We will quickly introduce a "Debug"-mode (with the next minor-release) which enables verbose console logging to allow any user checking the progress of the javac-linter.

How does that sound?

TAXUEZJU commented 8 years ago

Sounds good. Expect next release.

florianb commented 8 years ago

@TAXUEZJU done.. :+1:

It would be nice if you could provide some verbose log-messages. Thanks a lot... :game_die: :hourglass_flowing_sand:

florianb commented 8 years ago

I close this issue for now since i got no further response which is necessary to debug properly. Feel free to add information, the issue will then be reopened immediately.

Thanks everyone! :candy:

TAXUEZJU commented 8 years ago

Sorry so long to reply to you. I have tried the debug mode, and got some useful information. It seems linter-javac does work but does not show the error information.

linter-javac:  requiring modules finished.  
linter-javac:  providing linter, examining javac-callability.  
::shadow pseudo-element is deprecated. See https://www.chromestatus.com/features/6750456638341120 for more details.
Window load time: 1623ms
/deep/ combinator is deprecated. See https://www.chromestatus.com/features/6750456638341120 for more details.
'atom-beautify.language_riot_default_beautifier' could not set the default. Attempted default: "JS Beautify"; Schema: {"title":"Language Config - Riot.js - Default Beautifier","type":"string","default":"JS Beautify","description":"Default Beautifier to be used for Riot.js","enum":["Pretty Diff"]}
linter-javac:  starting to lint.
linter-javac:  start searching java-files with "/home/taxue/Documents/Java_practice" as search-directory.
linter-javac:  collected the following arguments: -Xlint:all -cp ::.:/opt/jdk1.8.0_77/lib:/opt/jdk1.8.0_77/jre/lib
linter-javac:  adding 1 files to the javac-arguments (from "/home/taxue/Documents/Java_practice/Welcome.java" to "/home/taxue/Documents/Java_practice/Welcome.java").
linter-javac:  calling javac with 4 arguments by invoking "/opt/jdk1.8.0_77/bin/javac". The approximated command length is 113 characters long, the last argument is: /home/taxue/Documents/Java_practice/Welcome.java
linter-javac:  parsing:
/home/taxue/Documents/Java_practice/Welcome.java:11: 错误: 程序包Systm不存在
            Systm.out.println(g);
                 ^
1 个错误
linter-javac:  returning 0 linter-messages.

Obviously, it works but does not show the error information. However, linter-gcc works well. Wish it can help you. Thanks.

florianb commented 8 years ago

Hey @TAXUEZJU - thank you very much! This helps a lot!

:joy: I haven't seen something like that yet. Oracles seems to internationalize it's system-output (i guess 错误 is chinese for "error") and since we're searching for "old" english "errors", the linter seems to miss the error-messages from javac.

I will have to take a deeper look, but i am confident we're able to fix that by at least adding a different regex.

However, i beg you for some patience. :beers:

florianb commented 8 years ago

@TAXUEZJU i couldn't find any way to control javac's behavior on that issue. So i would like to try creating a RegExp-pattern for that.

Since i was completely unable to make javac speak Chinese here, i would like to ask you fro a favour.

Could you please post the output of javac --version and an example for an error- as well as a warining-output here?

Thank you very much in advance! :beer:

TAXUEZJU commented 8 years ago

Like this?

taxue@Leap:~/Documents/Java_practice> javac -version
javac 1.8.0_77
taxue@Leap:~/Documents/Java_practice> which javac
/opt/jdk1.8.0_77/bin/javac
taxue@Leap:~/Documents/Java_practice> javac Welcome.java -Xlint
Welcome.java:14: 错误: 找不到符号
    InputFilter hexInputFilter()
    ^
  符号:   类 InputFilter
  位置: 类 Welcome
Welcome.java:11: 错误: 程序包Systm不存在
            Systm.out.println(g);
                 ^
Welcome.java:16: 错误: 找不到符号
    return new InputFilter()
               ^
  符号:   类 InputFilter
  位置: 类 Welcome
Welcome.java:45: 警告: Welcome.ClassWithOverridingMethod中的varargsMethod(String[])覆盖了Welcome.ClassWithVarargsMethod中的varargsMethod(String...); 覆盖的方法缺少 '...'
  void varargsMethod(String[] s) { }
       ^
3 个错误
1 个警告

You mean this problem may be caused by Language settings. Chinese error information caused linter-javac unable to catch the messages. So if I try to switch to English or use old java version this problem will not exist? Thanks very much. P.S.错误——error; 警告——warning

TAXUEZJU commented 8 years ago

Has the problem been solved?

Arcanemagus commented 8 years ago

@TAXUEZJU Does this look like a valid pulling out of the relevant information? https://regex101.com/r/rN1tA8/1

If the regex is switched to that you won't get badge highlights in the editor, but at least it will list the messages for you.

florianb commented 8 years ago

@TAXUEZJU i'll prepare the patch the next week. Did you try to change the language-settings?

TAXUEZJU commented 8 years ago

@florianb I have tried to switch the language-settings to English and linter-javac works well. So maybe you need to add more regular expressions if you want it to work under any languages. It's hard work.

florianb commented 8 years ago

@TAXUEZJU - yeah i assumed that. I hadn't had the time to push the patch yet but i'll do so in the next few days.

florianb commented 8 years ago

The enhancement (#88) to enable chinese-localization is maturing for a few hours and will then be published later this day. 🍷

florianb commented 8 years ago

@TAXUEZJU - the next minor release has been published. I would appreciate if you could prove the fix. 🍻

Ehekatl commented 8 years ago

@florianb still got problem here : ( bug

florianb commented 8 years ago

@Ehekatl thanks for reporting, could you please invoke javac by hand and post the output here?

It seems we're having an encoding problem at your debug console. - i guess you're using a Windows machine?

Ehekatl commented 8 years ago

@florianb yes, I'm on windwos 10, it should be encoding problem

F:\OneDrive\PRG\Java\cooker [develop +0 ~1 -1]> javac -Xlint:all AdditionOperatorWorkspaceObject.java
AdditionOperatorWorkspaceObject.java:156: 错误: 需要<标识符>
public dsad;

           ^
AdditionOperatorWorkspaceObject.java:157: 错误: 需要<标识符>
dhasudas;
        ^
2 个错误
florianb commented 8 years ago

@Ehekatl thanks a lot! 🍻

That's going to become a tough nut! 😁

Ehekatl commented 8 years ago

@florianb add -J-Dfile.encoding=UTF-8 in additional javac flags works but...

Error: Missing html/text field on Linter Response
Error: Missing html/text field on Linter Response
    at file:///C:/Users/goncc/.atom/packages/linter/lib/validate.coffee:40:19
    at Array.forEach (native)
    at Object.module.exports.Validate.messages (file:///C:/Users/goncc/.atom/packages/linter/lib/validate.coffee:27:14)
    at MessageRegistry.set (C:/Users/goncc/.atom/packages/linter/lib/message-registry.js:36:16)
    at file:///C:/Users/goncc/.atom/packages/linter/lib/linter.coffee:37:17
    at Function.module.exports.Emitter.simpleDispatch (C:\Users\goncc\AppData\Local\atom\app-1.7.2\resources\app.asar\node_modules\event-kit\lib\emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (C:\Users\goncc\AppData\Local\atom\app-1.7.2\resources\app.asar\node_modules\event-kit\lib\emitter.js:125:28)
    at C:/Users/goncc/.atom/packages/linter/lib/linter-registry.js:66:26
    at process._tickCallback (node.js:392:9)
linter-javac:  starting to lint.
init.coffee:302 linter-javac:  start searching java-files with "F:\OneDrive\PRG\Java\cooker" as search-directory.
init.coffee:302 linter-javac:  adding 1 additional javac-options.
init.coffee:302 linter-javac:  collected the following arguments: -Xlint:all -cp lib\Scenario-0.6.jar;$CLASSPATH;.;C:\Program Files\Java\jdk1.8.0_60\lib;C:\Program Files\Java\jdk1.8.0_60\lib\tools.jar -J-Dfile.encoding=UTF-8
init.coffee:302 linter-javac:  adding 68 files to the javac-arguments (from "F:\OneDrive\PRG\Java\cooker\ActualArgsPanel.java" to "F:\OneDrive\PRG\Java\cooker\XYLayout.java").
init.coffee:302 linter-javac:  calling javac with 72 arguments by invoking "javac". The approximated command length is 3945 characters long, the last argument is: F:\OneDrive\PRG\Java\cooker\XYLayout.java
init.coffee:302 linter-javac:  parsing:
警告: [path] 错误的路径元素 "$CLASSPATH": 没有这种文件或目录
F:\OneDrive\PRG\Java\cooker\AdditionOperatorWorkspaceObject.java:158: 错误: 需要';'
dsadsad
       ^
1 个错误
1 个警告
init.coffee:302 linter-javac:  detecting languages
init.coffee:302 linter-javac:  detected the following language-code: zh
init.coffee:302 linter-javac:  returning 1 linter-messages.
florianb commented 8 years ago

Oh no - i introduced accidentially a bug. Stay calm..

florianb commented 8 years ago

@Ehekatl i'd vote to set -J-Dfile.encoding=UTF-8 as a standard-option.

It seems that it would even be possible to set english just for a single invocation, annoying that i didn't find that earlier: http://stackoverflow.com/questions/2444712/os-x-terminal-output-of-javac-is-garbled

Ehekatl commented 8 years ago

@florianb 1.9.1 works well :tada: many thx and it's possible to set english by -J-Duser.language=en flag

florianb commented 8 years ago

@Ehekatl thanks for the hint.. these findings will influence #76

🍻

mapleriver commented 7 years ago

It doesn't work for me for another reason. I think this issue also relates to Chinese enconding. I'm using Windows 10 and my Active code page is 936 which means the encoding-GB2312 I just convert Your "init.coffee" file's encoding to GB2312 and rewrite the Chinese using Notepad++(sadly Atom doesn't support GB2312 yet) and it works pretty well. I think maybe some people who meets the similar issues can slolve the problem like this. Sorry for my poor English.