boolean (EvalExpressionDialog.Context context, XmlElement contextNode, Editor editor, Config cfg) { final Project project = editor.getProject(); try { final XPathSupport support = XPathSupport.getInstance(); final XPath xpath = support.createXPath((XmlFile)contextNode.getContainingFile(), context.input.expression, context.input.namespaces); xpath.setVariableContext(new CachedVariableContext(context.input.variables, xpath, contextNode)); // evaluate the expression on the whole document final Object result = xpath.evaluate(contextNode); LOG.debug("result = " + result); LOG.assertTrue(result != null, "null result?"); if (result instanceof List<?> list) { if (!list.isEmpty()) { if (cfg.HIGHLIGHT_RESULTS) { highlightResult(contextNode, editor, list); } if (cfg.SHOW_USAGE_VIEW) { showUsageView(editor, xpath, contextNode, list); } if (!cfg.SHOW_USAGE_VIEW && !cfg.HIGHLIGHT_RESULTS) { final String s = StringUtil.pluralize(XPathBundle.message("dialog.message.match"), list.size()); Messages.showInfoMessage(project, XPathBundle.message("dialog.message.expression.produced") + list.size() + " " + s, XPathBundle.message("dialog.title.xpath.result")); } } else { return Messages.showOkCancelDialog(project, XPathBundle.message("dialog.message.sorry.your.expression.did.not.return.any.result"), XPathBundle.message("dialog.title.xpath.result"), XPathBundle.message("button.ok"), XPathBundle.message("button.edit.expression"), Messages.getInformationIcon()) != Messages.OK; } } else if (result instanceof String) { Messages.showMessageDialog("'" + result + "'", XPathBundle.message("dialog.title.xpath.result.string"), Messages.getInformationIcon()); } else if (result instanceof Number) { final String s = result.toString(); //NON-NLS Messages.showMessageDialog(s, XPathBundle.message("dialog.title.xpath.result.number"), Messages.getInformationIcon()); } else if (result instanceof Boolean) { final String s = result.toString(); //NON-NLS Messages.showMessageDialog(s, XPathBundle.message("dialog.title.xpath.result.boolean"), Messages.getInformationIcon()); } else { LOG.error("Unknown XPath result: " + result); } } catch (XPathSyntaxException e) { LOG.debug(e); // TODO: Better layout of the error message with non-fixed size fonts return Messages.showOkCancelDialog(project, e.getMultilineMessage(), //NON-NLS XPathBundle.message("dialog.title.xpath.syntax.error"), XPathBundle.message("button.edit.expression"), XPathBundle.message("button.cancel"), Messages.getErrorIcon()) == Messages.OK; } catch (SAXPathException e) { LOG.debug(e); Messages.showMessageDialog(project, e.getMessage(), XPathBundle.message("dialog.title.xpath.error"), Messages.getErrorIcon()); } return false; }