mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEADEV-41816 DOM doesn't handle XML &EntityRefs; right
This commit is contained in:
@@ -19,7 +19,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import static com.intellij.patterns.XmlPatterns.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
@@ -43,6 +42,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.patterns.XmlPatterns.*;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -80,7 +81,7 @@ public class DomSemContributor extends SemContributor {
|
||||
}
|
||||
});
|
||||
|
||||
final ElementPattern<XmlTag> nonRootTag = xmlTag().withParent(xmlTag());
|
||||
final ElementPattern<XmlTag> nonRootTag = xmlTag().withParent(or(xmlTag(), xmlEntityRef().withParent(xmlTag())));
|
||||
registrar.registerSemElementProvider(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, nonRootTag, new NullableFunction<XmlTag, IndexedElementInvocationHandler>() {
|
||||
public IndexedElementInvocationHandler fun(XmlTag tag) {
|
||||
final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.patterns;
|
||||
|
||||
import com.intellij.psi.xml.XmlElement;
|
||||
import com.intellij.psi.xml.XmlEntityRef;
|
||||
import com.intellij.psi.xml.XmlText;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -53,4 +54,14 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
|
||||
}
|
||||
}
|
||||
|
||||
public static class XmlEntityRefPattern extends XmlElementPattern<XmlEntityRef, XmlEntityRefPattern> {
|
||||
public XmlEntityRefPattern() {
|
||||
super(new InitialPatternCondition<XmlEntityRef>(XmlEntityRef.class) {
|
||||
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
|
||||
return o instanceof XmlEntityRef;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,4 +49,8 @@ public class XmlPatterns extends PlatformPatterns {
|
||||
public static XmlElementPattern.XmlTextPattern xmlText() {
|
||||
return new XmlElementPattern.XmlTextPattern();
|
||||
}
|
||||
|
||||
public static XmlElementPattern.XmlEntityRefPattern xmlEntityRef() {
|
||||
return new XmlElementPattern.XmlEntityRefPattern();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user