Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 278
Migrate semantic highlighting to YARP#1000
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| # typed: strict | ||||||
| # frozen_string_literal: true | ||||||
| module RubyLsp | ||||||
| class ParameterScope | ||||||
| extend T::Sig | ||||||
| sig { returns(T.nilable(ParameterScope)) } | ||||||
| attr_reader :parent | ||||||
| sig { params(parent: T.nilable(ParameterScope)).void } | ||||||
| def initialize(parent = nil) | ||||||
| @parent = parent | ||||||
| @parameters = T.let(Set.new, T::Set[Symbol]) | ||||||
| end | ||||||
| sig { params(name: T.any(String, Symbol)).void } | ||||||
| def <<(name) | ||||||
| @parameters << name.to_sym | ||||||
| end | ||||||
| sig { params(name: T.any(Symbol, String)).returns(Symbol) } | ||||||
| def type_for(name) | ||||||
| parameter?(name) ? :parameter : :variable | ||||||
| end | ||||||
| sig { params(name: T.any(Symbol, String)).returns(T::Boolean) } | ||||||
| def parameter?(name) | ||||||
| sym = name.to_sym | ||||||
| @parameters.include?(sym) || (!@parent.nil? && @parent.parameter?(sym)) | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That fails typechecking because instead of returning | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
(nit) Since the only places where we don't pass an argument is in the tests, might it simplify things a little to make this a required parameter?
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.
We don't pass an argument when we instantiate it for the first time in
SemanticHighlighting#initialize. It would also not be correct to always require a parent given that the global scope doesn't have one.