mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix GrailsCompletionTest.testGspClosingJavascriptTag: restore completion of closing tags in SchemaPrefixReference
This commit is contained in:
+7
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.TailTypeDecorator;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.source.xml.SchemaPrefixReference;
|
||||
import com.intellij.psi.impl.source.xml.TagNameReference;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -54,6 +55,12 @@ public class TagNameReferenceCompletionProvider extends CompletionProvider<Compl
|
||||
TagNameReference tagNameReference = (TagNameReference)reference;
|
||||
collectCompletionVariants(tagNameReference, result);
|
||||
}
|
||||
else if (reference instanceof SchemaPrefixReference) {
|
||||
TagNameReference tagNameReference = ((SchemaPrefixReference) reference).getTagNameReference();
|
||||
if (tagNameReference != null && !tagNameReference.isStartTagFlag()) {
|
||||
result.consume(createClosingTagLookupElement((XmlTag)tagNameReference.getElement(), true, tagNameReference.getNameElement()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void collectCompletionVariants(TagNameReference tagNameReference,
|
||||
|
||||
@@ -37,7 +37,7 @@ public class XmlPrefixReferenceProvider extends PsiReferenceProvider {
|
||||
int i = value.indexOf(':');
|
||||
if (i > 0) {
|
||||
return new PsiReference[] {
|
||||
new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i))
|
||||
new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -568,7 +568,7 @@ public class SchemaReferencesProvider extends PsiReferenceProvider {
|
||||
final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
|
||||
final String prefix = XmlUtil.findPrefixByQualifiedName(attributeValue.getValue());
|
||||
if (prefix.length() > 0) {
|
||||
return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix);
|
||||
return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -37,16 +37,20 @@ public class SchemaPrefixReference extends PsiReferenceBase<XmlElement> implemen
|
||||
private final SchemaPrefix myPrefix;
|
||||
|
||||
private final String myName;
|
||||
@Nullable
|
||||
private final TagNameReference myTagNameReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param element XmlAttribute || XmlAttributeValue
|
||||
* @param range
|
||||
* @param name
|
||||
* @param reference
|
||||
*/
|
||||
public SchemaPrefixReference(XmlElement element, TextRange range, String name) {
|
||||
public SchemaPrefixReference(XmlElement element, TextRange range, String name, TagNameReference reference) {
|
||||
super(element, range);
|
||||
myName = name;
|
||||
myTagNameReference = reference;
|
||||
if (myElement instanceof XmlAttribute && (((XmlAttribute)myElement).isNamespaceDeclaration())) {
|
||||
myPrefix = new SchemaPrefix((XmlAttribute)myElement, getRangeInElement(), myName);
|
||||
}
|
||||
@@ -108,4 +112,9 @@ public class SchemaPrefixReference extends PsiReferenceBase<XmlElement> implemen
|
||||
public boolean isPrefixReference() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TagNameReference getTagNameReference() {
|
||||
return myTagNameReference;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,13 +325,13 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
|
||||
final String prefix = XmlUtil.findPrefixByQualifiedName(getName());
|
||||
final TextRange range =
|
||||
prefix.length() == 0 ? TextRange.from(getName().length(), 0) : TextRange.from(prefix.length() + 1, localName.length());
|
||||
refs[0] = new SchemaPrefixReference(this, range, localName);
|
||||
refs[0] = new SchemaPrefixReference(this, range, localName, null);
|
||||
}
|
||||
else {
|
||||
final String prefix = getNamespacePrefix();
|
||||
if (prefix.length() > 0 && getLocalName().length() > 0) {
|
||||
refs = new PsiReference[referencesFromProviders.length + 2];
|
||||
refs[0] = new SchemaPrefixReference(this, TextRange.from(0, prefix.length()), prefix);
|
||||
refs[0] = new SchemaPrefixReference(this, TextRange.from(0, prefix.length()), prefix, null);
|
||||
refs[1] = new XmlAttributeReference(this);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -180,7 +180,8 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
|
||||
}
|
||||
|
||||
private SchemaPrefixReference createPrefixReference(ASTNode startTagName, String prefix, TagNameReference tagRef) {
|
||||
return new SchemaPrefixReference(this, TextRange.from(startTagName.getStartOffset() - getStartOffset(), prefix.length()), prefix);
|
||||
return new SchemaPrefixReference(this, TextRange.from(startTagName.getStartOffset() - getStartOffset(), prefix.length()), prefix,
|
||||
tagRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user