RefactoringOptions (XPathExpression expression, Set<XPathExpression> matchingExpressions) { final String name = Messages.showInputDialog(expression.getProject(), XPathBundle.message("dialog.message.function.name"), getRefactoringName(), Messages.getQuestionIcon()); final boolean[] b = new boolean[]{false}; if (name != null) { final String[] parts = name.split(":", 2); if (parts.length < 2) { Messages.showMessageDialog(expression.getProject(), XPathBundle.message("dialog.message.custom.functions.require.prefixed.name"), XPathBundle.message("dialog.title.error"), Messages.getErrorIcon()); b[0] = true; } final XmlElement context = PsiTreeUtil.getContextOfType(expression, XmlElement.class); final NamespaceContext namespaceContext = expression.getXPathContext().getNamespaceContext(); if (namespaceContext != null && context != null && namespaceContext.resolve(parts[0], context) == null) { Messages.showMessageDialog(expression.getProject(), XPathBundle.message("dialog.message.prefix.not.defined", parts[0]), XPathBundle.message("dialog.title.error"), Messages.getErrorIcon()); b[0] = true; } } return new RefactoringOptions() { @Override public boolean isCanceled() { return b[0]; } @Override public String getName() { return name; } }; }