2 simple CustomReferenceConverter/PsiReference questions


As an experiment I wrote a CustomReferenceConverter implementation for IDEADEV-13628.
The code indeed works, but I still have some questions:

1) It seems that returning a PsiField[] from getVariants() does not work,
in contrast to the JavaDoc of getVariants().

Returning regular LookupValueFactory.createXxx objects works, but it would
be nicer to have Ctrl-Q in completion list.
Is there a way to achieve this? Why are PsiFields not accepted as return
value?

2) Unresolved references are marked red, even though I initialize the anonymous
PsiReferenceBase subclass to soft=true.

Is there a way to disable the 'red marking' of unresolved references?

-tt


4 comments

As an experiment I wrote a CustomReferenceConverter implementation for
IDEADEV-13628.
The code indeed works, but I still have some questions:

1) It seems that returning a PsiField[] from getVariants() does not
work, in contrast to the JavaDoc of getVariants().

Returning regular LookupValueFactory.createXxx objects works, but it
would be nicer to have Ctrl-Q in completion list.
Is there a way to achieve this? Why are PsiFields not accepted as return
value?

Ghm... Strange... They really should. I'll take a look.

2) Unresolved references are marked red, even though I initialize the
anonymous PsiReferenceBase subclass to soft=true.

Is there a way to disable the 'red marking' of unresolved references?


All DOM references should be soft since otherwise their highlighting
will be done not in inspection, and can't be switched off. So... DOM has
its own softness, which is specified in an attribute of @Convert or
@Resolve. Or you may just modify SpringModelInspection so that it
doesn't highlight your enums (but this wouldn't look very nice).

0

Hello Peter,

>> Returning regular LookupValueFactory.createXxx objects works, but it
>> would be nicer to have Ctrl-Q in completion list.
>> Is there a way to achieve this? Why are PsiFields not accepted as
>> return
>> value?

Ghm... Strange... They really should. I'll take a look.


I have attached the code. If I return psiFields directly from getVariants(), no suggestions are available.
Be careful not to commit it by accident, it's not complete / tested yet :)

>> 2) Unresolved references are marked red, even though I initialize the
>> anonymous PsiReferenceBase subclass to soft=true.
>>
>> Is there a way to disable the 'red marking' of unresolved references?
>>

All DOM references should be soft since otherwise their highlighting
will be done not in inspection, and can't be switched off. So... DOM
has its own softness, which is specified in an attribute of @Convert
or @Resolve. Or you may just modify SpringModelInspection so that it
doesn't highlight your enums (but this wouldn't look very nice).


I'll have to think about that...and experiment. Thanks.

-tt

Attachment not added (general error): "enum-values.patch"

0


Hmm, the patch seems to include some wacky method signature changes in ValueConvertersRegistry that I don't remember ever making.
Here's a clean version...

Attachment not added (general error): "enum-values-v2.patch"

0

Hmm, the patch seems to include some wacky method signature changes in ValueConvertersRegistry that I don't remember ever making.
Here's a clean version...


I've fixed this. So in the next Selena EAP everything should work.
BTW, would be very nice if you create some completion test to your
changes. It shouldn't be very difficult.

0

Please sign in to leave a comment.