Skip to content

Commit d68d601

Browse files
Abdul535safishamsi
authored andcommitted
feat: add R language extractor
(cherry picked from commit 250395d)
1 parent ebe1f32 commit d68d601

7 files changed

Lines changed: 584 additions & 9 deletions

File tree

‎graphify/extract.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from graphify.extractors.ocaml import extract_ocaml # noqa: F401
5555
from graphify.extractors.pascal_forms import extract_delphi_form, extract_lazarus_form # noqa: F401
5656
from graphify.extractors.powershell import extract_powershell, extract_powershell_manifest # noqa: F401
57+
from graphify.extractors.r import extract_r, resolve_r_sourced_calls # noqa: F401
5758
from graphify.extractors.razor import extract_razor # noqa: F401
5859
from graphify.extractors.robot import extract_robot # noqa: F401
5960
from graphify.extractors.rust import extract_rust # noqa: F401
@@ -2768,6 +2769,7 @@ def _lang_is_case_insensitive(source_file: object) -> bool:
27682769
".go": "go",
27692770
".rs": "rust",
27702771
".cbl": "cobol", ".cob": "cobol", ".cobol": "cobol", ".cpy": "cobol",
2772+
".r": "r",
27712773
".rb": "ruby", ".rake": "ruby",
27722774
".php": "php", ".phtml": "php", ".php3": "php", ".php4": "php",
27732775
".php5": "php", ".php7": "php", ".phps": "php",
@@ -5202,6 +5204,9 @@ def _resolve_kotlin_member_calls(
52025204
register_language_resolver(
52035205
LanguageResolver("vbnet_partial_calls", frozenset({".vb"}), resolve_vbnet_partial_calls)
52045206
)
5207+
register_language_resolver(
5208+
LanguageResolver("r_sourced_calls", frozenset({".r", ".R"}), resolve_r_sourced_calls)
5209+
)
52055210
register_language_resolver(
52065211
LanguageResolver(
52075212
"elixir_import_targets",
@@ -6287,6 +6292,7 @@ def add_existing_edge(edge: dict) -> None:
62876292
".cts": extract_js,
62886293
".go": extract_go,
62896294
".rs": extract_rust,
6295+
".r": extract_r,
62906296
".java": extract_java,
62916297
".groovy": extract_groovy,
62926298
".gradle": extract_groovy,
@@ -6392,6 +6398,7 @@ def add_existing_edge(edge: dict) -> None:
63926398
# extract() to tell the user which extra restores the language.
63936399
_EXTRA_FOR_EXTENSION = {
63946400
".vb": "vbnet",
6401+
".r": "r",
63956402
".sql": "sql",
63966403
".tf": "terraform",
63976404
".tfvars": "terraform",
@@ -6437,6 +6444,7 @@ def add_existing_edge(edge: dict) -> None:
64376444
"lua": extract_lua,
64386445
"php": extract_php,
64396446
"julia": extract_julia,
6447+
"Rscript": extract_r,
64406448
}
64416449

64426450

@@ -7000,7 +7008,7 @@ def extract(
70007008
_failed_seen.add(_key)
70017009

70027010
# #1689: a file counted as code (extension in CODE_EXTENSIONS) but with no AST
7003-
# extractor wired up (e.g. .r/.R — there is no tree-sitter-r dispatch) silently
7011+
# extractor wired up (e.g. .ets — there is no ArkTS dispatch) silently
70047012
# contributes zero nodes. The #1666 warning above deliberately skips these (it
70057013
# only fires when an extractor exists), so surface them explicitly, grouped by
70067014
# extension, rather than reporting success as if the language were mapped.

‎graphify/extractors/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from graphify.extractors.pascal import extract_pascal
2828
from graphify.extractors.pascal_forms import extract_delphi_form, extract_lazarus_form
2929
from graphify.extractors.powershell import extract_powershell, extract_powershell_manifest
30+
from graphify.extractors.r import extract_r
3031
from graphify.extractors.razor import extract_razor
3132
from graphify.extractors.rust import extract_rust
3233
from graphify.extractors.sln import extract_sln
@@ -59,6 +60,7 @@
5960
"pascal": extract_pascal,
6061
"powershell": extract_powershell,
6162
"powershell_manifest": extract_powershell_manifest,
63+
"r": extract_r,
6264
"razor": extract_razor,
6365
"rust": extract_rust,
6466
"sln": extract_sln,

0 commit comments

Comments
 (0)