Search in sources :

Example 1 with AttributeValueDocumentationProvider

use of org.jetbrains.android.dom.converters.AttributeValueDocumentationProvider in project android by JetBrains.

the class AndroidXmlDocumentationProvider method getDocumentationElementForLookupItem.

@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
    if (object instanceof ResourceReferenceConverter.DocumentationHolder) {
        final ResourceReferenceConverter.DocumentationHolder holder = (ResourceReferenceConverter.DocumentationHolder) object;
        return new ProvidedDocumentationPsiElement(psiManager, Language.ANY, holder.getValue(), holder.getDocumentation());
    }
    if (!(element instanceof XmlAttributeValue) || !(object instanceof String)) {
        return null;
    }
    final String value = (String) object;
    final PsiElement parent = element.getParent();
    if (!(parent instanceof XmlAttribute)) {
        return null;
    }
    final GenericAttributeValue domValue = DomManager.getDomManager(parent.getProject()).getDomElement((XmlAttribute) parent);
    if (domValue == null) {
        return null;
    }
    final Converter converter = domValue.getConverter();
    if (converter instanceof AttributeValueDocumentationProvider) {
        final String doc = ((AttributeValueDocumentationProvider) converter).getDocumentation(value);
        if (doc != null) {
            return new MyDocElement(element, doc);
        }
    }
    if ((value.startsWith(PREFIX_RESOURCE_REF) || value.startsWith(PREFIX_THEME_REF)) && !DataBindingUtil.isBindingExpression(value)) {
        return new MyResourceElement(element, value);
    }
    return null;
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) ResourceReferenceConverter(org.jetbrains.android.dom.converters.ResourceReferenceConverter) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) AttributeValueDocumentationProvider(org.jetbrains.android.dom.converters.AttributeValueDocumentationProvider) ResourceReferenceConverter(org.jetbrains.android.dom.converters.ResourceReferenceConverter) FakePsiElement(com.intellij.psi.impl.FakePsiElement) PsiElement(com.intellij.psi.PsiElement) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement)

Aggregations

PomTargetPsiElement (com.intellij.pom.PomTargetPsiElement)1 PsiElement (com.intellij.psi.PsiElement)1 FakePsiElement (com.intellij.psi.impl.FakePsiElement)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 AttributeValueDocumentationProvider (org.jetbrains.android.dom.converters.AttributeValueDocumentationProvider)1 ResourceReferenceConverter (org.jetbrains.android.dom.converters.ResourceReferenceConverter)1