syntax_suggest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +91 -0
- data/.github/workflows/check_changelog.yml +20 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.standard.yml +1 -0
- data/CHANGELOG.md +158 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +229 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dead_end.gemspec +32 -0
- data/exe/syntax_suggest +7 -0
- data/lib/syntax_suggest/api.rb +199 -0
- data/lib/syntax_suggest/around_block_scan.rb +224 -0
- data/lib/syntax_suggest/block_expand.rb +74 -0
- data/lib/syntax_suggest/capture_code_context.rb +233 -0
- data/lib/syntax_suggest/clean_document.rb +304 -0
- data/lib/syntax_suggest/cli.rb +129 -0
- data/lib/syntax_suggest/code_block.rb +100 -0
- data/lib/syntax_suggest/code_frontier.rb +178 -0
- data/lib/syntax_suggest/code_line.rb +239 -0
- data/lib/syntax_suggest/code_search.rb +139 -0
- data/lib/syntax_suggest/core_ext.rb +101 -0
- data/lib/syntax_suggest/display_code_with_line_numbers.rb +70 -0
- data/lib/syntax_suggest/display_invalid_blocks.rb +84 -0
- data/lib/syntax_suggest/explain_syntax.rb +103 -0
- data/lib/syntax_suggest/left_right_lex_count.rb +168 -0
- data/lib/syntax_suggest/lex_all.rb +55 -0
- data/lib/syntax_suggest/lex_value.rb +70 -0
- data/lib/syntax_suggest/parse_blocks_from_indent_line.rb +60 -0
- data/lib/syntax_suggest/pathname_from_message.rb +59 -0
- data/lib/syntax_suggest/priority_engulf_queue.rb +63 -0
- data/lib/syntax_suggest/priority_queue.rb +105 -0
- data/lib/syntax_suggest/ripper_errors.rb +36 -0
- data/lib/syntax_suggest/unvisited_lines.rb +36 -0
- data/lib/syntax_suggest/version.rb +5 -0
- data/lib/syntax_suggest.rb +3 -0
- metadata +88 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SyntaxSuggest
|
4
|
+
# Capture parse errors from ripper
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# puts RipperErrors.new(" def foo").call.errors
|
9
|
+
# # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"]
|
10
|
+
class RipperErrors < Ripper
|
11
|
+
attr_reader :errors
|
12
|
+
|
13
|
+
# Comes from ripper, called
|
14
|
+
# on every parse error, msg
|
15
|
+
# is a string
|
16
|
+
def on_parse_error(msg)
|
17
|
+
@errors ||= []
|
18
|
+
@errors << msg
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :on_alias_error, :on_parse_error
|
22
|
+
alias_method :on_assign_error, :on_parse_error
|
23
|
+
alias_method :on_class_name_error, :on_parse_error
|
24
|
+
alias_method :on_param_error, :on_parse_error
|
25
|
+
alias_method :compile_error, :on_parse_error
|
26
|
+
|
27
|
+
def call
|
28
|
+
@run_once ||= begin
|
29
|
+
@errors = []
|
30
|
+
parse
|
31
|
+
true
|
32
|
+
end
|
33
|
+
self
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SyntaxSuggest
|
4
|
+
# Tracks which lines various code blocks have expanded to
|
5
|
+
# and which are still unexplored
|
6
|
+
class UnvisitedLines
|
7
|
+
def initialize(code_lines:)
|
8
|
+
@unvisited = code_lines.sort_by(&:indent_index)
|
9
|
+
@visited_lines = {}
|
10
|
+
@visited_lines.compare_by_identity
|
11
|
+
end
|
12
|
+
|
13
|
+
def empty?
|
14
|
+
@unvisited.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
def peek
|
18
|
+
@unvisited.last
|
19
|
+
end
|
20
|
+
|
21
|
+
def pop
|
22
|
+
@unvisited.pop
|
23
|
+
end
|
24
|
+
|
25
|
+
def visit_block(block)
|
26
|
+
block.lines.each do |line|
|
27
|
+
next if @visited_lines[line]
|
28
|
+
@visited_lines[line] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
while @visited_lines[@unvisited.last]
|
32
|
+
@unvisited.pop
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syntax_suggest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- schneems
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: When you get an "unexpected end" in your syntax this gem helps you find
|
14
|
+
it
|
15
|
+
email:
|
16
|
+
- richard.schneeman+foo@gmail.com
|
17
|
+
executables:
|
18
|
+
- syntax_suggest
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".circleci/config.yml"
|
23
|
+
- ".github/workflows/check_changelog.yml"
|
24
|
+
- ".gitignore"
|
25
|
+
- ".rspec"
|
26
|
+
- ".standard.yml"
|
27
|
+
- CHANGELOG.md
|
28
|
+
- CODE_OF_CONDUCT.md
|
29
|
+
- Gemfile
|
30
|
+
- Gemfile.lock
|
31
|
+
- LICENSE.txt
|
32
|
+
- README.md
|
33
|
+
- Rakefile
|
34
|
+
- bin/console
|
35
|
+
- bin/setup
|
36
|
+
- dead_end.gemspec
|
37
|
+
- exe/syntax_suggest
|
38
|
+
- lib/syntax_suggest.rb
|
39
|
+
- lib/syntax_suggest/api.rb
|
40
|
+
- lib/syntax_suggest/around_block_scan.rb
|
41
|
+
- lib/syntax_suggest/block_expand.rb
|
42
|
+
- lib/syntax_suggest/capture_code_context.rb
|
43
|
+
- lib/syntax_suggest/clean_document.rb
|
44
|
+
- lib/syntax_suggest/cli.rb
|
45
|
+
- lib/syntax_suggest/code_block.rb
|
46
|
+
- lib/syntax_suggest/code_frontier.rb
|
47
|
+
- lib/syntax_suggest/code_line.rb
|
48
|
+
- lib/syntax_suggest/code_search.rb
|
49
|
+
- lib/syntax_suggest/core_ext.rb
|
50
|
+
- lib/syntax_suggest/display_code_with_line_numbers.rb
|
51
|
+
- lib/syntax_suggest/display_invalid_blocks.rb
|
52
|
+
- lib/syntax_suggest/explain_syntax.rb
|
53
|
+
- lib/syntax_suggest/left_right_lex_count.rb
|
54
|
+
- lib/syntax_suggest/lex_all.rb
|
55
|
+
- lib/syntax_suggest/lex_value.rb
|
56
|
+
- lib/syntax_suggest/parse_blocks_from_indent_line.rb
|
57
|
+
- lib/syntax_suggest/pathname_from_message.rb
|
58
|
+
- lib/syntax_suggest/priority_engulf_queue.rb
|
59
|
+
- lib/syntax_suggest/priority_queue.rb
|
60
|
+
- lib/syntax_suggest/ripper_errors.rb
|
61
|
+
- lib/syntax_suggest/unvisited_lines.rb
|
62
|
+
- lib/syntax_suggest/version.rb
|
63
|
+
homepage: https://github.com/zombocom/syntax_suggest.git
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
homepage_uri: https://github.com/zombocom/syntax_suggest.git
|
68
|
+
source_code_uri: https://github.com/zombocom/syntax_suggest.git
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.5.0
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Find syntax errors in your source in a snap
|
88
|
+
test_files: []
|