use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class WorkspaceManager method doRead.
public <T extends Object> T doRead(final URI uri, final Function2<? super Document, ? super XtextResource, ? extends T> work) {
final URI resourceURI = uri.trimFragment();
final ProjectManager projectMnr = this.getProjectManager(resourceURI);
Resource _resource = null;
if (projectMnr != null) {
_resource = projectMnr.getResource(resourceURI);
}
final XtextResource resource = ((XtextResource) _resource);
if ((resource == null)) {
return work.apply(null, null);
}
Document doc = this.getDocument(resource);
Resource _resource_1 = projectMnr.getResource(resourceURI);
return work.apply(doc, ((XtextResource) _resource_1));
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class DocumentSymbolService method getDefinitions.
public List<? extends Location> getDefinitions(final XtextResource resource, final int offset, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) {
final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(resource, offset);
if ((element == null)) {
return CollectionLiterals.<Location>emptyList();
}
final ArrayList<Location> locations = CollectionLiterals.<Location>newArrayList();
final TargetURIs targetURIs = this.collectTargetURIs(element);
for (final URI targetURI : targetURIs) {
{
this.operationCanceledManager.checkCanceled(cancelIndicator);
final Procedure1<EObject> _function = (EObject obj) -> {
final Location location = this._documentExtensions.newLocation(obj);
if ((location != null)) {
locations.add(location);
}
};
this.doRead(resourceAccess, targetURI, _function);
}
}
return locations;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class TextDocumentChangeToString method getTitle.
protected String getTitle(IEmfResourceChange change) {
URI newUri = change.getNewURI();
URI oldURI = change.getOldURI();
if (oldURI == null && newUri == null) {
return "error, both URIs are null";
}
if (newUri == null) {
return "deleted " + oldURI;
}
if (oldURI == null) {
return "created " + newUri;
}
if (oldURI.equals(newUri)) {
return oldURI.toString();
}
return "renamed " + oldURI + " to " + newUri;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class EObjectSnapshotProvider method createEObjectSnapshots.
protected Map<EObject, IEObjectSnapshot> createEObjectSnapshots(Resource resource) {
Map<EObject, IEObjectSnapshot> result = Maps.newLinkedHashMap();
for (IEObjectDescription desc : descriptionProvider.getEObjectDescriptions(resource)) {
EObject obj = EcoreUtil.resolve(desc.getEObjectOrProxy(), resource);
EObjectSnapshot snapshot = getOrCreate(result, obj);
snapshot.descriptions.add(desc);
}
ResourceSet resourceSet = resource.getResourceSet();
IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(resourceSet);
URI uri = resource.getURI();
for (IResourceDescription desc : descriptions.getAllResourceDescriptions()) {
for (IReferenceDescription ref : desc.getReferenceDescriptions()) {
URI targetURI = ref.getTargetEObjectUri();
URI sourceEObjectUri = ref.getSourceEObjectUri();
EReference reference = ref.getEReference();
if (targetURI == null || sourceEObjectUri == null || reference == null) {
continue;
}
if (!uri.equals(targetURI.trimFragment())) {
continue;
}
EObject target = resource.getEObject(targetURI.fragment());
if (target == null || target.eIsProxy()) {
continue;
}
EObjectSnapshot snapshot = getOrCreate(result, target);
ReferenceSnapshot rd = new ReferenceSnapshot(sourceEObjectUri, snapshot, reference, ref.getIndexInList(), ref.getContainerEObjectURI());
snapshot.incomingReferences.add(rd);
}
}
return result;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class RecordingXtextResourceUpdater method toString.
@Override
public String toString() {
StringBuilder result = new StringBuilder(getClass().getSimpleName());
URI oldURI = getSnapshot().getURI();
URI newURI = getResource().getURI();
if (oldURI.equals(newURI)) {
result.append(" " + oldURI);
} else {
result.append(" " + oldURI + " -> " + newURI);
}
if (document != null) {
result.append("\n" + document);
}
return result.toString();
}
Aggregations