IProjectFileLanguageService can't be resolved for my new xml language.

Hi

I'm trying to create a new language for Resharper using SDK. My language is based on XmlLanguage and services you already have in the SDK. For the reference I'm using dotPeek and looking into JetBrains.ReSharper.Psi.WebConfig.dll and the web.config language you've implemented there.

I've created basic classes following the http://confluence.jetbrains.net/display/ReSharper/New+Language+Support tutorial. However I inherited from XmlLanguage classes just like WebConfig language classes do.

When testing my plugin I've got the following exception. It's actually several exceptions that endup in the PsiProjectFileTypeCoordinator unable to get the IProjectFileLanguageService

--- EXCEPTION #2/2 [LoggerException]
Message = “Sequence contains more than one element”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.Application.Components.ComponentContainer.LogException(Exception e, Type type, IEnumerable`1 descriptors)
     at JetBrains.Application.Components.ComponentContainer.TryGetComponentDescriptor(Type type, IComponentDescriptor dependee)
     at JetBrains.Application.Components.ComponentContainer.ResolveDynamicImpl(Type type, IComponentDescriptor dependee)
     at JetBrains.Application.Components.ComponentContainer.ResolveDynamic(Type type)
     at JetBrains.Application.Components.ComponentContainerEx.TryGetComponent[TInterface](IComponentContainer container)
     at JetBrains.Application.Extensibility.SplittedComponentContainer`2.TryGetService[T](TDefinition definition)
     at JetBrains.ProjectModel.ProjectFileTypeServices.JetBrains.ProjectModel.IProjectFileTypeServices.TryGetService[T](ProjectFileType )
     at JetBrains.ReSharper.Psi.PsiProjectFileTypeCoordinator.TryGetService[T](ProjectFileType projectFileType)
     at JetBrains.ReSharper.Psi.PsiProjectFileTypeCoordinator.TryGetService(ProjectFileType projectFileType)

I've tried to debug the pluging with Reflector with decompiled sources and have found out that when ComponentContainer resolves the IProjectFileLanguageService for my language project file type it has both XmlProjectFileLanguageService and MyProjectFileLanguageService mapped to it and it fails, logs exception and uses XmlProjectFileLanguageService afterwards. But for some reason for WebConfig language it doesn't happed and there is only WebConfigProjectFileLanguageSevice in the interfaceMap there.

Do you have an idea what I'm doing wrong? I believe the same exception occurs for ILanguageService as well.

3 comments
Comment actions Permalink

On 05.04.2012 17:15, Vladimir Makaev wrote:

I've tried to debug the pluging with Reflector with decompiled sources and have found out that when ComponentContainer resolves the IProjectFileLanguageService for my language project file type it has both XmlProjectFileLanguageService and MyProjectFileLanguageService mapped to it and it fails, logs exception and uses XmlProjectFileLanguageService afterwards. But for some reason for WebConfig language it doesn't happed and there is only WebConfigProjectFileLanguageSevice in the interfaceMap there.

>

Do you have an idea what I'm doing wrong? I believe the same exception occurs for ILanguageService as well.


Vladimir, your MyProjectFileLanguageService must be inherited from XmlProjectFileLanguageService.

0
Comment actions Permalink


Vladimir, your MyProjectFileLanguageService must be inherited from XmlProjectFileLanguageService.

Slava I actually did inherited from this class. I'm basically reffering to WebConfigLanguage inside JetBrains.ReSharper.Psi.WebConfig.dl and implemented all required classes just like you do in there.
I have MyLanguage inherited from XmlLanguage, MyProjectFileLanguageService inherited from XmlProjectFileService, MyProjectFileType from XmlProjectFileType etc.

The problem is that inside ComponentContainer both MyProjectFileLanguageService and XmlProjectFileService are mapped to IProjectFileLanguageService  and there is a code inside something like (code from dotPeek)

                try
                {
                    IComponentDescriptor descriptor = entry.SingleOrDefault();     //fails here because there are 2 instances XmlProjectFileService and MyProjectFileLanguageService in the entry
                    //...
                }
                catch (Exception exception)
                {
                    LogException(exception, type, entry);
                    IComponentDescriptor descriptor2 = entry.FirstOrDefault<IComponentDescriptor>(); // logs exception that I see on the UI and returns XmlProjectFileService because it is first in the entry.
                }



I'm attaching my sample project, could you please try to replicate the problem cause it's probably a bug or help me find the workaround/ working solution?

Thanks,
Vladimir.

Attachment(s):
SampleXmlLanguage.rar.zip
0
Comment actions Permalink

I've submitted the issue on YouTrack with a better sample with ParserTest that replicates the problem. Could someone at Jetbrains please have a look at it?

http://youtrack.jetbrains.com/issue/RSRP-293613

0

Please sign in to leave a comment.