Class RegexTreeHelper

java.lang.Object
org.sonar.java.checks.helpers.RegexTreeHelper

public class RegexTreeHelper extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canReachWithoutConsumingInput(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal)
     
    static boolean
    canReachWithoutConsumingInputOrGoingThroughBoundaries(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start, org.sonarsource.analyzer.commons.regex.ast.AutomatonState goal)
     
    getGraphemeInList(List<? extends org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement> trees)
     
    static boolean
    intersects(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 boolean
    isAnchoredAtEnd(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start)
     
    static boolean
    isEndBoundary(org.sonarsource.analyzer.commons.regex.ast.AutomatonState state)
     
    static boolean
    onlyMatchesEmptySuffix(org.sonarsource.analyzer.commons.regex.ast.AutomatonState start)
     
    static boolean
    supersetOf(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static boolean intersects(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. 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

      public static boolean supersetOf(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.
    • 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)