Search in sources :

Example 1 with AndroidResourceDomFileDescription

use of org.jetbrains.android.dom.AndroidResourceDomFileDescription in project android by JetBrains.

the class AndroidXmlFormattingModelBuilder method getContextSpecificSettings.

@Nullable
private static ContextSpecificSettingsProviders.Provider getContextSpecificSettings(PsiElement context) {
    final PsiFile file = context.getContainingFile();
    if (!(file instanceof XmlFile) || AndroidFacet.getInstance(file) == null) {
        return null;
    }
    final DomFileDescription<?> description = DomManager.getDomManager(context.getProject()).getDomFileDescription((XmlFile) file);
    if (description instanceof LayoutDomFileDescription) {
        return ContextSpecificSettingsProviders.LAYOUT;
    } else if (description instanceof ManifestDomFileDescription) {
        return ContextSpecificSettingsProviders.MANIFEST;
    } else if (description instanceof ResourcesDomFileDescription || description instanceof DrawableStateListDomFileDescription || description instanceof ColorDomFileDescription) {
        return ContextSpecificSettingsProviders.VALUE_RESOURCE_FILE;
    } else if (description instanceof AndroidResourceDomFileDescription) {
        return ContextSpecificSettingsProviders.OTHER;
    }
    return null;
}
Also used : ManifestDomFileDescription(org.jetbrains.android.dom.manifest.ManifestDomFileDescription) LayoutDomFileDescription(org.jetbrains.android.dom.layout.LayoutDomFileDescription) XmlFile(com.intellij.psi.xml.XmlFile) AndroidResourceDomFileDescription(org.jetbrains.android.dom.AndroidResourceDomFileDescription) PsiFile(com.intellij.psi.PsiFile) ColorDomFileDescription(org.jetbrains.android.dom.color.ColorDomFileDescription) ResourcesDomFileDescription(org.jetbrains.android.dom.resources.ResourcesDomFileDescription) DrawableStateListDomFileDescription(org.jetbrains.android.dom.drawable.fileDescriptions.DrawableStateListDomFileDescription) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 AndroidResourceDomFileDescription (org.jetbrains.android.dom.AndroidResourceDomFileDescription)1 ColorDomFileDescription (org.jetbrains.android.dom.color.ColorDomFileDescription)1 DrawableStateListDomFileDescription (org.jetbrains.android.dom.drawable.fileDescriptions.DrawableStateListDomFileDescription)1 LayoutDomFileDescription (org.jetbrains.android.dom.layout.LayoutDomFileDescription)1 ManifestDomFileDescription (org.jetbrains.android.dom.manifest.ManifestDomFileDescription)1 ResourcesDomFileDescription (org.jetbrains.android.dom.resources.ResourcesDomFileDescription)1 Nullable (org.jetbrains.annotations.Nullable)1