IntelliJ not recognizing a particular file correctly, instead its stuck as a text file

眉间皱痕 提交于 2019-11-27 17:19:19
Vic

Please ensure that this file (or a pattern that represents it) is not listed under

SettingsEditorFile TypesText files

For OS X

PreferencesEditorFile TypesText files

EvilInside

Step 1: Click "File"==> "Settings"

Step 2: Expand "Editor" & Click "File Types"

Step 3: You will see all file types on Right. Navigate to the "Text Files" and Click it

Step 4: You should able to see your file name on the bottom of Registered Patterns (lower box)

Step 5: Remove your file from the Registered Patterns. The problem should be solved and let you rename with fileName.java

Step 6: If not, delete the file from the project and create it again with name fileName

Source

OSX:

Preferences > Editor > File Types > Text Files

Windows:

Settings > Editor > File Types > Text Files

I had the same problem and none of the above solution solved it. The thing that at the end solved it was by selecting the module and going to the module settings(press F4 on the module name)

Then in the Sources tab, select the "java" folder and press on the Sources button. That tells IntelliJ that the folder in question is a source code folder.

Then select the Test folder and press Tests.

That's it. Then it will recognize correctly the files and show errors as needed.

See below the screenshot.

Gurusharan Gupta

You might have by accident edited the template in File and Code Template. Press Ctrl+Alt+S

Under

 Settings -> Editor -> File and Code Templates

For me I changed the FileHeader.java file in includes tab.

Recall which type of template you might have changed earlier and revert it back to default.

Hope it works :)

I had the same problem to creat a new class java, the issue was on Header.java that can be access with the command crt+alt+s and go to Editor/FileAndCodeTemplates/Includes and this may be on this format:

/** * Created by Alex Leporoni on ${DATE}. */

This is solved my issue, now I can create classes again :) I hope that this article can help others that have the same problems to creat classes on IntelliJIdea... hugs to all.

Renaming the file with the file's type worked for me.

FileName.java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!