syntaxHighlighter on decompiled file

Answered

Hi. I have implemented a BinaryFileDecompiler attached to a FileType with method isBinary overridden.

I've also created a PsiFileBase for my compiled fileType and attached to the method createFile() in a ParserDefinition class

Decompiler works, but syntax highlighting does not work.

object MyParserDefinition : ParserDefinition {
...
override fun createFile(viewProvider: FileViewProvider): PsiFile = when (viewProvider.fileType) {
MySourceFileType -> MySourceFile(viewProvider)
MyIncludeFileType -> MyIncludeFile(viewProvider)
MyCompiledFileType -> MyCompiledFile(viewProvider)
else -> throw RuntimeException("Illegal viewProvider") // is this ok?
}
}
object MyCompiledFileType : FileType {
override fun getName(): String = "MY_COMPILED"
override fun isReadOnly(): Boolean = true
override fun isBinary(): Boolean = true
...
}

class MyCompiledFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, MyLanguage) {
override fun getFileType(): FileType = MyCompiledFileType
override fun toString(): String = "compiled file viewProvider"
}

 

 

Then, if I try to add a syntaxHighlighter, even with implementationClass value empty, I can open my compiled file, but it shows a infinite "Loading…" text.

Is it normal? Am I missing something to implement?

 

This is a similiar issue: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000006644-Parsing-decompiled-source-using-target-language-s-extensions , but his solution (including the syntaxHighlighter) does not work

2 comments
Comment actions Permalink

Please try implementing com.intellij.psi.PsiCompiledFile in your MyCompiledFile

0
Comment actions Permalink

Thanks for the your reply.

I fixed all the things. 

I had to create an implementation for my file which extends PsiFileBase and implements PsiFileEx and PsiCompiledBase and a new FileViewProvider with his factory. 

0

Please sign in to leave a comment.