mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
XmlParser: cleanup XmlParser
GitOrigin-RevId: 838a3a8bfc2cde9b47c15838df703044e05da11f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
028e4623fb
commit
6881811753
@@ -44,31 +44,37 @@ private fun reparseXmlTagByName(
|
||||
newNode: LighterASTNode,
|
||||
structure: FlyweightCapableTreeStructure<LighterASTNode>,
|
||||
): ThreeState {
|
||||
if (oldNode is PsiNamedElement
|
||||
&& oldNode.elementType === XmlElementType.XML_TAG
|
||||
&& newNode.tokenType === XmlElementType.XML_TAG
|
||||
) {
|
||||
val oldName = oldNode.name
|
||||
val childrenRef = Ref.create<Array<LighterASTNode>>()
|
||||
val count = structure.getChildren(newNode, childrenRef)
|
||||
|
||||
if (count < 3)
|
||||
return ThreeState.UNSURE
|
||||
|
||||
val children = childrenRef.get()!!
|
||||
if (children[0].tokenType !== XmlTokenType.XML_START_TAG_START)
|
||||
return ThreeState.UNSURE
|
||||
if (children[1].tokenType !== XmlTokenType.XML_NAME)
|
||||
return ThreeState.UNSURE
|
||||
if (children[2].tokenType !== XmlTokenType.XML_TAG_END)
|
||||
return ThreeState.UNSURE
|
||||
|
||||
val name = children[1] as LighterASTTokenNode
|
||||
val newName = name.text
|
||||
|
||||
if (!Comparing.equal(oldName, newName))
|
||||
return ThreeState.NO
|
||||
if (oldNode !is PsiNamedElement || oldNode.elementType !== XmlElementType.XML_TAG || newNode.tokenType !== XmlElementType.XML_TAG) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
|
||||
return ThreeState.UNSURE
|
||||
val oldName = oldNode.name
|
||||
val childrenRef = Ref.create<Array<LighterASTNode>>()
|
||||
val count = structure.getChildren(newNode, childrenRef)
|
||||
|
||||
if (count < 3) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
|
||||
val children = childrenRef.get()!!
|
||||
if (children[0].tokenType !== XmlTokenType.XML_START_TAG_START) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
if (children[1].tokenType !== XmlTokenType.XML_NAME) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
if (children[2].tokenType !== XmlTokenType.XML_TAG_END) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
|
||||
val name = children[1] as LighterASTTokenNode
|
||||
val newName = name.text
|
||||
|
||||
// note: oldName is String, newName is CharSequence, so plain kotlin `==` can't be used!
|
||||
if (Comparing.equal(oldName, newName)) {
|
||||
return ThreeState.UNSURE
|
||||
}
|
||||
|
||||
// different names => oldNode and newNode are not equal
|
||||
return ThreeState.NO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user