use of org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement in project xtext-eclipse by eclipse.
the class Bug303200Test method testBug303200_02.
@Test
public void testBug303200_02() throws Exception {
Bug303200TestLanguageParser parser = get(Bug303200TestLanguageParser.class);
Collection<FollowElement> elements = parser.getFollowElements("function f() {", false);
for (FollowElement element : elements) {
recursiveTestFollowElements(parser, element);
}
}
use of org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement in project xtext-eclipse by eclipse.
the class Bug303200Test method testBug303200_01.
@Test
public void testBug303200_01() throws Exception {
Bug303200TestLanguageParser parser = get(Bug303200TestLanguageParser.class);
Collection<FollowElement> followElements = parser.getFollowElements("function f() {", false);
assertEquals(4, followElements.size());
}
use of org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement in project xtext-eclipse by eclipse.
the class Bug303200Test method recursiveTestFollowElements.
protected void recursiveTestFollowElements(Bug303200TestLanguageParser parser, FollowElement element) {
if (element.getLookAhead() > 1) {
Collection<FollowElement> elements = parser.getFollowElements(element);
for (FollowElement followElement : elements) {
assertTrue(followElement.getLookAhead() < element.getLookAhead());
recursiveTestFollowElements(parser, followElement);
}
}
}
use of org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement in project xtext-xtend by eclipse.
the class FlexerBasedContentAssistContextFactory method createContextsForLastCompleteNode.
@Override
protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
String currentNodePrefix = getPrefix(currentNode);
if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
InternalFlexer flexer = flexerFactory.createFlexer(new StringReader(currentNodePrefix));
try {
int token = flexer.advance();
if (token == Token.EOF) {
// error case - nothing could be parsed
return;
}
while (token != Token.EOF) {
if (isErrorToken(token))
return;
token = flexer.advance();
}
} catch (IOException e) {
log.error(e.getMessage(), e);
return;
}
}
String prefix = "";
Collection<FollowElement> followElements = parseFollowElements(completionOffset, strict);
// String completeInput = viewer.getDocument().get(0, completionOffset);
// Collection<FollowElement> followElements = parser.getFollowElements(completeInput, strict);
doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
use of org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement in project n4js by eclipse.
the class ContentAssistContextFactory method createContextsForLastCompleteNode.
@Override
protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
String currentNodePrefix = getPrefix(currentNode);
if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
lexer.setCharStream(new ANTLRStringStream(currentNodePrefix));
Token token = lexer.nextToken();
if (token == Token.EOF_TOKEN) {
// error case - nothing could be parsed
return;
}
while (token != Token.EOF_TOKEN) {
if (isErrorToken(token))
return;
token = lexer.nextToken();
}
}
String prefix = "";
Collection<FollowElement> followElements = getParser().getFollowElements(rootNode, 0, completionOffset, strict);
doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
Aggregations