use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class XtextResourceSetBasedProjectProvider method getJavaProject.
@Override
public IJavaProject getJavaProject(ResourceSet resourceSet) {
if (resourceSet instanceof XtextResourceSet) {
XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet;
Object context = xtextResourceSet.getClasspathURIContext();
if (context instanceof IJavaProject)
return (IJavaProject) context;
}
return null;
}
use of org.eclipse.xtext.resource.XtextResourceSet 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.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class AbstractXbaseContentAssistBugTest method initializeTypeProvider.
protected void initializeTypeProvider(final XtextResource result) {
ResourceSet _resourceSet = result.getResourceSet();
final XtextResourceSet resourceSet = ((XtextResourceSet) _resourceSet);
final JdtTypeProviderFactory typeProviderFactory = new JdtTypeProviderFactory(this);
typeProviderFactory.findOrCreateTypeProvider(resourceSet);
resourceSet.setClasspathURIContext(this.getJavaProject(resourceSet));
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class CompilationTestHelper method unLoadedResourceSet.
/**
* same as {@link #resourceSet(Pair...)} but without actually loading the created resources.
*/
@SuppressWarnings("unchecked")
public ResourceSet unLoadedResourceSet(Pair<String, ? extends CharSequence>... resources) throws IOException {
XtextResourceSet result = resourceSetProvider.get();
for (Pair<String, ? extends CharSequence> entry : resources) {
URI uri = copyToWorkspace(getSourceFolderPath() + "/" + entry.getKey(), entry.getValue());
Resource resource = result.createResource(uri);
if (resource == null)
throw new IllegalStateException("Couldn't create resource for URI " + uri + ". Resource.Factory not registered?");
}
return result;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class AbstractXbaseContentAssistTest method getResourceSet.
protected final XtextResourceSet getResourceSet() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
typeProviderFactory.findOrCreateTypeProvider(resourceSet);
resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
return resourceSet;
}
Aggregations