public static bool IsMatch(Parser parser) { if (parser.CurrentInputElement.Data == ")" && parser.NextNonWhiteSpaceInputElement.Data == "{") { return true; } // Catches pattern like: public void checkSessionLock() throws MinecraftException if ( parser.CurrentInputElement.Data == ")" && parser.ForwardToken(1).Data == Keywords.Throws && parser.ForwardToken(2) is TokenInputElement && parser.ForwardToken(3).Data == "{") { return true; } var buffer = parser.GetBufferElements(); /* * TODO: A more correct way to solve this problem would be for the parser to be aware of its current context, * like if it's in the context of parsing a class, or being inside of a method. However, this is something * I only thought of in hindsight, so hopefully for now I can get away with doing it this way. * * By the way, without catching the abstract keyword, it was being mis-recognized as a simple statement. */ if ( ((parser.CurrentInputElement.Data == ")" && parser.NextNonWhiteSpaceInputElement.Data == ";") || (parser.CurrentInputElement.Data == "." && parser.PreviousNonWhiteSpaceInputElement.Data == ")")) && buffer.Any(x => x.Data == Keywords.Abstract)) { return true; } return false; }
public static bool IsSimpleStatement(Parser parser) { return (parser.CurrentInputElement.Data == ")" && parser.NextNonWhiteSpaceInputElement.Data == ";") || (parser.CurrentInputElement.Data == "." && parser.PreviousNonWhiteSpaceInputElement.Data == ")"); //Chained function calls, like: task().doWithTask(); }