Package com.redcareditor.onig

Examples of com.redcareditor.onig.Match


    }
  }

  // this method is mainly for testing in the Ruby specs
  public static String testRank(String selector_a, String selector_b, String scope_string) {
    Match m1 = match(selector_a, scope_string);
    Match m2 = match(selector_b, scope_string);
    int r = compareMatch(scope_string, m1, m2);
    if (r > 0) {
      return selector_a;
    } else if (r == 0) {
      return selector_a + " == " + selector_b;
View Full Code Here


      return selector_b;
    }
  }

  public static boolean testMatch(String selectorString, String scopeString) {
    Match m = getMatch(selectorString, scopeString);
    return (m != null);
  }
View Full Code Here

    Match m = getMatch(selectorString, scopeString);
    return (m != null);
  }

  public static Match getMatch(String selectorString, String scopeString) {
    Match m = match(selectorString, scopeString);
    if (m != null) {
//      System.out.printf("%d\n", m.numCaptures());
      Range firstCapture = m.getCapture(0);
//      System.out.printf("test_match('%s', '%s') == %d\n", selectorString, scopeString, firstCapture.start);
    } else {
//      System.out.printf("test_match('%s', '%s') == null\n", selectorString, scopeString);
    }
    return m;
View Full Code Here

  }

  public static Match match(String selectorString, String scopeString) {
    List<ScopeMatcher> matchers = ScopeMatcher.compile(selectorString);
    for (ScopeMatcher matcher : matchers) {
      Match m;
      if ((m = testMatchRe(matcher.pos_rx, matcher.neg_rxs, scopeString)) != null)
        return m;
    }
    return null;
  }
View Full Code Here

    }
    return ms;
  }

  public static Match testMatchRe(Rx positiveSelectorRegex, List<Rx> negativeSelectorRegexes, String scopeString) {
    Match m = positiveSelectorRegex.search(scopeString, 0, scopeString.length());
    if (m != null) {
      for (Rx negRx : negativeSelectorRegexes) {
        Match m1 = negRx.search(scopeString, 0, scopeString.length());
        if (m1 != null) {
          return null;
        }
      }
      return m;
View Full Code Here

  public Rx makeClosingRegex(String line, Scope scope, Marker m) {
    if (m.pattern instanceof DoublePattern && !m.isCloseScope) {
      DoublePattern dp = (DoublePattern) m.pattern;
      // System.out.printf("making closing regex: %s\n", dp.endString);
      Rx rx = Rx.createRx("\\\\(\\d+)");
      Match match;
      int pos = 0;
      StringBuilder src = new StringBuilder("");
      boolean found = false;
      while ((match = rx.search(dp.endString, pos, (int) dp.endString.length())) != null) {
        found = true;
        src.append(dp.endString.substring(pos, match.getCapture(0).start));
        String numstr = dp.endString.substring(match.getCapture(1).start, match.getCapture(1).end);
        int num = Integer.parseInt(numstr);
        // System.out.printf("capture found: %d\n", num);
        String capstr = line.substring(m.match.getCapture(num).start, m.match.getCapture(num).end);
        src.append(Rx.escape(capstr));
        pos = match.getCapture(1).end;
      }
      if (found)
        src.append(dp.endString.substring(pos, dp.endString.length()));
      else
        src.append(dp.endString);
View Full Code Here

    }
  }
 
  public ThemeSetting findSetting(String hierarchyNames, boolean inner, ThemeSetting excludeSetting) {
    // collect matching ThemeSettings
    Match m;
    ArrayList<ThemeSetting> matchingThemeSettings = new ArrayList<ThemeSetting>();
    for (ThemeSetting setting : settings) {
      if (setting == excludeSetting && excludeSetting != null) {
      }
      else {
View Full Code Here

  public void compileScopeMatchers() {
    this.matchers = ScopeMatcher.compile(scopeSelector);
  }

  public Match match(String scope) {
    Match m;
    if (this.matchers == null)
      compileScopeMatchers();
   
    for (ScopeMatcher matcher : this.matchers) {
      if ((m = ScopeMatcher.testMatchRe(matcher.pos_rx, matcher.neg_rxs, scope)) != null)
View Full Code Here

  @Benchmark(times = 1000)
  public void benchmarkAllPatternsOnSingleLine() {
    String line = lines.get(8); // this line has a class definition on it
    for (SinglePattern p : singlePatterns) {
      Rx regex = p.match;
      Match m = regex.search(line);
            // if(m != null){
            //  System.out.println(p.name);
            //  System.out.println(m);
            // }
    }
View Full Code Here

  @Benchmark(times = 500)
  public void benchmarkAllPatternsOnFile() {
    for(String line : lines){
      for (SinglePattern p : singlePatterns) {
        Rx regex = p.match;
        Match m = regex.search(line);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.redcareditor.onig.Match

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.