mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-68929 XmlEntityContextType moded on top (previously XmlEntityDecl.EntityContextType)
GitOrigin-RevId: c3f1fcb38868a17e71170968fc3844a301898346
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d1edb06662
commit
89239c9431
@@ -14,7 +14,7 @@ import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.xml.StartTagEndTokenProvider;
|
||||
import com.intellij.psi.xml.XmlElementType;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
import com.intellij.psi.xml.XmlEntityContextType;
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -67,13 +67,13 @@ public class DtdParsingTest extends ParsingTestCase {
|
||||
|
||||
public void testManualEmptyAttributeParsing() {
|
||||
String value = "<a><b c=\"\" > </b> </a>";
|
||||
final CompositeElement element = parseManually(value, XmlElementType.XML_ELEMENT_DECL, XmlEntityDecl.EntityContextType.GENERIC_XML);
|
||||
final CompositeElement element = parseManually(value, XmlElementType.XML_ELEMENT_DECL, XmlEntityContextType.GENERIC_XML);
|
||||
checkResult("testManualEmptyAttributeParsing.txt", DebugUtil.treeToString(element, true));
|
||||
}
|
||||
|
||||
private static CompositeElement parseManually(final String value,
|
||||
final IElementType xmlElementDecl,
|
||||
XmlEntityDecl.EntityContextType parseType) {
|
||||
XmlEntityContextType parseType) {
|
||||
return (CompositeElement)new DtdParsing(value, xmlElementDecl, parseType, null).parse();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ public class DtdParsingTest extends ParsingTestCase {
|
||||
public void testEntityDeclaration2() {
|
||||
String s = "| %pre.qname; | %blockquote.qname; | %address.qname;";
|
||||
CompositeElement element =
|
||||
parseManually(s, XmlElementType.XML_ELEMENT_CONTENT_SPEC, XmlEntityDecl.EntityContextType.ELEMENT_CONTENT_SPEC);
|
||||
parseManually(s, XmlElementType.XML_ELEMENT_CONTENT_SPEC, XmlEntityContextType.ELEMENT_CONTENT_SPEC);
|
||||
checkResult("testEntityDeclaration2.txt", DebugUtil.treeToString(element, true));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.xml
|
||||
|
||||
enum class XmlEntityContextType {
|
||||
ELEMENT_CONTENT_SPEC,
|
||||
ATTRIBUTE_SPEC,
|
||||
ATTLIST_SPEC,
|
||||
ENTITY_DECL_CONTENT,
|
||||
GENERIC_XML,
|
||||
ENUMERATED_TYPE,
|
||||
ATTR_VALUE,
|
||||
|
||||
;
|
||||
}
|
||||
@@ -6,15 +6,10 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
|
||||
public interface XmlEntityDecl extends XmlElement, PsiNamedElement {
|
||||
enum EntityContextType {
|
||||
ELEMENT_CONTENT_SPEC, ATTRIBUTE_SPEC, ATTLIST_SPEC, ENTITY_DECL_CONTENT, GENERIC_XML,
|
||||
ENUMERATED_TYPE, ATTR_VALUE
|
||||
}
|
||||
|
||||
@Override
|
||||
String getName();
|
||||
PsiElement getNameElement();
|
||||
XmlAttributeValue getValueElement();
|
||||
PsiElement parse(PsiFile baseFile, EntityContextType context, XmlEntityRef originalElement);
|
||||
PsiElement parse(PsiFile baseFile, XmlEntityContextType context, XmlEntityRef originalElement);
|
||||
boolean isInternalReference();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.intellij.psi.impl.source.parsing.xml.DtdParsing
|
||||
import com.intellij.psi.impl.source.xml.XmlFileImpl
|
||||
import com.intellij.psi.tree.IFileElementType
|
||||
import com.intellij.psi.xml.XmlElementType
|
||||
import com.intellij.psi.xml.XmlEntityDecl
|
||||
import com.intellij.psi.xml.XmlEntityContextType
|
||||
|
||||
class DTDParserDefinition :
|
||||
XMLParserDefinition() {
|
||||
@@ -28,7 +28,7 @@ class DTDParserDefinition :
|
||||
|
||||
override fun createParser(project: Project?): PsiParser =
|
||||
PsiParser { root, builder ->
|
||||
DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse()
|
||||
DtdParsing(root, XmlEntityContextType.GENERIC_XML, builder).parse()
|
||||
}
|
||||
|
||||
override fun getFileNodeType(): IFileElementType =
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.intellij.psi.impl.source.tree.FileElement;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
import com.intellij.psi.xml.XmlEntityContextType;
|
||||
import com.intellij.xml.parsing.XmlParserBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -28,10 +28,10 @@ public class DtdParsing extends XmlParsing {
|
||||
private static final Logger LOG = Logger.getInstance(XmlParser.class);
|
||||
|
||||
private final IElementType myRootType;
|
||||
public static final XmlEntityDecl.EntityContextType TYPE_FOR_MARKUP_DECL = XmlEntityDecl.EntityContextType.ELEMENT_CONTENT_SPEC;
|
||||
private final XmlEntityDecl.EntityContextType myContextType;
|
||||
public static final XmlEntityContextType TYPE_FOR_MARKUP_DECL = XmlEntityContextType.ELEMENT_CONTENT_SPEC;
|
||||
private final XmlEntityContextType myContextType;
|
||||
|
||||
public DtdParsing(IElementType root, XmlEntityDecl.EntityContextType contextType, PsiBuilder builder) {
|
||||
public DtdParsing(IElementType root, XmlEntityContextType contextType, PsiBuilder builder) {
|
||||
super(builder);
|
||||
myRootType = root;
|
||||
myContextType = contextType;
|
||||
@@ -40,7 +40,7 @@ public class DtdParsing extends XmlParsing {
|
||||
|
||||
public DtdParsing(CharSequence chars,
|
||||
final IElementType type,
|
||||
final XmlEntityDecl.EntityContextType contextType,
|
||||
final XmlEntityContextType contextType,
|
||||
PsiFile contextFile
|
||||
) {
|
||||
this(
|
||||
@@ -116,7 +116,7 @@ public class DtdParsing extends XmlParsing {
|
||||
return astNode;
|
||||
}
|
||||
|
||||
private static int getLexerInitialState(IElementType rootNodeType, XmlEntityDecl.EntityContextType context) {
|
||||
private static int getLexerInitialState(IElementType rootNodeType, XmlEntityContextType context) {
|
||||
short state = 0;
|
||||
|
||||
switch (context) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement) {
|
||||
public PsiElement parse(PsiFile baseFile, XmlEntityContextType contextType, final XmlEntityRef originalElement) {
|
||||
PsiElement dep = DEPENDING_ELEMENT.get(getParent());
|
||||
PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile)dep : baseFile);
|
||||
String value = null;
|
||||
@@ -93,7 +93,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl {
|
||||
|
||||
DtdParsing dtdParsing = new DtdParsing(value, XML_ELEMENT_DECL, contextType, baseFile);
|
||||
PsiElement generated = dtdParsing.parse().getPsi().getFirstChild();
|
||||
if (contextType == EntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec) {
|
||||
if (contextType == XmlEntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec) {
|
||||
generated = generated.getFirstChild();
|
||||
}
|
||||
setDependsOnElement(generated, dependsOnElement);
|
||||
|
||||
@@ -162,7 +162,7 @@ public final class XmlPsiUtil {
|
||||
}
|
||||
|
||||
private static PsiElement parseEntityRef(PsiFile targetFile, XmlEntityRef ref) {
|
||||
XmlEntityDecl.EntityContextType type = getContextType(ref);
|
||||
XmlEntityContextType type = getContextType(ref);
|
||||
|
||||
{
|
||||
final XmlEntityDecl entityDecl = ref.resolve(targetFile);
|
||||
@@ -199,27 +199,27 @@ public final class XmlPsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static XmlEntityDecl.EntityContextType getContextType(XmlEntityRef ref) {
|
||||
XmlEntityDecl.EntityContextType type = XmlEntityDecl.EntityContextType.GENERIC_XML;
|
||||
private static XmlEntityContextType getContextType(XmlEntityRef ref) {
|
||||
XmlEntityContextType type = XmlEntityContextType.GENERIC_XML;
|
||||
PsiElement temp = ref;
|
||||
while (temp != null) {
|
||||
if (temp instanceof XmlAttributeDecl) {
|
||||
type = XmlEntityDecl.EntityContextType.ATTRIBUTE_SPEC;
|
||||
type = XmlEntityContextType.ATTRIBUTE_SPEC;
|
||||
}
|
||||
else if (temp instanceof XmlElementDecl) {
|
||||
type = XmlEntityDecl.EntityContextType.ELEMENT_CONTENT_SPEC;
|
||||
type = XmlEntityContextType.ELEMENT_CONTENT_SPEC;
|
||||
}
|
||||
else if (temp instanceof XmlAttlistDecl) {
|
||||
type = XmlEntityDecl.EntityContextType.ATTLIST_SPEC;
|
||||
type = XmlEntityContextType.ATTLIST_SPEC;
|
||||
}
|
||||
else if (temp instanceof XmlEntityDecl) {
|
||||
type = XmlEntityDecl.EntityContextType.ENTITY_DECL_CONTENT;
|
||||
type = XmlEntityContextType.ENTITY_DECL_CONTENT;
|
||||
}
|
||||
else if (temp instanceof XmlEnumeratedType) {
|
||||
type = XmlEntityDecl.EntityContextType.ENUMERATED_TYPE;
|
||||
type = XmlEntityContextType.ENUMERATED_TYPE;
|
||||
}
|
||||
else if (temp instanceof XmlAttributeValue) {
|
||||
type = XmlEntityDecl.EntityContextType.ATTR_VALUE;
|
||||
type = XmlEntityContextType.ATTR_VALUE;
|
||||
}
|
||||
else {
|
||||
temp = temp.getContext();
|
||||
@@ -232,7 +232,7 @@ public final class XmlPsiUtil {
|
||||
|
||||
private static PsiElement parseEntityDecl(final XmlEntityDecl entityDecl,
|
||||
final PsiFile targetFile,
|
||||
final XmlEntityDecl.EntityContextType type,
|
||||
final XmlEntityContextType type,
|
||||
final XmlEntityRef entityRef) {
|
||||
CachedValue<PsiElement> value = ConcurrencyUtil.computeIfAbsent(entityRef, PARSED_DECL_KEY, () ->
|
||||
CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(() -> {
|
||||
|
||||
Reference in New Issue
Block a user