Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way of providing external instances without an existing file #782

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Jul 16, 2024

This adds a new interface InstanceProvider which can be used to provide custom instance "parsing", but without needing an actual file to be referenced by src. This makes it a lot easier to write tests for custom parsing (we don't need to deal with ReferenceManager) that don't actually care about the file in src, and will allow us to also provide instances without an underlying file.

What has been done to verify that this works as intended?

New tests.

Why is this the best possible solution? Were any other approaches considered?

We alternatively could have made FileInstanceParser implementations handle converting src to an actual file path, but this would have meant changing that interface and also duplicating a bunch of code that's currently shared.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

This just adds a new plugin interface, so there's not a lot of risk.

@@ -44,7 +44,7 @@ static Map<String, String> parseAttributes(String name) {
Map<String, String> attributes = new HashMap<>();
String[] words = name.split(" ");
for (String word : asList(words).subList(1, words.length)) {
String[] parts = word.split("(?<!\\))=(\"|')");
String[] parts = word.split("(?<!\\))=(\"|')", 2);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this problem when working on a related tests in Collect. Basically select1Dynamic did not work with nodeset expressions like instance('things')/root/item[property='value'] because it would split on the second =.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 That's a useful split signature I did not know about!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just discovered it myself!

@lognaturel lognaturel merged commit f829dc1 into getodk:master Jul 17, 2024
3 checks passed
@seadowg seadowg deleted the parsing-path branch July 17, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants