mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-45809 XML editing: Required attributes should be preferred in completion
This commit is contained in:
@@ -85,4 +85,9 @@ public class HtmlAttributeDescriptorImpl implements XmlAttributeDescriptor {
|
||||
public Object[] getDependences() {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,8 +416,6 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
|
||||
return setName(newName);
|
||||
}
|
||||
|
||||
// TODO[ik]: namespace support
|
||||
|
||||
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof PsiMetaOwner) {
|
||||
final PsiMetaOwner owner = (PsiMetaOwner)element;
|
||||
@@ -475,7 +473,8 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
|
||||
if (separator > 0) {
|
||||
element = element.withLookupString(name.substring(separator + 1));
|
||||
}
|
||||
variants.add(element.withCaseSensitivity(caseSensitive).withInsertHandler(XmlAttributeInsertHandler.INSTANCE));
|
||||
element = element.withCaseSensitivity(caseSensitive).withInsertHandler(XmlAttributeInsertHandler.INSTANCE);
|
||||
variants.add(descriptor.isRequired() ? PrioritizedLookupElement.withPriority(element.appendTailText("(required)", true), 100) : element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,9 @@ public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescrip
|
||||
public boolean isEnumerated(@Nullable XmlElement context) {
|
||||
return isEnumerated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,9 +243,4 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl
|
||||
public void setName(String name) throws IncorrectOperationException {
|
||||
NamedObjectDescriptor.setName(myTag, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,5 +636,15 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase {
|
||||
"xsi:noNamespaceSchemaLocation",
|
||||
"xsi:type");
|
||||
}
|
||||
|
||||
public void testRequiredAttributesOnTop() throws Exception {
|
||||
myFixture.configureByText("foo.html", "<img <caret>");
|
||||
myFixture.completeBasic();
|
||||
List<String> strings = myFixture.getLookupElementStrings();
|
||||
assertNotNull(strings);
|
||||
assertEquals("alt", strings.get(0));
|
||||
assertEquals("src", strings.get(1));
|
||||
assertEquals("align", strings.get(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user