mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 13:21:01 +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 []
|
# Returns an array of Languages or []
|
||||||
def self.disambiguate_c(data, languages)
|
def self.disambiguate_c(data, languages)
|
||||||
matches = []
|
matches = []
|
||||||
matches << Language["Objective-C"] if data.include?("@interface")
|
if (/@(interface|class|protocol|synchronised|selector|implementation)/.match(data))
|
||||||
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set)>$/.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 << Language["C++"]
|
||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user