IntelliJ automatically imports something I don't need imported - intellij-idea

I have an enum class with a ton of enums, which I like to address as
Enumclass.argument1
Enumclass.argument2
Enumclass.argument3
I had a ton of such references in a file, however IntelliJ decided to put import statements at the top:
import static com.abc.util.Enumclass.argument1;
import static com.abc.util.Enumclass.argument2;
import static com.abc.util.Enumclass.argument3;
and change the references to just
argument1
argument2
argument3
I want to disable this, and also revert what it did. I've been digging around but I just can't find where to do this! I'm on MAC OSX, IJ 12.1.4.

Found it. Hit Alt+Enter on the enum to bring up the options menu, and the first item should say Expand static import to Enumclass.argument1. Press Enter, then chose to do it for all occurrences of that argument1.

Related

Trouble with imports in IntelliJ IDEA CE for and FTC Robotics Simulator

I am trying to use the virtual robot simulator designed by team Beta#8397 and got the simulator working. Now I am trying to put my teams code in so that we can test it. I am getting a bunch of errors that I'm pretty sure all stem from one error that some of the imports aren't importing. Also, my teams code builds fine when not combined with the simulator. I'm not amazing a java, but do know how most of my teams code works. Here is the code for the imports
package org.firstinspires.ftc.teamcode.Robovines;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.robot.Robot;
import com.qualcomm.robotcore.util.Hardware;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.util.Range;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DigitalChannel;
The errors are on lines 4,5 and 13 with the package being the first line. On line 4 the error is that com.qualcomm.robotcore.robot.Robot does not exist. On lines 5 and 13 the error is that symbol "Hardware" and "DigitalChannel" respectively cannot be found.
Here is the whole project
#BookNinja S : The link you provided doesn't take me to your code.
The virtual robot simulator provides a subset of the functionality of the FTC SDK.
That subset has increased over time, but as commented by #CrazyCoder, the Controller module does not include the com.qualcomm.robotcore.robot.Robot, com.qualcomm.robotcore.util.Hardware, or com.qualcomm.robotcore.hardware.DigitalChannel classes.
With regard to DigitalChannel, this type of sensor is not part of the virtual robot functionality. But, it would be easy to add a dummy DigitalChannel class to the controller (so, getState would always return false, and setState would do nothing).
Dummy classes could probably be used for Hardware and Robot as well, but that would depend upon how you are using those classes in your op modes.
If you submit this as an issue on the virtual_robot github repository, with a link to your project or an explanation of how you are using the Hardware and Robot classes, we (ftc team Beta 8397) can probably add the needed functionality to the virtual_robot project.

How do you import a reference to a dart file when you only know the file name? Extension methods and others

To import a file in Dart (using IntelliJ) I will usually use start typing the name of a function, class or variable and select enter. Alternatively I might type the name of the class and press alt+enter on it. This will then give me an option to import the file reference.
For extension methods this doesn't work and sometimes I know the name of the package (file) I want to import but can't remember the name of the function.
Is there a way to use the filename to lookup and insert an import statement with the full package address?
Edit
Unfortunately my originally accepted answer doesn't always work. For example with extension methods. I'm trying to add a reference and it seems impossible to do without typing the full reference to the extension.
Edit2
Found out there is an open issue to fix this
https://github.com/dart-lang/sdk/issues/40365
You can write import 'som...' and ctrl+space for auto-complete and get IntelliJ to make suggestion across all packages imported with pubspec and files across the project. If the file is inside a package, it will automatically insert the full path.

Intellij Flutter - Import via Alt+Enter not working

My team members and me often face the problem in Intellij that we cannot import some classes via Alt+Enter because Intellij hasn't indexed them successfully.
Our set up
We have different Flutter projects which belong and work together.
ProjectFolder:
our_project/customer_app
our_project/provider_app
our_project/server_app
our_project/model_app
Some of these projects have dependencies to other projects which are declared in the pubspec.yaml file.
Problem
E.g. the customer_app has a dependency to the model_app.
Now we add this new class in model_app such as class MyModel.
Later in the process we want to use MyModel inside of the customer_app.
If we type something like MyModel() and try to press Alt+Enter it doesn't find the class immediately. (it works miracously only sometimes)
What we have to do then is to copy the path of MyModel and do the import manually. Which is often time consuming.
We even tried to run flutter packages get which also doesn't help to find this import of MyModel. Ideally we want that Intellij find the import automatically by indexing it without copying the path out of the other project.
This is a known issue and planned to be fixed eventually.
You can upvote https://github.com/dart-lang/sdk/issues/25820

intellij cannot resolve symbol "File"

I have this in my script
import groovy.io.FileType
.....
derp = new File("blah")
The script works but inetillij complains it cant resolve "File" and it suggested I import a totally different wrong library for it (com.jidesoft.icons.IconSet)
I already tried invalidating cache and restarting
How do I get intelllij to import groovy.io.FileType? I cant even find a way to suppress error either it doesnt give me that option
groovy.io.FileType is an enum class. It appears your variable derp would be of type File, not FileType.
You can statically import enums from the FileType class (for example):
import static groovy.io.FileType.*
In my Intellij on Java 8 the File class comes from the java.io package in a .groovy file.

Intellij auto complete just not working for java.util.HashMap

I'm using Intellij IDEA 2017.1.2 on MacOS High Sierra and the situation is when I type OPTION+ENTER it recommends me to import a class,Auto imports for all classes work well except for HashMap. For example, the class HashTable in the java.util package can auto complete.
I don't know what I had click or checked so how can I fix this problem?
See Preferences > Editor > General > Auto Import > Exclude from Import and Completion.
Here's a screenshot:
With this exclusion in place IntelliJ will not offer java.util.HashMap as an auto import option.
If you remove this exclusion IntelliJ will resume offering java.util.HashMap as an auto import option.