use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class AbstractNode method updateMapping.
private int updateMapping(int currentId, Map<EObject, Integer> grammarElementToIdMap, List<String> grammarIdToURIMap, EObject grammarElement) {
if (!grammarElementToIdMap.containsKey(grammarElement)) {
URI uri = EcoreUtil.getURI(grammarElement);
if (uri == null) {
throw new IllegalStateException("While building the map of grammar elements to an ID, " + "got a grammar element that does not have an URI. The " + "grammar element has class " + grammarElement.eClass().getName());
}
grammarElementToIdMap.put(grammarElement, currentId);
grammarIdToURIMap.add(uri.toString());
++currentId;
}
if (currentId != grammarIdToURIMap.size()) {
throw new IllegalStateException("The next id for a grammar element will be " + currentId + " but the number of elements in " + "the map of grammar elements to IDs contains a different number of elements: " + grammarIdToURIMap.size());
}
return currentId;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class EclipseProjectPropertiesEncodingProvider method getValue.
protected String getValue(Properties properties, URI resourceUri, String prefix) {
URI path = resourceUri;
do {
String value = properties.getProperty(prefix + path.path());
if (value != null)
return value;
path = path.trimSegments(1);
} while (path.segmentCount() > 0);
String value = properties.getProperty(prefix + PROJECT_PROPERTIES);
if (value != null)
return value;
return null;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class CrossReferenceSerializer method serializeCrossRef.
@Override
public String serializeCrossRef(EObject context, CrossReference grammarElement, final EObject target, INode node) {
final EReference ref = GrammarUtil.getReference(grammarElement, context.eClass());
String text = null;
if (node != null) {
List<EObject> objects = linkingService.getLinkedObjects(context, ref, node);
if (Iterables.any(objects, new Predicate<EObject>() {
private final URI targetURI = EcoreUtil.getURI(target);
@Override
public boolean apply(EObject input) {
return input == target || EcoreUtil.getURI(input).equals(targetURI);
}
}))
return ITokenSerializer.KEEP_VALUE_FROM_NODE_MODEL;
}
text = getUnconvertedLinkText(target, ref, context);
if (text != null)
return getConvertedValue(text, grammarElement);
if (node != null) {
return linkingHelper.getCrossRefNodeAsString(node, false);
}
return null;
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class ClassloaderClasspathUriResolver method findResourceOnClasspath.
public URI findResourceOnClasspath(ClassLoader classLoader, URI classpathUri) throws URISyntaxException {
String pathAsString = classpathUri.path();
if (classpathUri.hasAbsolutePath()) {
pathAsString = pathAsString.substring(1);
}
URL resource = classLoader.getResource(pathAsString);
if (resource == null)
throw new FileNotFoundOnClasspathException("Couldn't find resource on classpath. URI was '" + classpathUri + "'");
URI fileUri = URI.createURI(resource.toString(), true);
return fileUri.appendFragment(classpathUri.fragment());
}
use of org.eclipse.emf.common.util.URI in project xtext-core by eclipse.
the class DescriptionUtils method collectOutgoingReferences.
/**
* Collect the URIs of resources, that are referenced by the given description.
* @return the list of referenced URIs. Never <code>null</code>.
*/
public Set<URI> collectOutgoingReferences(IResourceDescription description) {
URI resourceURI = description.getURI();
Set<URI> result = null;
for (IReferenceDescription reference : description.getReferenceDescriptions()) {
URI targetResource = reference.getTargetEObjectUri().trimFragment();
if (!resourceURI.equals(targetResource)) {
if (result == null)
result = Sets.newHashSet(targetResource);
else
result.add(targetResource);
}
}
if (result != null)
return result;
return Collections.emptySet();
}
Aggregations