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
Please sign in to leave a comment.
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.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
finds nothing and returns com.intellij.lexer.EmptyLexer
Karol Lewandowski, do you have any ideas about the problem described?
Hi,
Sorry for the delay. I was on a long leave. Do you still have this issue?
Hi Karol. Yes, this problem has not been solved. I created a issue but no one answers it for a long time.
Hi, I asked the responsible developer for help and they are currently unavailable. Please be patient.
Thanks, Karol!