-
Notifications
You must be signed in to change notification settings - Fork 30
Implement document symbols for validations #283
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
Conversation
receiver = node.receiver | ||
return if receiver && !receiver.is_a?(Prism::SelfNode) | ||
|
||
message_value = node.message | ||
message = node.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message = node.message | |
message = T.must(node.message) |
then we can remove the T.must
s below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this one.
node.message
is nilable. Once we enter the switch-case, we know for sure that it's not nil
, but I don't think we can guarantee that before entering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged it without this, but we can fix this in the next PR based on your thoughts.
Although it began with #280, I'm now thinking more that we should have a visual distinction between macros and plain methods: |
(we could perhaps push for a |
One slight oddity: if you have multiple validations for one field, such as: validates :price, presence: true
validates :price,
numericality: { greater_than_or_equal_to: 0 }, Then you end up with multiple identical symbol entries.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried on large files in Core and didn't see any issues. As mentioned in the PR description, we'll need to do some refactoring afterwards to help separate the different aspects relating to symbols.
I agree, nothing in the set of symbols offered seems like a good fit. It is fairly easy to change down the road, so if something new is eventually released, it will be easy for us to change things. |
Yeah, it comes down to whether we leverage the additional arguments. I'm reflecting on this for the changes needed for relationships as well. For example, something like As you mentioned, I don't think it's optimal to leverage something like this for validations. If someone specifies many arguments, it'll introduce a lot of complexity. For each use case, we have to decide the benefits and costs of factoring in the arguments. |
ced1f6d
to
6a3ce32
Compare
f7135be
to
175b6f7
Compare
175b6f7
to
d349619
Compare
Implements document symbol for the various types of Rails validations.
The remaining dsl feature is relationships. Based on my experience in this PR, it looks like the manner in which we handle each type of dsl feature doesn't generalize particularly cleanly. Consequently, after all the features are implemented, we can then reflect on the appropriate abstraction. Abstracting before comprehensive feature completion might cause us to create abstractions that we have to later rectify.
For now, these changes are scoped to focus on implementing validations exclusively.