Extracting ObjectiveC regex into a constant

This commit is contained in:
Arfon Smith
2015-01-30 08:48:26 -06:00
parent 359e5157a8
commit 339370a703

View File

@@ -61,6 +61,9 @@ module Linguist
@heuristic.call(data)
end
# Common heuristics
ObjectiveCRegex = /^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/
disambiguate "BitBake", "BlitzBasic" do |data|
if /^\s*; /.match(data) || data.include?("End Function")
Language["BlitzBasic"]
@@ -78,7 +81,7 @@ module Linguist
end
disambiguate "Objective-C", "C++", "C" do |data|
if (/^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
if ObjectiveCRegex.match(data)
Language["Objective-C"]
elsif (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set|(i|o|io)stream)>/.match(data) ||
/^\s*template\s*</.match(data) || /^[ \t]*try/.match(data) || /^[ \t]*catch\s*\(/.match(data) || /^[ \t]*(class|(using[ \t]+)?namespace)\s+\w+/.match(data) || /^[ \t]*(private|public|protected):$/.match(data) || /std::\w+/.match(data))
@@ -170,7 +173,7 @@ module Linguist
end
disambiguate "M", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
if /^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data)
if ObjectiveCRegex.match(data)
Language["Objective-C"]
elsif data.include?(":- module")
Language["Mercury"]