Intelligently using IntelliJ
Overview
IntelliJ is the IDE that we recommend for robot programming on YETI. This page will go over how to use IntelliJ effectively and efficiently. Reading this will make you epic at navigating and organizing your project
Fuzzy Find
Fuzzy Find in IntelliJ enables you to quickly locate files, classes, or symbols. It guesses what you are looking for by keywords or parts of words to find what you are looking for. This can make coding faster because you don't have to spend time browsing files to find what you want.
You can use fuzzy find in IntelliJ by double-clicking the Shift key. When you do this, the following search bar will pop up, and you can just type a keyword or part of the item you are looking for, and IntelliJ will find it for you:
Gradle Stuff
You can access this Gradle tasks menu by hitting the (tootin') elephant on the top-right side of your screen:
The ones you'll likely use the most are listed below:
- build: This is under the build dropdown in the menu. This compiles the code.
- deploy: This is under the deployutils dropdown in the menu. This deploys the code to the roboRIO.
- simulateJava: This is under the other dropdown in the menu. This will launch the simulation window and let you simulate your code.
The Gradle refresh lets you refresh your project to sync up any changes to your Gradle config settings. In addition, it can also fix compilation errors. You can do this by hitting this button in the top-left corner of your Gradle menu:
Note that after running a Gradle task, you can easily run it again by hitting this play button:
Invalidate Cache
If you are having problems building, you may need to invalidate caches and restart the IDE to fix problems related to outdated or corrupted caches. You can do this by hitting File > Invalidate Caches as shown below:
Renaming Things
When you're renaming symbols, make sure you don't make the fatal (and suuuuuper goofy) mistake of only renaming one instance. This will lead to problems that can only be solved by throwing a magic ring into a volcano. Instead, right-click whatever you want to rename and hit Refactor > Rename, and type whatever you want the symbol to be renamed to. This will rename all instances of the symbol and ensure that you don't have to go on a whimsical adventure involving a cool archer elf. Below is the menu you will need to use:
Ctrl-Click
If you are using a Mac, replace Ctrl with Command
One of the most powerful tools IntelliJ will bestow upon you is the Ctrl-click. If you hold Ctrl while clicking on a piece of code, it will take you to its definition and show usages of it. Below is an example:
It takes you to the definition!
Ctrl-clicking the definition shows the usages!
Now you can Ctrl-click to your heart's content!
Git Stuff
So you wanna work with other programmers on a project? On YETI, we use Git and GitHub for organizing contributions between programmers. You can access some Git actions from the IntelliJ icons, but some things are easier to do with the terminal. Note that you can access the terminal by hitting the button below:
The following list outlines the Git actions that you'll likely use frequently.
- Pulling: There are two ways to pull and update your project
- Committing: Committing is usually easier through the IntelliJ icons than through the terminal. Follow these steps:
- Start by hitting this button:
- The menu will show the files that you have made changes to:
- Check the box to stage the changes and type out a commit message describing the changes you made:
- Then hit commit to save your changes locally, or hit commit and push to send your changes to the team repository. Your changes will show up in the repo: .
- Start by hitting this button:
- Pushing: Simply type git push into the terminal and hit enter. The commits you have will be pushed to the repo:
Navigating with the Structure Tab
One of the best ways to navigate the structure of your project files is by using the Structure tab on the top-left side of your screen:
This will open the following menu and let you easily look through the structure of your file: