Skip to content

Commit

Permalink
basic support for pattern matching across multiple lines
Browse files Browse the repository at this point in the history
  • Loading branch information
corux committed May 26, 2013
1 parent 314ae42 commit 938e63f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/messageutils/SourceKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

import play.Play;

Expand Down Expand Up @@ -51,13 +52,24 @@ public static SourceKeys lookUp() {
File file = iterator.next();
List<String> lines = IOUtils.readLines(new FileReader(file));
int i = 0;
String prevLine = null;
for (String line : lines) {
List<String> keys = matcher.match(line);
if (keys.size() == 0 && !StringUtils.isBlank(prevLine)) {
keys = matcher.match(prevLine.trim() + line.trim());
}

for (String key : keys) {
String snippet = getSnippet(key, i, lines);
foundKeys.addKey(key, file, snippet, i);
}
i++;

if (keys.size() > 0) {
prevLine = null;
} else {
prevLine = line;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 938e63f

Please sign in to comment.