theme-check 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +21 -0
  4. data/README.md +10 -0
  5. data/RELEASING.md +13 -0
  6. data/config/default.yml +5 -0
  7. data/data/shopify_liquid/deprecated_filters.yml +4 -0
  8. data/data/shopify_liquid/filters.yml +2 -1
  9. data/docs/checks/schema_json_format.md +76 -0
  10. data/docs/language_server/code-action-command-palette.png +0 -0
  11. data/docs/language_server/code-action-flow.png +0 -0
  12. data/docs/language_server/code-action-keyboard.png +0 -0
  13. data/docs/language_server/code-action-light-bulb.png +0 -0
  14. data/docs/language_server/code-action-problem.png +0 -0
  15. data/docs/language_server/code-action-quickfix.png +0 -0
  16. data/docs/language_server/how_to_correct_code_with_code_actions_and_execute_command.md +197 -0
  17. data/lib/theme_check/checks/asset_size_app_block_css.rb +2 -3
  18. data/lib/theme_check/checks/asset_size_app_block_javascript.rb +2 -3
  19. data/lib/theme_check/checks/asset_url_filters.rb +2 -0
  20. data/lib/theme_check/checks/default_locale.rb +1 -1
  21. data/lib/theme_check/checks/deprecated_filter.rb +79 -4
  22. data/lib/theme_check/checks/deprecated_global_app_block_type.rb +2 -3
  23. data/lib/theme_check/checks/matching_schema_translations.rb +4 -6
  24. data/lib/theme_check/checks/matching_translations.rb +1 -0
  25. data/lib/theme_check/checks/missing_required_template_files.rb +3 -3
  26. data/lib/theme_check/checks/missing_template.rb +1 -1
  27. data/lib/theme_check/checks/pagination_size.rb +2 -3
  28. data/lib/theme_check/checks/remote_asset.rb +5 -0
  29. data/lib/theme_check/checks/required_directories.rb +1 -1
  30. data/lib/theme_check/checks/schema_json_format.rb +29 -0
  31. data/lib/theme_check/checks/space_inside_braces.rb +132 -87
  32. data/lib/theme_check/checks/translation_key_exists.rb +33 -13
  33. data/lib/theme_check/checks/unused_snippet.rb +1 -1
  34. data/lib/theme_check/checks/valid_html_translation.rb +1 -1
  35. data/lib/theme_check/checks/valid_schema.rb +2 -2
  36. data/lib/theme_check/corrector.rb +28 -54
  37. data/lib/theme_check/file_system_storage.rb +4 -3
  38. data/lib/theme_check/html_node.rb +99 -6
  39. data/lib/theme_check/html_visitor.rb +1 -32
  40. data/lib/theme_check/in_memory_storage.rb +9 -0
  41. data/lib/theme_check/json_helpers.rb +14 -0
  42. data/lib/theme_check/language_server/bridge.rb +1 -1
  43. data/lib/theme_check/language_server/client_capabilities.rb +27 -0
  44. data/lib/theme_check/language_server/code_action_engine.rb +32 -0
  45. data/lib/theme_check/language_server/code_action_provider.rb +42 -0
  46. data/lib/theme_check/language_server/code_action_providers/quickfix_code_action_provider.rb +83 -0
  47. data/lib/theme_check/language_server/code_action_providers/source_fix_all_code_action_provider.rb +40 -0
  48. data/lib/theme_check/language_server/configuration.rb +69 -0
  49. data/lib/theme_check/language_server/diagnostic.rb +124 -0
  50. data/lib/theme_check/language_server/diagnostics_engine.rb +15 -60
  51. data/lib/theme_check/language_server/diagnostics_manager.rb +136 -0
  52. data/lib/theme_check/language_server/document_change_corrector.rb +267 -0
  53. data/lib/theme_check/language_server/document_link_provider.rb +6 -6
  54. data/lib/theme_check/language_server/execute_command_engine.rb +19 -0
  55. data/lib/theme_check/language_server/execute_command_provider.rb +30 -0
  56. data/lib/theme_check/language_server/execute_command_providers/correction_execute_command_provider.rb +48 -0
  57. data/lib/theme_check/language_server/execute_command_providers/run_checks_execute_command_provider.rb +22 -0
  58. data/lib/theme_check/language_server/handler.rb +79 -28
  59. data/lib/theme_check/language_server/io_messenger.rb +9 -1
  60. data/lib/theme_check/language_server/server.rb +8 -7
  61. data/lib/theme_check/language_server/uri_helper.rb +1 -0
  62. data/lib/theme_check/language_server/versioned_in_memory_storage.rb +69 -0
  63. data/lib/theme_check/language_server.rb +23 -5
  64. data/lib/theme_check/liquid_node.rb +249 -39
  65. data/lib/theme_check/locale_diff.rb +16 -4
  66. data/lib/theme_check/node.rb +16 -0
  67. data/lib/theme_check/offense.rb +27 -23
  68. data/lib/theme_check/regex_helpers.rb +1 -1
  69. data/lib/theme_check/schema_helper.rb +70 -0
  70. data/lib/theme_check/storage.rb +4 -0
  71. data/lib/theme_check/theme.rb +1 -1
  72. data/lib/theme_check/theme_file.rb +8 -1
  73. data/lib/theme_check/theme_file_rewriter.rb +18 -9
  74. data/lib/theme_check/version.rb +1 -1
  75. data/lib/theme_check.rb +7 -2
  76. metadata +26 -3
  77. data/lib/theme_check/language_server/diagnostics_tracker.rb +0 -66
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ThemeCheck
3
- VERSION = "1.8.0"
3
+ VERSION = "1.9.0"
4
4
  end
