Display String value in read-only file editor

Working on a plugin and I would like to display the content of a String in a read-only file editor. For instance, if I have a String variable holding the results of some I/O call, ie REST, Database, etc., and the resulting value is "this is a test" then I would like it to display it as:

Eventually I would add search, filtering etc. but for the time being just getting results to display would be a win. I've read through the architectural overview on the plugin development wiki but I am hoping that I do not have to go as far as creating my own custom Virtual File System, File Providers, etc. for just displaying string contents in a file editor. Any help would be appreciated, thanks!

0
2 comments

If you do not need anything unusual, you can use `com.intellij.testFramework.LightVirtualFile`.

 val file = LightVirtualFile("Sample Name", PlainTextFileType.INSTANCE, "file content")
file.isWritable = false
FileEditorManager.getInstance(project).openFile(file, true)
1
Avatar
Permanently deleted user

That worked like a charm. Thank you!

0

Please sign in to leave a comment.