use of org.jetbrains.android.dom.xml.PreferenceElement in project android by JetBrains.
the class AndroidCompletionContributor method addAndroidPrefixElement.
private static void addAndroidPrefixElement(PsiElement position, PsiElement parent, CompletionResultSet resultSet) {
if (position.getText().startsWith(SdkConstants.ANDROID_NS_NAME_PREFIX)) {
return;
}
final PsiElement grandparent = parent.getParent();
if (!(grandparent instanceof XmlTag)) {
return;
}
final DomElement element = DomManager.getDomManager(grandparent.getProject()).getDomElement((XmlTag) grandparent);
if (!(element instanceof LayoutElement) && !(element instanceof PreferenceElement)) {
return;
}
final String prefix = ((XmlTag) grandparent).getPrefixByNamespace(SdkConstants.NS_RESOURCES);
if (prefix == null || prefix.length() < 3) {
return;
}
final LookupElementBuilder e = LookupElementBuilder.create(prefix + ":").withTypeText("[Namespace Prefix]", true);
resultSet.addElement(PrioritizedLookupElement.withPriority(e, Double.MAX_VALUE));
}
Aggregations