Search in sources :

Example 6 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project rstudio by rstudio.

the class RmdYamlData method getOffsetParseError.

// Returns the parse error, with the line number adjusted by the given 
// offset. 
public final String getOffsetParseError(int offsetline) {
    String error = getParseError();
    String lineRegex = "line (\\d+),";
    RegExp reg = RegExp.compile(lineRegex);
    MatchResult result = reg.exec(error);
    if (result == null || result.getGroupCount() < 2)
        return getParseError();
    else {
        Integer newLine = Integer.parseInt(result.getGroup(1)) + offsetline;
        return error.replaceAll(lineRegex, "line " + newLine.toString() + ",");
    }
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 7 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project rstudio by rstudio.

the class BreakpointManager method onConsoleWriteInput.

@Override
public void onConsoleWriteInput(ConsoleWriteInputEvent event) {
    // when a file is sourced, replay all the breakpoints in the file.
    RegExp sourceExp = RegExp.compile("source(.with.encoding)?\\('([^']*)'.*");
    MatchResult fileMatch = sourceExp.exec(event.getInput());
    if (fileMatch == null || fileMatch.getGroupCount() == 0) {
        return;
    }
    String path = FilePathUtils.normalizePath(fileMatch.getGroup(2), workbench_.getCurrentWorkingDir().getPath());
    resetBreakpointsInPath(path, true);
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 8 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project rstudio by rstudio.

the class NewConnectionSnippetHost method updateCodePanel.

private void updateCodePanel() {
    String input = info_.getSnippet();
    RegExp regExp = RegExp.compile(pattern_, "g");
    StringBuilder builder = new StringBuilder();
    int inputIndex = 0;
    for (MatchResult matcher = regExp.exec(input); matcher != null; matcher = regExp.exec(input)) {
        if (matcher.getGroupCount() >= 2) {
            String key = matcher.getGroup(2);
            String value = matcher.getGroupCount() >= 4 ? matcher.getGroup(4) : null;
            String connStringField = matcher.getGroupCount() >= 6 ? matcher.getGroup(6) : null;
            if (value != null) {
                value = value.replaceAll("\\$colon\\$", ":");
                value = value.replaceAll("\\$equal\\$", "=");
            }
            builder.append(input.substring(inputIndex, matcher.getIndex()));
            if (partsKeyValues_.containsKey(key)) {
                value = partsKeyValues_.get(key);
            }
            if (value != null) {
                if (connStringField != null) {
                    builder.append(connStringField);
                    builder.append("=");
                }
                builder.append(value);
                if (connStringField != null) {
                    builder.append(";");
                }
            }
            inputIndex = matcher.getIndex() + matcher.getGroup(0).length();
        }
    }
    builder.append(input.substring(inputIndex, input.length()));
    codePanel_.setCode(builder.toString(), "");
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 9 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project kie-wb-common by kiegroup.

the class SvgDataUriGenerator method removeUseTagsById.

private static String removeUseTagsById(final String content, final Predicate<String> isRemove) {
    String result = content;
    String temp = content;
    while (USE_TAG_REFID_PATTERN.test(temp)) {
        final MatchResult matchResult = USE_TAG_REFID_PATTERN.exec(temp);
        if (matchResult != null) {
            String id = matchResult.getGroup(1);
            if (isRemove.test(id)) {
                result = result.replace(matchResult.getGroup(0), "");
            }
            temp = temp.substring(matchResult.getIndex() + id.length());
        }
    }
    return result;
}
Also used : MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 10 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project ovirt-engine by oVirt.

the class ErrorTranslator method resolveMessage.

private String resolveMessage(String message, Map<String, LinkedList<String>> variables) {
    String returnValue = message;
    // $NON-NLS-1$ //$NON-NLS-2$
    RegExp regex = RegExp.compile(VARIABLE_PATTERN, "gi");
    MatchResult result;
    while (returnValue.length() > 0) {
        result = regex.exec(returnValue);
        if (result == null) {
            // No more matches
            break;
        }
        String match = result.getGroup(0);
        String key = match.substring(2, match.length() - 1);
        if (variables.containsKey(key)) {
            LinkedList<String> values = variables.get(key);
            String value = values.size() == 1 ? values.getFirst() : // $NON-NLS-1$
            values.size() > 1 ? values.removeFirst() : "";
            returnValue = returnValue.replace(match, value);
        } else {
            // infinite loop
            break;
        }
        // Make the next search start from the beginning
        regex.setLastIndex(0);
    }
    return returnValue;
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Aggregations

MatchResult (com.google.gwt.regexp.shared.MatchResult)47 RegExp (com.google.gwt.regexp.shared.RegExp)23 ArrayList (java.util.ArrayList)7 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)3 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Node (com.google.gwt.dom.client.Node)1 PreElement (com.google.gwt.dom.client.PreElement)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)1 ItemTexts (cz.metacentrum.perun.webgui.model.ItemTexts)1 AutoCompletionChoice (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)1 AutoCompletionResult (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionResult)1 EditorPosition (edu.stanford.bmir.gwtcodemirror.client.EditorPosition)1 CollectionId (edu.stanford.bmir.protege.web.shared.collection.CollectionId)1 CollectionItem (edu.stanford.bmir.protege.web.shared.collection.CollectionItem)1 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)1 GetUserIdCompletionsAction (edu.stanford.bmir.protege.web.shared.itemlist.GetUserIdCompletionsAction)1