| Summary: | [Testing API] Improve ParseHelper | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Christian Dietrich <christian.dietrich.opensource> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | sebastian.zarnekow |
| Version: | 2.0.0 | Flags: | sebastian.zarnekow:
indigo+
|
| Target Milestone: | SR2 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
A patch is welcome. (In reply to comment #1) > A patch is welcome. For clarification: The patch should introduce something like #parse(CharSequence, String uri, ResourceSet resourceSet) I don't like the idea of a 'global' resource set and the parse helper should be stateless. this seems to be already fixed. See last comment. Hi,
no i actually saw that
public T parse(CharSequence text, URI uriToUse, ResourceSet resourceSetToUse)
throws Exception {
return super.parse(getAsStream(text),uriToUse, null, resourceSetToUse);
}
is still missing
just copy and paste add this method.
~Christian
Pushed to master. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
Build Identifier: 2.0.0 With ParserHelper i have a nice and easy way to parse model files for tests. but the support for tests that include global scoping could be better e.g. @InjectWith(typeof(DomainmodelInjectorProvider)) @RunWith(typeof(XtextRunner)) class ParserTest { @Inject ParseHelper<Domainmodel> parser @Inject Provider<XtextResourceSet> resourceSetProvider @Test def void parseEmptyEntity() { val rs = resourceSetProvider.get val model = parser.parse( getAsStream("entity MyEntity {}"), URI::createURI("a.dmodel") , null,rs) val model2 = parser.parse( getAsStream("entity MyEntity2 extends MyEntity {}"),URI::createURI("b.dmodel") ,null, rs) val Entity entity = model.elements.head as Entity assertTrue(entity.features.isEmpty) val Entity entity2 = model2.elements.head as Entity println(entity2.superType.simpleName) } def InputStream getAsStream(CharSequence text) { new StringInputStream(text.toString) } } could be much easier if ParserHelper would offer a method public T parse(String content, String uriToUse, ResourceSet resourceSet); or even public T parse(String content, String uriToUse); with beeing a global resourceset beeing default Reproducible: Always