Search in sources :

Example 21 with Match

use of org.rstudio.core.client.regex.Match in project rstudio by rstudio.

the class RoxygenHelper method listParametersInRoxygenBlock.

private JsArrayString listParametersInRoxygenBlock(JsArrayString block, Pattern pattern) {
    JsArrayString roxygenParams = JsArrayString.createArray().cast();
    for (int i = 0; i < block.length(); i++) {
        String line = block.get(i);
        Match match = pattern.match(line, 0);
        if (match != null)
            roxygenParams.push(match.getGroup(1));
    }
    return roxygenParams;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) Match(org.rstudio.core.client.regex.Match)

Example 22 with Match

use of org.rstudio.core.client.regex.Match in project rstudio by rstudio.

the class RTokenizer method peek.

private String peek(String regex) {
    Match match = Pattern.create(regex).match(data_, pos_);
    if (match == null)
        return null;
    int idx = match.getIndex();
    if (idx != pos_)
        return null;
    return match.getValue();
}
Also used : Match(org.rstudio.core.client.regex.Match)

Example 23 with Match

use of org.rstudio.core.client.regex.Match in project rstudio by rstudio.

the class Link method removeHost.

/**
    * If the URL has the same scheme, hostname, and port as the current page,
    * then drop them from the URL.
    *
    * For example,
    *    http://rstudio.com/help/base/ls
    * becomes
    *    /help/base/ls
    */
private String removeHost(String url) {
    String pageUrl = Document.get().getURL();
    Pattern p = Pattern.create("^http(s?)://[^/]+");
    Match m = p.match(pageUrl, 0);
    if (m == null) {
        assert false : "Couldn't parse page URL: " + url;
        return url;
    }
    String prefix = m.getValue();
    if (!url.startsWith(prefix))
        return url;
    else
        return url.substring(prefix.length());
}
Also used : Pattern(org.rstudio.core.client.regex.Pattern) Match(org.rstudio.core.client.regex.Match)

Example 24 with Match

use of org.rstudio.core.client.regex.Match in project rstudio by rstudio.

the class RequestLogEntry method getRequestMethodName.

public String getRequestMethodName() {
    if (requestData_.equals("[REDACTED]"))
        return requestData_;
    Pattern p = Pattern.create("\\\"method\\\":\\s*\\\"([^\"]+)\\\"");
    Match match = p.match(requestData_, 0);
    if (match == null)
        return null;
    return match.getGroup(1);
}
Also used : Pattern(org.rstudio.core.client.regex.Pattern) Match(org.rstudio.core.client.regex.Match)

Example 25 with Match

use of org.rstudio.core.client.regex.Match in project rstudio by rstudio.

the class DomUtils method countLinesInternal.

private static int countLinesInternal(Text textNode, boolean pre) {
    if (!pre)
        return 0;
    String value = textNode.getData();
    Pattern pattern = Pattern.create("\\n");
    int count = 0;
    Match m = pattern.match(value, 0);
    while (m != null) {
        count++;
        m = m.nextMatch();
    }
    return count;
}
Also used : Pattern(org.rstudio.core.client.regex.Pattern) JsArrayString(com.google.gwt.core.client.JsArrayString) Point(org.rstudio.core.client.Point) Match(org.rstudio.core.client.regex.Match)

Aggregations

Match (org.rstudio.core.client.regex.Match)33 Pattern (org.rstudio.core.client.regex.Pattern)22 JsArrayString (com.google.gwt.core.client.JsArrayString)10 ArrayList (java.util.ArrayList)5 Point (org.rstudio.core.client.Point)3 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)2 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)2 JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)1 Iterator (java.util.Iterator)1 Pair (org.rstudio.core.client.Pair)1 TextCursor (org.rstudio.core.client.TextCursor)1 ReplaceOperation (org.rstudio.core.client.regex.Pattern.ReplaceOperation)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)1 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)1