use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class SyntacticSequencerPDAProviderNavigatorTest method getParserRule.
protected ISynAbsorberState getParserRule(String body, String name, String typeName) throws Exception {
Grammar grammar = (Grammar) getModel(HEADER + body);
// SyntacticSequencerPDA2SimpleDot.drawGrammar("pdf/" + getName(),
// grammar);
// SyntacticSequencerPDA2ExtendedDot.drawGrammar(createSequenceParserPDAProvider(),
// "pdf/" + getName(), grammar);
ISyntacticSequencerPDAProvider pdaProvider = get(ISyntacticSequencerPDAProvider.class);
SerializationContextMap<ISynAbsorberState> pdas = pdaProvider.getSyntacticSequencerPDAs(grammar);
for (SerializationContextMap.Entry<ISynAbsorberState> e : pdas.sortedCopy().values()) {
for (ISerializationContext context : e.getContexts()) {
if (context.getAssignedAction() != null)
continue;
ISynAbsorberState pda = e.getValue();
ParserRule rule = context.getParserRule();
EClass type = context.getType();
boolean nameMatches = rule == null || name == null || rule.getName().equals(name);
boolean typeMatches = type == null || typeName == null || typeName.equals(type.getName());
if (nameMatches && typeMatches)
return pda;
}
}
throw new IllegalStateException();
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class NodeModelUtilsTest method testFindActualSemanticObjectFor_11.
@Test
public void testFindActualSemanticObjectFor_11() throws Exception {
String grammarString = "grammar foo.Bar with org.eclipse.xtext.common.Terminals generate foo 'bar' Model<Param>:name=ID;";
Grammar grammar = (Grammar) getModel(grammarString);
ILeafNode lessThan = NodeModelUtils.findLeafNodeAtOffset(NodeModelUtils.getNode(grammar), grammarString.indexOf("<"));
EObject object = NodeModelUtils.findActualSemanticObjectFor(lessThan);
assertTrue(object instanceof ParserRule);
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class NodeModelUtilsTest method testFindActualNode_02.
@Test
public void testFindActualNode_02() throws Exception {
String grammarString = "grammar foo.Bar with org.eclipse.xtext.common.Terminals generate foo 'bar' Model<Param>:name=ID;";
Grammar grammar = (Grammar) getModel(grammarString);
ParserRule rule = (ParserRule) grammar.getRules().get(0);
ICompositeNode node = NodeModelUtils.findActualNodeFor(rule);
assertEquals(" Model<Param>:name=ID;", node.getText());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class PartialParserTest method preserveEntryParserRuleOnFullyReparse1.
@Test
public void preserveEntryParserRuleOnFullyReparse1() throws Exception {
with(ReferenceGrammarTestLanguageStandaloneSetupGenerated.class);
ParserRule rule = get(ReferenceGrammarTestLanguageGrammarAccess.class).getKindRule();
String model = "kind (Fritz 12)";
checkFullReparse(rule, model);
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class ComplexReconstrTest method testPrintGrammar.
@Test
public void testPrintGrammar() {
XtextResourceSet rs = get(XtextResourceSet.class);
rs.setClasspathURIContext(getClass());
URI u = URI.createURI("classpath:/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTestLanguage.xtextbin");
EObject o = rs.getResource(u, true).getContents().get(0);
for (Object x : o.eContents()) if (x instanceof ParserRule) {
ParserRule pr = (ParserRule) x;
if (pr.getName().toLowerCase().contains("tricky")) {
if (logger.isTraceEnabled())
logger.trace(EmfFormatter.objToStr(pr));
}
}
}
Aggregations