Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gitgalaxy/core/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4445,7 +4445,7 @@ def _extract_name(self, raw_match: str) -> str:
# Group 1 now grabs the optional `(Ident::)+` chain immediately
# before the `operator` keyword and it's prefixed back on below.
op_match = re.search(
r"((?:[a-zA-Z_]\w*::)*)\b(operator\s*(?:\[\s*\]|\(\s*\)|[^a-zA-Z0-9_\s({]+|[a-zA-Z_]\w*(?:\s*\*+)?))",
r"((?:[a-zA-Z_]\w*::)*)\b(operator\s*(?:\[\s*\]|\(\s*\)|(?:::)?[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*(?:\s*\*+)?|[^a-zA-Z0-9_\s({]+))",
match_strip,
)
if op_match:
Expand Down
6 changes: 3 additions & 3 deletions gitgalaxy/standards/language_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
| -------- | ----------- | -------------- | ------------ | --------------- |
| Apex | 100.0% | 95.0% | 100.0% | 100.0% |
| C | 93.3% | 99.5% | 100.0% | 100.0% |
| Cpp | 92.3% | 96.2% | 98.6% | 92.6% |
| Cpp | 93.4% | 95.7% | 98.6% | 92.6% |
| Csharp | 99.2% | 99.8% | 100.0% | 100.0% |
| Css | 100.0% | 100.0% | N/A | N/A |
| Dart | 96.0% | 97.8% | 100.0% | 100.0% |
Expand Down Expand Up @@ -3011,7 +3011,7 @@ class PrismConfigSchema(TypedDict):
# literal `[*&]`, the other forbids consuming past the first
# non-whitespace char), so this doesn't reopen the Rule 14
# backtracking gap the surrounding bounds were built to close.
r"(?:(?![ \t]*#)[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*"
r"(?:(?![ \t]*#)(?!(?:[a-zA-Z_]\w*::)*operator\b)[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*"
r"(?:<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?"
r"(?:[ \t]{0,20}[*&]{1,5}[ \t\n]{0,200}|[ \t\n]{1,200})){0,5}"
# 5. THE "NOT A FUNCTION" SHIELD
Expand All @@ -3025,7 +3025,7 @@ class PrismConfigSchema(TypedDict):
# `(?:[a-zA-Z_]\w*::)*`. Out-of-line operator overload definitions (defined in a
# .cpp file, declared in the header) are mainstream, common C++ -- completely
# invisible to func_start before this fix.
r"(?![ \t]*#)((?:[a-zA-Z_]\w*::)*[~a-zA-Z_]\w*|(?:[a-zA-Z_]\w*::)*operator[ \t]*[^a-zA-Z_\s(]+|(?:[a-zA-Z_]\w*::)*operator[ \t]+(?:new|delete)(?:\[\])?)"
r"(?![ \t]*#)((?:[a-zA-Z_]\w*::)*operator[ \t]*\(\)|(?:[a-zA-Z_]\w*::)*operator[ \t]+(?:::)?[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*(?:[ \t]*[*&]+)?|(?:[a-zA-Z_]\w*::)*operator[ \t]*[^a-zA-Z_\s(]+|(?:[a-zA-Z_]\w*::)*operator[ \t]+(?:new|delete)(?:\[\])?|(?:[a-zA-Z_]\w*::)*[~a-zA-Z_]\w*)"
# 7. THE PARAMETER BLOCK (Supports vertical gap)
# [NESTED PARENTHESIS FIX]: Uses 1-Level Nesting Trick to swallow function pointers without ReDoS.
r"[ \t\n]{0,200}(?:ARGS\d+\s*\([^)]*\)|\((?:[^)(]|\([^)]*\))*\)|NOARGS)"
Expand Down
16 changes: 16 additions & 0 deletions tests/extraction/languages/test_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@
"TargetClass& TargetClass::operator=(const TargetClass& other) {",
"TargetClass::operator=",
), # out-of-line operator= -- was a real bug, now fixed
(
"MyClass::operator()() const {",
"MyClass::operator()",
), # functor operator()
(
"MyClass::operator bool() const {",
"MyClass::operator bool",
), # primitive type conversion operator
(
"MyClass::operator std::string() const {",
"MyClass::operator std::string",
), # namespace-qualified type conversion operator
(
"MyClass::operator Foo() const {",
"MyClass::operator Foo",
), # custom type conversion operator
(
"MyClass::MyClass(int x) : field_(x), other_(0) {",
"MyClass::MyClass",
Expand Down
8 changes: 4 additions & 4 deletions tests/tree_sitter_accuracy_baseline_cpp.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"args_comparable": 1376,
"args_exact_match": 1202,
"args_comparable": 1392,
"args_exact_match": 1207,
"corpus_path": "language-crucible/data/cpp",
"extra_classes": 11,
"extra_functions": 55,
"extra_functions": 62,
"files_scanned": 29,
"found_classes": 138,
"found_functions": 1376,
"found_functions": 1392,
"real_classes": 140,
"real_functions": 1491
}
Loading