data/lib/theme_check.rb CHANGED
@@ -4,6 +4,7 @@ require "liquid"
4
4
  require_relative "theme_check/version"
5
5
  require_relative "theme_check/bug"
6
6
  require_relative "theme_check/exceptions"
7
+ require_relative "theme_check/schema_helper"
7
8
  require_relative "theme_check/theme_file_rewriter"
8
9
  require_relative "theme_check/theme_file"
9
10
  require_relative "theme_check/liquid_file"
@@ -24,10 +25,10 @@ require_relative "theme_check/regex_helpers"
24
25
  require_relative "theme_check/json_helpers"
25
26
  require_relative "theme_check/position_helper"
26
27
  require_relative "theme_check/position"
27
- require_relative "theme_check/language_server"
28
28
  require_relative "theme_check/checks"
29
29
  require_relative "theme_check/config"
30
30
  require_relative "theme_check/node"
31
+ require_relative "theme_check/tags"
31
32
  require_relative "theme_check/liquid_node"
32
33
  require_relative "theme_check/html_node"
33
34
  require_relative "theme_check/offense"
@@ -38,11 +39,11 @@ require_relative "theme_check/string_helpers"
38
39
  require_relative "theme_check/storage"
39
40
  require_relative "theme_check/file_system_storage"
40
41
  require_relative "theme_check/in_memory_storage"
41
- require_relative "theme_check/tags"
42
42
  require_relative "theme_check/theme"
43
43
  require_relative "theme_check/corrector"
44
44
  require_relative "theme_check/liquid_visitor"
45
45
  require_relative "theme_check/html_visitor"
46
+ require_relative "theme_check/language_server"
46
47
 
47
48
  Dir[__dir__ + "/theme_check/checks/*.rb"].each { |file| require file }
48
49
 
@@ -55,6 +56,10 @@ module ThemeCheck
55
56
  ENV["THEME_CHECK_DEBUG"] == "true"
56
57
  end
57
58
 
59
+ def self.debug_log_file
60
+ ENV["THEME_CHECK_DEBUG_LOG_FILE"]
61
+ end
62
+
58
63
  def self.with_liquid_c_disabled
