Skip to content

Commit

Permalink
Make sure there is a space between the return and the normalize event…
Browse files Browse the repository at this point in the history
… call.
  • Loading branch information
gdotdesign authored and Namek committed Jan 31, 2021
1 parent ee2dc77 commit 975b212
Show file tree
Hide file tree
Showing 45 changed files with 108 additions and 21 deletions.
3 changes: 0 additions & 3 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: mint
version: 0.12.0-devel

authors:
- Szikszai Gusztáv

dependencies:
string_inflection:
github: mosop/string_inflection
Expand Down
2 changes: 1 addition & 1 deletion src/assets/runtime.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/compilers/component.cr
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module Mint

def compile_component_store_data(node : Ast::Component) : Array(Codegen::Node)
node.connects.reduce([] of Codegen::Node) do |memo, item|
store = ast.stores.find(&.name.==(item.store))
store = ast.stores.find { |entity| entity.name == item.store }

if store
item.keys.map do |key|
Expand All @@ -122,11 +122,11 @@ module Mint
name = js.variable_of(key)

case
when store.constants.any?(&.name.==(original)),
store.gets.any?(&.name.value.==(original)),
when store.constants.any? { |constant| constant.name == original },
store.gets.any? { |get| get.name.value == original },
store.states.find(&.name.value.==(original))
memo << js.get(name, Codegen.join ["return ", store_name, ".", id, ";"])
when store.functions.any?(&.name.value.==(original))
when store.functions.any? { |func| func.name.value == original }
memo << Codegen.join [name, " (...params) { return ", store_name, ".", id, "(...params); }"]
end
end
Expand Down Expand Up @@ -193,7 +193,7 @@ module Mint
function.keep_name = true if function

# If the user defined the same function the code goes after it.
if function && !value.empty?
if function && value.any?
compile function, js.statements(value)
elsif !value.empty?
js.function(key, %w[], js.statements(value))
Expand Down
2 changes: 2 additions & 0 deletions src/compilers/html_attribute.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Mint
end
when "ref"
value = Codegen.join ["(ref => { ref ? ", value, ".call(this, ref) : null })"]
else
# ignore
end

if downcase_name == "readonly" && is_element
Expand Down
2 changes: 2 additions & 0 deletions src/compilers/module_access.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module Mint
if node.variable.value == "subscriptions"
return Codegen.join [name, "._subscriptions"]
end
else
# ignore
end

variable =
Expand Down
2 changes: 2 additions & 0 deletions src/compilers/next_call.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Mint
entity
.states
.find(&.name.value.==(item.key.value))
else
# ignore
end

if field
Expand Down
8 changes: 7 additions & 1 deletion src/compilers/parallel.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Mint
if type.name.in?("Promise", "Result") && type.parameters[0]
node
.catches
.select(&.type.==(type.parameters[0].name))
.select { |item| item.type == type.parameters[0].name }
.map { |item| compile(item) }
end
else
Expand Down Expand Up @@ -73,7 +73,11 @@ module Mint
"")
end
end
else
# ignore
end
else
# ignore
end || js.asynciif do
prefix.call(Codegen.join ["await ", expression])
end
Expand Down Expand Up @@ -107,6 +111,8 @@ module Mint
target.parameters.map do |variable|
js.let(Codegen.symbol_mapped(variable, js.variable_of(variable)), "null")
end
else
# ignore
end
end.flatten.compact

Expand Down
6 changes: 5 additions & 1 deletion src/compilers/sequence.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module Mint
if type.name.in?("Promise", "Result") && type.parameters[0]
node
.catches
.select(&.type.==(type.parameters[0].name))
.select { |item| item.type == type.parameters[0].name }
.map { |item| compile(item) }
else
[] of Codegen::Node
Expand Down Expand Up @@ -83,7 +83,11 @@ module Mint
end.as(Codegen::Node)
prefix.call(Codegen.join ["await ", try])
end
else
# ignore
end
else
# ignore
end || prefix.call(Codegen.join ["await ", expression])
end

Expand Down
2 changes: 2 additions & 0 deletions src/compilers/test.cr
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module Mint
})(constants)",
]
end
else
# ignore
end

