Commit Graph

1693 Commits

Author SHA1 Message Date
Nikita Katkov
9dbc5b0a65 [json] Provide pretty json schema node text in case the node is an object
Previously used asText() method always returns empty string for object nodes, which makes using the readChildNode(..) API inconvenient. Currently, we use pretty rendered string here

GitOrigin-RevId: 4c22553db897e371d6013f8dd8a7be2aa782c431
2024-07-11 18:12:41 +00:00
Nikita Katkov
32456fa0df [json] Fallback to minimal supported json schema version in case no version was chosen
GitOrigin-RevId: 1c621748cbfd29540493dcfb3c0a81cdbe2c58db
2024-07-09 18:13:44 +00:00
Nikita Katkov
d524aec751 [json] IJPL-157406 Fix presentable schema version name
GitOrigin-RevId: 6ad3686198090f9ac42d49e9e1fae73181d7abaa
2024-07-08 18:53:35 +00:00
Tagir Valeev
d263e30396 Remove raw types in PopupStep#onChosen inheritors
GitOrigin-RevId: df36f1a249ab4d87c2d10e3d39c27f0351298921
2024-07-08 16:18:24 +00:00
Tagir Valeev
31b989d0cd Apply 'Copy of existing static method body' fixes
GitOrigin-RevId: 139c1d45abf749d40ec4e1c9004b16dea0b3a954
2024-07-05 19:36:03 +00:00
Yuriy Artamonov
bec6b53104 [json] IJPL-157746 JsonLiteralAnnotator is not part of API
GitOrigin-RevId: d124a9cecb37054d446ff098b826c22a6a1117e9
2024-07-03 21:37:18 +00:00
Yann Cébron
4504284ed9 [various] plugin descriptors: suppress "Invalid extension point name" warnings
we can't change existing names in a backwards-compatible way

GitOrigin-RevId: 46f8980842d90dd1aae3ce5a9a32dfd4afc30735
2024-07-03 20:24:32 +00:00
Anton Lobov
d9b7362258 [amper] fix completion item filtering with nested completion
GitOrigin-RevId: 2236a915064d994515d49481245875d5d0ef38d2
2024-07-02 14:18:33 +00:00
Anton Lobov
a75baa1bc6 [amper] fix context computation for code completion
GitOrigin-RevId: 22ea2d183f02a70c09c616b361205d889e9f6844
2024-07-01 18:34:28 +00:00
Nikita Katkov
86e193d79f [json] IJPL-156923 Cache element validity against a particular schema node to avoid double computation
With the introduction of if-then-else resolve that selects a branch depending on a given instance file element, the number of calls to JsonSchemaResolver.isCorrect method increased significantly. It is expected, as any validation/reference contribution/other editor features require a resolved schema node.

Resolve results are cached on language modification tracker because with the instance file updates, a previously valid if-else branch might become invalid

GitOrigin-RevId: f197203a3c53a7c4e7c1d502faaff3d50a9451e3
2024-06-27 18:54:11 +00:00
Anton Lobov
c58f381025 [json schema] support adding arbitrary metadata to schema elements and use that facility in amper for filtering of completion items
GitOrigin-RevId: 34d3641afeb2c2d3e6932d33f1e3c091b76e2205
2024-06-26 13:35:22 +00:00
Nikita Katkov
c7ef524aae [json] IJPL-157032 Disabled merging test
To fix it, we should make MatchResult store schemas in a set to avoid equal objects from being present in the resolve result. But this for some reason breaks ancient anyOf validation. The related code seems really hard to debug, so the merging test is currently disabled. The corresponding change is reverted in the previous commit.

GitOrigin-RevId: 08e7fd02cb6556044c3a80863bd29fa1d770155f
2024-06-24 00:51:36 +00:00
Nikita Katkov
30eb459a35 Revert "[json] IJPL-157032 Prefer storing resolved tree nodes in a set to avoid processing the effective same branches multiple times"
This reverts commit 14f06c419ff394383dd974da36c34da91b8c488a.

The change in the MatchResult cannot be used so far because ancient allOf/anyOf resolve relies on having several equal-by-pointer json schema objects in a collection.

GitOrigin-RevId: 48bda04351f25fd783d1e051bf61115876e0739e
2024-06-24 00:51:36 +00:00
Nikita Katkov
f587af6ada [json] IJPL-157032 Do not inherit required properties
Validation-related methods should not be inherited, only the methods providing access to the parent node should. Example: getPropertyByName