59
64
  if defined?(Liquid::C)
60
65
  was_enabled = Liquid::C.enabled
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: theme-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-André Cournoyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -121,6 +121,7 @@ files:
121
121
  - docs/checks/remote_asset.md
122
122
  - docs/checks/required_directories.md
123
123
  - docs/checks/required_layout_theme_object.md
124
+ - docs/checks/schema_json_format.md
124
125
  - docs/checks/space_inside_braces.md
125
126
  - docs/checks/syntax_error.md
126
127
  - docs/checks/template_length.md
@@ -133,6 +134,13 @@ files:
133
134
  - docs/checks/valid_json.md
134
135
  - docs/checks/valid_schema.md
135
136
  - docs/flamegraph.svg
137
+ - docs/language_server/code-action-command-palette.png
138
+ - docs/language_server/code-action-flow.png
139
+ - docs/language_server/code-action-keyboard.png
140
+ - docs/language_server/code-action-light-bulb.png
141
+ - docs/language_server/code-action-problem.png
142
+ - docs/language_server/code-action-quickfix.png
143
+ - docs/language_server/how_to_correct_code_with_code_actions_and_execute_command.md
136
144
  - docs/preview.png
137
145
  - exe/theme-check
138
146
  - exe/theme-check-language-server
@@ -173,6 +181,7 @@ files:
173
181
  - lib/theme_check/checks/remote_asset.rb
174
182
  - lib/theme_check/checks/required_directories.rb
175
183
  - lib/theme_check/checks/required_layout_theme_object.rb
184
+ - lib/theme_check/checks/schema_json_format.rb
176
185
  - lib/theme_check/checks/space_inside_braces.rb
177
186
  - lib/theme_check/checks/syntax_error.rb
178
187
  - lib/theme_check/checks/template_length.rb
@@ -203,6 +212,11 @@ files:
203
212
  - lib/theme_check/language_server.rb
204
213
  - lib/theme_check/language_server/bridge.rb
205
214
  - lib/theme_check/language_server/channel.rb
215
+ - lib/theme_check/language_server/client_capabilities.rb
216
+ - lib/theme_check/language_server/code_action_engine.rb
217
+ - lib/theme_check/language_server/code_action_provider.rb
218
+ - lib/theme_check/language_server/code_action_providers/quickfix_code_action_provider.rb
219
+ - lib/theme_check/language_server/code_action_providers/source_fix_all_code_action_provider.rb
206
220
  - lib/theme_check/language_server/completion_engine.rb
207
221
  - lib/theme_check/language_server/completion_helper.rb
208
222
  - lib/theme_check/language_server/completion_provider.rb
@@ -210,15 +224,22 @@ files:
210
224
  - lib/theme_check/language_server/completion_providers/object_completion_provider.rb
211
225
  - lib/theme_check/language_server/completion_providers/render_snippet_completion_provider.rb
212
226
  - lib/theme_check/language_server/completion_providers/tag_completion_provider.rb
227
+ - lib/theme_check/language_server/configuration.rb
213
228
  - lib/theme_check/language_server/constants.rb
229
+ - lib/theme_check/language_server/diagnostic.rb
214
230
  - lib/theme_check/language_server/diagnostics_engine.rb
215
- - lib/theme_check/language_server/diagnostics_tracker.rb
231
+ - lib/theme_check/language_server/diagnostics_manager.rb
232
+ - lib/theme_check/language_server/document_change_corrector.rb
216
233
  - lib/theme_check/language_server/document_link_engine.rb
217
234
  - lib/theme_check/language_server/document_link_provider.rb
218
235
  - lib/theme_check/language_server/document_link_providers/asset_document_link_provider.rb
219
236
  - lib/theme_check/language_server/document_link_providers/include_document_link_provider.rb
220
237
  - lib/theme_check/language_server/document_link_providers/render_document_link_provider.rb
221
238
  - lib/theme_check/language_server/document_link_providers/section_document_link_provider.rb
