eclipse-xtext / eclipse-xtext/xtext
InMemoryFileSystemAccess creates weird paths
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
When I call
var fsa = new InMemoryFileSystemAccess
fsa.generateFile("foo", "...")
the resulting path in fsa.textFiles is "DEFAULT_OUTPUTfoo", which looks pretty weird. I think it would be better to insert a separator after the output configuration name, i.e. "DEFAULT_OUTPUT/foo".
In addition, I found that there is a class org.eclipse.xtext.junit4.util.InMemoryURIConverter, but it is unrelated to InMemoryFileSystemAccess. I created one for my tests as follows:
@Accessors(NONE)
class InMemoryURIConverter extends ExtensibleURIConverterImpl
{
val InMemoryFileSystemAccess fileSystemAccess
override boolean exists(URI uri, Map<?, ?> options)
{
fileSystemAccess.isFile(uri.convert)
}
override InputStream createInputStream(URI uri, Map<?, ?> options)
{
fileSystemAccess.readBinaryFile(uri.convert)
}
def String convert(URI uri)
{
val path = Path.fromPortableString(uri.path)
if (uri.scheme == "memory" && path.segment(0) == "DEFAULT_OUTPUT")
"/" + path.removeFirstSegments(1).toPortableString
else
throw new IllegalArgumentException("Bad URI for InMemoryURIConverter: " + uri)
}
}
Obviously, this only handles the default output configuration. I think this might be useful for others as well and be included with xtext, but it might need to be generalized to support any output configuration.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with InMemoryFileSystemAccess.generateFile and inspect how its output configuration name is combined with the generated file path in fsa.textFiles. Confirm the expected separator behavior, then review the existing org.eclipse.xtext.junit4.util.InMemoryURIConverter and the proposed converter to determine whether support for arbitrary output configurations belongs here; done means the path is correctly formed and the converter scope is settled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100