mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 04:18:48 +00:00
@@ -20,12 +20,14 @@ module Linguist
|
|||||||
end
|
end
|
||||||
|
|
||||||
# .h extensions are ambigious between C, C++, and Objective-C.
|
# .h extensions are ambigious between C, C++, and Objective-C.
|
||||||
# We want to shortcut look for Objective-C.
|
# We want to shortcut look for Objective-C _and_ now C++ too!
|
||||||
#
|
#
|
||||||
# Returns an array of Languages or []
|
# Returns an array of Languages or []
|
||||||
|
# TODO rename this method as we're not strictly disambiguating between .h files here.
|
||||||
def self.disambiguate_h(data, languages)
|
def self.disambiguate_h(data, languages)
|
||||||
matches = []
|
matches = []
|
||||||
matches << Language["Objective-C"] if data.include?("@interface")
|
matches << Language["Objective-C"] if data.include?("@interface")
|
||||||
|
matches << Language["C++"] if data.include?("#include <cstdint>")
|
||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -511,8 +511,8 @@
|
|||||||
".gemrc"
|
".gemrc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"tokens_total": 436395,
|
"tokens_total": 436401,
|
||||||
"languages_total": 507,
|
"languages_total": 508,
|
||||||
"tokens": {
|
"tokens": {
|
||||||
"ABAP": {
|
"ABAP": {
|
||||||
"*/**": 1,
|
"*/**": 1,
|
||||||
@@ -8562,7 +8562,7 @@
|
|||||||
"C++": {
|
"C++": {
|
||||||
"class": 40,
|
"class": 40,
|
||||||
"Bar": 2,
|
"Bar": 2,
|
||||||
"{": 580,
|
"{": 581,
|
||||||
"protected": 4,
|
"protected": 4,
|
||||||
"char": 127,
|
"char": 127,
|
||||||
"*name": 6,
|
"*name": 6,
|
||||||
@@ -8572,7 +8572,7 @@
|
|||||||
"hello": 2,
|
"hello": 2,
|
||||||
"(": 2729,
|
"(": 2729,
|
||||||
")": 2731,
|
")": 2731,
|
||||||
"}": 580,
|
"}": 581,
|
||||||
"//": 278,
|
"//": 278,
|
||||||
"///": 843,
|
"///": 843,
|
||||||
"mainpage": 1,
|
"mainpage": 1,
|
||||||
@@ -9245,7 +9245,7 @@
|
|||||||
"#ifndef": 27,
|
"#ifndef": 27,
|
||||||
"BCM2835_H": 3,
|
"BCM2835_H": 3,
|
||||||
"#define": 341,
|
"#define": 341,
|
||||||
"#include": 120,
|
"#include": 121,
|
||||||
"<stdint.h>": 2,
|
"<stdint.h>": 2,
|
||||||
"defgroup": 7,
|
"defgroup": 7,
|
||||||
"constants": 1,
|
"constants": 1,
|
||||||
@@ -10120,7 +10120,7 @@
|
|||||||
"<string>": 4,
|
"<string>": 4,
|
||||||
"<vector>": 4,
|
"<vector>": 4,
|
||||||
"<fstream>": 2,
|
"<fstream>": 2,
|
||||||
"namespace": 30,
|
"namespace": 31,
|
||||||
"std": 52,
|
"std": 52,
|
||||||
"DEFAULT_DELIMITER": 1,
|
"DEFAULT_DELIMITER": 1,
|
||||||
"CsvStreamer": 5,
|
"CsvStreamer": 5,
|
||||||
@@ -11276,6 +11276,8 @@
|
|||||||
"wrapMode": 2,
|
"wrapMode": 2,
|
||||||
"wmode.": 1,
|
"wmode.": 1,
|
||||||
"wmode": 1,
|
"wmode": 1,
|
||||||
|
"<cstdint>": 2,
|
||||||
|
"Gui": 1,
|
||||||
"rpc_init": 1,
|
"rpc_init": 1,
|
||||||
"rpc_server_loop": 1,
|
"rpc_server_loop": 1,
|
||||||
"v8": 9,
|
"v8": 9,
|
||||||
@@ -11573,7 +11575,6 @@
|
|||||||
"desc": 2,
|
"desc": 2,
|
||||||
"look": 1,
|
"look": 1,
|
||||||
"ahead": 1,
|
"ahead": 1,
|
||||||
"<cstdint>": 1,
|
|
||||||
"smallPrime_t": 1,
|
"smallPrime_t": 1,
|
||||||
"UTILS_H": 3,
|
"UTILS_H": 3,
|
||||||
"<QtGlobal>": 1,
|
"<QtGlobal>": 1,
|
||||||
@@ -46342,7 +46343,7 @@
|
|||||||
"Bluespec": 1298,
|
"Bluespec": 1298,
|
||||||
"Brightscript": 579,
|
"Brightscript": 579,
|
||||||
"C": 58858,
|
"C": 58858,
|
||||||
"C++": 31175,
|
"C++": 31181,
|
||||||
"Ceylon": 50,
|
"Ceylon": 50,
|
||||||
"Clojure": 510,
|
"Clojure": 510,
|
||||||
"COBOL": 90,
|
"COBOL": 90,
|
||||||
@@ -46478,7 +46479,7 @@
|
|||||||
"Bluespec": 2,
|
"Bluespec": 2,
|
||||||
"Brightscript": 1,
|
"Brightscript": 1,
|
||||||
"C": 26,
|
"C": 26,
|
||||||
"C++": 26,
|
"C++": 27,
|
||||||
"Ceylon": 1,
|
"Ceylon": 1,
|
||||||
"Clojure": 7,
|
"Clojure": 7,
|
||||||
"COBOL": 4,
|
"COBOL": 4,
|
||||||
@@ -46600,5 +46601,5 @@
|
|||||||
"Xtend": 2,
|
"Xtend": 2,
|
||||||
"YAML": 1
|
"YAML": 1
|
||||||
},
|
},
|
||||||
"md5": "7ab5683c610f7e81d6ea5fb470111bbe"
|
"md5": "4bd97c3aa060155c82b903fea0fecc57"
|
||||||
}
|
}
|
||||||
6
samples/C++/render_adapter.cpp
Normal file
6
samples/C++/render_adapter.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Gui
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,6 +28,12 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cpp_by_heuristics
|
||||||
|
languages = ["C++", "Objective-C"]
|
||||||
|
results = Heuristics.disambiguate_h(fixture("C++/render_adapter.cpp"), languages)
|
||||||
|
assert_equal Language["C++"], results.first
|
||||||
|
end
|
||||||
|
|
||||||
def test_detect_still_works_if_nothing_matches
|
def test_detect_still_works_if_nothing_matches
|
||||||
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
||||||
assert_equal Language["Objective-C"], match
|
assert_equal Language["Objective-C"], match
|
||||||
|
|||||||
Reference in New Issue
Block a user