The reason: currently, every property step involves inheriting a parent's schema -> might result in incorrect validations applied to child nodes. A better fix would be to introduce inheritance strategy and inherit different options for if-then, one/any/allOf and other cases. See JsonSchema2020FeaturesTest#test adjacent if-then completion and comment for an example

GitOrigin-RevId: 3c3b790a2ee07529d7671a4f3d3866981926d75d
2024-06-24 00:51:36 +00:00
Nikita Katkov
b1d33aaa24 [json] IJPL-157032 Prefer storing resolved tree nodes in a set to avoid processing the effective same branches multiple times
GitOrigin-RevId: bc3af9a831c28cf6b9d9c7f46a1756987e90ef0a
2024-06-24 00:51:36 +00:00
Nikita Katkov
14c0629620 [json] IJPL-157032 Do not inherit hasPatternProperties check, they seem to be bound to the exact location
GitOrigin-RevId: 94cc427817cc74fe1b56ad20c5d5bc954b4471b1
2024-06-24 00:51:36 +00:00
Nikita Katkov
5723d5b61e [json] IJPL-157032 Do not forget to inherit schema objects in an array step just like in a property step
GitOrigin-RevId: 73ad3d09da2ffbeec94a6b1ce0bd77a242b4bdee
2024-06-24 00:51:36 +00:00
Nikita Katkov
962b3cc353 [json] IJPL-157032 Removed excessive inheritance from reference resolver
The resolved object will anyway be associated with the referenceOwner later during the propertyStep() method execution. There is no need to nest two inherited objects inside each other for no reason

GitOrigin-RevId: 8c1a9820d1e1eb976a2888998a44462287b309af
2024-06-24 00:51:36 +00:00
Nikita Katkov
9ad4797fbf [json] IJPL-157032 Implemented InheritedObjectView and specified which exactly methods should and should not be inherited
Inherited works as follows:
- it wraps parent and child JsonSchemaObjects
- it delegates composed schema access to child object (oneOf, anyOf, allOf, not, if-else)
- it combines other properties and prefers children's one if the property is present in both objects

This helps solve dynamicAnchor and dynamicRef problem where an anchor declared in a base schema could be overridden in the dependent one. References to the anchor must resolve to the overridden anchor location -> we have to keep track of both declarations via inheritance mechanics.

GitOrigin-RevId: f26f14735ff937326cd559ae05288d369477e1a6
2024-06-24 00:51:36 +00:00
Andrii Zinchenko
d4059839e2 [devcontainers] IJPL-67049: suggest to try Ultimate by devcontainer.json/.devcontainer.json file opening in the Editor
GitOrigin-RevId: 7744cd002a656e85b354697e4a49da718f5775e1
2024-06-21 13:45:33 +00:00
Tagir Valeev
be91af43bb [surrounder] Surrounder.surroundElements: remove declared unchecked exception (unnecessary and rarely thrown anyway)
GitOrigin-RevId: c8122acc2c3ee0d2bf78c70efb5525c54020fe70
2024-06-20 12:13:06 +00:00
Nikita Katkov
b29ca8a465 [json] IJPL-63554 Introduced new tests for the updated JSON schema versions support
- if-then-else tests for smart and basic completion with different resolve logic
- dynamic anchors with overridden values
- unevaluated properties
- prefix items
- dependent schemas
- various new validations tests
- yaml and json coverage

GitOrigin-RevId: 63ec3d8176ef368a8c80ebcd3687fb3732412df3
2024-06-18 20:26:11 +00:00
Nikita Katkov
41ccf9c452 [json] IJPL-63554 Resolve json schema node with explicitly provided PSI element to make it possible to process if-then-else schema expressions
All client calls of the resolver API were updated to make PSI-dependent resolve possible

GitOrigin-RevId: f0b1596048e0a73953f044d7cf391dea9e6a8feb
2024-06-18 20:26:11 +00:00
Nikita Katkov
4037d0676a [json] IJPL-63554 Attempted to support schema inheritance via existing MergedSchemaNode mechanics
- Inheritance plays a crucial role in dynamicRefs resolve and makes it possible to override the dynamicAnchor declared in the base schema and overridden in a dependent one

