platformos-check 0.0.3 → 0.1.0
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 +7 -0
- data/data/platformos_liquid/documentation/filters.json +1 -1
- data/lib/platformos_check/app.rb +21 -18
- data/lib/platformos_check/checks/invalid_args.rb +7 -39
- data/lib/platformos_check/cli.rb +3 -4
- data/lib/platformos_check/file_system_storage.rb +3 -7
- data/lib/platformos_check/graphql_file.rb +25 -1
- data/lib/platformos_check/in_memory_storage.rb +2 -24
- data/lib/platformos_check/language_server/completion_providers/background_partial_completion_provider.rb +19 -0
- data/lib/platformos_check/language_server/completion_providers/function_partial_completion_provider.rb +19 -0
- data/lib/platformos_check/language_server/completion_providers/graphql_partial_completion_provider.rb +19 -0
- data/lib/platformos_check/language_server/completion_providers/include_partial_completion_provider.rb +19 -0
- data/lib/platformos_check/language_server/completion_providers/render_partial_completion_provider.rb +19 -0
- data/lib/platformos_check/language_server/constants.rb +1 -1
- data/lib/platformos_check/language_server/diagnostics_engine.rb +2 -3
- data/lib/platformos_check/language_server/document_link_engine.rb +1 -3
- data/lib/platformos_check/language_server/hover_providers/filter_hover_provider.rb +9 -15
- data/lib/platformos_check/language_server/partial_completion_provider.rb +48 -0
- data/lib/platformos_check/language_server.rb +1 -0
- data/lib/platformos_check/liquid_visitor.rb +1 -1
- data/lib/platformos_check/platformos_liquid/source_index/filter_entry.rb +35 -2
- data/lib/platformos_check/platformos_liquid/source_index/parameter_entry.rb +4 -0
- data/lib/platformos_check/storage.rb +2 -2
- data/lib/platformos_check/version.rb +1 -1
- metadata +8 -3
- data/lib/platformos_check/language_server/completion_providers/render_snippet_completion_provider.rb +0 -50
data/lib/platformos_check/app.rb
CHANGED
@@ -39,29 +39,32 @@ module PlatformosCheck
|
|
39
39
|
CONFIG_REGEX => ConfigFile
|
40
40
|
}
|
41
41
|
|
42
|
-
attr_reader :storage
|
42
|
+
attr_reader :storage, :grouped_files
|
43
43
|
|
44
44
|
def initialize(storage)
|
45
45
|
@storage = storage
|
46
|
+
@grouped_files = {}
|
47
|
+
REGEXP_MAP.each_value { |v| @grouped_files[v] ||= {} }
|
48
|
+
process_files(storage.files)
|
46
49
|
end
|
47
50
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
def update(files, remove: false)
|
52
|
+
process_files(files, remove:)
|
53
|
+
end
|
54
|
+
|
55
|
+
def process_files(files, remove: false)
|
56
|
+
files.each do |path|
|
57
|
+
regexp, klass = REGEXP_MAP.detect { |k, _v| k.match?(path) }
|
58
|
+
next unless regexp
|
59
|
+
|
60
|
+
f = klass.new(path, storage)
|
61
|
+
if remove
|
62
|
+
@grouped_files[klass].delete(f.name)
|
63
|
+
else
|
64
|
+
@grouped_files[klass][f.name] = f
|
62
65
|
end
|
63
|
-
hash
|
64
66
|
end
|
67
|
+
@grouped_files
|
65
68
|
end
|
66
69
|
|
67
70
|
def assets
|
@@ -121,7 +124,7 @@ module PlatformosCheck
|
|
121
124
|
end
|
122
125
|
|
123
126
|
def all
|
124
|
-
|
127
|
+
grouped_files.values.map(&:values).flatten
|
125
128
|
end
|
126
129
|
|
127
130
|
def [](name_or_relative_path)
|
@@ -129,7 +132,7 @@ module PlatformosCheck
|
|
129
132
|
when Pathname
|
130
133
|
all.find { |t| t.relative_path == name_or_relative_path }
|
131
134
|
else
|
132
|
-
all.find { |t| t.
|
135
|
+
all.find { |t| t.relative_path.to_s == name_or_relative_path }
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
@@ -2,33 +2,6 @@
|
|
2
2
|
|
3
3
|
module PlatformosCheck
|
4
4
|
class InvalidArgs < LiquidCheck
|
5
|
-
class ParsedGraphQL
|
6
|
-
def initialize(ast)
|
7
|
-
@ast = ast
|
8
|
-
end
|
9
|
-
|
10
|
-
def required_arguments
|
11
|
-
variables.each_with_object([]) do |v, vars|
|
12
|
-
vars << v.name if v.type.is_a?(GraphQL::Language::Nodes::NonNullType)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def defined_arguments
|
17
|
-
variables.map(&:name)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :ast
|
23
|
-
|
24
|
-
def variables
|
25
|
-
@variables ||= definition&.variables || []
|
26
|
-
end
|
27
|
-
|
28
|
-
def definition
|
29
|
-
@definition ||= ast.definitions.detect { |d| d.is_a?(GraphQL::Language::Nodes::OperationDefinition) }
|
30
|
-
end
|
31
|
-
end
|
32
5
|
severity :error
|
33
6
|
category :liquid, :graphql
|
34
7
|
doc docs_url(__FILE__)
|
@@ -49,27 +22,22 @@ module PlatformosCheck
|
|
49
22
|
graphql_partial = node.value.partial_name
|
50
23
|
return unless graphql_partial.is_a?(String)
|
51
24
|
|
52
|
-
|
53
|
-
return unless
|
25
|
+
graphql_file = platformos_app.grouped_files[GraphqlFile][graphql_partial]
|
26
|
+
return unless graphql_file
|
54
27
|
|
55
28
|
provided_arguments = node.value.attributes
|
56
29
|
|
57
30
|
return if provided_arguments.include?('args')
|
58
31
|
|
59
|
-
|
60
|
-
|
61
|
-
required_arguments = parsed_graphql.required_arguments
|
62
|
-
defined_arguments = parsed_graphql.defined_arguments
|
63
|
-
|
64
|
-
(provided_arguments - defined_arguments).each do |name|
|
65
|
-
add_offense("Undefined argument `#{name}` provided to `#{graqphql_file.relative_path}`", node:)
|
32
|
+
(provided_arguments - graphql_file.defined_arguments).each do |name|
|
33
|
+
add_offense("Undefined argument `#{name}` provided to `#{graphql_file.relative_path}`", node:)
|
66
34
|
end
|
67
35
|
|
68
|
-
(required_arguments - provided_arguments).each do |name|
|
69
|
-
add_offense("Required argument `#{name}` not provided to `#{
|
36
|
+
(graphql_file.required_arguments - provided_arguments).each do |name|
|
37
|
+
add_offense("Required argument `#{name}` not provided to `#{graphql_file.relative_path}`", node:)
|
70
38
|
end
|
71
39
|
rescue GraphQL::ParseError => e
|
72
|
-
add_offense("GraphQL Parse error triggered by `#{
|
40
|
+
add_offense("GraphQL Parse error triggered by `#{graphql_file.relative_path}`: #{e.message}", node:)
|
73
41
|
end
|
74
42
|
|
75
43
|
def add_duplicated_key_offense(node)
|
data/lib/platformos_check/cli.rb
CHANGED
@@ -190,13 +190,12 @@ module PlatformosCheck
|
|
190
190
|
|
191
191
|
warn "Checking #{@config.root} ..."
|
192
192
|
storage = PlatformosCheck::FileSystemStorage.new(@config.root, ignored_patterns: @config.ignored_patterns)
|
193
|
-
platformos_app
|
194
|
-
raise Abort, "No platformos_app files found." if platformos_app.all.empty?
|
193
|
+
raise Abort, "No platformos_app files found." if storage.platformos_app.all.empty?
|
195
194
|
|
196
|
-
analyzer = PlatformosCheck::Analyzer.new(platformos_app, @config.enabled_checks, @config.auto_correct)
|
195
|
+
analyzer = PlatformosCheck::Analyzer.new(storage.platformos_app, @config.enabled_checks, @config.auto_correct)
|
197
196
|
analyzer.analyze_platformos_app
|
198
197
|
analyzer.correct_offenses
|
199
|
-
print_with_format(platformos_app, analyzer, out_stream)
|
198
|
+
print_with_format(storage.platformos_app, analyzer, out_stream)
|
200
199
|
# corrections are committed after printing so that the
|
201
200
|
# source_excerpts are still pointing to the uncorrected source.
|
202
201
|
analyzer.write_corrections
|
@@ -31,10 +31,13 @@ module PlatformosCheck
|
|
31
31
|
|
32
32
|
file(relative_path).dirname.mkpath unless file(relative_path).dirname.directory?
|
33
33
|
file(relative_path).write(content, mode: 'w+b', encoding: 'UTF-8')
|
34
|
+
@platformos_app&.update([relative_path])
|
34
35
|
end
|
35
36
|
|
36
37
|
def remove(relative_path)
|
37
38
|
file(relative_path).delete
|
39
|
+
|
40
|
+
@platformos_app&.update([relative_path], remove: true)
|
38
41
|
reset_memoizers
|
39
42
|
end
|
40
43
|
|
@@ -60,12 +63,6 @@ module PlatformosCheck
|
|
60
63
|
.map { |path| path.relative_path_from(@root).to_s }
|
61
64
|
end
|
62
65
|
|
63
|
-
def directories
|
64
|
-
@directories ||= glob('**/')
|
65
|
-
.select { |f| File.directory?(f) }
|
66
|
-
.map { |f| f.relative_path_from(@root).to_s }
|
67
|
-
end
|
68
|
-
|
69
66
|
private
|
70
67
|
|
71
68
|
def file_exists?(relative_path)
|
@@ -74,7 +71,6 @@ module PlatformosCheck
|
|
74
71
|
|
75
72
|
def reset_memoizers
|
76
73
|
@file_array = nil
|
77
|
-
@directories = nil
|
78
74
|
end
|
79
75
|
|
80
76
|
def glob(pattern)
|
@@ -13,6 +13,12 @@ module PlatformosCheck
|
|
13
13
|
@storage.write(@relative_path, content.gsub("\n", @eol))
|
14
14
|
@source = content
|
15
15
|
@rewriter = nil
|
16
|
+
@ast = nil
|
17
|
+
@variables = nil
|
18
|
+
@definition = nil
|
19
|
+
@parse = nil
|
20
|
+
@required_arguments = nil
|
21
|
+
@defined_arguments = nil
|
16
22
|
end
|
17
23
|
|
18
24
|
def rewriter
|
@@ -48,7 +54,7 @@ module PlatformosCheck
|
|
48
54
|
end
|
49
55
|
|
50
56
|
def warnings
|
51
|
-
|
57
|
+
parse.warnings
|
52
58
|
end
|
53
59
|
|
54
60
|
def root
|
@@ -59,8 +65,26 @@ module PlatformosCheck
|
|
59
65
|
Struct.new(:warnings, :root)
|
60
66
|
end
|
61
67
|
|
68
|
+
def required_arguments
|
69
|
+
@required_arguments ||= variables.each_with_object([]) do |v, vars|
|
70
|
+
vars << v.name if v.type.is_a?(GraphQL::Language::Nodes::NonNullType)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def defined_arguments
|
75
|
+
@defined_arguments ||= variables.map(&:name)
|
76
|
+
end
|
77
|
+
|
62
78
|
private
|
63
79
|
|
80
|
+
def variables
|
81
|
+
@variables ||= definition&.variables || []
|
82
|
+
end
|
83
|
+
|
84
|
+
def definition
|
85
|
+
@definition ||= parse.definitions.detect { |d| d.is_a?(GraphQL::Language::Nodes::OperationDefinition) }
|
86
|
+
end
|
87
|
+
|
64
88
|
def bounded(lower, x, upper)
|
65
89
|
[lower, [x, upper].min].max
|
66
90
|
end
|
@@ -22,47 +22,25 @@ module PlatformosCheck
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def write(relative_path, content)
|
25
|
+
@platformos_app&.update([relative_path])
|
25
26
|
@files[relative_path] = content
|
26
27
|
end
|
27
28
|
|
28
29
|
def remove(relative_path)
|
30
|
+
@platformos_app&.update([relative_path], remove: true)
|
29
31
|
@files.delete(relative_path)
|
30
32
|
end
|
31
33
|
|
32
34
|
def mkdir(relative_path)
|
33
35
|
@files[relative_path] = nil
|
34
|
-
reset_memoizers
|
35
36
|
end
|
36
37
|
|
37
|
-
# TODO: Fix corrector
|
38
|
-
# def rename(old_path, new_path)
|
39
|
-
# old_path += '/' if old_path[-1] != '/'
|
40
|
-
# new_path += '/' if new_path[-1] != '/'
|
41
|
-
# @files.transform_keys! { |k| k.sub(/\A#{old_path}/, new_path) }
|
42
|
-
#
|
43
|
-
# reset_memoizers
|
44
|
-
# end
|
45
|
-
|
46
38
|
def files
|
47
39
|
@files.keys
|
48
40
|
end
|
49
41
|
|
50
|
-
def directories
|
51
|
-
@directories ||= @files
|
52
|
-
.keys
|
53
|
-
.flat_map { |relative_path| Pathname.new(relative_path).ascend.to_a }
|
54
|
-
.map(&:to_s)
|
55
|
-
.uniq
|
56
|
-
end
|
57
|
-
|
58
42
|
def relative_path(absolute_path)
|
59
43
|
Pathname.new(absolute_path).relative_path_from(@root).to_s
|
60
44
|
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def reset_memoizers
|
65
|
-
@directories = nil
|
66
|
-
end
|
67
45
|
end
|
68
46
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class BackgroundPartialCompletionProvider < CompletionProvider
|
6
|
+
include PartialCompletionProvider
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def files
|
11
|
+
@storage.platformos_app.partials
|
12
|
+
end
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
PARTIAL_BACKGROUND
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class FunctionPartialCompletionProvider < CompletionProvider
|
6
|
+
include PartialCompletionProvider
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def files
|
11
|
+
@storage.platformos_app.partials
|
12
|
+
end
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
PARTIAL_FUNCTION
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class GraphqlPartialCompletionProvider < CompletionProvider
|
6
|
+
include PartialCompletionProvider
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def files
|
11
|
+
@storage.platformos_app.graphqls
|
12
|
+
end
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
PARTIAL_GRAPHQL
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class IncludePartialCompletionProvider < CompletionProvider
|
6
|
+
include PartialCompletionProvider
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def files
|
11
|
+
@storage.platformos_app.partials
|
12
|
+
end
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
PARTIAL_INCLUDE
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/platformos_check/language_server/completion_providers/render_partial_completion_provider.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class RenderPartialCompletionProvider < CompletionProvider
|
6
|
+
include PartialCompletionProvider
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def files
|
11
|
+
@storage.platformos_app.partials
|
12
|
+
end
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
PARTIAL_RENDER
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -15,7 +15,7 @@ module PlatformosCheck
|
|
15
15
|
|
16
16
|
def self.partial_tag_with_result(tag)
|
17
17
|
/
|
18
|
-
\{%-?\s*#{tag}\s+(?<var>[\w]+)
|
18
|
+
\{%-?\s*#{tag}\s+(?<var>[\w]+)\s*=\s*'(?<partial>[^']*)'|
|
19
19
|
\{%-?\s*#{tag}\s+(?<var>[\w]+)\s*=\s*"(?<partial>[^"]*)"|
|
20
20
|
|
21
21
|
# in liquid tags the whole line is white space until the tag
|
@@ -21,13 +21,12 @@ module PlatformosCheck
|
|
21
21
|
def analyze_and_send_offenses(absolute_path_or_paths, config, force: false, only_single_file: false)
|
22
22
|
return unless @diagnostics_lock.try_lock
|
23
23
|
|
24
|
-
|
25
|
-
analyzer = PlatformosCheck::Analyzer.new(platformos_app, config.enabled_checks)
|
24
|
+
analyzer = PlatformosCheck::Analyzer.new(storage.platformos_app, config.enabled_checks)
|
26
25
|
|
27
26
|
if !only_single_file && (@diagnostics_manager.first_run? || force)
|
28
27
|
run_full_platformos_check(analyzer)
|
29
28
|
else
|
30
|
-
run_partial_platformos_check(absolute_path_or_paths, platformos_app, analyzer, only_single_file)
|
29
|
+
run_partial_platformos_check(absolute_path_or_paths, storage.platformos_app, analyzer, only_single_file)
|
31
30
|
end
|
32
31
|
|
33
32
|
@diagnostics_lock.unlock
|
@@ -12,10 +12,8 @@ module PlatformosCheck
|
|
12
12
|
buffer = @storage.read(relative_path)
|
13
13
|
return [] unless buffer
|
14
14
|
|
15
|
-
platformos_app = PlatformosCheck::App.new(@storage)
|
16
|
-
|
17
15
|
@providers.flat_map do |p|
|
18
|
-
p.document_links(buffer, platformos_app)
|
16
|
+
p.document_links(buffer, @storage.platformos_app)
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -18,7 +18,10 @@ module PlatformosCheck
|
|
18
18
|
variable_lookup = VariableLookupFinder.lookup(context)
|
19
19
|
denied_filters = denied_filters_for(variable_lookup)
|
20
20
|
available_filters_for(determine_input_type(variable_lookup))
|
21
|
-
.select
|
21
|
+
.select do |filter|
|
22
|
+
partial_name = partial(content, cursor)
|
23
|
+
(filter.name == partial_name || filter.aliases.any? { |a| a == partial_name }) && denied_filters.none?(filter.name)
|
24
|
+
end
|
22
25
|
.map { |filter| filter_to_completion(filter) }
|
23
26
|
.first
|
24
27
|
end
|
@@ -88,23 +91,14 @@ module PlatformosCheck
|
|
88
91
|
partial_match[1]
|
89
92
|
end
|
90
93
|
|
91
|
-
def param_to_doc(param)
|
92
|
-
"#{param&.name || 'object'}:#{param&.return_type&.downcase || 'untyped'}"
|
93
|
-
end
|
94
|
-
|
95
94
|
def filter_to_completion(filter)
|
96
95
|
content = PlatformosLiquid::Documentation.render_doc(filter)
|
97
|
-
first_param, *other_params = filter.parameters
|
98
|
-
other_params = other_params.map { |param| param_to_doc(param) }
|
99
|
-
other_params = other_params.any? ? ": #{other_params.join(', ')}" : ""
|
100
|
-
content += " \n\n#{param_to_doc(first_param)} | #{filter.name}#{other_params} => #{filter.return_type}"
|
101
|
-
|
102
96
|
{
|
103
|
-
contents: content
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
97
|
+
contents: content,
|
98
|
+
label: filter.name,
|
99
|
+
kind: CompletionItemKinds::FUNCTION,
|
100
|
+
**format_hash(filter),
|
101
|
+
**doc_hash(content)
|
108
102
|
}
|
109
103
|
end
|
110
104
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
module PartialCompletionProvider
|
6
|
+
def completions(context)
|
7
|
+
content = context.buffer.lines[context.line]
|
8
|
+
cursor = context.col
|
9
|
+
@file_name = nil
|
10
|
+
|
11
|
+
return [] if content.nil?
|
12
|
+
return [] unless cursor_on_quoted_argument?(content, cursor)
|
13
|
+
|
14
|
+
files
|
15
|
+
.select { |x| x.name.start_with?(@file_name) }
|
16
|
+
.map { |x| file_to_completion(x) }
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def cursor_on_quoted_argument?(content, cursor)
|
22
|
+
match = content.match(regexp)
|
23
|
+
return false if match.nil?
|
24
|
+
|
25
|
+
return false unless match.begin(:partial) <= cursor && cursor <= match.end(:partial)
|
26
|
+
|
27
|
+
@file_name = match[:partial]
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def files
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def regexp
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
def file_to_completion(file)
|
40
|
+
{
|
41
|
+
label: file.name,
|
42
|
+
kind: CompletionItemKinds::SNIPPET,
|
43
|
+
detail: file.source
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -32,6 +32,7 @@ require_relative "language_server/completion_context"
|
|
32
32
|
require_relative "language_server/completion_helper"
|
33
33
|
require_relative "language_server/completion_provider"
|
34
34
|
require_relative "language_server/completion_engine"
|
35
|
+
require_relative "language_server/partial_completion_provider"
|
35
36
|
Dir[__dir__ + "/language_server/completion_providers/*.rb"].each do |file|
|
36
37
|
require file
|
37
38
|
end
|
@@ -12,7 +12,7 @@ module PlatformosCheck
|
|
12
12
|
def visit_liquid_file(liquid_file)
|
13
13
|
visit(LiquidNode.new(liquid_file.root, nil, liquid_file))
|
14
14
|
rescue Liquid::Error => e
|
15
|
-
e.template_name = liquid_file.
|
15
|
+
e.template_name = liquid_file.relative_path
|
16
16
|
call_checks(:on_error, e)
|
17
17
|
end
|
18
18
|
|
@@ -1,12 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cgi'
|
4
|
+
|
3
5
|
module PlatformosCheck
|
4
6
|
module PlatformosLiquid
|
5
7
|
class SourceIndex
|
6
8
|
class FilterEntry < BaseEntry
|
7
9
|
def parameters
|
8
|
-
(hash['parameters'] || [])
|
9
|
-
|
10
|
+
@parameters ||= (hash['parameters'] || []).map { |hash| ParameterEntry.new(hash) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def summary
|
14
|
+
hash['summary']&.strip == 'returns' ? nil : hash['summary']
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
@descritpion = begin
|
19
|
+
desc = hash['description']&.strip || ''
|
20
|
+
desc = '' if desc == 'returns'
|
21
|
+
if parameters.any?
|
22
|
+
desc += "Parameters:"
|
23
|
+
parameters.each { |p| desc += "\n- #{p.full_summary}" }
|
24
|
+
end
|
25
|
+
if hash['return_type']&.any?
|
26
|
+
rt = hash['return_type'].first
|
27
|
+
rt['description'] = nil if rt['description']&.strip == ''
|
28
|
+
desc += "\n\nReturns:"
|
29
|
+
desc += "\n- #{[rt['type'], rt['description']].compact.join(': ')}\n"
|
30
|
+
end
|
31
|
+
if hash['examples']
|
32
|
+
desc += "\n\n---\n\n"
|
33
|
+
hash['examples'].each_with_index do |e, i|
|
34
|
+
example = e['raw_liquid'].gsub(/[\n]+/, "\n").strip.split('=>')
|
35
|
+
input = example[0].strip
|
36
|
+
output = example[1]&.strip
|
37
|
+
desc += "\n - Example #{i}:\n\n```liquid\n#{input}\n```"
|
38
|
+
desc += "\n##\nOutput: #{output}" if output
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
desc
|
10
43
|
end
|
11
44
|
|
12
45
|
def aliases
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: platformos-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Bliszczyk
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-09-
|
13
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: graphql
|
@@ -205,10 +205,14 @@ files:
|
|
205
205
|
- lib/platformos_check/language_server/completion_helper.rb
|
206
206
|
- lib/platformos_check/language_server/completion_provider.rb
|
207
207
|
- lib/platformos_check/language_server/completion_providers/assignments_completion_provider.rb
|
208
|
+
- lib/platformos_check/language_server/completion_providers/background_partial_completion_provider.rb
|
208
209
|
- lib/platformos_check/language_server/completion_providers/filter_completion_provider.rb
|
210
|
+
- lib/platformos_check/language_server/completion_providers/function_partial_completion_provider.rb
|
211
|
+
- lib/platformos_check/language_server/completion_providers/graphql_partial_completion_provider.rb
|
212
|
+
- lib/platformos_check/language_server/completion_providers/include_partial_completion_provider.rb
|
209
213
|
- lib/platformos_check/language_server/completion_providers/object_attribute_completion_provider.rb
|
210
214
|
- lib/platformos_check/language_server/completion_providers/object_completion_provider.rb
|
211
|
-
- lib/platformos_check/language_server/completion_providers/
|
215
|
+
- lib/platformos_check/language_server/completion_providers/render_partial_completion_provider.rb
|
212
216
|
- lib/platformos_check/language_server/completion_providers/tag_completion_provider.rb
|
213
217
|
- lib/platformos_check/language_server/configuration.rb
|
214
218
|
- lib/platformos_check/language_server/constants.rb
|
@@ -235,6 +239,7 @@ files:
|
|
235
239
|
- lib/platformos_check/language_server/hover_providers/filter_hover_provider.rb
|
236
240
|
- lib/platformos_check/language_server/io_messenger.rb
|
237
241
|
- lib/platformos_check/language_server/messenger.rb
|
242
|
+
- lib/platformos_check/language_server/partial_completion_provider.rb
|
238
243
|
- lib/platformos_check/language_server/protocol.rb
|
239
244
|
- lib/platformos_check/language_server/server.rb
|
240
245
|
- lib/platformos_check/language_server/tokens.rb
|