SyntaxTools { protected static Set<String> parseShortInvokedMethods(String line) { Set<String> methods = Sets.newHashSet(); Set<String> blacklist = Sets.newHashSet("time", "date"); String regex = "\\b(?!" + StringUtils.join(blacklist, "|") + ")[\\w\\.]+\\("; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(line); while (matcher.find()) { if(!matcher.group().startsWith("concourse.")) { methods.add(matcher.group().replace("(", "")); } } return methods; } private  SyntaxTools(); static String handleMissingArgCommas(String line,
            List<String> methods); static String handleShortSyntax(String line, List<String> options);  }
@Test public void testParseSingleInvokedMethod() { Set<String> methods = SyntaxTools.parseShortInvokedMethods("foo()"); Assert.assertEquals(1, methods.size()); Assert.assertTrue(methods.contains("foo")); }
@Test public void testParseSingleInvokedConcourseMethod() { Set<String> methods = SyntaxTools .parseShortInvokedMethods("concourse.foo()"); Assert.assertEquals(0, methods.size()); Assert.assertFalse(methods.contains("concourse.foo")); }
@Test public void testParseNestedInvokvedMethods() { Set<String> methods = SyntaxTools .parseShortInvokedMethods("foo(bar(x))"); Assert.assertEquals(methods, Sets.newHashSet("foo", "bar")); }
@Test public void testParseSingleInvokedBlacklistedMethod() { Set<String> methods = SyntaxTools.parseShortInvokedMethods("time(x)"); Assert.assertEquals(0, methods.size()); Assert.assertFalse(methods.contains("time")); }
@Test public void testParseNestedInvokedBlacklistedMethod() { Set<String> methods = SyntaxTools .parseShortInvokedMethods("foo(time(x, y))"); Assert.assertEquals(methods, Sets.newHashSet("foo")); }
@Test public void testParseNestedInvokedConcourseMethod() { Set<String> methods = SyntaxTools .parseShortInvokedMethods("foo(concourse.bar(x, y))"); Assert.assertEquals(methods, Sets.newHashSet("foo")); }
@Test public void testParseNestedNestedInvokvedMethods() { Set<String> methods = SyntaxTools .parseShortInvokedMethods("foo(bar(x, baz(time(z))))"); Assert.assertEquals(methods, Sets.newHashSet("foo", "bar", "baz")); }