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
Settings → Editor → File Types→ Text files
For OS X
Preferences → Editor → File Types→ Text 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 solved and let you to rename with fileName.java
Step 6: If not, delete the file from the project and create it again with name fileName
Source: http://bit.ly/1ySFa5z
回答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