expression = compile raw_expression unless expression
Expand Down
2 changes: 1 addition & 1 deletion src/compilers/top_level.cr
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ module Mint
const _normalizeEvent = function (event) {
return
JS1
),
) + " ",
from_event_call,
(
<<-JS2
Expand Down
2 changes: 2 additions & 0 deletions src/compilers/try.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module Mint
js.statements(catched.compact)
end
end
else
# ignore
end

if catches && !Codegen.empty?(catches)
Expand Down
4 changes: 4 additions & 0 deletions src/compilers/variable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module Mint
when Ast::State then entity.name.value
when Ast::Get then entity.name.value
when Ast::Constant then entity.name
else
# ignore
end

if store
Expand All @@ -35,6 +37,8 @@ module Mint
end
end
end
else
# ignore
end

result =
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/function.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Mint
value =
format node.arguments

if value.sum { |string| replace_skipped(string).size } > 50
if value.map { |string| replace_skipped(string) }.map(&.size).sum > 50
"(\n#{indent(value.join(",\n"))}\n)"
else
"(#{value.join(", ")})"
Expand Down
2 changes: 2 additions & 0 deletions src/formatters/if.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Mint
list falsy_item + node.falsy_head_comments + node.falsy_tail_comments
when Ast::Node
list [falsy_item] + node.falsy_head_comments + node.falsy_tail_comments
else
# ignore
end

" else {\n#{indent(body)}\n}" if body
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/inline_function.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Mint
format node.arguments

arguments =
if value.sum { |string| replace_skipped(string).size } > 50
if value.map { |string| replace_skipped(string) }.map(&.size).sum > 50
"\n#{indent(value.join(",\n"))}\n"
else
value.join(", ")
Expand Down
4 changes: 3 additions & 1 deletion src/formatters/style.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module Mint
value =
format node.arguments

if value.sum { |string| replace_skipped(string).size } > 50
if value
.map { |string| replace_skipped(string) }
.map(&.size).sum > 50
"(\n#{indent(value.join(",\n"))}\n) "
else
"(#{value.join(", ")}) "
Expand Down
6 changes: 2 additions & 4 deletions src/installer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ module Mint
unless @resolved[dependency]?
eliminated =
@eliminated
.select(&.[0][:name].==(dependency))
.map do |item|
"#{item[0][:version]} by #{item[2]} from #{item[1][:name]}:#{item[1][:version]}"
end
.select { |item| item[0][:name] == dependency }
.map { |item| "#{item[0][:version]} by #{item[2]} from #{item[1][:name]}:#{item[1][:version]}" }

raise InstallerFailedToInstall, {
"package" => "#{base[:name]}:#{base[:version]}",
Expand Down
2 changes: 2 additions & 0 deletions src/js.cr
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ module Mint
case node
when Ast::Function
return node.name.value if node.keep_name?
else
# ignore
end

@cache[node] ||= next_variable
Expand Down
4 changes: 4 additions & 0 deletions src/message.cr
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,13 @@ module Mint
bold item.value
when Code
code item.value
else
# ignore
end
end
end
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/messages/installer_failed_to_install.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ message InstallerFailedToInstall do
bold name
end
end
else
# ignore
end
end
2 changes: 2 additions & 0 deletions src/parsers/case.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module Mint
branches << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/component.cr
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module Mint
gets << item
when Ast::Use
uses << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/enum.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module Mint
options << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/module.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module Mint
constants << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/parallel.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module Mint
statements << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/provider.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module Mint
comments << item
when Ast::Get
gets << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/routes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Mint
routes << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/sequence.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module Mint
statements << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module Mint
states << item
when Ast::Get
gets << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/suite.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module Mint
constants << item
when Ast::Test
tests << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/top_level.cr
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ module Mint
@ast.enums << item
when Ast::Comment
@ast.comments << item
else
# ignore
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/parsers/try.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module Mint
statements << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/parsers/where.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Mint
statements << item
when Ast::Comment
comments << item
else
# ignore
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/style_builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ module Mint
when Ast::If
ifs[{style_node, selector}] ||= [] of Ast::If
ifs[{style_node, selector}] << item
else
# ignore
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/test_runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ module Mint
when "FAILED"
@reporter.failed data.name, data.result
@failed << data
else
# ignore
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/type_checkers/case.cr
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ module Mint
"node" => node,
}
end
else
# ignore
end

first
Expand Down
Loading

0 comments on commit 975b212

Please sign in to comment.