mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Extracting ObjectiveC regex into a constant
This commit is contained in:
		@@ -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"]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user