use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-eclipse by eclipse.
the class AbstractSmokeTest method testSkipNodesInBetween.
@Test
public void testSkipNodesInBetween() 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);
processModel(builder.toString());
}
}
}
}
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-eclipse by eclipse.
the class AbstractXtextTests method doGetResource.
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
rs.setClasspathURIContext(getClass());
XtextResource resource = (XtextResource) getResourceFactory().createResource(uri);
rs.getResources().add(resource);
resource.load(in, null);
if (resource instanceof LazyLinkingResource) {
((LazyLinkingResource) resource).resolveLazyCrossReferences(CancelIndicator.NullImpl);
} else {
EcoreUtil.resolveAll(resource);
}
return resource;
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-core by eclipse.
the class AbstractXtextTests method doGetResource.
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
rs.setClasspathURIContext(getClasspathURIContext());
XtextResource resource = (XtextResource) getResourceFactory().createResource(uri);
rs.getResources().add(resource);
resource.load(in, null);
if (resource instanceof LazyLinkingResource) {
((LazyLinkingResource) resource).resolveLazyCrossReferences(CancelIndicator.NullImpl);
} else {
EcoreUtil.resolveAll(resource);
}
return resource;
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project xtext-core by eclipse.
the class AbstractCleaningLinker method beforeModelLinked.
protected void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
Resource resource = model.eResource();
if (resource instanceof LazyLinkingResource) {
((LazyLinkingResource) resource).clearLazyProxyInformation();
}
ImportedNamesAdapter adapter = ImportedNamesAdapter.find(resource);
if (adapter != null)
adapter.clear();
}
use of org.eclipse.xtext.linking.lazy.LazyLinkingResource in project statecharts by Yakindu.
the class RenameElementHandler method findElementForFakeInStatechart.
private NamedElement findElementForFakeInStatechart(NamedElement fakeElement) {
Resource resource = fakeElement.eResource();
// only do something if element is really from fake resource
if (resource instanceof LazyLinkingResource) {
Statechart sct = getStatechartFromFakeResource((LazyLinkingResource) resource);
EList<Scope> scopes = sct.getScopes();
for (Scope scope : scopes) {
// check all declarations
EList<Declaration> declarations = scope.getDeclarations();
for (Declaration decl : declarations) {
if (decl.eClass().getName().equals(fakeElement.eClass().getName()) && decl.getName().equals(fakeElement.getName())) {
return decl;
}
}
// check scope itself it is a named one
if (scope instanceof NamedElement) {
NamedElement namedScope = (NamedElement) scope;
if (namedScope.eClass().getName().equals(fakeElement.eClass().getName()) && namedScope.getName().equals(fakeElement.getName())) {
return namedScope;
}
}
}
}
return fakeElement;
}
Aggregations