Autocomplete for a member of another class
Is it possible to just type in the first letters of a static class member and then (by magic shortcut) the completion list lists all possible class.member entries?
More detailed explanation:
I have 15 classes in the form:
class AClass
{
public static readonly string Volumeclass = "abcd";
//... other members
}
class AnotherClass
{
public static readonly string Volumeclass = "xyz";
//... other members
}
When I want to access these members, I want to inject the Volumeclass and I want to get the list:
- AClass.Volumeclass
- AnotherClass.Volumeclass
by intellect. So I only need to select the correct character instead of remembering the correct class name.
I tried Smart Completion but it didn't work.
source to share
I cannot say that I know such a label. Obviously, if you use the Navigation Go To Symbol ( IntelliJ:
Ctrl-Shift-Alt-T or Visual Studio:
Ctrl-Shift-Alt-T) you can have a list of all VolumeClass
properties in your code:
But that's not what you want. The closest I could suggest is to use a completion Import Symbol
( Ctrl- Alt- Space) and then enter the first letters of that type. It will display all globally available types and import the appropriate directive if necessary using
.
Edit . Another idea is to create this with the ReSharper Live Template, which will allow you to generate a statement based on the first few letters:
- Go to ReSharper - Templates Explorer (in ReSharper 6)
- In the Live Templates section, click the New Template button
- Provide a name for the shortcut, eg
vc
. Write a description if desired. - In the main text area, enter:
$prefix$.Volumeclass
- Save and exit template explorer
Now you can enter the code vc
and then the name of the class that has the property.
Hope it helps.
source to share
You can put classes in a common namespace. Then, after entering a period following the namespace name, a list of classes should appear. After selecting the class, you still need to add the property Volumeclass
.
I wouldn't restructure your namespace hierarchy specifically for this purpose, but it might be a good option if classes need to be grouped logically. If the namespace name is long, you can add with the alias directive (for example using Prods = MyCompany.MyProject.Products;
)
source to share