mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
A C++ shibboleth?
This commit is contained in:
@@ -16,12 +16,14 @@ module Linguist
|
||||
end
|
||||
|
||||
# .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 []
|
||||
# TODO rename this method as we're not strictly disambiguating between .h files here.
|
||||
def self.disambiguate_h(data, languages)
|
||||
matches = []
|
||||
matches << Language["Objective-C"] if data.include?("@interface")
|
||||
matches << Language["C++"] if data.include?("#include <cstdint>")
|
||||
matches
|
||||
end
|
||||
end
|
||||
|
||||
@@ -163,6 +163,9 @@
|
||||
".json",
|
||||
".lock"
|
||||
],
|
||||
"JSON5": [
|
||||
".json5"
|
||||
],
|
||||
"Julia": [
|
||||
".jl"
|
||||
],
|
||||
@@ -509,8 +512,8 @@
|
||||
".gemrc"
|
||||
]
|
||||
},
|
||||
"tokens_total": 428226,
|
||||
"languages_total": 503,
|
||||
"tokens_total": 428289,
|
||||
"languages_total": 506,
|
||||
"tokens": {
|
||||
"ABAP": {
|
||||
"*/**": 1,
|
||||
@@ -8560,7 +8563,7 @@
|
||||
"C++": {
|
||||
"class": 40,
|
||||
"Bar": 2,
|
||||
"{": 562,
|
||||
"{": 563,
|
||||
"protected": 4,
|
||||
"char": 126,
|
||||
"*name": 6,
|
||||
@@ -8570,15 +8573,15 @@
|
||||
"hello": 2,
|
||||
"(": 2498,
|
||||
")": 2500,
|
||||
"}": 562,
|
||||
"}": 563,
|
||||
"#pragma": 2,
|
||||
"once": 2,
|
||||
"#include": 117,
|
||||
"#include": 118,
|
||||
"<string>": 4,
|
||||
"<vector>": 4,
|
||||
"<fstream>": 2,
|
||||
"using": 4,
|
||||
"namespace": 30,
|
||||
"namespace": 31,
|
||||
"std": 52,
|
||||
"#define": 197,
|
||||
"DEFAULT_DELIMITER": 1,
|
||||
@@ -9957,6 +9960,8 @@
|
||||
"wrapMode": 2,
|
||||
"wmode.": 1,
|
||||
"wmode": 1,
|
||||
"<cstdint>": 1,
|
||||
"Gui": 1,
|
||||
"v8": 9,
|
||||
"Scanner": 16,
|
||||
"UnicodeCache*": 4,
|
||||
@@ -23686,6 +23691,50 @@
|
||||
"}": 73,
|
||||
"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": {
|
||||
"##": 5,
|
||||
"Test": 1,
|
||||
@@ -45100,7 +45149,7 @@
|
||||
"Bluespec": 1298,
|
||||
"Brightscript": 579,
|
||||
"C": 58858,
|
||||
"C++": 22665,
|
||||
"C++": 22671,
|
||||
"Ceylon": 50,
|
||||
"Clojure": 510,
|
||||
"COBOL": 90,
|
||||
@@ -45134,6 +45183,7 @@
|
||||
"Java": 8987,
|
||||
"JavaScript": 76934,
|
||||
"JSON": 183,
|
||||
"JSON5": 57,
|
||||
"Julia": 247,
|
||||
"Kotlin": 155,
|
||||
"KRL": 25,
|
||||
@@ -45235,7 +45285,7 @@
|
||||
"Bluespec": 2,
|
||||
"Brightscript": 1,
|
||||
"C": 26,
|
||||
"C++": 23,
|
||||
"C++": 24,
|
||||
"Ceylon": 1,
|
||||
"Clojure": 7,
|
||||
"COBOL": 4,
|
||||
@@ -45269,6 +45319,7 @@
|
||||
"Java": 6,
|
||||
"JavaScript": 20,
|
||||
"JSON": 4,
|
||||
"JSON5": 2,
|
||||
"Julia": 1,
|
||||
"Kotlin": 1,
|
||||
"KRL": 1,
|
||||
@@ -45356,5 +45407,5 @@
|
||||
"Xtend": 2,
|
||||
"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
|
||||
{
|
||||
|
||||
}
|
||||
@@ -27,6 +27,12 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
assert_equal Language["Objective-C"], results.first
|
||||
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
|
||||
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
||||
|
||||
Reference in New Issue
Block a user