mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Remove inactive heuristics
We can add these back when we’re ready to enable them.
This commit is contained in:
@@ -115,37 +115,5 @@ module Linguist
|
|||||||
Language["GLSL"]
|
Language["GLSL"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# .h extensions are ambiguous between C, C++, and Objective-C.
|
|
||||||
# We want to shortcut look for Objective-C _and_ now C++ too!
|
|
||||||
#
|
|
||||||
# Returns an array of Languages or []
|
|
||||||
def self.disambiguate_c(data)
|
|
||||||
matches = []
|
|
||||||
if data.include?("@interface")
|
|
||||||
matches << Language["Objective-C"]
|
|
||||||
elsif data.include?("#include <cstdint>")
|
|
||||||
matches << Language["C++"]
|
|
||||||
end
|
|
||||||
matches
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.disambiguate_ts(data)
|
|
||||||
matches = []
|
|
||||||
if (data.include?("</translation>"))
|
|
||||||
matches << Language["XML"]
|
|
||||||
else
|
|
||||||
matches << Language["TypeScript"]
|
|
||||||
end
|
|
||||||
matches
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.disambiguate_r(data)
|
|
||||||
matches = []
|
|
||||||
matches << Language["Rebol"] if /\bRebol\b/i.match(data)
|
|
||||||
matches << Language["R"] if data.include?("<-")
|
|
||||||
matches
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,21 +20,6 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
Dir.glob("#{samples_path}/#{language_name}/#{file}")
|
Dir.glob("#{samples_path}/#{language_name}/#{file}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Candidate languages = ["C++", "Objective-C"]
|
|
||||||
def test_obj_c_by_heuristics
|
|
||||||
# Only calling out '.h' filenames as these are the ones causing issues
|
|
||||||
all_fixtures("Objective-C", "*.h").each do |fixture|
|
|
||||||
results = Heuristics.disambiguate_c(fixture("Objective-C/#{File.basename(fixture)}"))
|
|
||||||
assert_equal Language["Objective-C"], results.first
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Candidate languages = ["C++", "Objective-C"]
|
|
||||||
def test_cpp_by_heuristics
|
|
||||||
results = Heuristics.disambiguate_c(fixture("C++/render_adapter.cpp"))
|
|
||||||
assert_equal Language["C++"], results.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_detect_still_works_if_nothing_matches
|
def test_detect_still_works_if_nothing_matches
|
||||||
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
|
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
|
||||||
match = Language.detect(blob)
|
match = Language.detect(blob)
|
||||||
@@ -79,18 +64,6 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
# Candidate languages = ["TypeScript", "XML"]
|
|
||||||
def test_ts_typescript_by_heuristics
|
|
||||||
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"))
|
|
||||||
assert_equal Language["TypeScript"], results.first
|
|
||||||
end
|
|
||||||
|
|
||||||
# Candidate languages = ["TypeScript", "XML"]
|
|
||||||
def test_ts_xml_by_heuristics
|
|
||||||
results = Heuristics.disambiguate_ts(fixture("XML/pt_BR.xml"))
|
|
||||||
assert_equal Language["XML"], results.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_cl_by_heuristics
|
def test_cl_by_heuristics
|
||||||
assert_heuristics({
|
assert_heuristics({
|
||||||
"Common Lisp" => all_fixtures("Common Lisp"),
|
"Common Lisp" => all_fixtures("Common Lisp"),
|
||||||
|
|||||||
Reference in New Issue
Block a user