Dart library import shortcuts - import

In cases where I have to import the main file from a library in dart I have to do:
import 'package:<package_name>/<package_name>.dart';
Is there a shorthand for doing this in Dart?
Something like
import 'package:<package_name>';
Cause mentioning the package name twice seems redundant.

Seems redundant but there is no way around.
The new "add import" quick fix makes this mostly a non-issue IMHO.
DartEditor ctrl+1
WebStorm/IntelliJ ctrl+Enter
You have to wait until analyzing is done and a hint/warning (wiggled underline) is shown.

Related

I cant import another file

I can't import a file in Pycharm.
I use this code:
import useful_tools
This is the error:
Unused import statement, this inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top level and class level items are supported better than instance items
The warning means you did not uses useful_tools in the code after the import. It will work in runtime, but it's useless if PyCharm is not mistaken of course. Please provide the whole script code, as it's hard to tell more.

Eclipse wraps NOPMD Tag after imports

I have a little problem with Eclipse. When i set a //NOPMD tag behind an import it wraps the tag to the end of the imports. How can I avoid that eclipse wraps any //NOPMD tags during beautifying the java program?
Example before beautifying:
import java.io.IOException;//NOPMD
Example after beautifying:
import java.io.IOException;
//NOPMD
How about using #SupressWarnings("PMD.NameOfRule"). This will suppress all instances of that rule in the class which may or may not be what you want. But it is immune to code reformatting and organize imports.
As a reference, here are the options for suppressing.
Found a better answer once I stopped looking at this as a PMD problem! The accepted answer to this question shows how to turn off formatting on sections of the code by writing:
// #formatter:off
...
// #formatter:on
You'd need to do this on each class around your imports. Or each class that has //NOPMD that is. And you'd need to turn on the setting in your workspace. And have your teammates to this same if you are on a team.

Is there a way to tell Eclipse how to resolve ambiguous java names?

My eclipse is configured so that when I save the java source file, it automatically inserts the missing import declarations. Except when the reference is ambiguous. Fpr instance, the most annoying ambiguity is with List<T> - both java.util and java.awt declare it. Here eclipse demands manual resolution.
I was wondering if it was possible to configure somewhere that whenever List<T> is used then java.util should be imported. Or alternatively, since I am not using java.awt, I could just remove it from the list of possible suggestions.
Any ideas?
Thanks.
This sounds like a possible duplicate of Exclude packages from Eclipse's organize imports.
Basically, you want to change your Type Filters preference to exclude java.awt.* packages. Keep in mind that doing so will make things harder/confusing if you ever try to write AWT/Swing code.
One thing that pops into my mind is altering the class template in the preferences to include the line:
import java.util.List
Unless you are going to use the AWT version of a List, or care about unused import statements, that should solve this annoying issue ..
Manually invoke Organize Imports and it will ask you when an ambiguity is found.

Eclipse/FDT closes imports when typing in a new import

For example I type the following:
import shared.
And on the dot, it closes the imports forcing me to reopen the imports and continue typing. Is there a way to disable this? What is the point of this?
This cannot be disabled without completely disabling autocomplete.
With autocomplete, when a selection is made, FDT will use that and then return you to the editor so you can enter another keyword.
You shouldn't ever need to type an import with FDT. You can:
1) Use autocomplete on a class / type and have FDT auto import the class
2) Use Organize Imports
3) Use a quick fix to import the class.
See more here:
http://fdt.powerflasher.com/docs/Main_Page

How to import scala class automatically in eclipse?

I use eclipse as my scala ide. And I know that in java I can use short cut by content assistent to import classes. So I do not need type in the whole class name. Just need to type the first several characters.
But in scala, I can not import classes automatically. Do I need to do some set up or it is just because scala plugin do not support this.
Ctrl + 1
on symbol works for me :)
There is Scala IDE for Eclipse however it is not very mature these days, however improving day by day. As far as I remember it can import automatically, or you can use Eclipse global fix import hotkey ctrl+shift+o.