IntelliJ on Mac Can't detect syntax errors for

2019-02-10 10:25发布

I just started using IntelliJ on Mac. The problem I met is that syntax error on my java file can't be detected and highlighted as in PC.

The problem is errors are not detected instead of errors not being highlighted, because I have checked the highlighting setting.

Any configuration I can play with to let the syntax error can be detected?

i.e.,

test = "Test"; There is no class declaration.

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-10 11:09

I'm going to guess that your Java classes have this icon when you open them:

enter image description here

What this means is that your Java class file isn't in a recognized source root. IntelliJ doesn't know that this is a source file, so it won't treat it as one.

Right-click on the folder, and select "Mark Directory As" -> "Sources Root".

enter image description here

After that, drag and drop your Java class into that folder. Then, you'll see it appear as this:

enter image description here

Then IntelliJ will report all of your errors.

查看更多
登录 后发表回答