Search in sources :

Example 11 with DataBindingInfo

use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.

the class DataBindingXmlReferenceContributor method getDataBindingInfo.

@Nullable
public static DataBindingInfo getDataBindingInfo(PsiElement element) {
    DataBindingInfo dataBindingInfo = null;
    Module module = ModuleUtilCore.findModuleForPsiElement(element);
    if (module != null) {
        AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet != null && facet.isDataBindingEnabled()) {
            LocalResourceRepository moduleResources = facet.getModuleResources(true);
            PsiFile topLevelFile = InjectedLanguageUtil.getTopLevelFile(element);
            if (topLevelFile != null) {
                String name = topLevelFile.getName();
                name = name.substring(0, name.lastIndexOf('.'));
                dataBindingInfo = moduleResources.getDataBindingInfoForLayout(name);
            }
        }
    }
    return dataBindingInfo;
}
Also used : LocalResourceRepository(com.android.tools.idea.res.LocalResourceRepository) Module(com.intellij.openapi.module.Module) DataBindingInfo(com.android.tools.idea.res.DataBindingInfo) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DataBindingInfo (com.android.tools.idea.res.DataBindingInfo)11 Nullable (org.jetbrains.annotations.Nullable)5 LocalResourceRepository (com.android.tools.idea.res.LocalResourceRepository)4 Module (com.intellij.openapi.module.Module)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 NotNull (org.jetbrains.annotations.NotNull)3 PsiDataBindingResourceItem (com.android.tools.idea.res.PsiDataBindingResourceItem)2 PsiClass (com.intellij.psi.PsiClass)2 ResourceUrl (com.android.ide.common.resources.ResourceUrl)1 Project (com.intellij.openapi.project.Project)1 TextRange (com.intellij.openapi.util.TextRange)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 ArrayList (java.util.ArrayList)1