NameDotTokenFilter implements TokenSource { @Override public Token nextToken() { if ((currentToken != null) && (currentToken.getType() == Token.EOF)) { return currentToken; } if (queue.isEmpty()) { fillHeap(); } ProToken tok = queue.poll(); if (tok != null) { currentToken = tok; } return currentToken; } NameDotTokenFilter(TokenSource source); @Override Token nextToken(); @Override int getLine(); @Override int getCharPositionInLine(); @Override CharStream getInputStream(); @Override String getSourceName(); @Override void setTokenFactory(TokenFactory<?> factory); @Override TokenFactory<?> getTokenFactory();  }
@Test public void testEmptyList() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); Token tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), Token.EOF); tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), Token.EOF); }
@Test public void testNoNameDot() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("message 'Hello'.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); Token tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), ABLNodeType.MESSAGE.getType()); tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), ABLNodeType.WS.getType()); tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), ABLNodeType.QSTRING.getType()); tok = filter.nextToken(); assertNotNull(tok); assertEquals(tok.getType(), ABLNodeType.PERIOD.getType()); }
@Test public void testNameDot00() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap(".Lang.Object.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.NAMEDOT); assertEquals(tok.getText(), "."); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ID); assertEquals(tok.getText(), "Lang.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); }
@Test public void testNameDot01() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("using Riverside.Lang.Object.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.USING); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.WS); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ID); assertEquals(tok.getText(), "Riverside.Lang.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.EOF_ANTLR4); }
@Test public void testNameDot02() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("using Progress.Lang.Object.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.USING); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.WS); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ID); assertEquals(tok.getText(), "Progress.Lang.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.EOF_ANTLR4); }
@Test public void testNameDot03() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("using Riverside.20190101.Object.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.USING); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.WS); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ID); assertEquals(tok.getText(), "Riverside.20190101.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.EOF_ANTLR4); }
@Test public void testNameDot04() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("using Riverside. 20190101.Object.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.USING); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.WS); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ID); assertEquals(tok.getText(), "Riverside.20190101.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.EOF_ANTLR4); }
@Test public void testAnnotation01() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("@Riverside.Lang.Object. MESSAGE 'foo'.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ANNOTATION); assertEquals(tok.getText(), "@Riverside.Lang.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.WS); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.MESSAGE); }
@Test public void testAnnotation02() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("@Riverside.20190101.Object. MESSAGE 'foo'.".getBytes()), "file.txt"); TokenSource filter = new NameDotTokenFilter(lexer.getTokenSource()); ProToken tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.ANNOTATION); assertEquals(tok.getText(), "@Riverside.20190101.Object"); tok = (ProToken) filter.nextToken(); assertNotNull(tok); assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); }