PyCharm not doing full syntax coloring for a specific file name - django

In my Django projet, I have one models.py file that PyCharm is only partially syntax coloring: it's coloring the Python keywords and comments but not other things it normally does like coloring method names, keyword parameters. This is the only file in my project like this -- all other .py files are fully syntax colored.
It's the file name not contents that is the issue. I know this because when I rename the file, PyCharm immediately fully syntax colors it. When I rename it back to models.py, it goes back to partial coloring.
Note it's not just the syntax coloring that's off -- it's also other code analysis-related tools for this file.
What could be causing PyCharm to be treating this one file differently?

In the PyCharm status bar, there is a "Highlighting level" indicator. Clicking on it allows you to choose the highlighting level between "None", "Syntax" and "Inspections", and the selected value is persisted per file. Please try clicking on it and making sure that the level is set to "Inspections".

Related

Navigate to the file from output in the terminal - WebStorm

Is it possible to tune WebStorm so that when I have something like this in my terminal window, then I just click on the filename and jump to it.
Not possible using built-in terminal (please vote for IDEA-118566 and IDEA-154439).
Awesome Console plugin might be a solution; but it doesn't support built-in terminal (https://github.com/anthraxx/intellij-awesome-console/issues/23)
there is also Output Link Filter plugin that provides similar functionality, but it looks outdated and (also) doesn't work in built-in terminal
Update (2022): IDEA-118566 is already fixed, links should work. Please note that providing links for particular output needs adding specific logic handing such output. Thus, if you encounter missing links in a particular output, please file a separate issue request describing link output format and steps to reproduce such output.
Webstorm does in fact now have this functionality.
Note that the bug about this functionality being missing (linked in another answer) has been marked as fixed: https://youtrack.jetbrains.com/issue/IDEA-118566.
It's not quite a single click solution, but what I do, is double click the text so that it auto selects and copies the path, including line and char numbers to clipboard. Then use the shortcut for Goto File.... Hit paste (cmd+v) then Enter and it will take you to the exact location.
For me, the shortcut for Goto File... is cmd+shift+O - you can check your shortcut in the menu Navigate -> File...
You can use the following format to output text in the terminal via console.log and the path will be clickable:
at ($FILE_FULL_PATH:$LINE_NUMBER:$SYMBOL_NUMBER)
Example with the full path to the file:
at (/home/ubuntu/project/index.js:12:55)
However, if you're running WebStorm with exact file path's project's folder, you can use the following format:
at (./project/index.js:12:55)
I installed Awesome Console plugin and with this plugin, all files and links in the console and terminal will be highlighted and can be clicked. Source code files will be opened in the IDE, other links with the default viewer/browser for this type.
You can jump to files from the terminal with left click
Just select file path (dblclick) & press "shift" twice (search everywhere) & press "enter"...

How do I track down specifics for an opencart module that is rendering on my site but missing everything except the catalog template file?

