From 9bdf890fd85a729a9be52ea2b692369f1df15743 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 19 May 2015 09:24:19 -0400 Subject: [PATCH 1/2] Fix nil NoMethodError when converting a duplicated grammar We were sticking a nil value into the grammars Array when we encountered a duplicate scope. Now we strip out nils before returning the Array. --- script/convert-grammars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/convert-grammars b/script/convert-grammars index 7c45a7c8..01b80ce0 100755 --- a/script/convert-grammars +++ b/script/convert-grammars @@ -195,7 +195,7 @@ def load_grammars(tmp_dir, source, all_scopes) end all_scopes[scope] = p.url grammar - end + end.compact end def install_grammars(grammars, path) From 57429f3194eb5a849b134a3b3a6efb9f9477a9e8 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 19 May 2015 09:25:34 -0400 Subject: [PATCH 2/2] Don't warn if a package contains multiple copies of a grammar This is pretty common (e.g., if the package contains the grammar in both XML and JSON). --- script/convert-grammars | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/script/convert-grammars b/script/convert-grammars index 01b80ce0..ec3287db 100755 --- a/script/convert-grammars +++ b/script/convert-grammars @@ -188,9 +188,11 @@ def load_grammars(tmp_dir, source, all_scopes) scope = grammar['scopeName'] if all_scopes.key?(scope) - $stderr.puts "WARN: Duplicated scope #{scope}\n" + - " Current package: #{p.url}\n" + - " Previous package: #{all_scopes[scope]}" + unless all_scopes[scope] == p.url + $stderr.puts "WARN: Duplicated scope #{scope}\n" + + " Current package: #{p.url}\n" + + " Previous package: #{all_scopes[scope]}" + end next end all_scopes[scope] = p.url