-
-
Notifications
You must be signed in to change notification settings - Fork 165
Add new Pin::FactoryParameter #1063
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
Open
lekemula
wants to merge
13
commits into
castwide:master
Choose a base branch
from
lekemula:factory-parameters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9275d16
Add new Pin::FactoryParameter
lekemula 48a3e36
Implement find definition for factory parameter
lekemula 3f3c8ff
Fix require defintions
lekemula 8a98091
Some rubocop formatting fixes
lekemula 91e05fd
RSpec enable --next-failure
lekemula 3ef5215
Index factory parameter pins
lekemula 61c2532
[WIP] Fix Clip#define for FactoryParameter
lekemula e0f13be
Fix duplicate FactoryParam in index
lekemula 516d7fe
Fix return_value nil error
lekemula c22af84
Fix string values not included in literal.value
lekemula 4d3616f
Refactor - remove redundant if branching
lekemula 48f3d08
Fix NoMethodError:undefined method `contain?' for nil
lekemula 9610eb0
Linting fixes
lekemula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Solargraph | ||
| module Pin | ||
| # A method parameter with a literal value used in a factory method. | ||
| # | ||
| # @example | ||
| # RSpec.shared_examples 'some examples' | ||
| # | ||
| # FactoryParameter.new( | ||
| # method_name: 'shared_examples', | ||
| # method_namespace: 'RSpec', | ||
| # method_scope: :class, | ||
| # param_name: 'name', | ||
| # value: 'some examples', | ||
| # decl: :arg, | ||
| # return_type: 'void' | ||
| # ) | ||
| class FactoryParameter < Base | ||
|
Contributor
Author
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. Open to other naming suggestions! |
||
| # @return [String] | ||
| attr_reader :method_name | ||
| # @return [String] | ||
| attr_reader :method_namespace | ||
| # @return [Symbol] :class or :instance | ||
| attr_reader :method_scope | ||
| # @return [String, nil] | ||
| attr_reader :param_name | ||
| # @return [::String, ::Symbol] The literal value | ||
| attr_reader :value | ||
| # @return decl [::Symbol] :arg, :optarg, :kwarg, :kwoptarg, :restarg, :kwrestarg, :block, :blockarg | ||
| attr_reader :decl | ||
| # @return [Location, nil] | ||
| attr_reader :location | ||
|
|
||
| # @param method_name [String] The name of the method that this parameter belongs to | ||
| # @param method_namespace [String] The class of the method that this parameter belongs to | ||
| # @param method_scope [Symbol] The scope of the method, either :class or :instance | ||
| # @param param_name [String, nil] The name of the parameter | ||
| # @param value [String, Symbol] The value of the parameter | ||
| # @param decl [::Symbol] :arg, :kwarg | ||
| # @param location [Location, nil] The location of the parameter in the source code | ||
| # @param return_type [String, nil] The return type of the method that this parameter belongs to | ||
| def initialize method_name:, | ||
| method_namespace:, | ||
| method_scope:, | ||
| param_name:, | ||
| value:, | ||
| return_type:, | ||
| decl: :arg, | ||
| location: nil | ||
| super(location: location) | ||
| @method_name = method_name | ||
| @method_namespace = method_namespace | ||
| @method_scope = method_scope | ||
| @param_name = param_name | ||
| @value = value | ||
| @decl = decl | ||
| @return_type = return_type | ||
| end | ||
|
|
||
| def name | ||
| param_name | ||
| end | ||
|
|
||
| def text_documentation | ||
| "#{method_path}(#{param_name}) = #{value.inspect}" | ||
| end | ||
|
|
||
| # @return [String] | ||
| def method_path | ||
| # @sg-ignore false failure on method_scope "Wrong argument type for Solargraph::Pin::Base#==: other expected | ||
| # Solargraph::Pin::Base, received :instance" | ||
| @method_path ||= "#{method_namespace}#{method_scope == :instance ? '#' : '.'}#{method_name}" | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def inner_desc | ||
| "method_path=#{method_path}, value=#{value.inspect}, decl=#{decl.inspect}, " \ | ||
| "return_type=#{return_type&.to_s || 'nil'}" | ||
| end | ||
| end | ||
| end | ||
| end | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Initially, I wanted to make this work as a chain of:
method_call > parameter; however, I struggled to find a good way to pass the last method call resolution to theChain::Parameteras a context here:solargraph/lib/solargraph/source/chain.rb
Lines 108 to 133 in 48f3d08
So I ended up with
parameter(method_call_chain).Maybe I don't understand the
Pin::ProxyTypewell enough, so if you have a suggestion on how to make it work, I'd be more than happy to refactor this into an "appropriate chain".