I was wondering if there is a way to move clases form one package to another without refactoring package name.
And if possible, after that, do the refactoring of the whole packages and references of the application, maybe with an inspection or something.
Ok here's a hacky way to move classes around without refactoring.
Above your source files, find the source root marked in blue. For example if you are using standard maven layout then it will be src/main/java - right click on java, select Mark Directory As -> Unmark as source root
Notice that your java files are no longer recognized as java source - you can drag and drop your files, and the package name should not be factored.
Remark your java folder as a source root - Mark Directory As -> Source Root
Hope this helps!
Related
When I use the "Project Pane -> Project" view in IntelliJ, my Java package paths are collapsed based on the Modules in my Project Structure (e.g. com.company.project). I would like to use IntelliJ for code reviews, so I've checked out the changes locally and am looking at the "Project Pane -> Changed Files" view, but this doesn't pick up the project structure, so each folder takes an extra line. Can I get the best of both worlds here?
I figured this out with the help of this answer about expanding the folders (which I also wanted to do) How to expand folded package chain in Intellij IDEA?
Right click on "1:Project" to see the options for the project pane and then check "Flatten Packages".
Why can't I change package name in intellij idea?
I want to change "java" package to something else, for example "junit" or "jtests":
But when I select Refactor -> Rename I wind up with the dialog window:
then I select Rename current, in the next window I enter desired package name:
and then, no matters whether I click Refactor or Preview button, nothing happens. Nothing at all: no errors, no warnings, no actions. Why can't I rename this package?
It seems to be a bug of IntelliJ IDEA. I found the solution on JetBrains forum. By invalidating the cache and restarting, I got the ability to rename this package.
For me invalidation didn't work. I made a new package and temporarily moved the classes out of the package I wanted to rename. It would disapear when I would rename them, so I would create them again.
Just a bug in intellij. Invalidate the caches and restart. Here's how, it's easy.
Only folders under java are part of the package qualified name.
Example:
If you have a file in a folder located under app/src/main/java/com/my/package then the package will be com.my.package
So, you only want to change folders under java.
However, regarding the "com" folder, the IDE does not provide an option to refactor package name. In this case, you need to manually rename all code occurrences of the old folder and invalidate the cache after renaming the folder.
File > Invalidate caches... > Clear system
For me it was due to memory problem, after increasing memory (heap size) it solved.
Is it possible in IntelliJ/WebStorm to add a custom icon somewhere in a toolbar that runs a custom command, e.g. CLI?
If yes, is it also possible to add this in the projects .idea so that my team members also have this icon without any configuration?
My goal is to add some custom Git commands.
I'm not sure about icons (never used them myself) .. but as far as I'm aware this would not be easily to copy it over (custom toolbar actions) as it would be an IDE-wide setting which you cannot copy as separate file (it will be a part of actual IDE customisation config -- hence uniqueness for each user). Therefore tool buttons are rather user-specific and not recommended way if you want to share this stuff or update it in a future with not much hassle (at very least to have such possibility).
Instead you could just use External Tools functionality for executing your custom CLI commands -- this will also be an IDE-wide setting but each group is stored in separate file.. so others will have to copy such file into IDE config folder. Each such tool can then be accesses via context menus (it has 4 places where such commands can be placed: Tools menu and 3 context menus).
Another alternative (that could be shared as part of the actual project) is to code all your custom CLI commands as Gulp/Grunt/NPM script tasks and execute them that way. Since such files are usually placed in project root (or subfolder) .. they can be easily shared via VCS.
All tasks/scripts are loaded from actual task definition files (package.json/gulpfile.js/etc) .. so they are not stored inside .idea subfolder. But you can create Run/Debug Configurations (to quickly run specific task with possible custom parameters etc) .. and such stuff is placed inside .idea (make sure to mark them as "Shared" .. otherwise they will be stored inside user-specific and not-VCS-shareable workspace.xml file rather than individual files).
I have enabled MvcBuildViews task in my project file and I have found it finds and tries to build views that aren't in the project.
These views were totally out of date but not knowing whether to delete them or not from source I opted to relocate them (until I can find out) to a new folder called 'Obsolete'.
After relocating the view I try and build the project and it still somehow finds these views in the 'Obsolete' folder now.
How can I instruct the MvcBuildViews task to only compile views found in their usual search location and not everywhere in the project directory?
So after doing some more hunting I find that the MvcBuildViews uses the aspnet_compiler.exe under the hood. It appears the only solution if I want to hand pick the locations is to point it at the specific folders themselves. My other option is to move the views outside of the project.
http://msdn.microsoft.com/en-US/library/ms229863(v=vs.100).aspx
Is there a way to search a project for all uses of some text, without highlighting that text first. I.e. bring up a search interface, and then type in the text I want to find? I'm not seeing how to do this in the Intellij docs.
Note, when I select some text in a file and I do a Search->Find Usages, it responds by giving a little popup "Cannot find usages. Position to an element which usages you wish to find and try again". I get this whether I search on a variable name in a groovy file, or some text in a comment. So for some strange reason, this isn't working at all.
I'm using Intellij Ultimate 10.5 (version 10.5.1)
Thanks for any help or workarounds.
Is Search->Find in Path what you're looking for? (Ctrl-Shift-F on Windows) You can find text in the whole project, a certain directory, or a custom scope.
I was having the exact same problem searching strings in strings.xml but the project wasn't compiled against that file.
So make sure you have compiled against that build variant, module, flavour, etc.
make sure project configuration is allright
File -> Project Structure -> Project -> set correct SDK
File -> Project Structure -> Projects Settings -> Modules -> + -> Import Module -> import your gradle or maven projects
now clear all existing cache
File -> Invalidate Caches
restart Intellij and wait until the indexes are rebuild. Worked for me :)