WI-51002 Fetch all RegExpClassElement children as class elements instead of manually peeking by tokens

To not miss potential candidates like RegExpPosixBracketExpression

GitOrigin-RevId: f37553a211a5dc78163301e52f1f058852e03472
This commit is contained in:
Kirill Smelov
2021-08-04 09:59:57 +03:00
committed by intellij-monorepo-bot
parent aad83a3f2e
commit 4b8afb79ff
2 changed files with 6 additions and 10 deletions

View File

@@ -44,6 +44,4 @@ public interface RegExpElementTypes {
TokenSet ATOMS = TokenSet.create(CLOSURE, BOUNDARY, SIMPLE_CLASS, CLASS, CHAR, GROUP, PROPERTY, BACKREF, NAMED_GROUP_REF,
CONDITIONAL, NAMED_CHARACTER, SET_OPTIONS);
TokenSet CLASS_ELEMENTS = TokenSet.create(CHAR, CHAR_RANGE, SIMPLE_CLASS, CLASS, INTERSECTION, PROPERTY);
}

View File

@@ -16,7 +16,7 @@
package org.intellij.lang.regexp.psi.impl;
import com.intellij.lang.ASTNode;
import org.intellij.lang.regexp.RegExpElementTypes;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.RegExpClass;
import org.intellij.lang.regexp.psi.RegExpClassElement;
@@ -25,6 +25,8 @@ import org.jetbrains.annotations.NotNull;
public class RegExpClassImpl extends RegExpElementImpl implements RegExpClass {
private static final RegExpClassElement[] EMPTY_CHILDREN = new RegExpClassElement[0];
public RegExpClassImpl(ASTNode astNode) {
super(astNode);
}
@@ -37,12 +39,8 @@ public class RegExpClassImpl extends RegExpElementImpl implements RegExpClass {
@Override
public RegExpClassElement @NotNull [] getElements() {
final ASTNode[] nodes = getNode().getChildren(RegExpElementTypes.CLASS_ELEMENTS);
final RegExpClassElement[] e = new RegExpClassElement[nodes.length];
for (int i = 0; i < e.length; i++) {
e[i] = (RegExpClassElement)nodes[i].getPsi();
}
return e;
RegExpClassElement[] children = PsiTreeUtil.getChildrenOfType(this, RegExpClassElement.class);
return children != null ? children : EMPTY_CHILDREN;
}
@Override