use of org.eclipse.xtext.parsetree.impl.commentAssociation.Element in project xtext-core by eclipse.
the class CommentAssociationTest method testCommentAssociationWithAction.
@Test
public void testCommentAssociationWithAction() throws Exception {
String textModel = "// comment pre x\n" + "element /* comment inside x */ x // comment post x\n" + "// comment pre y\n" + "parent /* comment inside y */ y // comment post y\n" + "// comment pre z\n" + "element z";
Model model = (Model) getModel(textModel);
Multimap<EObject, String> multimap = createModel2CommentMap(model);
EList<Element> elements = model.getElements();
Element y = elements.get(0);
Element x = y.getChild();
Element z = elements.get(1);
checkComments(multimap, x, "// comment pre x\n", "/* comment inside x */", "// comment post x\n");
checkComments(multimap, y, "// comment pre y\n", "/* comment inside y */", "// comment post y\n");
checkComments(multimap, z, "// comment pre z\n");
}
use of org.eclipse.xtext.parsetree.impl.commentAssociation.Element in project xtext-core by eclipse.
the class CommentAssociationTest method testCommentsAtEndOfFile.
@Test
public void testCommentsAtEndOfFile() throws Exception {
String textModel = "element x // comment post x\n";
Model model = (Model) getModel(textModel);
EList<Element> elements = model.getElements();
Element x = elements.get(0);
Element y = CommentAssociationFactory.eINSTANCE.createElement();
y.setName("y");
y.setChild(x);
Element z = CommentAssociationFactory.eINSTANCE.createElement();
z.setName("z");
model.getElements().add(y);
model.getElements().add(z);
String serialized = serialize(model);
assertEquals("element x // comment post x\nparent y element z", serialized);
}
use of org.eclipse.xtext.parsetree.impl.commentAssociation.Element in project xtext-core by eclipse.
the class CommentAssociationTest method testCommentAssociation.
@Test
public void testCommentAssociation() throws Exception {
String textModel = "element x // comment post x\n" + "// comment pre y\n" + "element /* comment inside y */ y // comment post y\n" + "// comment pre z\n" + "element z";
Model model = (Model) getModel(textModel);
Multimap<EObject, String> multimap = createModel2CommentMap(model);
EList<Element> elements = model.getElements();
Element x = elements.get(0);
Element y = elements.get(1);
Element z = elements.get(2);
checkComments(multimap, x, "// comment post x\n");
checkComments(multimap, y, "// comment pre y\n", "/* comment inside y */", "// comment post y\n");
checkComments(multimap, z, "// comment pre z\n");
}
use of org.eclipse.xtext.parsetree.impl.commentAssociation.Element in project xtext-core by eclipse.
the class ElementImpl method basicSetChild.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetChild(Element newChild, NotificationChain msgs) {
Element oldChild = child;
child = newChild;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CommentAssociationPackage.ELEMENT__CHILD, oldChild, newChild);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.xtext.parsetree.impl.commentAssociation.Element in project xtext-core by eclipse.
the class CommentAssociationTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == CommentAssociationPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case CommentAssociationPackage.ELEMENT:
if (rule == grammarAccess.getElementRule()) {
sequence_Element(context, (Element) semanticObject);
return;
} else if (action == grammarAccess.getElementAccess().getElementChildAction_2_0()) {
sequence_Element_Element_2_0(context, (Element) semanticObject);
return;
} else
break;
case CommentAssociationPackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations