问题
Webstorm doesn't recognize one of my .js files as a JavaScript file so I'm losing syntax highlighting and being able to add break points. I've looked in the workspace.xml
file and the file in question seems to have similar settings to other .js files that work correctly.
If I change the name of the file it works ok. So somehow Webstorm is stuck on misinterpreting the type of a file that has this name. Where else can I edit the project?
回答1:
So I see three possible reasons of the problem:
1) The file was marked as 'Plain text'
2) There is a pattern for 'Text files' file type that matches this file (or back: file type 'JavaScript' exclude this file name). See image below
3) There is a custom plugin that overrides default behaviour for files with this name (unlikely)
Note: the solution works for all IDEA-based IDEs: IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm.
回答2:
If the file was marked as "Plain Text", then this can be fixed as follows:
Right click on the file.
One of the menu options is "Mark as Javascript" . Just below "Delete".
Click that. Your file is now recognized as javascript by WebStorm.
Since WebStorm was not allowing screenshots after right click so couldn't add it here.
回答3:
File -> Settings -> Editor -> FileTypes -> Text files -> check for "ContentRepository.js" pattern there and remove it.
回答4:
For me this did the trick
1) Preferences
2) Editor
3) FileTypes
4) Search for javascript
5) Add *.js
to registered patterns
回答5:
You can also try "Template data languages" (in file > settings) which will force a specific language synatax high-lighting on a specific file or folder. See screenshot below
For a block of code you can also use "language injection". Simply high-light the block of code, wait for the little lamp to appear then select the bottom choice and then the language you need (screenshot also attached)
来源:https://stackoverflow.com/questions/26872024/webstorm-not-recognising-javascript-file