org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement Java Examples
The following examples show how to use
org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 6 votes |
private ObservableXtextTokenStream toTokenStream(FollowElement element, ITokenDefProvider tokenDefProvider) { Iterator<LookAheadTerminal> iter = element.getLookAheadTerminals().iterator(); return new ObservableXtextTokenStream(new TokenSource() { @Override public Token nextToken() { if (iter.hasNext()) { LookAheadTerminal lookAhead = iter.next(); return lookAhead.getToken(); } return Token.EOF_TOKEN; } @Override public String getSourceName() { return "LookAheadTerminalTokenSource"; } }, tokenDefProvider); }
Example #2
Source File: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 6 votes |
private AbstractInternalContentAssistParser createParser(AbstractElement parseMe, FollowElement baseFollowElement) { AbstractInternalContentAssistParser parser = createParser(); parser.setUnorderedGroupHelper(getUnorderedGroupHelper().get()); parser.getUnorderedGroupHelper().initializeWith(parser); ObservableXtextTokenStream tokens = toTokenStream(baseFollowElement, parser); parser.setTokenStream(tokens); tokens.setListener(parser); parser.getGrammarElements().addAll(baseFollowElement.getTrace()); parser.getGrammarElements().add(parseMe); parser.getLocalTrace().addAll(baseFollowElement.getLocalTrace()); parser.getLocalTrace().add(parseMe); parser.getParamStack().addAll(baseFollowElement.getParamStack()); if (parseMe instanceof UnorderedGroup && baseFollowElement.getGrammarElement() == parseMe) { UnorderedGroup group = (UnorderedGroup) parseMe; final IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper(); helper.enter(group); for (AbstractElement consumed : baseFollowElement.getHandledUnorderedGroupElements()) { parser.before(consumed); helper.select(group, group.getElements().indexOf(consumed)); helper.returnFromSelection(group); parser.after(consumed); } parser.setUnorderedGroupHelper(wrap(helper)); } return parser; }
Example #3
Source File: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public Collection<FollowElement> getFollowElements(FollowElement element) { try (Measurement m = dataCollectors.dcParseFollowElements().getMeasurement()) { if (element.getLookAhead() <= 1) throw new IllegalArgumentException("lookahead may not be less than or equal to 1"); Collection<FollowElement> result = new ArrayList<>(); Collection<AbstractElement> elementsToParse = getElementsToParse(element); for (AbstractElement elementToParse : elementsToParse) { // fix is here elementToParse = unwrapSingleElementGroups(elementToParse); // done collectFollowElements(elementToParse, element, result); } return result; } }
Example #4
Source File: FlexerBasedContentAssistContextFactory.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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); }
Example #5
Source File: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * First pass. Use the tokens that have been computed from the production parser's result and collect the follow * elements from those. */ private CustomInternalN4JSParser collectFollowElements( TokenSource tokens, AbstractElement grammarElement, String ruleName, boolean strict, Set<FollowElement> result) { CustomInternalN4JSParser parser = createParser(); parser.setStrict(strict); try { if (grammarElement != null) parser.getGrammarElements().add(grammarElement); ObservableXtextTokenStream tokenStream = new ObservableXtextTokenStream(tokens, parser); result.addAll(doGetFollowElements(parser, tokenStream, ruleName)); } catch (InfiniteRecursion infinite) { // this guards against erroneous infinite recovery loops in Antlr. // Grammar dependent and not expected something that is expected for N4JS // is used in the base class thus also used here. result.addAll(parser.getFollowElements()); } return parser; }
Example #6
Source File: EntryRuleContentAssistParser.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (entryRule == null) return super.getFollowElements(parser); try { Method method = parser.getClass().getMethod(ENTRY_RULE + entryRule); method.invoke(parser); return parser.getFollowElements(); } catch (Exception ex) { throw new RuntimeException(ex); } }
Example #7
Source File: PartialXtextGrammarTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #8
Source File: PartialSARLContentAssistParser.java From sarl with Apache License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #9
Source File: PartialGamlContentAssistParser.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #10
Source File: PartialXtextContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #11
Source File: PartialHelloWorldContentAssistParser.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #12
Source File: PartialNestedRefsTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #13
Source File: PartialNoJdtTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #14
Source File: PartialPartialSerializationTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #15
Source File: PartialRenameTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #16
Source File: PartialIndentationAwareUiTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #17
Source File: PartialPartialContentAssistTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #18
Source File: Bug281198ParserTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private Set<AbstractElement> computeSearchElements(Collection<FollowElement> followSet) { return Sets.newHashSet( Iterables.transform(followSet, new Function<FollowElement, AbstractElement>(){ @Override public AbstractElement apply(FollowElement from) { return from.getGrammarElement(); } })); }
Example #19
Source File: PartialTestLanguageContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #20
Source File: AbstractParserTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private Set<AbstractElement> computeSearchElements(Collection<FollowElement> followSet) { return Sets.newHashSet( Iterables.transform(followSet, new Function<FollowElement, AbstractElement>(){ @Override public AbstractElement apply(FollowElement from) { return from.getGrammarElement(); } })); }
Example #21
Source File: AbstractParserTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void assertFollowers(String input, Set<AbstractElement> expected) throws RecognitionException { Collection<FollowElement> followSet = getFollowSet(input); // Collection<FollowElement> followList = com.google.common.collect.Lists.newArrayList(getFollowSet(input)); assertEquals(expected.size(), followSet.size()); Set<AbstractElement> grammarElements = computeSearchElements(followSet); // Collection<AbstractElement> followElementList = com.google.common.collect.Lists.newArrayList(grammarElements); assertEquals(expected, grammarElements); }
Example #22
Source File: PartialXtendContentAssistParser.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #23
Source File: PartialCodetemplatesContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #24
Source File: PartialBuilderTestLanguageContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #25
Source File: PartialArithmeticsContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #26
Source File: PartialRuleEngineContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #27
Source File: PartialStatemachineContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #28
Source File: PartialDomainmodelContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #29
Source File: PartialEcore2XtextTestContentAssistParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) { if (rule == null || rule.eIsProxy()) return Collections.emptyList(); String methodName = "entryRule" + rule.getName(); PolymorphicDispatcher<Collection<FollowElement>> dispatcher = new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser)); dispatcher.invoke(); return parser.getFollowElements(); }
Example #30
Source File: Bug281198ParserTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void assertFollowers(String input, Set<AbstractElement> expected) { Collection<FollowElement> followSet = getFollowSet(input); // Collection<FollowElement> followList = com.google.common.collect.Lists.newArrayList(getFollowSet(input)); assertEquals(expected.size(), followSet.size()); Set<AbstractElement> grammarElements = computeSearchElements(followSet); assertEquals(grammarElements.toString(), expected, grammarElements); }