About MultiHostInjector,how to calc range?
Answered
In Language Injection | IntelliJ Platform Plugin SDK (jetbrains.com) introduce a example of inject into several fragments at once, but I don't know how to calc rangeForBody :
registrar.addPlace(null, "}}", context, rangeForBody(context));
Thanks for any response!
Please sign in to leave a comment.
Hi,
You should calculate text range in the host element. There is no common algorithm for it. See com.intellij.lang.injection.MultiHostRegistrar#addPlace Javadoc. It contains an example.
Thanks.
according to the example, the host element should is the “name” tag value “foo”, but rangeForBody is calc the “body” tag value “System.out.println(42);”,the “body“ tag is out of the range of the "name” tag。
Is it my misunderstanding?
You can walk the tree and find the elements needed for calculations.