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() + ",");
}
}
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);
}
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(), "");
}
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;
}
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;
}
Aggregations