mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Improved the Obj-C heuristic with a Regex matching multiple unique keywords
Also improved the C++ heuristic by checking for class without an @ on the front.
This commit is contained in:
@@ -37,8 +37,10 @@ module Linguist
|
||||
# Returns an array of Languages or []
|
||||
def self.disambiguate_c(data, languages)
|
||||
matches = []
|
||||
matches << Language["Objective-C"] if data.include?("@interface")
|
||||
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set)>$/.match(data))
|
||||
if (/@(interface|class|protocol|synchronised|selector|implementation)/.match(data))
|
||||
matches << Language["Objective-C"]
|
||||
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set)>$/.match(data) or
|
||||
/template\s*</.match(data) or /[^@]class/.match(data))
|
||||
matches << Language["C++"]
|
||||
matches
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user