GitOrigin-RevId: a87c59be41eda46454e99e50fd9eec557cb7ebcd
2024-06-18 20:26:11 +00:00
Nikita Katkov
d74283cefe [json] IJPL-63554 Removed dedicated if-then-else completion in favor of new resolve mechanism capable of processing conditions too
GitOrigin-RevId: a00d00415ef2c6ac2c2d7b06fc029eab26bf0326
2024-06-18 20:26:11 +00:00
Nikita Katkov
59cc5d6e02 [json] IJPL-63554 Extracted schema validation collectors to a separate class
Now validations are provided by schema nodes themselves which sounds natural. Set of available validations highly depends on the node validation happens against.

GitOrigin-RevId: abfbdfda6025da5fff7b9b7670c7e9687cec4c9b
2024-06-18 20:26:11 +00:00
Nikita Katkov
b9979d9c4f [json] IJPL-63554 Refactored existing schema validators
- Some large methods were split into several
- Inspected value adapters were reused to ensure correct resolve
- Old incorrect if-else validation was removed in favor of if-else expansion; The idea is that after resolve there wouldn't be any if-then-else expressions to process - we have to resolve to some final json schema node in the end, where plain validations would work perfectly without some special treatment. This is now unified with other applicators like oneOf or referenced schema nodes

GitOrigin-RevId: 6ad07cc467965c039ff29184be6c94e3f33d8b01
2024-06-18 20:26:11 +00:00
Nikita Katkov
177d6969f6 [json] IJPL-63554 Reflected changes made to the resolve-tree during if-then-else operation in the sibling operations
Now all available expansion types require passing a resolve request that provides access to the inspected PSI element. Since operations may nest, all of them should transfer the initial element's-wrapping adapter into their children

GitOrigin-RevId: 489718014e5eb3e83da207fafbed357b4cf202fe
2024-06-18 20:26:11 +00:00
Nikita Katkov
37f0c8daa2 [json] IJPL-63554 Introduced the if-then-else resolve-tree building operation
To be able to work with if-else expressions met in the middle of the resolve path and to avoid various hacks related to inability to select the correct branch resulting frequently in incorrect validation results, the new IfThenElseBranchOperation is introduced.

It is responsible for choosing the right branch to resolve to and actually works during resolve phase, not during the resolved object consumption by any client extension like completion contributor or inspection.

To ensure correct branch selection, one must provide an inspected PSI element wrapper. Schema will try to process its content and select the branch depending on it. There is also a mode where all branches are considered valid - useful for completion purposes

GitOrigin-RevId: 103c7c0e97bebe1469e85b7b914be5264b4ca3af
2024-06-18 20:26:11 +00:00
Nikita Katkov
a8f366c941 [json] IJPL-63554 Made PsiWalker return the inspected KeyValue's key adapter if requested for the key PSI element
GitOrigin-RevId: 35e77e74a0200699bed9274adeb2341b423921d7
2024-06-18 20:26:11 +00:00
Nikita Katkov
4e9d6032c6 [json] IJPL-63554 Updated JsonSchemaAnnotatorChecker internal API
Now it accepts an inspected PSI element adapter required for in-schema resolve against a validated instance file. Expressions like if-then-else would benefit a lot from such an improvement

GitOrigin-RevId: cc1e986786a7d68ad4666319b05a6662037af243
2024-06-18 20:26:11 +00:00
Nikita Katkov
4a13cf76f8 [json] IJPL-63554 Updated JsonSchemaVersion enum
GitOrigin-RevId: 97b545b4f78a86bfd85f91fe49aa4c946cbe9603
2024-06-18 20:26:11 +00:00
Nikita Katkov
552be49571 [json] IJPL-63554 Schema version strategy implementation introduced
GitOrigin-RevId: 91b10795bc5f5bde3197e1f16a36da796a468a63
2024-06-18 20:26:11 +00:00
Nikita Katkov
34aaba39de [json] IJPL-63554 Minor importance utility methods added to support new schema features
GitOrigin-RevId: 28291a5474a8bc9763c5a514d0074b8a1f3dc9ab
2024-06-18 20:26:11 +00:00
Nikita Katkov
1350be015e [json] IJPL-63554 Made base schema node wrapper now delegates to the version strategy to provide its internal state to the client
All keywords and specific behavioural patterns like reference resolve are to be extracted to separate abstractions provided by strategy instance. Many of the properties remain the same between different schema versions, though it's worth to ensure equally looking method implementations -> each method asks strategy about how a particular feature should work in the selected schema version.

