mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
A C++ shibboleth?
This commit is contained in:
@@ -16,12 +16,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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -163,6 +163,9 @@
|
|||||||
".json",
|
".json",
|
||||||
".lock"
|
".lock"
|
||||||
],
|
],
|
||||||
|
"JSON5": [
|
||||||
|
".json5"
|
||||||
|
],
|
||||||
"Julia": [
|
"Julia": [
|
||||||
".jl"
|
".jl"
|
||||||
],
|
],
|
||||||
@@ -509,8 +512,8 @@
|
|||||||
".gemrc"
|
".gemrc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"tokens_total": 428226,
|
"tokens_total": 428289,
|
||||||
"languages_total": 503,
|
"languages_total": 506,
|
||||||
"tokens": {
|
"tokens": {
|
||||||
"ABAP": {
|
"ABAP": {
|
||||||
"*/**": 1,
|
"*/**": 1,
|
||||||
@@ -8560,7 +8563,7 @@
|
|||||||
"C++": {
|
"C++": {
|
||||||
"class": 40,
|
"class": 40,
|
||||||
"Bar": 2,
|
"Bar": 2,
|
||||||
"{": 562,
|
"{": 563,
|
||||||
"protected": 4,
|
"protected": 4,
|
||||||
"char": 126,
|
"char": 126,
|
||||||
"*name": 6,
|
"*name": 6,
|
||||||
@@ -8570,15 +8573,15 @@
|
|||||||
"hello": 2,
|
"hello": 2,
|
||||||
"(": 2498,
|
"(": 2498,
|
||||||
")": 2500,
|
")": 2500,
|
||||||
"}": 562,
|
"}": 563,
|
||||||
"#pragma": 2,
|
"#pragma": 2,
|
||||||
"once": 2,
|
"once": 2,
|
||||||
"#include": 117,
|
"#include": 118,
|
||||||
"<string>": 4,
|
"<string>": 4,
|
||||||
"<vector>": 4,
|
"<vector>": 4,
|
||||||
"<fstream>": 2,
|
"<fstream>": 2,
|
||||||
"using": 4,
|
"using": 4,
|
||||||
"namespace": 30,
|
"namespace": 31,
|
||||||
"std": 52,
|
"std": 52,
|
||||||
"#define": 197,
|
"#define": 197,
|
||||||
"DEFAULT_DELIMITER": 1,
|
"DEFAULT_DELIMITER": 1,
|
||||||
@@ -9957,6 +9960,8 @@
|
|||||||
"wrapMode": 2,
|
"wrapMode": 2,
|
||||||
"wmode.": 1,
|
"wmode.": 1,
|
||||||
"wmode": 1,
|
"wmode": 1,
|
||||||
|
"<cstdint>": 1,
|
||||||
|
"Gui": 1,
|
||||||
"v8": 9,
|
"v8": 9,
|
||||||
"Scanner": 16,
|
"Scanner": 16,
|
||||||
"UnicodeCache*": 4,
|
"UnicodeCache*": 4,
|
||||||
@@ -23686,6 +23691,50 @@
|
|||||||
"}": 73,
|
"}": 73,
|
||||||
"true": 3
|
"true": 3
|
||||||
},
|
},
|
||||||
|
"JSON5": {
|
||||||
|
"{": 6,
|
||||||
|
"foo": 1,
|
||||||
|
"while": 1,
|
||||||
|
"true": 1,
|
||||||
|
"this": 1,
|
||||||
|
"here": 1,
|
||||||
|
"//": 2,
|
||||||
|
"inline": 1,
|
||||||
|
"comment": 1,
|
||||||
|
"hex": 1,
|
||||||
|
"xDEADbeef": 1,
|
||||||
|
"half": 1,
|
||||||
|
".5": 1,
|
||||||
|
"delta": 1,
|
||||||
|
"+": 1,
|
||||||
|
"to": 1,
|
||||||
|
"Infinity": 1,
|
||||||
|
"and": 1,
|
||||||
|
"beyond": 1,
|
||||||
|
"finally": 1,
|
||||||
|
"oh": 1,
|
||||||
|
"[": 3,
|
||||||
|
"]": 3,
|
||||||
|
"}": 6,
|
||||||
|
"name": 1,
|
||||||
|
"version": 1,
|
||||||
|
"description": 1,
|
||||||
|
"keywords": 1,
|
||||||
|
"author": 1,
|
||||||
|
"contributors": 1,
|
||||||
|
"main": 1,
|
||||||
|
"bin": 1,
|
||||||
|
"dependencies": 1,
|
||||||
|
"devDependencies": 1,
|
||||||
|
"mocha": 1,
|
||||||
|
"scripts": 1,
|
||||||
|
"build": 1,
|
||||||
|
"test": 1,
|
||||||
|
"homepage": 1,
|
||||||
|
"repository": 1,
|
||||||
|
"type": 1,
|
||||||
|
"url": 1
|
||||||
|
},
|
||||||
"Julia": {
|
"Julia": {
|
||||||
"##": 5,
|
"##": 5,
|
||||||
"Test": 1,
|
"Test": 1,
|
||||||
@@ -45100,7 +45149,7 @@
|
|||||||
"Bluespec": 1298,
|
"Bluespec": 1298,
|
||||||
"Brightscript": 579,
|
"Brightscript": 579,
|
||||||
"C": 58858,
|
"C": 58858,
|
||||||
"C++": 22665,
|
"C++": 22671,
|
||||||
"Ceylon": 50,
|
"Ceylon": 50,
|
||||||
"Clojure": 510,
|
"Clojure": 510,
|
||||||
"COBOL": 90,
|
"COBOL": 90,
|
||||||
@@ -45134,6 +45183,7 @@
|
|||||||
"Java": 8987,
|
"Java": 8987,
|
||||||
"JavaScript": 76934,
|
"JavaScript": 76934,
|
||||||
"JSON": 183,
|
"JSON": 183,
|
||||||
|
"JSON5": 57,
|
||||||
"Julia": 247,
|
"Julia": 247,
|
||||||
"Kotlin": 155,
|
"Kotlin": 155,
|
||||||
"KRL": 25,
|
"KRL": 25,
|
||||||
@@ -45235,7 +45285,7 @@
|
|||||||
"Bluespec": 2,
|
"Bluespec": 2,
|
||||||
"Brightscript": 1,
|
"Brightscript": 1,
|
||||||
"C": 26,
|
"C": 26,
|
||||||
"C++": 23,
|
"C++": 24,
|
||||||
"Ceylon": 1,
|
"Ceylon": 1,
|
||||||
"Clojure": 7,
|
"Clojure": 7,
|
||||||
"COBOL": 4,
|
"COBOL": 4,
|
||||||
@@ -45269,6 +45319,7 @@
|
|||||||
"Java": 6,
|
"Java": 6,
|
||||||
"JavaScript": 20,
|
"JavaScript": 20,
|
||||||
"JSON": 4,
|
"JSON": 4,
|
||||||
|
"JSON5": 2,
|
||||||
"Julia": 1,
|
"Julia": 1,
|
||||||
"Kotlin": 1,
|
"Kotlin": 1,
|
||||||
"KRL": 1,
|
"KRL": 1,
|
||||||
@@ -45356,5 +45407,5 @@
|
|||||||
"Xtend": 2,
|
"Xtend": 2,
|
||||||
"YAML": 1
|
"YAML": 1
|
||||||
},
|
},
|
||||||
"md5": "7e305e6e7267f7d227fa871bf83546b8"
|
"md5": "1b96eb81ded03f57c14ee681d73d5db6"
|
||||||
}
|
}
|
||||||
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.find_by_heuristics(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