How to rename a file in IntelliJ without finding usages? - intellij-idea

I am developing a Node.js project in IntelliJ.
The only way to rename files seems to be Shift+F6 which attempts to find all usages which takes too long (~30s - 1min).
Is there a way to simply rename the file without searching for usages?
This only happens when code is stored in Modules (which is necessary to be able to compact empty middle packages).

Best way I have found is to map ALT+SHIFT+F6 to Reveal in Finder. Then just press enter and type in new name.
It's good because its very similar to SHIFT+F6 rename refactor.

No.
IntelliJ must find the usages to rename them, otherwise you're just renaming the file, not refactoring. If you only want to rename the file, use the mv command from a terminal. You can also tell IntelliJ not to look in strings and text, which speeds things up somewhat, but is probably a bad idea in a javascript project (where almost everything is string or text).
I use rename a lot, and on my codebase, which is pretty big, it only takes a couple of seconds. Maybe intellij needs more memory to operate in, so you could try increasing that.

If You are doing it many times, You can create a custom scope for the refactoring:
There You can narrow the scope to few files/folders/modules etc. And for very narrow scope it will work as normal rename.

Related

Finding a scratch file in IntelliJ IDEA

I would like a quick way to open a given scratch file.
For example. If I have a notes.md scratch. It does not show up using:
cmd + n then typing notes.md
shift + shift then typing notes.md
The only way I know to find them is by choosing Scratches in the Project tool window as described here: IntelliJ IDEA Help. This is painfully slow. Especially given that the whole purpose of a scratch is that it is a quick place to store something.
In case anyone comes across this thread like I did:
You can use File > New > Import Module from Existing Sources... on the existing directory where Intellij keeps the scratch files. This will create a "scratches" module in your project, which forces indexing of its contents. In my case, they're in C:\Users\jacob.hanson\.IntelliJIdea2019.1\config\scratches. You can find the full path by right clicking an existing scratch file in the project view and choosing Show in Explorer.
It's not the prettiest solution, but it preserves the default location of the scratches and keeps from having to increase the 'Recent File' buffer limit.
scratch files will appear in your Shift Shift searches!
I've run into the same problem and have tried increasing the file limit to a ridiculously high number, but I was feeling that contributed to sluggish behavior as the buffer grew.
Since then, I've discovered the Scratch plugin by dkandalov which has much better scratch file management (albeit using an entirely different implementation?).
https://plugins.jetbrains.com/plugin/4428-scratch

Emacs equivalent of Xcode's "Open Quickly"

I'm trying to get a Cocoa development environment working in Emacs, and I'm 80% of the way there. The one feature I miss is Xcode's "Open Quickly", which basically performs a fuzzy match of the string you type against the filenames referenced in the Xcode workspace and the symbols defined in those files.
My problem is that our project is huge: if I generate a TAGS file using etags for the .h and .m files in our project's sub-directories, the result is over a gig in size and Emacs complains "TAGS file is large. Really open?", and if I say yes, then Emacs hangs and becomes essentially unusable. Of course, this is before I've even considered indexing tags for system libraries. I've also tried projectile, but unfortunately it's similarly unusable on a project of my size (on the order of a full minute to find a match).
It occurs to me that all the indexing information I really want is in the Xcode projects themselves, so if I had an Emacs package that could parse them and traverse their dependencies, that might be a start, but I'm not aware of any such package.
Any suggestions/solutions in this respect?
I've never found a single function quite as convenient as Xcode's "Open Quickly", but these days I use
helm-projectile-git-grep when I want to match on strings I know to be in the filenames, and
helm-git-grep for quick searches through the contents of the files themselves.
I've found that this gets me really close to what I wanted in my original question.

If I have multiple classes in one file, is there a tool to make them into separate files?

Some colleagues, now departed, had the habit of adding new classes within a related class file.
This makes refactoring painful.
Is there a tool, perhaps within XCode or AppCode or just a simple script, that will split up these monster files?
It appears there is a tool to help with this in AppCode, but it only semi-automates the process.
I'm using AppCode 2.0, I don't know if the same tool is available in AppCode 1.x.
To extract one class from a file to a new file, right-click the#interface or #implementation line and select Refactor > Move. Alternatively press F6 on that line. You can now enter a new file name, though you probably want to copy+paste the class name in here. At this point you can also select any defines you want to move.
I have done some work on a script to extract all classes in a file. I'd love to share this one day, when I get the chance to remove our clients code from the unit tests!
I don't think so there is any tool for this. However you can write your own osx application for doing the same.
The application will ask to browse the file, and it will search for #interface....#endand#implementation....~#end` and will create a file from this. If a single file contains two classes then it will result in for files (two headers and two implementation). Then the original file can be deleted manually or automatically.
I think this above task can be completed in few hours.
Here you can go for save the original file in a folder, just in case you want to rollback.

Hyperlink navigation - inside code files

Does anyone know if there's an existing plugin / system for setting up hyperlink-style navigation inside a code file? I've been dealing with some overly large files recently, and I was thinking it'd be nice to set up a javadoc-style list of function names up top in a block comment, with some kind of editor plugin to jump to the appropriate line number.
What I don't know, is if that sort of behavior is already present in any popular IDE or available in any plugins. I think it'd be a fairly useful tool, but I don't want to go through the effort of writing a plugin if it's already been written.
Apologies if this is slightly off topic, it seems too specific for programmers.stackoverflow.com
IntelliJ IDEA (my favourite IDE) offers Ctrl+Click navigation since long ago.
You ctrl+click on a name of class or function or variable and IDEA takes you to its definition.
It also has "jump to file member" functionality, which, I think, is more than you're looking for (because you can invoke it from any place in a file).

What's the best method for traversing long scripts?

When your script gets to be thousands of lines long, finding a particular function or variable declaration gets to be a real pain. Are there any methods you can use to avoid this?
It really depends on the language and the editor you use.
If the language supports importing from external files, as most of them do, you should refactor your script into smaller modules and import/include them into your main script.
Also, most editors have some means of searching within a file and some, such as 'TextMate' (on Mac) or 'e', its Windows clone, provide a special view displaying all the symbols within the source which you can click on to immediately reorient the editor to the chosen target.
You split your code into separate files/modules/etc., generally organized by similar functionality, and require them in your main script.