Embedded Java in custom language: how to enable standard syntax coloring in embedded Java
So I have Java code embedded in my custom language now, but I'd like to
provide context. I'd like to specify a series of PsiVariables and
methods which are accessible from each instance of Java code in a file
of my custom language. How do I do this?
Please sign in to leave a comment.
Keith Lea wrote:
I noticed that the subject of this post does not match the body. I changed my
mind about which question to ask while I was writing it, because I thought of a
possible solution. It didn't work out however, so now I ask: how can I get
embedded Java code to highlight properly?
Also, my import list is showing up greyed out as "unused import" - even though
there's no java code other than the import! How can I fix this?
Keith Lea wrote:
If there's no code using the imported class, then I would expect it be
marked as an unused import.
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001
Gordon Tyler wrote:
>> Also, my import list is showing up greyed out as "unused import" -
>> even though there's no java code other than the import! How can I fix
>> this?
It's impossible for any code to use the imported class because the only code
possibly embedded in the file is a PsiImportList.
This custom language is for a language which is used to generate Java code.
There are actually references to those classes in the file, logically, but they
are also, more specifically, references to constructs defined in the file
itself, which map to Java classes, but not directly via PSI.
Keith Lea wrote:
>> Keith Lea wrote:
>>> Also, my import list is showing up greyed out as "unused import" -
>>> even though there's no java code other than the import! How can I fix
>>> this?
>>
>> If there's no code using the imported class, then I would expect it be
>> marked as an unused import.
>>
>> Ciao,
>> Gordon
>>
Keith Lea wrote:
Ah, I see. Can you not override PsiImportList so that it returns the
correct list of references?
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001
Hello Keith,
KL> So I have Java code embedded in my custom language now, but I'd like
KL> to provide context. I'd like to specify a series of PsiVariables and
KL> methods which are accessible from each instance of Java code in a
KL> file of my custom language. How do I do this?
You should be able to override PsiElement.processDeclarations() on the element
from your custom language which is the parent of the Java code element, and
call processor.execute() passing to it all the accessible elements.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"