This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
/
InternalParserTest.java
54 lines (47 loc) · 2.36 KB
/
InternalParserTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*******************************************************************************
* Copyright (c) 2009, 2016 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.ide.tests.editor.contentassist.antlr.internal;
import static org.junit.Assert.*;
import java.util.Set;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.RecognitionException;
import org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement;
import org.eclipse.xtext.ide.editor.contentassist.antlr.ObservableXtextTokenStream;
import org.eclipse.xtext.ide.tests.editor.contentassist.antlr.AbstractParserTest;
import org.eclipse.xtext.testlanguages.xtextgrammar.ide.contentassist.antlr.internal.InternalXtextGrammarTestLanguageLexer;
import org.eclipse.xtext.testlanguages.xtextgrammar.ide.contentassist.antlr.internal.InternalXtextGrammarTestLanguageParser;
import org.junit.Test;
/**
* @author Sebastian Zarnekow - Initial contribution and API
*/
public class InternalParserTest extends AbstractParserTest {
protected InternalXtextGrammarTestLanguageParser createParser(String input) {
CharStream stream = new ANTLRStringStream(input);
InternalXtextGrammarTestLanguageLexer lexer = new InternalXtextGrammarTestLanguageLexer(stream);
InternalXtextGrammarTestLanguageParser result = new InternalXtextGrammarTestLanguageParser(null);
ObservableXtextTokenStream tokenStream = new ObservableXtextTokenStream(lexer, result);
tokenStream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT");
tokenStream.setListener(result);
result.setGrammarAccess(grammarAccess);
result.setTokenStream(tokenStream);
return result;
}
@Test
public void testSetup() {
String input = "";
InternalXtextGrammarTestLanguageParser parser = createParser(input);
assertNotNull(parser);
}
@Override
protected Set<FollowElement> getFollowSet(String input) throws RecognitionException {
InternalXtextGrammarTestLanguageParser parser = createParser(input);
parser.entryRuleGrammar();
return parser.getFollowElements();
}
}