239
+ - lib/theme_check/language_server/execute_command_engine.rb
240
+ - lib/theme_check/language_server/execute_command_provider.rb
241
+ - lib/theme_check/language_server/execute_command_providers/correction_execute_command_provider.rb
242
+ - lib/theme_check/language_server/execute_command_providers/run_checks_execute_command_provider.rb
222
243
  - lib/theme_check/language_server/handler.rb
223
244
  - lib/theme_check/language_server/io_messenger.rb
224
245
  - lib/theme_check/language_server/messenger.rb
@@ -227,6 +248,7 @@ files:
227
248
  - lib/theme_check/language_server/tokens.rb
228
249
  - lib/theme_check/language_server/uri_helper.rb
229
250
  - lib/theme_check/language_server/variable_lookup_finder.rb
251
+ - lib/theme_check/language_server/versioned_in_memory_storage.rb
230
252
  - lib/theme_check/liquid_check.rb
231
253
  - lib/theme_check/liquid_file.rb
232
254
  - lib/theme_check/liquid_node.rb
@@ -242,6 +264,7 @@ files:
242
264
  - lib/theme_check/regex_helpers.rb
243
265
  - lib/theme_check/releaser.rb
244
266
  - lib/theme_check/remote_asset_file.rb
267
+ - lib/theme_check/schema_helper.rb
245
268
  - lib/theme_check/shopify_liquid.rb
246
269
  - lib/theme_check/shopify_liquid/deprecated_filter.rb
247
270
  - lib/theme_check/shopify_liquid/filter.rb
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
- require "logger"
3
-
4
- module ThemeCheck
5
- module LanguageServer
6
- class DiagnosticsTracker
7
- def initialize
8
- @previously_reported_files = Set.new
9
- @single_files_offenses = {}
10
- @first_run = true
11
- end
12
-
13
- def first_run?
14
- @first_run
15
- end
16
-
17
- def build_diagnostics(offenses, analyzed_files: nil)
18
- reported_files = Set.new
19
- new_single_file_offenses = {}
20
- analyzed_files = analyzed_files.map { |path| Pathname.new(path) } if analyzed_files
21
-
22
- offenses.group_by(&:theme_file).each do |theme_file, template_offenses|
23
- next unless theme_file
24
- reported_offenses = template_offenses
25
- previous_offenses = @single_files_offenses[theme_file.path]
26
- if analyzed_files.nil? || analyzed_files.include?(theme_file.path)
27
- # We re-analyzed the file, so we know the template_offenses are update to date.
28
- reported_single_file_offenses = reported_offenses.select(&:single_file?)
29
- if reported_single_file_offenses.any?
30
- new_single_file_offenses[theme_file.path] = reported_single_file_offenses
31
- end
32
- elsif previous_offenses
33
- # Merge in the previous ones, if some
34
- reported_offenses |= previous_offenses
35
- end
36
- yield theme_file.path, reported_offenses
37
- reported_files << theme_file.path
38
- end
39
-
40
- @single_files_offenses.each do |path, _|
41
- # Already reported above, skip
42
- next if reported_files.include?(path)
43
-
44
- if analyzed_files.nil? || analyzed_files.include?(path)
45
- # We re-analyzed this file, if it was not reported, all offenses in it got fixed
46
- yield path, []
47
- new_single_file_offenses[path] = nil
48
- end
49
- # NOTE: No need to re-report previous offenses as LSP should keep them around until
50
- # we clear them.
51
- reported_files << path
52
- end
53
-
54
- # Publish diagnostics with empty array if all issues on a previously reported theme_file
55
- # have been fixed.
56
- (@previously_reported_files - reported_files).each do |path|
57
- yield path, []
58
- end
59
-
60
- @previously_reported_files = reported_files
61
- @single_files_offenses.merge!(new_single_file_offenses)
62
- @first_run = false
63
- end
64
- end
65
- end
66
- end