Package org.sonar.java.checks.helpers
Class RegexTreeHelper
java.lang.Object
org.sonar.java.checks.helpers.RegexTreeHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanReachWithoutConsumingInput(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal) static booleancanReachWithoutConsumingInputOrGoingThroughBoundaries(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal) static List<RegexCheck.RegexIssueLocation>getGraphemeInList(List<? extends org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement> trees) static booleanintersects(SubAutomaton auto1, SubAutomaton auto2, boolean defaultAnswer) If both sub-automata have allowPrefix set to true, this method will check whether auto1 intersects the prefix of auto2 or auto2 intersects the prefix of auto1.static booleanisAnchoredAtEnd(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start) static booleanisEndBoundary(org.sonarsource.analyzer.commons.regex.ast.AutomatonState state) static booleanonlyMatchesEmptySuffix(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start) static booleansupersetOf(SubAutomaton auto1, SubAutomaton auto2, boolean defaultAnswer) Here auto2.allowPrefix means that if supersetOf(auto1, auto2), then for every string matched by auto2, auto1 can match a prefix of it auto1.allowPrefix means that if supersetOf(auto1, auto2), then for every string matched by auto2, auto1 can match a continuation of it If both are set, it means either one can be the case.
-
Method Details
-
getGraphemeInList
public static List<RegexCheck.RegexIssueLocation> getGraphemeInList(List<? extends org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement> trees) -
canReachWithoutConsumingInput
public static boolean canReachWithoutConsumingInput(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal) -
canReachWithoutConsumingInputOrGoingThroughBoundaries
public static boolean canReachWithoutConsumingInputOrGoingThroughBoundaries(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal) -
intersects
If both sub-automata have allowPrefix set to true, this method will check whether auto1 intersects the prefix of auto2 or auto2 intersects the prefix of auto1. This is different than checking whether the prefix of auto1 intersects the prefix of auto2 (which would always be true because both prefix always contain the empty string). defaultAnswer will be returned in case of unsupported features or the state limit is exceeded. It should be whichever answer does not lead to an issue being reported to avoid false positives. -
supersetOf
Here auto2.allowPrefix means that if supersetOf(auto1, auto2), then for every string matched by auto2, auto1 can match a prefix of it auto1.allowPrefix means that if supersetOf(auto1, auto2), then for every string matched by auto2, auto1 can match a continuation of it If both are set, it means either one can be the case. -
isAnchoredAtEnd
public static boolean isAnchoredAtEnd(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start) -
isEndBoundary
public static boolean isEndBoundary(org.sonarsource.analyzer.commons.regex.ast.AutomatonState state) -
onlyMatchesEmptySuffix
public static boolean onlyMatchesEmptySuffix(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start)
-