fix: anyOf compare alternatives#32
Open
p-spacek wants to merge 10 commits into
Open
Conversation
p-spacek
commented
Oct 24, 2024
| let enumValueMatch = false; | ||
| for (const e of schema.enum) { | ||
| if (equals(val, e) || (callFromAutoComplete && isString(val) && isString(e) && val && e.startsWith(val))) { | ||
| if (equals(val, e) || isAutoCompleteEqualMaybe(callFromAutoComplete, node, val, e)) { |
Collaborator
Author
There was a problem hiding this comment.
null value is a good match in auto-completion
| } else if (compareResult === 0) { | ||
| } else if ( | ||
| compareResult === 0 || | ||
| ((node.value === null || node.type === 'null') && node.length === 0) // node with no value can match any schema potentially |
Collaborator
Author
There was a problem hiding this comment.
null yaml value is a good match for sub-schemas, similar to isAutoCompleteEqualMaybe for const and enums
| if ( | ||
| !maxOneMatch && | ||
| !subValidationResult.hasProblems() && | ||
| (!bestMatch.validationResult.hasProblems() || callFromAutoComplete) |
Collaborator
Author
There was a problem hiding this comment.
(!bestMatch.validationResult.hasProblems() || callFromAutoComplete) didn't solve the previous problem properly
problem was when the order of the subschemas in anyOf changed.
this previous fix allows 'issues' only on the previous bestMatch
| return bestMatch; | ||
| } | ||
|
|
||
| function mergeValidationMatches( |
Collaborator
Author
There was a problem hiding this comment.
only refactor - move to separate function, no functional change
| 18, | ||
| DiagnosticSeverity.Error, | ||
| 'yaml-schema: Package', | ||
| 'yaml-schema: Composer Package', |
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
The import from `prettier` includes support for all languages supported by Prettier. The `prettier/standalone` import only includes the core. The `prettier` export also points to `prettier/standalone` for the `browser` export condition. This means that with this change `yaml-language-server` has to load less code, leading to faster startup time. And depending on configuration, it may lead to smaller bundle sizes. Co-authored-by: Muthurajan Sivasubramanian <93245779+msivasubramaniaan@users.noreply.github.com>
* add function to calculate remainder for floats correctly without rounding errors and fix checking if a number is a multipleOf for floats * fix formatting * add unit test * rm copyright --------- Co-authored-by: Steinke, Rico <Rico.Steinke@vector.com> Co-authored-by: Muthurajan Sivasubramanian <93245779+msivasubramaniaan@users.noreply.github.com>
* added support for enum yes and no Signed-off-by: msivasubramaniaan <msivasub@redhat.com> * added support for enum yes and no Signed-off-by: msivasubramaniaan <msivasub@redhat.com> * added test case Signed-off-by: msivasubramaniaan <msivasub@redhat.com> * Quote were appended based on the yaml settings --------- Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
improve compare mechanism that should choose correct schema alternatives
What issues does this PR fix or reference?
fixes this issue redhat-developer#684
replces this PR redhat-developer#759
Is it tested? How?
added tests