vs code 提示[myfile].java is a non-project file, only syntax errors are reported

今天在用vs code直接打开一个Java 文件的时候,vs code提示 [myfile].java is a non-project file, only syntax errors are reported 。如下图一所示。搜索了一下发现大部分都是关于Warning: Classpath is incomplete. Only syntax errors will be reported.跟这个Warning相关的很难找到,不过还在根据一个StackOverflow上的问答找到了问题所在,就是vs code在打开一个文件的时候,直接通过点击File->Open File打开之后(如图二),在编辑器左侧还会让你再打开该文件所在的文件夹,然后Warning就显示了。而且StackOverflow上说最好是打开直接父文件夹,而不是间接的父文件夹,不过我尝试了一下并没有使问题重现。

另外就是我感觉在vs code打开文件的正确姿势应该是先Open Filder,然后Open file,而不是直接Open file,还有就是Open Filder的时候是不会显示Filder里面的内容的,这个是正常的,打开Filder之后才会显示,我刚开始以为是出错了呢。

图一
vs code 提示[myfile].java is a non-project file, only syntax errors are reported
图二
vs code 提示[myfile].java is a non-project file, only syntax errors are reported