use of org.intellij.lang.regexp.psi.RegExpClosure in project intellij-community by JetBrains.
the class SimplifyQuantifierAction method invoke.
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
if (myReplacement == null) {
myQuantifier.delete();
} else {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final ASTNode modifier = myQuantifier.getModifier();
final PsiFile f = factory.createFileFromText("dummy.regexp", RegExpFileType.INSTANCE, "a" + myReplacement + (modifier != null ? modifier.getText() : ""));
final RegExpPattern pattern = PsiTreeUtil.getChildOfType(f, RegExpPattern.class);
assert pattern != null;
final RegExpClosure closure = (RegExpClosure) pattern.getBranches()[0].getAtoms()[0];
myQuantifier.replace(closure.getQuantifier());
}
}
Aggregations