I've inherited an opencart 1.5.5.1 site and am completely new to the cms. From what I've been able to gather, it was built by a competent developer but then went through a hack-it-up development team, and then on to me. So, I really don't know what all to expect from it.
I currently have a module that is rendering in the left sidebar and I don't know why it's rendering there. The only file I can find in the file stack related at all to this "module" is a single template file within the catalog directory structure called:
/catalog/view/theme/mytheme/template/module/affiliate_profile_select.tpl
All of the other installed modules on the site seem to have lots of other files associated with them, whose locations are verified by the research I've done on creating opencart modules: ie, module files in the following directories:
/catalog/controller/module/
/catalog/language/english/module/
/catalog/model/module/
/catalog/view/theme/mytheme/template/module/
/admin/controller/module/
/admin/language/english/module/
/admin/model/module/
/admin/view/template/module/
From what I've been able to find though, this single file (affiliate_profile_select.tpl) is the only file in the file stack that is associated with this module.
I can't find anything related to this module, and/or file, inside any of the vqmod php or xml files.
I can't find anything related to this module in the admin area. I've tried searching through all of the installed modules for other generic identifiers (the section view is rendering at the very top of the left-sidebar on most non-logged-in pages, so I'm looking for layout locations of "Left Sidebar" and positions less than 2), but haven't found anything.
And yet, the section is obviously rendering on the site, so it has to be there somewhere. In fact, it's rendering in two places. It's also in the top-content section of the mobile view of the home page.
Right now it's almost feeling like it was a module that had been written, installed, and configured, and then someone deleted all but one of the files associated with the module. Could a situation like that happen?
Is there any way to track this issue down by querying the database? Or would the template inclusion obviously be inside a file somewhere and I just need to find it? To complicate matters, the hosting company doesn't allow remote login with a console (from what I can tell). Otherwise I'd just have run a grep for the filename in case someone had just thrown an "include()" statement in somewhere. The only place I've checked for something like that so far was in the left-sidebar template file:
/catalog/view/theme/default/template/common/column_left.tpl
but it's just a simple for-loop that echoes out the module views.
Any help or direction on how I might be able to track this problem down would be of significant help.
In Opencart, .tpl (template) files are always called by controllers which as you probably guessed are in catalog/controller/. An if it's a module (showing in left sidebar position, it's probably going to be in catalog/controller/module/. First order of business would be to find the controller that's calling the template you referred to. I'd probably start by getting into a shell and doing something like this from the site's docroot:
grep -r affiliate_profile_select .
From there you should be able to find the associated module controller and any other logic involved. Sometimes people use vQmod to add something on to a pre-existing module so that can possibly explain the lack of other similarly named files.

gruntfile not color codes like other JS files

For some reason Webstorm will not color the code within a Gruntfile, it opens like a standard text file, I cant seem to find the settings to make it work like a normal JS file. I don't recall changing any setting which could have effected this.
Please check if 'Gruntfile.js' (or 'gruntfile.js' if your file name starts with lower case) is added to text file patterns in Settings | Editor | File types -> 'Text files' file type. Removing this pattern should solve your problem

How to correctly assign template file in IntelliJ?

I inherited an old Zope project, and I am also new to Intellij.
Template files got the file ending .xpt (eXtended PageTemplates)
They contain mostly html, but also tal-tags, which either include syntax like person/getName or even "name python: user.getName()".
Currently, those files show white text on black background.
I want those file endings associated with html/xml whatever, so I get a better overview visually.
BUT I really need to keep the Intellij functions like refactor and find usages and so on working, so Intellij finds methods, which are only called inside those templates.
Any help is appreciated!
Go to File -> Settings -> File types. There in Recognized File Types you can find XML files template, then in Registered Patterns add your file pattern: *.xpt

How can I change the file type association of an existing file in WebStorm?

I accidentally created a file with no extension and I chose the wrong file type association. Text Document I think. I renamed it to have the .js extension which is what I wanted, but now it's stuck without any syntax highlighting. WebStorm doesn't treat it as a javascript file. I can't find anywhere to change how WebStorm treats this file. I've tried renaming it and renaming it back and that doesn't work. With any other name, (with a .js extension) it treats it as a javascript file, but not as the original name.
How can I fix this? The WebStorm documentation is no help.
In Settings (or Preferences for mac) > Editor > File Types you can edit patterns by which a file gets associated as some type or other.
If you select the patterns for a file type you have wrongly selected (in your case Text type) you can remove the filename pattern with which was created to associate you file's filename as a wrong type.
Then click Apply > OK
I've had this problem in php storm 8.0.3 on OSX.
I was struggling with a single file that had been added as a text file, but I'd typed in the .js extension.
I tried deleting and recreating, renaming and renaming back, deleting .idea altogether. Nothing worked.
I found that PHPStorm had added the entire file name to the list of patterns for a text file.
....
*.txt
myfile.js
... etc
This was obviously overriding all other settings. And futhermore it was in the IDE Config not the project config. So I'm guessing every other project would have suffered the same issue.
Once I knew where to look it was easily fixed.
Navigate to:
PhpStorm > Preferences > Editor > File Types > <highlight> Text files
Then find myfile.js in the Registered Patterns panel and delete it.
The file should immediately assume it's correct association.
Go to Settings->File Types and then click on "Text Files". You should see the file if you scroll down. You can then remove it with the association by selecting it and clicking the - (minus) button
Refer to File -> Settings -> IDE Settings -> File Types
In right select "Text files" in Reconigzed File Types then find in Registered Patterns your file and click remove your file
On Windows 8, I was able to remove the invalid association by going under File > Settings > Editor > File Types, then I selected "Text files" as the Recognised File Type and removed the invalid entry from the Registered Patterns block at the bottom.
So much answers and everything is close but no one as in my case.
A had an issue with .vue files. My old PHpStorm version did not track the .vue files, so I somehow associated them as .js files. However, this was a mistake because the syntax is different and I saw a lot of "mistakes" in the code.
Yeah, the solution is really in Settings (or Preferences for mac) > Editor > File Types dialogue. In the window you can see the list of possible associations. At the very bottom of the list you'll see the Vue.js Templates and I had no associations in the bottom window (see the pic), so I manually added *.vue association after clicking green "+".
I think this would be right for any proper file type added to PHPStorm. However, you can add your own file type.
In the new WebStorm versions we can click on the file, select the option Override File Type and change for the type that we want.
Selecting the Override File Type option:
Selecting the file extension:
I have found in phpstorm that I can use the Refactor > Rename... function to associate a file of unspecified file type (e.g. a name with no extension) with a file type.
For example if I have a bash script named do_the_things I can Refactor > Rename it to do_the_things.sh which causes it to pick up the bash highlighting, then when I Refactor > Rename it back to do_the_things it keeps the bash highlighting.
This works in PHPStorm, i can assume in WebStorm should be something similar
Go to Preferences directory
Here is how to find for your OS
https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
Find a file YOUR_PREFERENCES_DIRECTORY/options/filetypes.xml
Edit it with any text editor and delete needed row, for example
<mapping pattern="delete.yaml" type="PLAIN_TEXT" />
Top Menu File->Invalidate Caches / Restart
Enjoy
In my case, the file in question, DepositBreakdownList.js, was associated with a "type" called "File type auto-detected by file content". Selecting it and then removing it (with the minus sign button) allowed the file to be treated as a proper JavaScript file again.
Until I did that, I was unable to use Live Templates associated with JavaScript, even though the file extension was .js, which was just maddening.
I've found a solution,
delete (o rename as .old) the file:
C:\Users\.PyCharmCE\config\options\filetypes.xml
Es:
C:\Users\goofy.PyCharmCE2018.3\config\options\filetypes.xml
After like an hour of searching and screwing around I found a fix:
I renamed the file (through the refactor command) to a temporary file name. Then I created a new file with the correct name with the .js extension and it worked, then I copied the code from the original to the newly created file with the correct extension.
I imagine selecting "new javascript file" and doing the same thing would also work.