void (RegExpPattern pattern) { final RegExpBranch[] branches = pattern.getBranches(); if (branches.length < 2) { return; } boolean emptyBranchSeen = false; for (int i = 0; i < branches.length; i++) { final RegExpBranch branch = branches[i]; if (branch.getAtoms().length > 0) { continue; } if (i == 0) { // empty branch at beginning allowed emptyBranchSeen = true; continue; } if (!emptyBranchSeen && i == branches.length - 1) { // empty branch at end allowed, if no empty branch at beginning continue; } myHolder.registerProblem(branch.getPrevSibling(), RegExpBundle.message("inspection.warning.empty.branch.in.alternation"), new EmptyAlternationBranchFix()); } }