Navigating from reference using definitionsScopedSearch

Hi there,

I've implemented a <definitionsScopedSearch> that allows me to use ctrl-alt-b to navigate from a field in a Java class to another field in a related Java class. This is working quite nicely.

However, I'd also like to navigate to the field in the related class when invoking ctrl-alt-b on a reference to the original field.
Currently, this brings me to the definition of the original field, rather than to the related class. In my debugger, I do see my custom QueryExecutor being called, and it is finding the field in the related class (which I'd like it to navigate to) and supplying it to the process() call on the consumer. Still, it's not navigating to that field, but to the original field.

Any thoughts on how to make it navigate to the field in the related class?


Hope I'm making any sense.
To clarify this a bit more:

  • Invoking ctrl-alt-b on source (the 2nd line) in class A below brings me to's great.
  • Invoking ctrl-alt-b on source in the println() call brings me to line 2. But I would like it to bring me to
class A {
String source;

A() {

class Related {
String target;

My QueryExecutor is as follows:


public class ValueObjectMetaFieldSearcher extends QueryExecutorBase<PsiField, DefinitionsScopedSearch.SearchParameters> {

public ValueObjectMetaFieldSearcher() {

public void processQuery(@NotNull DefinitionsScopedSearch.SearchParameters params, @NotNull Processor<PsiField> consumer) {

final PsiElement element = params.getElement();

if (!(element instanceof PsiField)) return;

final PsiClass baseClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);

if (baseClass.getModifierList().findAnnotation("") == null) {

PsiClass targetClass = MyClassUtil.findClassByName(element.getProject(),

PsiField field = targetClass.findFieldByName(((PsiField) element).getName(), false);

if (field != null) {

Hello Guno,

Are you implementing goto or view quick definition?

is source resolved to target?


Hi Imants,


I'm implementing goto. And it does work actually, source is resolved to target. when invoking ctrl-alt-b on source on line 2 in my example.
But not when I invoke ctrl-alt-b on the reference to source in the println() call. If I do that, it navigates to the definition of source, instead of to the definition of target.


a, ctrl-alt-b is goto implementation

take a look at GotoImplementationAction and GotoImplementationHandler

maybe add a custom action with a custom handler?



I'll try that, thanks!

Working fine now, using a custom action and handler!


Please sign in to leave a comment.