Search in sources :

Example 1 with InternalFlexer

use of org.eclipse.xtend.core.parser.InternalFlexer 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);
}
Also used : StringReader(java.io.StringReader) InternalFlexer(org.eclipse.xtend.core.parser.InternalFlexer) IOException(java.io.IOException) FollowElement(org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement)

Aggregations

IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 InternalFlexer (org.eclipse.xtend.core.parser.InternalFlexer)1 FollowElement (org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement)1