use of org.intellij.lang.xpath.psi.XPathFunction in project intellij-community by JetBrains.
the class XsltDocumentationProvider method getUrlFor.
@Nullable
public List<String> getUrlFor(PsiElement psiElement, PsiElement psiElement1) {
if (psiElement instanceof XsltElement)
return null;
final String category;
final String name;
final String tagName = getTagName(psiElement);
if (tagName != null) {
name = tagName;
category = "element";
} else if (psiElement instanceof XPathFunction) {
name = ((XPathFunction) psiElement).getName();
category = "function";
} else if (psiElement instanceof DocElement) {
name = ((DocElement) psiElement).getName();
category = ((DocElement) psiElement).getCategory();
} else {
return null;
}
try {
final Document document = getDocumentationDocument();
final XPath xPath = XPath.newInstance("//x:" + category + "[@name = '" + name + "']");
xPath.addNamespace("x", document.getRootElement().getNamespaceURI());
final Element e = (Element) xPath.selectSingleNode(document);
if (e != null) {
return Collections.singletonList(e.getParentElement().getAttributeValue("base") + e.getAttributeValue("href"));
}
} catch (Exception e) {
Logger.getInstance(getClass().getName()).error(e);
}
return null;
}
use of org.intellij.lang.xpath.psi.XPathFunction in project intellij-community by JetBrains.
the class XPathParameterInfoHandler method updateUI.
public void updateUI(XPathFunction function, @NotNull ParameterInfoUIContext context) {
final Function declaration = function.getDeclaration();
if (declaration != null) {
if (declaration.getParameters().length > 0) {
final String signature = declaration.buildSignature();
final int length = declaration.getName().length();
final String hint = signature.substring(length + 1, signature.length() - 1);
final int currentParameterIndex = context.getCurrentParameterIndex();
if (currentParameterIndex < 0 || currentParameterIndex >= declaration.getParameters().length) {
context.setupUIComponentPresentation(hint, -1, -1, false, false, false, context.getDefaultParameterColor());
} else {
final String[] ps = hint.split(",");
final TextRange[] ts = new TextRange[ps.length];
int start = 0;
for (int i = 0; i < ps.length; i++) {
String p = ps[i];
ts[i] = TextRange.from(start, p.length());
start += p.length() + 1;
}
final TextRange range = ts[currentParameterIndex];
context.setupUIComponentPresentation(hint, range.getStartOffset(), range.getEndOffset(), false, false, false, context.getDefaultParameterColor());
}
} else {
context.setupUIComponentPresentation(noParamsMessage(), -1, -1, false, false, false, context.getDefaultParameterColor());
}
}
}
Aggregations