steep 1.1.1 → 1.2.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +12 -11
- data/Gemfile.steep +1 -1
- data/Gemfile.steep.lock +9 -9
- data/README.md +3 -3
- data/Steepfile +23 -0
- data/bin/steep-prof +2 -1
- data/lib/steep/annotation_parser.rb +1 -1
- data/lib/steep/ast/types/class.rb +4 -0
- data/lib/steep/ast/types/factory.rb +86 -602
- data/lib/steep/ast/types/instance.rb +4 -0
- data/lib/steep/ast/types/literal.rb +1 -1
- data/lib/steep/ast/types/proc.rb +22 -8
- data/lib/steep/ast/types/self.rb +4 -0
- data/lib/steep/ast/types/union.rb +1 -1
- data/lib/steep/cli.rb +24 -1
- data/lib/steep/diagnostic/ruby.rb +17 -22
- data/lib/steep/drivers/checkfile.rb +205 -0
- data/lib/steep/drivers/validate.rb +3 -1
- data/lib/steep/equatable.rb +2 -0
- data/lib/steep/interface/block.rb +21 -11
- data/lib/steep/interface/builder.rb +756 -0
- data/lib/steep/interface/function.rb +32 -24
- data/lib/steep/interface/method_type.rb +191 -78
- data/lib/steep/interface/shape.rb +132 -0
- data/lib/steep/interface/substitution.rb +23 -12
- data/lib/steep/interface/type_param.rb +1 -2
- data/lib/steep/path_helper.rb +1 -1
- data/lib/steep/project.rb +5 -7
- data/lib/steep/server/base_worker.rb +2 -2
- data/lib/steep/server/change_buffer.rb +4 -3
- data/lib/steep/server/interaction_worker.rb +1 -1
- data/lib/steep/server/master.rb +69 -9
- data/lib/steep/server/type_check_worker.rb +13 -11
- data/lib/steep/server/worker_process.rb +9 -7
- data/lib/steep/services/completion_provider.rb +15 -3
- data/lib/steep/services/hover_provider/singleton_methods.rb +5 -6
- data/lib/steep/services/signature_service.rb +13 -8
- data/lib/steep/services/type_check_service.rb +2 -0
- data/lib/steep/signature/validator.rb +1 -1
- data/lib/steep/subtyping/check.rb +154 -103
- data/lib/steep/subtyping/relation.rb +3 -3
- data/lib/steep/subtyping/result.rb +20 -2
- data/lib/steep/subtyping/variable_variance.rb +9 -0
- data/lib/steep/type_construction.rb +558 -299
- data/lib/steep/type_inference/block_params.rb +169 -86
- data/lib/steep/type_inference/logic_type_interpreter.rb +9 -14
- data/lib/steep/type_inference/method_params.rb +12 -7
- data/lib/steep/type_inference/send_args.rb +41 -35
- data/lib/steep/type_inference/type_env_builder.rb +1 -1
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +71 -2
- data/rbs_collection.steep.lock.yaml +18 -30
- data/rbs_collection.steep.yaml +1 -0
- data/sig/shims/language-server_protocol.rbs +20 -0
- data/sig/shims/tagged_logging.rbs +6 -0
- data/sig/steep/ast/annotation/collection.rbs +6 -6
- data/sig/steep/ast/types/class.rbs +3 -0
- data/sig/steep/ast/types/factory.rbs +38 -32
- data/sig/steep/ast/types/instance.rbs +3 -0
- data/sig/steep/ast/types/intersection.rbs +1 -1
- data/sig/steep/ast/types/literal.rbs +7 -7
- data/sig/steep/ast/types/name.rbs +14 -13
- data/sig/steep/ast/types/proc.rbs +3 -1
- data/sig/steep/ast/types/self.rbs +3 -0
- data/sig/steep/ast/types/var.rbs +1 -1
- data/sig/steep/diagnostic/ruby.rbs +30 -34
- data/sig/steep/drivers/annotations.rbs +17 -0
- data/sig/steep/drivers/check.rbs +33 -0
- data/sig/steep/drivers/checkfile.rbs +26 -0
- data/sig/steep/drivers/diagnostic_printer.rbs +25 -0
- data/sig/steep/drivers/init.rbs +19 -0
- data/sig/steep/drivers/langserver.rbs +35 -0
- data/sig/steep/drivers/print_project.rbs +15 -0
- data/sig/steep/drivers/stats.rbs +37 -0
- data/sig/steep/drivers/utils/driver_helper.rbs +23 -0
- data/sig/steep/drivers/utils/jobs_count.rbs +11 -0
- data/sig/steep/drivers/validate.rbs +15 -0
- data/sig/steep/drivers/vendor.rbs +19 -0
- data/sig/steep/drivers/watch.rbs +27 -0
- data/sig/steep/drivers/worker.rbs +31 -0
- data/sig/steep/equatable.rbs +11 -0
- data/sig/steep/index/rbs_index.rbs +91 -0
- data/sig/steep/index/signature_symbol_provider.rbs +29 -0
- data/sig/steep/index/source_index.rbs +63 -0
- data/sig/steep/interface/block.rbs +3 -1
- data/sig/steep/interface/builder.rbs +152 -0
- data/sig/steep/interface/function.rbs +67 -55
- data/sig/steep/interface/method_type.rbs +60 -12
- data/sig/steep/interface/shape.rbs +61 -0
- data/sig/steep/interface/substitution.rbs +18 -22
- data/sig/steep/interface/type_param.rbs +9 -1
- data/sig/steep/path_helper.rbs +7 -0
- data/sig/steep/project/pattern.rbs +10 -10
- data/sig/steep/project/target.rbs +2 -2
- data/sig/steep/project.rbs +15 -8
- data/sig/steep/server/base_worker.rbs +49 -0
- data/sig/steep/server/change_buffer.rbs +32 -0
- data/sig/steep/server/interaction_worker.rbs +41 -0
- data/sig/steep/server/lsp_formatter.rbs +29 -0
- data/sig/steep/server/master.rbs +260 -0
- data/sig/steep/server/type_check_worker.rbs +135 -0
- data/sig/steep/server/worker_process.rbs +29 -0
- data/sig/steep/services/completion_provider.rbs +5 -5
- data/sig/steep/services/content_change.rbs +14 -12
- data/sig/steep/services/file_loader.rbs +12 -4
- data/sig/steep/services/hover_provider/singleton_methods.rbs +1 -1
- data/sig/steep/services/path_assignment.rbs +7 -7
- data/sig/steep/services/signature_service.rbs +67 -40
- data/sig/steep/services/type_check_service.rbs +53 -39
- data/sig/steep/subtyping/check.rbs +80 -44
- data/sig/steep/subtyping/relation.rbs +24 -22
- data/sig/steep/subtyping/result.rbs +48 -30
- data/sig/steep/subtyping/variable_variance.rbs +2 -0
- data/sig/steep/type_construction.rbs +132 -23
- data/sig/steep/type_inference/block_params.rbs +120 -18
- data/sig/steep/type_inference/context.rbs +45 -20
- data/sig/steep/type_inference/context_array.rbs +37 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +3 -1
- data/sig/steep/type_inference/method_params.rbs +13 -9
- data/sig/steep/type_inference/send_args.rbs +229 -0
- data/sig/steep/type_inference/type_env_builder.rbs +1 -1
- data/sig/steep/typing.rbs +4 -4
- data/sig/steep.rbs +4 -2
- data/smoke/block/e.rb +12 -0
- data/smoke/block/e.rbs +4 -0
- data/smoke/block/test_expectations.yml +12 -0
- data/smoke/regression/block_param_split.rb +7 -0
- data/smoke/regression/block_param_split.rbs +3 -0
- data/smoke/regression/empty_yield.rb +5 -0
- data/smoke/regression/empty_yield.rbs +3 -0
- data/smoke/regression/test_expectations.yml +12 -0
- data/smoke/yield/test_expectations.yml +4 -4
- data/steep.gemspec +2 -1
- metadata +61 -9
- data/lib/steep/interface/interface.rb +0 -34
- data/sig/steep/interface/interface.rbs +0 -23
- data/sig/version.rbs +0 -3
@@ -1,25 +1,25 @@
|
|
1
1
|
module Steep
|
2
2
|
class Project
|
3
3
|
class Pattern
|
4
|
-
attr_reader patterns:
|
4
|
+
attr_reader patterns: Array[String]
|
5
5
|
|
6
|
-
attr_reader ignores:
|
6
|
+
attr_reader ignores: Array[String]
|
7
7
|
|
8
|
-
attr_reader prefixes:
|
8
|
+
attr_reader prefixes: Array[String]
|
9
9
|
|
10
|
-
attr_reader ignore_prefixes:
|
10
|
+
attr_reader ignore_prefixes: Array[String]
|
11
11
|
|
12
|
-
attr_reader ext:
|
12
|
+
attr_reader ext: String
|
13
13
|
|
14
|
-
def initialize: (patterns:
|
14
|
+
def initialize: (patterns: Array[String], ext: String, ?ignores: Array[String]) -> void
|
15
15
|
|
16
|
-
def =~: (
|
16
|
+
def =~: (Pathname | String path) -> bool
|
17
17
|
|
18
|
-
def match?: (
|
18
|
+
def match?: (Pathname path) -> bool
|
19
19
|
|
20
|
-
def ignore?: (
|
20
|
+
def ignore?: (Pathname path) -> bool
|
21
21
|
|
22
|
-
def test_string: (
|
22
|
+
def test_string: (Pathname path, Array[String] patterns, Array[String] prefixes) -> bool
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,9 +5,9 @@ module Steep
|
|
5
5
|
|
6
6
|
attr_reader options: untyped
|
7
7
|
|
8
|
-
attr_reader source_pattern:
|
8
|
+
attr_reader source_pattern: Pattern
|
9
9
|
|
10
|
-
attr_reader signature_pattern:
|
10
|
+
attr_reader signature_pattern: Pattern
|
11
11
|
|
12
12
|
attr_reader code_diagnostics_config: untyped
|
13
13
|
|
data/sig/steep/project.rbs
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
module Steep
|
2
2
|
class Project
|
3
|
-
attr_reader targets:
|
3
|
+
attr_reader targets: Array[Target]
|
4
4
|
|
5
|
-
attr_reader steepfile_path:
|
5
|
+
attr_reader steepfile_path: Pathname
|
6
6
|
|
7
|
-
def initialize: (steepfile_path:
|
7
|
+
def initialize: (steepfile_path: Pathname) -> void
|
8
8
|
|
9
|
-
def base_dir: () ->
|
9
|
+
def base_dir: () -> Pathname
|
10
10
|
|
11
|
-
def relative_path: (
|
11
|
+
def relative_path: (Pathname path) -> Pathname
|
12
12
|
|
13
|
-
def absolute_path: (
|
13
|
+
def absolute_path: (Pathname path) -> Pathname
|
14
14
|
|
15
|
-
def target_for_source_path: (
|
15
|
+
def target_for_source_path: (Pathname path) -> Target?
|
16
16
|
|
17
|
-
|
17
|
+
# Returns target or array of targets that *can* contain given path
|
18
|
+
#
|
19
|
+
# * `Target` will return if `path` is a source code
|
20
|
+
# * `Array[Target]` will return if `path` is a signature
|
21
|
+
#
|
22
|
+
# `path` can be non-existent file.
|
23
|
+
#
|
24
|
+
def targets_for_path: (Pathname path) -> (Target | Array[Target] | nil)
|
18
25
|
end
|
19
26
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
class BaseWorker
|
4
|
+
interface _Queue[A]
|
5
|
+
def pop: () -> A?
|
6
|
+
|
7
|
+
def <<: (A) -> A
|
8
|
+
|
9
|
+
def close: () -> void
|
10
|
+
end
|
11
|
+
|
12
|
+
LSP: untyped
|
13
|
+
|
14
|
+
@skip_jobs_after_shutdown: bool
|
15
|
+
|
16
|
+
@skip_job: bool
|
17
|
+
|
18
|
+
@shutdown: bool
|
19
|
+
|
20
|
+
attr_reader project: Project
|
21
|
+
|
22
|
+
attr_reader reader: LanguageServer::Protocol::Transport::Io::Reader
|
23
|
+
|
24
|
+
attr_reader writer: LanguageServer::Protocol::Transport::Io::Writer
|
25
|
+
|
26
|
+
attr_reader queue: _Queue[untyped]
|
27
|
+
|
28
|
+
class ShutdownJob
|
29
|
+
attr_reader id: String
|
30
|
+
|
31
|
+
def initialize: (id: String) -> void
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize: (project: Project, reader: LanguageServer::Protocol::Transport::Io::Reader, writer: LanguageServer::Protocol::Transport::Io::Writer) -> void
|
35
|
+
|
36
|
+
def skip_jobs_after_shutdown!: (?bool flag) -> void
|
37
|
+
|
38
|
+
def skip_jobs_after_shutdown?: () -> bool
|
39
|
+
|
40
|
+
def skip_job?: () -> bool
|
41
|
+
|
42
|
+
def handle_request: (untyped request) -> void
|
43
|
+
|
44
|
+
def handle_job: (untyped job) -> void
|
45
|
+
|
46
|
+
def run: () -> void
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
module ChangeBuffer : _WithProject
|
4
|
+
interface _WithProject
|
5
|
+
def project: () -> Project
|
6
|
+
end
|
7
|
+
|
8
|
+
type changes = Hash[Pathname, Array[Services::ContentChange]]
|
9
|
+
|
10
|
+
attr_reader mutex: Thread::Mutex
|
11
|
+
|
12
|
+
attr_reader buffered_changes: changes
|
13
|
+
|
14
|
+
# Yields `buffered_changes` to modify with synchronization
|
15
|
+
#
|
16
|
+
def push_buffer: [A] () { (changes) -> A } -> A
|
17
|
+
|
18
|
+
# Yields or returns a copy of `buffered_changes` after clearing `buffered_changes` content
|
19
|
+
#
|
20
|
+
def pop_buffer: [A] () { (changes) -> A } -> A
|
21
|
+
| () -> changes
|
22
|
+
|
23
|
+
# Load files from `project` to `buffered_changes`
|
24
|
+
#
|
25
|
+
def load_files: (project: Project, commandline_args: Array[String]) -> void
|
26
|
+
|
27
|
+
# Load changes from a request with `DidChangeTextDocumentParams` into `buffered_changes`
|
28
|
+
#
|
29
|
+
def collect_changes: (untyped request) -> void
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
class InteractionWorker < BaseWorker
|
4
|
+
include ChangeBuffer
|
5
|
+
|
6
|
+
ApplyChangeJob: untyped
|
7
|
+
|
8
|
+
HoverJob: untyped
|
9
|
+
|
10
|
+
CompletionJob: untyped
|
11
|
+
|
12
|
+
LSP: untyped
|
13
|
+
|
14
|
+
attr_reader service: untyped
|
15
|
+
|
16
|
+
def initialize: (project: untyped, reader: untyped, writer: untyped, ?queue: untyped) -> void
|
17
|
+
|
18
|
+
def handle_job: (untyped job) -> untyped
|
19
|
+
|
20
|
+
def handle_request: (untyped request) -> untyped
|
21
|
+
|
22
|
+
def process_hover: (untyped job) -> untyped
|
23
|
+
|
24
|
+
def process_completion: (untyped job) -> untyped
|
25
|
+
|
26
|
+
def format_completion_item_for_rbs: (untyped sig_service, untyped type_name, untyped context, untyped job, untyped prefix) -> (nil | untyped)
|
27
|
+
|
28
|
+
def format_comment: (untyped comment) -> (untyped | nil)
|
29
|
+
|
30
|
+
def format_comments: (untyped comments) -> (untyped | nil)
|
31
|
+
|
32
|
+
def format_completion_item: (untyped item) -> untyped
|
33
|
+
|
34
|
+
def method_type_to_snippet: (untyped method_type) -> ::String
|
35
|
+
|
36
|
+
def params_to_snippet: (untyped fun) -> untyped
|
37
|
+
|
38
|
+
def relative_name_in_context: (untyped type_name, untyped context) -> untyped
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
module LSPFormatter
|
4
|
+
include Services
|
5
|
+
|
6
|
+
class CommentBuilder
|
7
|
+
def initialize: () -> void
|
8
|
+
|
9
|
+
def self.build: () { (untyped) -> untyped } -> untyped
|
10
|
+
|
11
|
+
def to_s: () -> (untyped | nil)
|
12
|
+
|
13
|
+
def <<: (untyped string) -> (untyped | nil)
|
14
|
+
|
15
|
+
def push: () { (untyped) -> untyped } -> untyped
|
16
|
+
end
|
17
|
+
|
18
|
+
def self?.format_hover_content: (untyped content) -> untyped
|
19
|
+
|
20
|
+
def self?.to_list: (untyped collection) ?{ () -> untyped } -> untyped
|
21
|
+
|
22
|
+
def self?.name_and_args: (untyped name, untyped args) -> ::String
|
23
|
+
|
24
|
+
def self?.name_and_params: (untyped name, untyped params) -> ::String
|
25
|
+
|
26
|
+
def self?.declaration_summary: (untyped decl) -> untyped
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
class Master
|
4
|
+
LSP: singleton(LanguageServer::Protocol)
|
5
|
+
|
6
|
+
class TypeCheckRequest
|
7
|
+
attr_reader guid: String
|
8
|
+
|
9
|
+
attr_reader library_paths: Set[Pathname]
|
10
|
+
|
11
|
+
attr_reader signature_paths: Set[Pathname]
|
12
|
+
|
13
|
+
attr_reader code_paths: Set[Pathname]
|
14
|
+
|
15
|
+
attr_reader priority_paths: Set[Pathname]
|
16
|
+
|
17
|
+
attr_reader checked_paths: Set[Pathname]
|
18
|
+
|
19
|
+
def initialize: (guid: String) -> void
|
20
|
+
|
21
|
+
def uri: (Pathname path) -> URI::File
|
22
|
+
|
23
|
+
def as_json: (assignment: Services::PathAssignment) -> { guid: String, library_uris: Array[String], signature_uris: Array[String], code_uris: Array[String], priority_uris: Array[String] }
|
24
|
+
|
25
|
+
def total: () -> Integer
|
26
|
+
|
27
|
+
def percentage: () -> Integer
|
28
|
+
|
29
|
+
def all_paths: () -> Set[Pathname]
|
30
|
+
|
31
|
+
def checking_path?: (Pathname path) -> bool
|
32
|
+
|
33
|
+
def checked: (Pathname path) -> void
|
34
|
+
|
35
|
+
def finished?: () -> bool
|
36
|
+
|
37
|
+
def unchecked_paths: () -> Set[Pathname]
|
38
|
+
|
39
|
+
def unchecked_code_paths: () -> Set[Pathname]
|
40
|
+
|
41
|
+
def unchecked_library_paths: () -> Set[Pathname]
|
42
|
+
|
43
|
+
def unchecked_signature_paths: () -> Set[Pathname]
|
44
|
+
end
|
45
|
+
|
46
|
+
# TypeCheckController remembers changed files, keep track of open editors, and make a TypeCheckRequest that contains list of all files to be type checked
|
47
|
+
#
|
48
|
+
# ```rb
|
49
|
+
# controller = TypeCheckController.new(project: project)
|
50
|
+
#
|
51
|
+
# controller.push_changes(file_path) # Remember that the path is changed
|
52
|
+
# controller.update_priority(open: file_path) # Remember that an editor opens the path
|
53
|
+
# controller.make_request(...) # Make an instance of TypeCheckRequest that contains list of all paths to type check
|
54
|
+
# ```
|
55
|
+
class TypeCheckController
|
56
|
+
attr_reader project: Project
|
57
|
+
|
58
|
+
attr_reader priority_paths: Set[Pathname]
|
59
|
+
|
60
|
+
attr_reader changed_paths: Set[Pathname]
|
61
|
+
|
62
|
+
attr_reader target_paths: Array[TargetPaths]
|
63
|
+
|
64
|
+
class TargetPaths
|
65
|
+
attr_reader project: Project
|
66
|
+
|
67
|
+
attr_reader target: Project::Target
|
68
|
+
|
69
|
+
attr_reader code_paths: Set[Pathname]
|
70
|
+
|
71
|
+
attr_reader signature_paths: Set[Pathname]
|
72
|
+
|
73
|
+
attr_reader library_paths: Set[Pathname]
|
74
|
+
|
75
|
+
def initialize: (project: Project, target: Project::Target) -> void
|
76
|
+
|
77
|
+
def all_paths: () -> Set[Pathname]
|
78
|
+
|
79
|
+
def library_path?: (Pathname path) -> bool
|
80
|
+
|
81
|
+
def signature_path?: (Pathname path) -> bool
|
82
|
+
|
83
|
+
def code_path?: (Pathname path) -> bool
|
84
|
+
|
85
|
+
def add: (Pathname path) -> void
|
86
|
+
|
87
|
+
alias << add
|
88
|
+
end
|
89
|
+
|
90
|
+
def initialize: (project: Project) -> void
|
91
|
+
|
92
|
+
def load: (command_line_args: Array[String]) -> void
|
93
|
+
|
94
|
+
def push_changes: (Pathname path) -> void
|
95
|
+
|
96
|
+
def update_priority: (open: Pathname) -> void
|
97
|
+
| (close: Pathname) -> void
|
98
|
+
|
99
|
+
def make_request: (?guid: String, ?last_request: TypeCheckRequest?, ?include_unchanged: bool) -> TypeCheckRequest?
|
100
|
+
end
|
101
|
+
|
102
|
+
type lsp_notification = { method: String, params: untyped }
|
103
|
+
|
104
|
+
type lsp_request = { id: String, method: String, params: untyped }
|
105
|
+
|
106
|
+
type lsp_response = { id: String, result: untyped }
|
107
|
+
|
108
|
+
type lsp_message = { method: String, id: String?, params: untyped?, result: untyped? }
|
109
|
+
|
110
|
+
class ResultHandler
|
111
|
+
attr_reader request: lsp_request
|
112
|
+
|
113
|
+
attr_reader completion_handler: (^(lsp_response) -> void)?
|
114
|
+
|
115
|
+
attr_reader response: lsp_response?
|
116
|
+
|
117
|
+
@completed: bool
|
118
|
+
|
119
|
+
def initialize: (request: untyped) -> void
|
120
|
+
|
121
|
+
def process_response: (lsp_response message) -> bool
|
122
|
+
|
123
|
+
def result: () -> untyped
|
124
|
+
|
125
|
+
def completed?: () -> bool
|
126
|
+
|
127
|
+
def on_completion: () ?{ (lsp_response) -> void } -> void
|
128
|
+
end
|
129
|
+
|
130
|
+
class GroupHandler
|
131
|
+
attr_reader request: lsp_request
|
132
|
+
|
133
|
+
attr_reader handlers: Hash[String, ResultHandler]
|
134
|
+
|
135
|
+
attr_reader completion_handler: (^(Array[ResultHandler]) -> void)?
|
136
|
+
|
137
|
+
def initialize: () -> void
|
138
|
+
|
139
|
+
def process_response: (lsp_response message) -> bool
|
140
|
+
|
141
|
+
def completed?: () -> bool
|
142
|
+
|
143
|
+
def <<: (ResultHandler handler) -> void
|
144
|
+
|
145
|
+
def on_completion: () { (Array[ResultHandler]) -> void } -> void
|
146
|
+
end
|
147
|
+
|
148
|
+
class ResultController
|
149
|
+
attr_reader handlers: Array[ResultHandler | GroupHandler]
|
150
|
+
|
151
|
+
def initialize: () -> void
|
152
|
+
|
153
|
+
def <<: (ResultHandler | GroupHandler handler) -> void
|
154
|
+
|
155
|
+
def request_group: () { (GroupHandler) -> void } -> GroupHandler
|
156
|
+
|
157
|
+
def process_response: (lsp_response message) -> bool
|
158
|
+
end
|
159
|
+
|
160
|
+
module MessageUtils : _WithMessage
|
161
|
+
interface _WithMessage
|
162
|
+
def message: () -> untyped
|
163
|
+
end
|
164
|
+
|
165
|
+
def request?: () -> bool
|
166
|
+
|
167
|
+
def notification?: () -> bool
|
168
|
+
|
169
|
+
def response?: () -> bool
|
170
|
+
|
171
|
+
%a{pure} def method: () -> String?
|
172
|
+
|
173
|
+
%a{pure} def id: () -> String?
|
174
|
+
|
175
|
+
%a{pure} def result: () -> untyped?
|
176
|
+
|
177
|
+
%a{pure} def params: () -> untyped?
|
178
|
+
end
|
179
|
+
|
180
|
+
class ReceiveMessageJob
|
181
|
+
attr_reader source: WorkerProcess | :client
|
182
|
+
|
183
|
+
attr_reader message: untyped
|
184
|
+
|
185
|
+
def initialize: (source: WorkerProcess | :client, message: untyped) -> void
|
186
|
+
|
187
|
+
include MessageUtils
|
188
|
+
end
|
189
|
+
|
190
|
+
class SendMessageJob
|
191
|
+
attr_reader dest: WorkerProcess | :client
|
192
|
+
|
193
|
+
attr_reader message: untyped
|
194
|
+
|
195
|
+
def initialize: (dest: WorkerProcess | :client, message: untyped) -> void
|
196
|
+
|
197
|
+
def self.to_worker: (WorkerProcess, message: untyped) -> SendMessageJob
|
198
|
+
|
199
|
+
def self.to_client: (message: untyped) -> SendMessageJob
|
200
|
+
|
201
|
+
include MessageUtils
|
202
|
+
end
|
203
|
+
|
204
|
+
attr_reader project: Project
|
205
|
+
|
206
|
+
attr_reader reader: LanguageServer::Protocol::Transport::Io::Reader
|
207
|
+
|
208
|
+
attr_reader writer: LanguageServer::Protocol::Transport::Io::Writer
|
209
|
+
|
210
|
+
attr_reader commandline_args: Array[String]
|
211
|
+
|
212
|
+
attr_reader interaction_worker: WorkerProcess?
|
213
|
+
|
214
|
+
attr_reader typecheck_workers: Array[WorkerProcess]
|
215
|
+
|
216
|
+
attr_reader job_queue: Thread::Queue
|
217
|
+
|
218
|
+
attr_reader current_type_check_request: TypeCheckRequest?
|
219
|
+
|
220
|
+
attr_reader controller: TypeCheckController
|
221
|
+
|
222
|
+
attr_reader result_controller: ResultController
|
223
|
+
|
224
|
+
attr_reader initialize_params: untyped
|
225
|
+
|
226
|
+
attr_accessor typecheck_automatically: bool
|
227
|
+
|
228
|
+
def initialize: (project: Project, reader: untyped, writer: untyped, interaction_worker: WorkerProcess?, typecheck_workers: Array[WorkerProcess], ?queue: Thread::Queue) -> void
|
229
|
+
|
230
|
+
def start: () -> void
|
231
|
+
|
232
|
+
def each_worker: () { (WorkerProcess) -> void } -> void
|
233
|
+
| () -> Enumerator[WorkerProcess, void]
|
234
|
+
|
235
|
+
def pathname: (String uri) -> Pathname?
|
236
|
+
|
237
|
+
def work_done_progress_supported?: () -> bool
|
238
|
+
|
239
|
+
def process_message_from_client: (untyped message) -> void
|
240
|
+
|
241
|
+
def process_message_from_worker: (untyped message, worker: WorkerProcess) -> void
|
242
|
+
|
243
|
+
def start_type_check: (TypeCheckRequest request, last_request: TypeCheckRequest?, start_progress: bool) -> void
|
244
|
+
|
245
|
+
def on_type_check_update: (guid: String, path: Pathname) -> void
|
246
|
+
|
247
|
+
def broadcast_notification: (lsp_notification message) -> void
|
248
|
+
|
249
|
+
def send_notification: (lsp_notification message, worker: WorkerProcess) -> void
|
250
|
+
|
251
|
+
def fresh_request_id: () -> String
|
252
|
+
|
253
|
+
def send_request: (method: String, worker: WorkerProcess, ?id: String, ?params: untyped?) ?{ (ResultHandler) -> void } -> ResultHandler
|
254
|
+
|
255
|
+
def group_request: () { (GroupHandler) -> void } -> GroupHandler
|
256
|
+
|
257
|
+
def kill: () -> void
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
# TypeCheckWorker provides two features:
|
4
|
+
#
|
5
|
+
# 1. Type check and validate source code invoked by `$/typecheck/start` notification
|
6
|
+
# 2. Language related features: `workspace/symbol`, `textDocument/definition`, `textDocument/implementation`, and `steep/stats` command
|
7
|
+
#
|
8
|
+
# `$/typecheck/start` notification is delivered to `#enqueue_typecheck_jobs` command that creates *jobs*.
|
9
|
+
#
|
10
|
+
# * `StartTypeCheckJob` applies the pending changes
|
11
|
+
# * `ValidateAppSignatureJob` validates an *application* RBS file
|
12
|
+
# * `ValidateLibrarySignatureJob` validates a *library* RBS file
|
13
|
+
# * `TypeCheckCodeJob` type checks a ruby code
|
14
|
+
#
|
15
|
+
class TypeCheckWorker < BaseWorker
|
16
|
+
attr_reader project: Project
|
17
|
+
|
18
|
+
attr_reader assignment: Services::PathAssignment
|
19
|
+
|
20
|
+
attr_reader service: Services::TypeCheckService
|
21
|
+
|
22
|
+
attr_reader commandline_args: Array[String]
|
23
|
+
|
24
|
+
attr_reader current_type_check_guid: String?
|
25
|
+
|
26
|
+
class WorkspaceSymbolJob
|
27
|
+
attr_reader id: String
|
28
|
+
|
29
|
+
attr_reader query: String
|
30
|
+
|
31
|
+
def initialize: (id: String, query: String) -> void
|
32
|
+
end
|
33
|
+
|
34
|
+
class StatsJob
|
35
|
+
attr_reader id: String
|
36
|
+
|
37
|
+
def initialize: (id: String) -> void
|
38
|
+
end
|
39
|
+
|
40
|
+
class StartTypeCheckJob
|
41
|
+
attr_reader guid: String
|
42
|
+
|
43
|
+
attr_reader changes: ChangeBuffer::changes
|
44
|
+
|
45
|
+
def initialize: (guid: String, changes: ChangeBuffer::changes) -> void
|
46
|
+
end
|
47
|
+
|
48
|
+
class TypeCheckCodeJob
|
49
|
+
attr_reader guid: String
|
50
|
+
|
51
|
+
attr_reader path: Pathname
|
52
|
+
|
53
|
+
def initialize: (guid: String, path: Pathname) -> void
|
54
|
+
end
|
55
|
+
|
56
|
+
class ValidateAppSignatureJob
|
57
|
+
attr_reader guid: String
|
58
|
+
|
59
|
+
attr_reader path: Pathname
|
60
|
+
|
61
|
+
def initialize: (guid: String, path: Pathname) -> void
|
62
|
+
end
|
63
|
+
|
64
|
+
class ValidateLibrarySignatureJob
|
65
|
+
attr_reader guid: String
|
66
|
+
|
67
|
+
attr_reader path: Pathname
|
68
|
+
|
69
|
+
def initialize: (guid: String, path: Pathname) -> void
|
70
|
+
end
|
71
|
+
|
72
|
+
class GotoJob
|
73
|
+
type kind = :implementation | :definition
|
74
|
+
|
75
|
+
attr_reader id: String
|
76
|
+
|
77
|
+
attr_reader kind: kind
|
78
|
+
|
79
|
+
type params = Hash[Symbol, untyped]
|
80
|
+
|
81
|
+
attr_reader params: params
|
82
|
+
|
83
|
+
def initialize: (id: String, params: params, kind: kind) -> void
|
84
|
+
|
85
|
+
def self.implementation: (id: String, params: params) -> GotoJob
|
86
|
+
|
87
|
+
def self.definition: (id: String, params: params) -> GotoJob
|
88
|
+
|
89
|
+
def implementation?: () -> bool
|
90
|
+
|
91
|
+
def definition?: () -> bool
|
92
|
+
end
|
93
|
+
|
94
|
+
include ChangeBuffer
|
95
|
+
|
96
|
+
def initialize: (
|
97
|
+
project: Project,
|
98
|
+
reader: LanguageServer::Protocol::Transport::Io::Reader,
|
99
|
+
writer: LanguageServer::Protocol::Transport::Io::Writer,
|
100
|
+
assignment: Services::PathAssignment,
|
101
|
+
commandline_args: Array[String]
|
102
|
+
) -> void
|
103
|
+
|
104
|
+
def handle_request: (untyped request) -> void
|
105
|
+
|
106
|
+
type type_check_start_params = {
|
107
|
+
guid: String,
|
108
|
+
priority_uris: Array[String],
|
109
|
+
library_uris: Array[String],
|
110
|
+
signature_uris: Array[String],
|
111
|
+
code_uris: Array[String]
|
112
|
+
}
|
113
|
+
|
114
|
+
def enqueue_typecheck_jobs: (type_check_start_params) -> void
|
115
|
+
|
116
|
+
type job = WorkspaceSymbolJob
|
117
|
+
| StartTypeCheckJob
|
118
|
+
| TypeCheckCodeJob
|
119
|
+
| ValidateAppSignatureJob
|
120
|
+
| ValidateLibrarySignatureJob
|
121
|
+
| GotoJob
|
122
|
+
| StatsJob
|
123
|
+
|
124
|
+
def handle_job: (job) -> void
|
125
|
+
|
126
|
+
def typecheck_progress: (guid: String, path: Pathname) -> void
|
127
|
+
|
128
|
+
def workspace_symbol_result: (untyped query) -> untyped
|
129
|
+
|
130
|
+
def stats_result: () -> untyped
|
131
|
+
|
132
|
+
def goto: (GotoJob job) -> Array[untyped]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module Server
|
3
|
+
class WorkerProcess
|
4
|
+
attr_reader reader: untyped
|
5
|
+
|
6
|
+
attr_reader writer: untyped
|
7
|
+
|
8
|
+
attr_reader stderr: untyped
|
9
|
+
|
10
|
+
attr_reader name: untyped
|
11
|
+
|
12
|
+
attr_reader wait_thread: untyped
|
13
|
+
|
14
|
+
attr_reader index: untyped
|
15
|
+
|
16
|
+
def initialize: (reader: untyped, writer: untyped, stderr: untyped, wait_thread: untyped, name: untyped, ?index: untyped?) -> void
|
17
|
+
|
18
|
+
def self.spawn_worker: (untyped `type`, name: untyped, steepfile: untyped, ?steep_command: ::String, ?options: untyped, ?delay_shutdown: bool, ?index: untyped?) -> untyped
|
19
|
+
|
20
|
+
def self.spawn_typecheck_workers: (steepfile: untyped, args: untyped, ?steep_command: ::String, ?count: untyped, ?delay_shutdown: bool) -> untyped
|
21
|
+
|
22
|
+
def <<: (untyped message) -> untyped
|
23
|
+
|
24
|
+
def read: () ?{ () -> untyped } -> untyped
|
25
|
+
|
26
|
+
def kill: () -> untyped
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -71,15 +71,15 @@ module Steep
|
|
71
71
|
def inherited?: () -> bool
|
72
72
|
end
|
73
73
|
|
74
|
-
attr_reader source_text:
|
74
|
+
attr_reader source_text: String
|
75
75
|
|
76
|
-
attr_reader path:
|
76
|
+
attr_reader path: Pathname
|
77
77
|
|
78
|
-
attr_reader subtyping:
|
78
|
+
attr_reader subtyping: Subtyping::Check
|
79
79
|
|
80
|
-
attr_reader modified_text:
|
80
|
+
attr_reader modified_text: String
|
81
81
|
|
82
|
-
attr_reader source:
|
82
|
+
attr_reader source: Source
|
83
83
|
|
84
84
|
attr_reader typing: Typing
|
85
85
|
|