use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class UriBasedReader method setClasspathURIContext.
public void setClasspathURIContext(Object class1) {
final XtextResourceSet resourceSet = new XtextResourceSet();
resourceSet.setClasspathURIContext(class1);
setResourceSetProvider(new Provider<ResourceSet>() {
@Override
public ResourceSet get() {
return resourceSet;
}
});
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class UriBasedReader method invokeInternal.
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
ResourceSet resourceSet = getResourceSet();
for (URI uri : uris2) {
Resource resource = resourceSet.getResource(uri, true);
int numberResources;
do {
numberResources = resourceSet.getResources().size();
EcoreUtil.resolveAll(resource);
} while (numberResources != resourceSet.getResources().size());
}
getValidator().validate(resourceSet, getRegistry(), issues);
addModelElementsToContext(ctx, resourceSet);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ResourceSetGlobalScopeProvider method getScope.
@Override
protected IScope getScope(Resource resource, boolean ignoreCase, EClass type, Predicate<IEObjectDescription> filter) {
IScope parent = IScope.NULLSCOPE;
if (resource == null || resource.getResourceSet() == null)
return parent;
final ResourceSet resourceSet = resource.getResourceSet();
if (resourceSet instanceof ResourceSetReferencingResourceSet) {
ResourceSetReferencingResourceSet set = (ResourceSetReferencingResourceSet) resourceSet;
Iterable<ResourceSet> referencedSets = Lists.reverse(set.getReferencedResourceSets());
for (ResourceSet referencedSet : referencedSets) {
parent = createScopeWithQualifiedNames(parent, resource, filter, referencedSet, type, ignoreCase);
}
}
return createScopeWithQualifiedNames(parent, resource, filter, resourceSet, type, ignoreCase);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class EcoreUtil2 method isValidUri.
/**
* checks whether the given URI can be loaded given the context. I.e. there's a resource set with a corresponding
* resource factory and the physical resource exists.
*/
public static boolean isValidUri(Resource resource, URI uri) {
if (uri == null || uri.isEmpty()) {
return false;
}
URI newURI = getResolvedImportUri(resource, uri);
try {
ResourceSet resourceSet = resource.getResourceSet();
if (resourceSet.getResource(uri, false) != null)
return true;
URIConverter uriConverter = resourceSet.getURIConverter();
URI normalized = uriConverter.normalize(newURI);
if (normalized != null)
// fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=326760
if ("platform".equals(normalized.scheme()) && !normalized.isPlatform())
return false;
return uriConverter.exists(normalized, Collections.emptyMap());
} catch (RuntimeException e) {
// thrown by org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean)
log.trace("Cannot load resource: " + newURI, e);
}
return false;
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ValidatorFragment2 method generateValidationToDeprecateRules.
protected StringConcatenationClient generateValidationToDeprecateRules() {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
{
if (ValidatorFragment2.this.generateDeprecationValidation) {
{
List<AbstractRule> _deprecatedRulesFromGrammar = ValidatorFragment2.this.getDeprecatedRulesFromGrammar();
for (final AbstractRule deprecatedRule : _deprecatedRulesFromGrammar) {
EClassifier _classifier = deprecatedRule.getType().getClassifier();
ResourceSet _resourceSet = ValidatorFragment2.this.getGrammar().eResource().getResourceSet();
final TypeReference elementType = new TypeReference(((EClass) _classifier), _resourceSet);
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("@");
_builder.append(Check.class);
_builder.newLineIfNotEmpty();
_builder.append("public void checkDeprecated");
String _simpleName = elementType.getSimpleName();
_builder.append(_simpleName);
_builder.append("(");
_builder.append(elementType);
_builder.append(" element) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("warning(\"This part of the language is marked as deprecated and might get removed in the future!\", element, null);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
}
}
}
}
};
return _client;
}
Aggregations