use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-xtend by eclipse.
the class AbstractSmokeTest method createResource.
protected LazyLinkingResource createResource(final String model) throws IOException {
if (logger.isTraceEnabled()) {
logger.trace("createResource: " + model);
}
XtextResourceSet set = getResourceSet();
typeProviderFactory.findOrCreateTypeProvider(set);
LazyLinkingResource resource = (LazyLinkingResource) resourceFactory.createResource(URI.createURI("Test.xtend"));
set.getResources().add(resource);
resource.load(new StringInputStream(model), null);
resource.resolveLazyCrossReferences(CancelIndicator.NullImpl);
return resource;
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-xtend by eclipse.
the class AbstractSmokeTest method testSkipNodesInBetween.
@Test
public void testSkipNodesInBetween() throws Exception {
for (String string : smokeTestModels) {
LazyLinkingResource resource = createResource(string);
ICompositeNode rootNode = resource.getParseResult().getRootNode();
ReplaceRegion replaceRegion = null;
for (INode node : rootNode.getAsTreeIterable()) {
int offset = node.getTotalOffset();
int length = node.getTotalLength();
if (replaceRegion == null || replaceRegion.getOffset() != offset || replaceRegion.getLength() != length) {
replaceRegion = new ReplaceRegion(offset, length, "");
StringBuilder builder = new StringBuilder(string);
replaceRegion.applyTo(builder);
doParseAndCheckForSmoke(builder.toString());
}
}
}
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-eclipse by eclipse.
the class AbstractSmokeTest method testSkipNodesInBetweenWithoutResourceSet.
@Test
public void testSkipNodesInBetweenWithoutResourceSet() throws Exception {
for (String string : getSmokeTestModels()) {
LazyLinkingResource resource = createResource(string);
if (resource != null) {
ICompositeNode rootNode = resource.getParseResult().getRootNode();
ReplaceRegion replaceRegion = null;
for (INode node : rootNode.getAsTreeIterable()) {
int offset = node.getTotalOffset();
int length = node.getTotalLength();
if (replaceRegion == null || replaceRegion.getOffset() != offset || replaceRegion.getLength() != length) {
replaceRegion = new ReplaceRegion(offset, length, "");
StringBuilder builder = new StringBuilder(string);
replaceRegion.applyTo(builder);
processModelWithoutResourceSet(builder.toString());
}
}
}
}
}
Aggregations