Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Add interface for complex LSInput #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

physikerwelt
Copy link

  • Limit the max depth to avoid being trapped in cycles

* Limit the max depth to avoid being trapped in cycles
Copy link
Collaborator

@zazi zazi left a comment

Choose a reason for hiding this comment

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

thanks a lot for the PR @physikerwelt. Albeit, it's a rather simple cycle check (I think it requires a proper logic to check for cycles instead of the recursion depth), I would welcome it, if you could make the value definition of MAX_RECURSION_DEPTH configurable via a parameter. So thanks again for your contribution.

@@ -76,6 +76,7 @@
//private static final XSImplementation impl = (XSImplementation) new XSImplementationImpl();

private static final XSLoader LOADER;
private static final int MAX_RECURSION_DEPTH = 7;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to provide this attribute/information via a parameter? - since, "7" seems to be rather arbitrary ;)

private Optional<JSElement> iterateElement(final XSElementDeclaration elementDecl) {

private Optional<JSElement> iterateElement(final XSElementDeclaration elementDecl, int depth) {
if(depth>MAX_RECURSION_DEPTH) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to make this check optional? or to set the default value for MAX_RECURSION_DEPTH to a higher value?

@zazi zazi self-assigned this May 2, 2018
@@ -242,7 +247,7 @@ else if (term instanceof XSModelGroupDefinition) {
}).orElseGet(() -> {
final JSObject jsElements = new JSObject(elementName, isMixed);
Copy link
Author

Choose a reason for hiding this comment

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

I looked into that deeper some time (until I figured out that I will be better off with parsing the rng file rather than the xsd file). In my second attempt I did drop the depth counter and installed bookkeeping for the jsobjects, here. The drawback of this approach is that it introduces state. Do you think that's a better way of fixing that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants