where META_P is as follows in com.intellij.struts2.model.jam.convention.JamParentPackage
public static final JamMemberMeta<PsiPackage, JamParentPackage> META_P = new JamMemberMeta<PsiPackage, JamParentPackage>( null, JamParentPackage.class).addAnnotation(PARENT_PACKAGE_META);
does not work.. I tried a couple of other possibilities via PsiPackageStatement, but no success.. any hints?
Spent 2 minutes on the following and it looks like everything works just fine:
// jam class public class MappedPackageImpl implements JamElement { private final PsiPackage myPsiPackage;
public MappedPackageImpl(final PsiPackage psiPackage) { myPsiPackage = psiPackage; } }
// meta declaration public static final JamMemberMeta<PsiPackage, MappedPackageImpl> PACKAGE_META = new JamMemberMeta<PsiPackage,MappedPackageImpl>(null, MappedPackageImpl.class);
// part of Jam contributor: PACKAGE_META.register(registrar, psiElement(PsiPackage.class));
// Now this call returns the Jam element for the package. PACKAGE_META.getJamElement(JavaPsiFacade.getInstance(project).findPackage("com"))
Indeed, binding and finding the JamReference works (verified for my example).
I was unclear about what does not work: trying to bind the JamSimpleReferenceConverter to the annotation in the context of package-info.java. It does work on PsiClass level, but it seems like ReferenceProvider is not registered at all/not properly for package-info.java context (I only get PsiProperty completion). Could you verify this behaviour?
Another question: using JamSimpleReferenceConverter should enable "backwards" find usages from XML to reference in Package-parameter? It seems this doesn't work for me (seecom.intellij.struts2.model.jam.convention.JamParentPackage#STRUTS_PACKAGE_JAM_CONVERTER). Do I have to provide anything else?
For anyone else struggling with references to DOM-elements from JAM: let your DomElement extend com.intellij.javaee.model.xml.impl.BaseImpl where all the nasty magic happens
Nobody has needed this until now. I believe that the JAM should hang on
a PsiPackage object. As for the pattern, you can create it yourself.
where META_P is as follows in com.intellij.struts2.model.jam.convention.JamParentPackage
does not work.. I tried a couple of other possibilities via PsiPackageStatement, but no success.. any hints?
Spent 2 minutes on the following and it looks like everything works just fine:
Gregory,
thanks for your feedback.
Indeed, binding and finding the JamReference works (verified for my example).
I was unclear about what does not work: trying to bind the JamSimpleReferenceConverter to the annotation in the context of package-info.java. It does work on PsiClass level, but it seems like ReferenceProvider is not registered at all/not properly for package-info.java context (I only get PsiProperty completion). Could you verify this behaviour?
Thanks,
Yan
Another question: using JamSimpleReferenceConverter should enable "backwards" find usages from XML to reference in Package-parameter? It seems this doesn't work for me (seecom.intellij.struts2.model.jam.convention.JamParentPackage#STRUTS_PACKAGE_JAM_CONVERTER). Do I have to provide anything else?
Thanks,
Yann
Indeed, there's problem with JAM package support. I've just committed a fix that should enable JamConverters.
Important: JamPackageMeta should be used instead of JamMemberMeta.
Great, thanks for the quick fix!
may I suggest to add "target"-parameter in UOE-message from com.intellij.jam.JamSimpleReferenceConverter#createLookupElementFor
Ok, it's there.
For anyone else struggling with references to DOM-elements from JAM: let your DomElement extend com.intellij.javaee.model.xml.impl.BaseImpl where all the nasty magic happens