use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class BasicLazyLinkingTest method doGetResource.
@Override
public 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);
return resource;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class XtendHighlightingCalculatorTest method getResourceSet.
@Override
protected XtextResourceSet getResourceSet() {
XtextResourceSet result = super.getResourceSet();
result.setClasspathURIContext(getClass().getClassLoader());
return result;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method setUp.
@Before
public void setUp() {
try {
final File tempDir = this.temporaryFolder.newFolder();
JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
File _file = new File(tempDir, "foo");
FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
it_2.addSourceFolder("src");
};
return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
};
it.setProjectConfigProvider(_function_1);
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
it.setEncodingProvider(_runtime);
XtextResourceSet _xtextResourceSet = new XtextResourceSet();
it.setContext(_xtextResourceSet);
};
JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
this.fs = _doubleArrow;
this.createProject("foo");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class FormatterFacade method format.
public String format(final String xtendCode) {
try {
final XtextResourceSet resourceSet = new XtextResourceSet();
Resource _createResource = this.resourceFactory.createResource(URI.createURI("synthetic://to-be-formatted.xtend"));
final XtextResource resource = ((XtextResource) _createResource);
EList<Resource> _resources = resourceSet.getResources();
_resources.add(resource);
StringInputStream _stringInputStream = new StringInputStream(xtendCode);
resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
final ITextRegionAccess regionAccess = this.regionAccessBuilder.get().forNodeModel(resource).create();
FormatterRequest _formatterRequest = new FormatterRequest();
final Procedure1<FormatterRequest> _function = (FormatterRequest it) -> {
it.setAllowIdentityEdits(false);
it.setTextRegionAccess(regionAccess);
it.setPreferences(TypedPreferenceValues.castOrWrap(this.cfgProvider.getPreferenceValues(resource)));
};
FormatterRequest request = ObjectExtensions.<FormatterRequest>operator_doubleArrow(_formatterRequest, _function);
List<ITextReplacement> replacements = this.formatter.format(request);
return regionAccess.getRewriter().renderToString(replacements);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class JdtBasedProcessorProvider method getClassLoader.
@Override
public ClassLoader getClassLoader(final EObject ctx) {
ResourceSet _resourceSet = ctx.eResource().getResourceSet();
final XtextResourceSet rs = ((XtextResourceSet) _resourceSet);
final boolean isBuilder = ResourceSetContext.get(rs).isBuilder();
final boolean isEditor = ResourceSetContext.get(rs).isEditor();
if (isBuilder) {
final ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter adapter = IterableExtensions.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>head(Iterables.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>filter(rs.eAdapters(), ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter.class));
if ((adapter != null)) {
return adapter.getClassLoader();
}
}
if (isEditor) {
final ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter adapter_1 = IterableExtensions.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>head(Iterables.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>filter(this.getEditorResource(ctx).eAdapters(), ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter.class));
if ((adapter_1 != null)) {
ClassLoader _classLoader = adapter_1.getClassLoader();
boolean _tripleEquals = (_classLoader == null);
if (_tripleEquals) {
this.getEditorResource(ctx).eAdapters().remove(adapter_1);
} else {
return adapter_1.getClassLoader();
}
}
}
Object _classpathURIContext = rs.getClasspathURIContext();
final IJavaProject project = ((IJavaProject) _classpathURIContext);
final URLClassLoader classloader = this.createClassLoaderForJavaProject(project);
if (isBuilder) {
EList<Adapter> _eAdapters = rs.eAdapters();
ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter _processorClassloaderAdapter = new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(classloader);
_eAdapters.add(_processorClassloaderAdapter);
}
if (isEditor) {
EList<Adapter> _eAdapters_1 = this.getEditorResource(ctx).eAdapters();
ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter _processorClassloaderAdapter_1 = new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(classloader);
_eAdapters_1.add(_processorClassloaderAdapter_1);
}
return classloader;
}
Aggregations