use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.
the class DataBindingUtil method getViewClassNameFromLayoutReferenceTag.
private static String getViewClassNameFromLayoutReferenceTag(XmlTag tag, AndroidFacet facet) {
String layout = tag.getAttributeValue(SdkConstants.ATTR_LAYOUT);
if (layout == null) {
return null;
}
LocalResourceRepository moduleResources = facet.getModuleResources(false);
if (moduleResources == null) {
return null;
}
ResourceUrl resourceUrl = ResourceUrl.parse(layout);
if (resourceUrl == null || resourceUrl.type != ResourceType.LAYOUT) {
return null;
}
DataBindingInfo info = moduleResources.getDataBindingInfoForLayout(resourceUrl.name);
if (info == null) {
return null;
}
return info.getQualifiedName();
}
use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.
the class DataBindingUtil method invalidateAllSources.
public static boolean invalidateAllSources(DataBindingProjectComponent component) {
boolean invalidated = false;
for (AndroidFacet facet : component.getDataBindingEnabledFacets()) {
LocalResourceRepository moduleResources = facet.getModuleResources(true);
Map<String, DataBindingInfo> dataBindingResourceFiles = moduleResources.getDataBindingResourceFiles();
if (dataBindingResourceFiles == null) {
continue;
}
for (DataBindingInfo info : dataBindingResourceFiles.values()) {
PsiClass psiClass = info.getPsiClass();
if (psiClass != null) {
PsiFile containingFile = psiClass.getContainingFile();
if (containingFile != null) {
containingFile.subtreeChanged();
invalidated = true;
}
}
}
}
return invalidated;
}
use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.
the class DataBindingClassFinder method findClass.
@Nullable
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
if (!isEnabled()) {
return null;
}
for (AndroidFacet facet : myComponent.getDataBindingEnabledFacets()) {
LocalResourceRepository moduleResources = facet.getModuleResources(true);
Map<String, DataBindingInfo> dataBindingResourceFiles = moduleResources.getDataBindingResourceFiles();
if (dataBindingResourceFiles == null) {
continue;
}
DataBindingInfo dataBindingInfo = dataBindingResourceFiles.get(qualifiedName);
if (dataBindingInfo == null) {
continue;
}
VirtualFile file = dataBindingInfo.getPsiFile().getVirtualFile();
if (file != null && scope.accept(file)) {
return DataBindingUtil.getOrCreatePsiClass(dataBindingInfo);
}
}
return null;
}
use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.
the class DataBindingShortNamesCache method getClassesByName.
@NotNull
@Override
public PsiClass[] getClassesByName(@NotNull @NonNls String name, @NotNull GlobalSearchScope scope) {
if (!isEnabled()) {
return PsiClass.EMPTY_ARRAY;
}
List<DataBindingInfo> infoList = myNameCache.getValue().get(name);
if (infoList == null || infoList.size() == 0) {
return PsiClass.EMPTY_ARRAY;
}
List<PsiClass> selected = Lists.newArrayList();
for (DataBindingInfo info : infoList) {
if (scope.accept(info.getPsiFile().getVirtualFile())) {
selected.add(DataBindingUtil.getOrCreatePsiClass(info));
}
}
if (selected.isEmpty()) {
return PsiClass.EMPTY_ARRAY;
}
return selected.toArray(new PsiClass[selected.size()]);
}
use of com.android.tools.idea.res.DataBindingInfo in project android by JetBrains.
the class LightBindingClass method getExtendsListTypes.
@NotNull
@Override
public PsiClassType[] getExtendsListTypes() {
if (myExtendsListTypes == null) {
DataBindingInfo mergedInfo = myInfo.getMergedInfo();
String superClassName = mergedInfo == null ? SdkConstants.CLASS_DATA_BINDING_BASE_BINDING : mergedInfo.getQualifiedName();
myExtendsListTypes = new PsiClassType[] { PsiType.getTypeByName(superClassName, myInfo.getProject(), myFacet.getModule().getModuleWithDependenciesAndLibrariesScope(false)) };
}
return myExtendsListTypes;
}
Aggregations