Merge pull request #2003 from pchaigno/cs-heuristics

Heuristics for .cs files: C# and Smalltalk
This commit is contained in:
Arfon Smith
2015-01-17 09:10:58 -06:00
2 changed files with 15 additions and 0 deletions

View File

@@ -69,6 +69,14 @@ module Linguist
end end
end end
disambiguate "C#", "Smalltalk" do |data|
if /![\w\s]+methodsFor: /.match(data)
Language["Smalltalk"]
elsif /^\s*namespace\s*[\w\.]+\s*{/.match(data) || /^\s*\/\//.match(data)
Language["C#"]
end
end
disambiguate "Objective-C", "C++", "C" do |data| disambiguate "Objective-C", "C++", "C" do |data|
if (/^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data)) if (/^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
Language["Objective-C"] Language["Objective-C"]

View File

@@ -133,6 +133,13 @@ class TestHeuristcs < Minitest::Test
}) })
end end
def test_cs_by_heuristics
assert_heuristics({
"C#" => all_fixtures("C#", "*.cs"),
"Smalltalk" => all_fixtures("Smalltalk", "*.cs")
})
end
def assert_heuristics(hash) def assert_heuristics(hash)
candidates = hash.keys.map { |l| Language[l] } candidates = hash.keys.map { |l| Language[l] }