GitOrigin-RevId: b04398007e1862f96d4dab95b79b814f3e3f7df1
2024-06-18 20:26:11 +00:00
Nikita Katkov
209a45d994 [json] IJPL-63554 Made RootSchemaObject responsible for providing a strategy corresponding to the schema version
A strategy is an abstraction to store version-specific schema reading/validation/resolve logic. Since the schema is most likely specified in the top-level $schema property or manually per file, it is enough to have a single strategy instance for all nodes corresponding to the same physical schema file

GitOrigin-RevId: 9ab9acc0e54714b4da8025180f40b22f97d13666
2024-06-18 20:26:11 +00:00
Nikita Katkov
86809d001c [json] IJPL-63554 Introduced a bunch of new methods for the JsonSchemaObject api to support new schema formats
A minimal set of methods was added for the new features support, as well as some old signatures were updated to reflect the upcoming updates

GitOrigin-RevId: de66f9a354bf27b690be8fbd0fd092da0e406334
2024-06-18 20:26:11 +00:00
Nikita Katkov
55780a7d30 [json] IJPL-63554 Refactor json schema self provider
Removed strange looking schema determination by bundled file name, split presentable name and id, simplified code

GitOrigin-RevId: 92ffa6c906dcecf978321ab0b826df7b2bfe021f
2024-06-18 20:26:11 +00:00
Nikita Katkov
bf1cf0936f Rename .java to .kt
IJPL-63554

GitOrigin-RevId: 4e46b01ecfcc57c338edbc66121c47f397132406
2024-06-18 20:26:11 +00:00
Nikita Katkov
e9825c5666 [json] IJPL-63554 Bundle vocabularies for 2019 and 2020 schema versions
GitOrigin-RevId: ff4f1231043c4d1c7b8c1a9283f4367f38055f1c
2024-06-18 20:26:10 +00:00
Alexandr Trushev
1e4e505e16 IJPL-797 intellij.platform.editor review internal API
GitOrigin-RevId: 514591f43e57749b752d8399d08b2cfd79fb34ea
2024-06-17 22:06:02 +00:00
Anton Lobov
91b1e453f4 [json schema] nested completions - expand shorthands where applicable (cases like AMPER-301)
GitOrigin-RevId: 30bf8ff3cb8e4669eba2b72550bdf2820c6970ac
2024-06-13 10:51:59 +00:00
Anton Lobov
89ccd58e7b [json schema] nested completions - simplify property expansion
GitOrigin-RevId: ec3eeab7dec09635bdfa19fb860081c602a07de7
2024-06-13 10:51:59 +00:00
Anton Lobov
7bf3d1bbed [json schema] don't insert whitespace if it's already there
GitOrigin-RevId: cac960ad0a4029484f611a8200f98dc4969fd99d
2024-06-13 10:51:59 +00:00
Anton Lobov
5340653c50 [amper] expanding shorthand values and intentions as the first application of that
GitOrigin-RevId: 5fcdbca7efcc11bf9f7bf252ec0d7239c11d4d5b
2024-06-12 19:49:54 +00:00
Anton Lobov
49581b199c [json schema] nested completion refactoring - fix lookup items and re-query the leaf at caret in the handler
GitOrigin-RevId: 5ef144f8d895c5fdeb9a1354c1927ef84674a096
2024-06-11 17:45:27 +00:00
Anton Lobov
3fa9e2e014 [json schema] nested completion refactoring - add a test for the broken case of in between properties and fix it
GitOrigin-RevId: 80f79dbee93de3f498a7d5fb94094a2272659f1c
2024-06-11 17:45:27 +00:00
Anton Lobov
62c25769e3 [json schema] nested completion refactoring - fixes for amperlang
GitOrigin-RevId: 91f2663d289130939fb599851731e46e8f645862
2024-06-11 17:45:27 +00:00
Anton Lobov
659aa5bdbb [json schema] nested completion refactoring - properly compute parent object properties for pure json
GitOrigin-RevId: 9db35ff9e49172a4afefd2afcdc1932f5545b689
2024-06-11 17:45:27 +00:00
Anton Lobov
fa617a4e2d [json schema] nested completion refactoring - cleanup
GitOrigin-RevId: 9dd676ba681ca6a4a91d22db3a5cafb5b56a06fb
2024-06-11 17:45:27 +00:00