use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class ContentAssistContextFactory method computeCurrentModel.
protected Multimap<EObject, AbstractElement> computeCurrentModel(EObject currentModel, INode lastCompleteNode, Collection<AbstractElement> followElements) {
Multimap<EObject, AbstractElement> result = LinkedHashMultimap.create();
ICompositeNode currentParserNode = NodeModelUtils.getNode(currentModel);
if (currentParserNode == null) {
result.putAll(currentModel, followElements);
return result;
}
EObject currentGrammarElement = currentParserNode.getGrammarElement();
AbstractRule currentRule = getRule(currentGrammarElement);
for (AbstractElement grammarElement : followElements) {
AbstractRule rule = currentRule;
ICompositeNode loopParserNode = currentParserNode;
EObject loopLastGrammarElement = lastCompleteNode.getGrammarElement();
while (!canBeCalledAfter(rule, loopLastGrammarElement, lastCompleteNode.getText(), grammarElement) && loopParserNode.getParent() != null) {
loopLastGrammarElement = loopParserNode.getGrammarElement();
loopParserNode = loopParserNode.getParent();
while (loopParserNode.getGrammarElement() == null && loopParserNode.getParent() != null) loopParserNode = loopParserNode.getParent();
EObject loopGrammarElement = loopParserNode.getGrammarElement();
rule = getRule(loopGrammarElement);
}
EObject context = loopParserNode.getSemanticElement();
result.put(context, grammarElement);
}
return result;
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class XtextLinkingService method getLinkedMetaModel.
private List<EObject> getLinkedMetaModel(TypeRef context, EReference ref, ILeafNode text) throws IllegalNodeException {
final ICompositeNode parentNode = text.getParent();
BidiIterator<INode> iterator = parentNode.getChildren().iterator();
while (iterator.hasPrevious()) {
INode child = iterator.previous();
if (child instanceof ILeafNode) {
ILeafNode leaf = (ILeafNode) child;
if (text == leaf)
return super.getLinkedObjects(context, ref, text);
if (!(leaf.getGrammarElement() instanceof Keyword) && !leaf.isHidden()) {
IScope scope = getScope(context, ref);
return XtextMetamodelReferenceHelper.findBestMetamodelForType(context, text.getText(), leaf.getText(), scope);
}
}
}
return Collections.emptyList();
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class SyntacticSequencerTestLanguageSyntacticSequencer method emit_MandatoryManyTransition_KW1ParserRuleCall_1_p.
/**
* Syntax: KW1+
*/
@Override
protected void emit_MandatoryManyTransition_KW1ParserRuleCall_1_p(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
ICompositeNode node = (ICompositeNode) nodes.get(0);
acceptUnassignedDatatype(ga.getMandatoryManyTransitionAccess().getKW1ParserRuleCall_1(), "matched 4", node);
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class SyntacticSequencerTestLanguageSyntacticSequencer method emit_AlternativeTransition_KW1ParserRuleCall_1_0_or_Kw2Keyword_1_1.
/**
* Syntax: 'kw2' | KW1
*/
@Override
protected void emit_AlternativeTransition_KW1ParserRuleCall_1_0_or_Kw2Keyword_1_1(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
ICompositeNode node = (ICompositeNode) nodes.get(0);
acceptUnassignedDatatype(ga.getAlternativeTransitionAccess().getKW1ParserRuleCall_1_0(), "matched 5", node);
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class Bug250313Test method testDatatypeConversion_01.
@Test
public void testDatatypeConversion_01() throws Exception {
Model model = (Model) getModel("1 foo - bar");
assertEquals("str", model.getValue());
assertEquals("org.eclipse.xtext.valueconverter.Bug250313.Datatype", lexerRule);
assertTrue(node instanceof ICompositeNode);
assertEquals(6, Iterables.size(((ICompositeNode) node).getChildren()));
assertEquals("foo - bar", string);
assertEquals(1, convertCallCount);
}
Aggregations