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

别说谁变了你拦得住时间么 提交于 2019-11-26 18:55:04

问题


There is a freemarker file (ftl) in my IntelliJ project that is incorrectly recognized as a text file. There are many of the same type that are correct. I am aware of the "Mark as text" option. This may be the original reason this file was marked as text but I am not provided with a "mark as ftl file" option to turn it back, if indeed this is the problem. If I mark other ftl files as txt, I am able to turn them back into ftl files as expected.


回答1:


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

SettingsEditorFile TypesText files

For OS X

PreferencesEditorFile TypesText files




回答2:


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




回答3:


OSX:

Preferences > Editor > File Types > Text Files

Windows:

Settings > Editor > File Types > Text Files



回答4:


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.




回答5:


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 :)




回答6:


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.




回答7:


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

FileName.java



来源:https://stackoverflow.com/questions/15915202/intellij-not-recognizing-a-particular-file-correctly-instead-its-stuck-as-a-tex

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