PsiElement () { if (myNavigationElement == null && myElement.isValid()) { final Class[] allInterfaces = CompletionLists.getAllInterfaces(myElement.getClass()); myNavigationElement = (PsiElement)Proxy.newProxyInstance(getClass().getClassLoader(), allInterfaces, new InvocationHandler() { @Override @Nullable @SuppressWarnings({"StringEquality", "AutoBoxing", "AutoUnboxing"}) public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { final XmlAttributeValue nameElement = XsltElementImpl.this.getNameElement(); return switch (method.getName()) { case "navigate" -> { assert nameElement != null; ((NavigationItem)nameElement).navigate((Boolean)args[0]); yield null; } case "canNavigate" -> nameElement instanceof NavigationItem item && item.canNavigate(); case "getTextOffset" -> nameElement != null ? nameElement.getTextOffset() : myElement.getTextOffset(); default -> method.invoke(myElement, args); }; } catch (InvocationTargetException e1) { throw e1.getTargetException(); } } }); } return myElement.isValid() ? myNavigationElement : this; }