-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to RubyVM::AbstractSyntaxTree parsing
- Should improve the performance (castwide/solargraph#522 (comment)) - Reuse existing AST tree from solargraph and avoid redundant parsing - Required for making type inference work Squashed commit of the following: commit 42f0ace Author: Lekë Mula <[email protected]> Date: Sun May 19 20:59:02 2024 +0200 Remove redundant code Parsing commit 35ca92f Author: Lekë Mula <[email protected]> Date: Sun May 19 20:47:35 2024 +0200 Suppress SyntaxError from RubyVM in SpecWalker commit 99a4736 Author: Lekë Mula <[email protected]> Date: Sun May 19 19:57:25 2024 +0200 Refactor specs and add more unhappy paths commit f33e74e Author: Lekë Mula <[email protected]> Date: Sun May 19 19:39:39 2024 +0200 Refactor SpecWalker - extract sub-classes into own files commit daf2cd6 Author: Lekë Mula <[email protected]> Date: Sun May 19 19:32:04 2024 +0200 Rename RubyVMSpecWalker to SpecWalker commit 555ad9d Author: Lekë Mula <[email protected]> Date: Sun May 19 19:23:05 2024 +0200 Replace Util with PinFactory commit e55ce29 Author: Lekë Mula <[email protected]> Date: Sun May 19 18:35:29 2024 +0200 Don't pass AST nodes into correctors commit 102ac76 Author: Lekë Mula <[email protected]> Date: Sun May 19 18:13:30 2024 +0200 Remove old SpecWalker commit 3235e89 Author: Lekë Mula <[email protected]> Date: Sun May 19 18:10:04 2024 +0200 Adapt ExampleAndHookBlocksBindingCorrector with RubyVM commit e359861 Author: Lekë Mula <[email protected]> Date: Sun May 19 17:44:23 2024 +0200 Adapt SubjectMethodCorrector with RubyVM commit cddb93f Author: Lekë Mula <[email protected]> Date: Sun May 19 17:19:15 2024 +0200 Adapt LetMethodsCorrector with RubyVM commit 541f4df Author: Lekë Mula <[email protected]> Date: Sun May 19 16:43:15 2024 +0200 Adapt DescribedClassCorrector with RubyVM commit 66ff1ca Author: Lekë Mula <[email protected]> Date: Sun May 19 15:53:20 2024 +0200 Adapt ContextBlockNamespaceCorrector with RubyVM commit f5e6046 Author: Lekë Mula <[email protected]> Date: Thu May 16 17:56:02 2024 +0200 Implement RubyVMSpecWalker#on_described_class Last one for REAL! commit 982914b Author: Lekë Mula <[email protected]> Date: Thu May 16 17:38:35 2024 +0200 Implement RubyVMSpecWalker#on_blocks_in_examples Last hook! commit 080f9e6 Author: Lekë Mula <[email protected]> Date: Thu May 16 17:22:05 2024 +0200 Implement RubyVMSpecWalker#on_hook_block commit 4e8e662 Author: Lekë Mula <[email protected]> Date: Thu May 16 16:57:16 2024 +0200 Implement RubyVMSpecWalker#on_example_block commit badd097 Author: Lekë Mula <[email protected]> Date: Thu May 16 16:34:32 2024 +0200 Implement RubyVMSpecWalker#on_let_method commit 74ba354 Author: Lekë Mula <[email protected]> Date: Thu May 16 16:10:40 2024 +0200 Implement RubyVMSpecWalker#on_subject commit e264bd1 Author: Lekë Mula <[email protected]> Date: Thu May 16 15:18:40 2024 +0200 Implement RubyVMSpecWalker#on_each_context_block commit f8a4d6a Author: Lekë Mula <[email protected]> Date: Thu May 16 11:50:13 2024 +0200 Add walker specs
- Loading branch information
Showing
21 changed files
with
770 additions
and
268 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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,98 @@ | ||
# frozen_string_literal: true | ||
|
||
# Credits: This file is a copy of the file from the solargraph-rspec gem | ||
|
||
module Solargraph | ||
module Rspec | ||
# Factory class for building pins and references. | ||
module PinFactory | ||
# @param namespace [Solargraph::Pin::Namespace] | ||
# @param name [String] | ||
# @param types [Array<String>] | ||
# @param location [Solargraph::Location] | ||
# @param comments [Array<String>] | ||
# @param attribute [Boolean] | ||
# @param scope [:instance, :class] | ||
# @return [Solargraph::Pin::Method] | ||
def self.build_public_method( | ||
namespace, | ||
name, | ||
types: nil, | ||
location: nil, | ||
comments: [], | ||
attribute: false, | ||
scope: :instance | ||
) | ||
opts = { | ||
name: name, | ||
location: location, | ||
closure: namespace, | ||
scope: scope, | ||
attribute: attribute, | ||
comments: [] | ||
} | ||
|
||
comments << "@return [#{types.join(",")}]" if types | ||
|
||
opts[:comments] = comments.join("\n") | ||
|
||
Solargraph::Pin::Method.new(**opts) | ||
end | ||
|
||
# @param namespace [Solargraph::Pin::Namespace] | ||
# @param name [String] | ||
# @param location [Solargraph::Location] | ||
# @return [Solargraph::Pin::Reference::Include] | ||
def self.build_module_include(namespace, module_name, location) | ||
Solargraph::Pin::Reference::Include.new( | ||
closure: namespace, | ||
name: module_name, | ||
location: location | ||
) | ||
end | ||
|
||
# @param namespace [Solargraph::Pin::Namespace] | ||
# @param module_name [String] | ||
# @param location [Solargraph::Location] | ||
# @return [Solargraph::Pin::Reference::Extend] | ||
def self.build_module_extend(namespace, module_name, location) | ||
Solargraph::Pin::Reference::Extend.new( | ||
closure: namespace, | ||
name: module_name, | ||
location: location | ||
) | ||
end | ||
|
||
# @param path [String] | ||
# @return [Solargraph::Location] | ||
def self.dummy_location(path) | ||
Solargraph::Location.new( | ||
File.expand_path(path), | ||
Solargraph::Range.from_to(0, 0, 0, 0) | ||
) | ||
end | ||
|
||
# @param ast [RubyVM::AbstractSyntaxTree::Node] | ||
# @see [RubyVM::AbstractSyntaxTree::NodeWrapper] - for why we need -1 for lineno | ||
# @return [Solargraph::Range] | ||
def self.build_location_range(ast) | ||
Solargraph::Range.from_to( | ||
ast.first_lineno - 1, | ||
ast.first_column, | ||
ast.last_lineno - 1, | ||
ast.last_column | ||
) | ||
end | ||
|
||
# @param location_range [Solargraph::Range] | ||
# @param path [String] | ||
# @return [Solargraph::Location] | ||
def self.build_location(location_range, path) | ||
Solargraph::Location.new( | ||
File.expand_path(path), | ||
location_range | ||
) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.