Mac上的IntelliJ无法检测到JAVA的语法错误 [英] IntelliJ on Mac Can't detect syntax errors for JAVA

查看:92
本文介绍了Mac上的IntelliJ无法检测到JAVA的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始在Mac上使用IntelliJ.我遇到的问题是无法像在PC中那样检测到并突出显示Java文件上的语法错误.

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?

test =测试";没有类声明.

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

推荐答案

我猜您打开它们时,您的Java类具有此图标:

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

这意味着您的Java类文件不在公认的源根目录中. IntelliJ不知道这是源文件,因此不会将其视为一个文件.

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".

然后,将Java类拖放到该文件夹​​中.然后,您会看到它显示为:

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

然后 IntelliJ将报告您的所有错误.

Then IntelliJ will report all of your errors.

这篇关于Mac上的IntelliJ无法检测到JAVA的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