views:

20

answers:

1

Does anyone know where I can get a list of BaseDefinitions for the ClassificationTypeDefitions in Visual Studio 2010?

I'm trying to define a base definition of "UserTypes" but it doesn't seem to work. For those that don't quite know what I'm talking about and need code to make it easier...

[Export(typeof(ClassificationTypeDefinition))]
[Name("keyword")]
[BaseDefinition("keyword")]
internal static ClassificationTypeDefinition KeywordDefinition = null;

That currently uses the keyword definition of c# for highlighting or what not. But I can't seem to get the one for User types to work (Class/enum/structure names and other similar objects). I've tried using the vs settings file and using the definitions defined in there but the definition "User Types" didn't work.

Thanks, in advance

+1  A: 

The PredefinedClassificationTypeNames type has a list of common/shared ones, but "User Types" is an example of one that is supplied by languages.

The short answer is that the [BaseDefinition] should match up with the display name in the Fonts and Colors dialog for language services that haven't moved off the VS2008 interfaces (like C#). If it isn't working when that is the case, you may be able to convince it to work by adding a second classification type definition with that name ("User Types").

The long answer is this:

In order to supply classification type information for these languages, the editor dynamically generates them the first time you open a file that is associated with a language service. The synchronization process is essentially:

  1. Walk through the colorable items provided by the language service (IVsColorableItemsProvider)
  2. If any of the colorable items don't have associated classification types, generate a new classification type for it (using IClassificationTypeRegistryService.CreateClassificationType).
  3. Walk through the information from Fonts and Colors to create/modify formatting information for these classification types

So the problem would be that the type doesn't exist at the time that your classification type definition is picked up by the editor. However, adding a classification type definition for the would-be-dynamically generated type should keep both parts happy: your type's base definition will be set up correctly, and the synchronization process will happily skip step #2, since there is already an item by that name.

Noah Richards
Ok, I see what you're saying and now it makes sense as to why it doesn't show up properly. In this case the problem is I'm not actually editing a c# file so I think that's why it's not working the way I expect it to.
BuildStarted
Ah, yeah, should have made that more clear :) In that case, you can define it yourself, but it may not pick up the colors from F I'm guessing that's the reason you want to inherit the value?If so, there may possibly be a hacky way to force the editor to synchronize C# even without a C# file loaded. Let me know if you need help with that.
Noah Richards
Yeah, basically I just wanted to find the color of the "User Types" definition so I can use it. All the others work just fine but, as you pointed out, it's simply because they were language agnostic definitions. I was thinking of just loading it directly from the settings file...I just didn't like that method. If you happen to have any insights I would gladly take them :)
BuildStarted
Can you send me an email (noahric @ ms)? We can put the answer up here eventually, but it'll require some help from one of my coworkers and a bit of back and forth to figure it out.
Noah Richards
Sent. Thanks again, for all your help.
BuildStarted