Skip to content

Instantly share code, notes, and snippets.

@thombergs
Last active December 28, 2015 14:09
Show Gist options
  • Save thombergs/7512852 to your computer and use it in GitHub Desktop.
Save thombergs/7512852 to your computer and use it in GitHub Desktop.
public enum ParserState {
INITIAL {
@Override
public ParserState nextState(ParseWindow window) {
String line = window.getFocusLine();
if (matchesFromFilePattern(line)) {
logTransition(line, INITIAL, FROM_FILE);
return FROM_FILE;
} else {
logTransition(line, INITIAL, HEADER);
return HEADER;
}
}
}
// ... other states
public abstract ParserState nextState(ParseWindow window);
// ... other methods
}
public enum ParserState {
INITIAL,
HEADER,
FROM_FILE,
TO_FILE,
HUNK_START,
FROM_LINE,
TO_LINE,
NEUTRAL_LINE,
END;
}
HEADER: Modified: trunk/test.txt
HEADER: ===================================================================
FROM_FILE: --- /trunk/test.txt 2013-10-23 19:41:56 UTC (rev 46)
TO_FILE: +++ /trunk/test.txt 2013-10-23 19:44:39 UTC (rev 47)
HUNK_START: @@ -1,4 +1,3 @@
NEUTRAL_LINE: test1
FROM_LINE: -test1
TO_LINE: +test234
NEUTRAL_LINE:
FROM_LINE: -test1
NEUTRAL_LINE: \ No newline at end of file
HUNK_START: @@ -5,9 +6,10 @@
FROM_LINE: -test1
FROM_LINE: -test1
TO_LINE: +asdasd
TO_LINE: +asdasd
INITIAL -> HEADER: Modified: trunk/test.txt
HEADER -> HEADER: ===================================================================
HEADER -> FROM_FILE: --- /trunk/test.txt 2013-10-23 19:41:56 UTC (rev 46)
FROM_FILE -> TO_FILE: +++ /trunk/test.txt 2013-10-23 19:44:39 UTC (rev 47)
TO_FILE -> HUNK_START: @@ -1,4 +1,3 @@
HUNK_START -> NEUTRAL_LINE: test1
NEUTRAL_LINE -> FROM_LINE: -test1
FROM_LINE -> TO_LINE: +test234
TO_LINE -> NEUTRAL_LINE:
NEUTRAL_LINE -> FROM_LINE: -test1
FROM_LINE -> NEUTRAL_LINE: \ No newline at end of file
NEUTRAL_LINE -> HUNK_START: @@ -5,9 +6,10 @@
HUNK_START -> FROM_LINE: -test1
FROM_LINE -> FROM_LINE: -test1
FROM_LINE -> TO_LINE: +asdasd
TO_LINE -> TO_LINE: +asdasd
Modified: trunk/test.txt
===================================================================
--- /trunk/test.txt 2013-10-23 19:41:56 UTC (rev 46)
+++ /trunk/test.txt 2013-10-23 19:44:39 UTC (rev 47)
@@ -1,4 +1,3 @@
test1
-test1
+test234
-test1
\ No newline at end of file
@@ -5,9 +6,10 @@
-test1
-test1
+asdasd
+asdasd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment