MultiplePsiFilesPerDocumentFileViewProvider for Smarty language

Answered

I am trying to create a custom language that extends the Smarty language. 

I added in   plugin.xml
 


<lang.substitutor language="Smarty" implementationClass="com.example.mylanguage.lang.MyLanguageSubstitutor"/>      

Created a class MyFileViewProvider  that extends which  MultiplePsiFilesPerDocumentFileViewProvider.

But after my extension, syntax highlighting and Smarty language autocompletion stop working, while the exact same HTML language extension works fine

I found that SmartyLanguage is not in the list that TemplateDataLanguageMappings.getTemplateableLanguages() returns. As a result the code is not executed

if (TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang)) {
    dataLang = substituteLang;
}

There is an error in the console

com.example.mylanguage.lang.MyFileViewProvider{vFile=file:///MylangTest/test.tpl, vFileId=2632, content=VirtualFileContent{size=1431}, eventSystemEnabled=true}(class com.example.mylanguage.lang.MyFileViewProvider).getPsi(Language: Smarty) is null for file MyFile:test.tpl
java.lang.Throwable: com.example.mylanguage.lang.MyFileViewProvider{vFile=file:///MylangTest/test.tpl, vFileId=2632, content=VirtualFileContent{size=1431}, eventSystemEnabled=true}(class com.example.mylanguage.lang.MyFileViewProvider).getPsi(Language: Smarty) is null for file MyFile:test.tpl
0
7 comments

Hi,

I don't understand why you are pointing to TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang) as the issue cause.

In my opinion, the problem is in MyFileViewProvider.createFile(Language), which doesn't return file for Smarty language.

0

I changed the return language value for the getDefaultTemplateLang function from HtmlFileType.INSTANCE to SmartyFileType.INSTANCE. The error disappeared, but the Smarty and HTML tags stopped highlighting and auto-completed.

When getDefaultTemplateLang returned HtmlFileType.INSTANCE Html tags were highlighted and autocompletion worked.

As far as I understand, highlighting for the Smarty language does not work because for it 

SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);

 finds nothing and returns com.intellij.lexer.EmptyLexer

 

0

Karol Lewandowski, do you have any ideas about the problem described?

0

Hi,

Sorry for the delay. I was on a long leave. Do you still have this issue?

0

Hi Karol. Yes, this problem has not been solved. I created a issue  but no one answers it for a long time.

0

Hi, I asked the responsible developer for help and they are currently unavailable. Please be patient.

0

Please sign in to leave a comment.