brgerner
brgerner

Reputation: 4371

Auto Complete to member of other class

Is it possible to just enter first letters of a static member of a class and then (by a magic shortcut) the completion list lists all possible class.member entries?


More detailed explanation:

I have 15 classes in form of:

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 type Volumeclass and want to get the list:

by intelligence. So I need to select only the right symbol instead of remember the right class name.

I tried Smart Completion, but it did not work in that manner.

Upvotes: 3

Views: 386

Answers (3)

Igal Tabachnik
Igal Tabachnik

Reputation: 31548

I can't say that I know of such shortcut. Obviously if you use the Go To Symbol navigation (IntelliJ: Ctrl-Shift-Alt-T or Visual Studio: Ctrl-Shift-Alt-T) , you can have a list of all VolumeClass properties in your code:

http://i.imgur.com/YP7nd.png

But this is not what you want. The closest I could suggest is using the Import Symbol completion (Ctrl-Alt-Space) and then type the first letters of the type. It will show all globally available types, and will import the appropriate using directive when needed.

Edit Another idea is to generate this with ReSharper Live Template that would allow you to generate the statement based on the first few letters:

  1. Go to ReSharper - Templates Explorer (in ReSharper 6)
  2. Under Live Templates tab, click the New Template button
  3. Give a name for your shortcut, for example, vc. Optionally, write a description.
  4. In the main text area, type: $prefix$.Volumeclass
  5. Save and exit the Templates Explorer

You can now type in your code vc, and then the name of the class that has the property.

Hope that helps.

Upvotes: 3

Justin
Justin

Reputation: 6711

You can put the classes into a common namespace. Then after you type the dot following the namespace name, the list of classes should pop up. After you select a class, you will still need to add the Volumeclass property, though.

I wouldn't restructure your namespace hierarchy just for this purpose, but it may be a good option if the classes should logically be grouped together. If the namespace name is long, you can optionally add a using alias directive (e.g., using Prods = MyCompany.MyProject.Products;)

Upvotes: 1

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112334

You have to type the class name first

AClass.<now the list of static members appears>

Note that there are tens of thousands classes in the .NET Framework class library. Do you want millions of members appear automatically?

Upvotes: 0

Related Questions