Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add salesforce apex support #579

Merged
merged 34 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9c6c629
Initial Commit - parse and highlight
aheber Aug 24, 2022
b0dc3d3
Add tagging support
aheber Sep 25, 2022
481a55b
Drop artifacts and cleanup tracked files
aheber Sep 27, 2022
a69484e
Getting ready for initial release
aheber Sep 29, 2022
dce0c7a
Add github.io site, enabled playround, update README
aheber Sep 29, 2022
86af1d9
Adding CI jobs
aheber Oct 1, 2022
0571097
Better CI
aheber Oct 1, 2022
3fd2823
Trying to massage CI run
aheber Oct 1, 2022
0e33305
Attemp 1 Auto build release
aheber Oct 1, 2022
3daea3a
Include package
aheber Oct 1, 2022
7a488a4
Update Lock
aheber Oct 1, 2022
ee5265f
V0.0.3
aheber Oct 1, 2022
873ffcf
v0.0.4
aheber Oct 1, 2022
c4724a5
v0.0.5
aheber Oct 1, 2022
db05cac
v0.0.6
aheber Oct 3, 2022
98ac0e4
v0.0.7
aheber Oct 11, 2022
8a66088
v0.0.7b
aheber Oct 11, 2022
17d7fd4
v0.0.8
aheber Oct 15, 2022
d687179
Update WASM binaries
aheber Oct 15, 2022
b944c38
Fix Typo in "SOQL"
cwarden Feb 9, 2023
bc0de52
Merge pull request #11 from cwarden/patch-1
aheber Feb 9, 2023
6ca8fcb
Add support for Anon Apex
aheber Jul 13, 2023
31853f4
Update wasm binaries
aheber Jul 21, 2023
58bdaa3
Add web-tree-sitter-sfapex package
aheber Sep 13, 2023
e63bcdc
Set version to 0.0.9
aheber Sep 13, 2023
646b30a
add nvim-treesitter guidance
finxxi Sep 23, 2023
a1f5349
readme update
finxxi Sep 23, 2023
a768c95
Merge pull request #17 from xixiaofinland/main
aheber Oct 2, 2023
b818b47
Add 'vendored_parsers/tree-sitter-sfapex/' from commit 'a768c956b6aee…
rody Oct 4, 2023
05d78ca
add support for Salesforce Apex
rody Oct 4, 2023
3c32465
Merge branch 'Wilfred:master' into feature/salesforce_apex_support
rody Oct 6, 2023
5256d9c
Merge branch 'master' into feature/salesforce_apex_support
rody Oct 10, 2023
f502c82
Merge remote-tracking branch 'myfork/feature/salesforce_apex_support'…
rody Oct 10, 2023
e18b5d0
Merge branch 'master' into feature/salesforce_apex_support
rody Dec 5, 2023
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
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-sql-src",
extra_files: vec!["scanner.cc"],
},
TreeSitterParser {
name: "tree-sitter-sfapex",
src_dir: "vendored_parsers/tree-sitter-sfapex-src",
extra_files: vec![],
},
TreeSitterParser {
name: "tree-sitter-swift",
src_dir: "vendored_parsers/tree-sitter-swift-src",
Expand Down
1 change: 1 addition & 0 deletions manual/src/languages_supported.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ with `difft --list-languages`.
| Language | Parser Used |
|-----------------|---------------------------------------------------------------------------------------------|
| Ada | [briot/tree-sitter-ada](https://github.com/briot/tree-sitter-ada) |
| Apex | [aheber/tree-sitter-sfapex](https://github.com/aheber/tree-sitter-sfapex) |
| Bash | [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) |
| C | [tree-sitter/tree-sitter-c](https://github.com/tree-sitter/tree-sitter-c) |
| C++ | [tree-sitter/tree-sitter-cpp](https://github.com/tree-sitter/tree-sitter-cpp) |
Expand Down
10 changes: 10 additions & 0 deletions sample_files/apex_after.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @description diffstatic test file
*/
public with sharing class MyClass extends OtherClass implements MyInterface {
private static final Integer A_CONSTANT = 0;

public void doSomething(Object param1, Object param2) {
System.debug('Hello world!');
}
}
14 changes: 14 additions & 0 deletions sample_files/apex_before.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @description diffstatic test file
*/
public with sharing class MyClass extends OtherClass
implements MyInterface {

private static final Integer A_CONSTANT = 0;

public void doSomething(Object param1,
Object param2) {

System.debug('Hello world!');
}
}
3 changes: 3 additions & 0 deletions sample_files/compare.expected
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ sample_files/ada_before.adb sample_files/ada_after.adb
sample_files/added_line_before.txt sample_files/added_line_after.txt
5996d2f9cc7c1e3acfdeafcf0f5e43c1 -

sample_files/apex_before.cls sample_files/apex_after.cls
fde5c2cb739fb8bb42a592f64190137e -

sample_files/align_footer_before.txt sample_files/align_footer_after.txt
202e1821f9214f74568578dbc12ca83e -

Expand Down
3 changes: 3 additions & 0 deletions src/parse/guess_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use strum::{EnumIter, IntoEnumIterator};
#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter)]
pub(crate) enum Language {
Ada,
Apex,
Bash,
C,
Clojure,
Expand Down Expand Up @@ -105,6 +106,7 @@ pub(crate) fn language_override_from_name(name: &str) -> Option<LanguageOverride
pub(crate) fn language_name(language: Language) -> &'static str {
match language {
Ada => "Ada",
Apex => "Apex",
Bash => "Bash",
C => "C",
Clojure => "Clojure",
Expand Down Expand Up @@ -217,6 +219,7 @@ pub(crate) fn language_globs(language: Language) -> Vec<glob::Pattern> {
"zshenv",
"zshrc",
],
Apex => &["*.cls", "*.apexc", "*.trigger"],
C => &["*.c"],
Clojure => &[
"*.bb", "*.boot", "*.clj", "*.cljc", "*.clje", "*.cljs", "*.cljx", "*.edn", "*.joke",
Expand Down
25 changes: 25 additions & 0 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) struct TreeSitterConfig {

extern "C" {
fn tree_sitter_ada() -> ts::Language;
fn tree_sitter_apex() -> ts::Language;
fn tree_sitter_bash() -> ts::Language;
fn tree_sitter_c() -> ts::Language;
fn tree_sitter_c_sharp() -> ts::Language;
Expand Down Expand Up @@ -146,6 +147,30 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
sub_languages: vec![],
}
}
Apex => {
let language = unsafe { tree_sitter_apex() };
TreeSitterConfig {
language,
atom_nodes: vec![
"string_literal",
"null_literal",
"boolean",
"int",
"decimal_floating_point_literal",
"date_literal",
"currency_literal",
]
.into_iter()
.collect(),
delimiter_tokens: vec![("[", "]"), ("(", ")"), ("{", "}")],
highlight_query: ts::Query::new(
language,
include_str!("../../vendored_parsers/highlights/apex.scm"),
)
.unwrap(),
sub_languages: vec![],
}
}
Bash => {
let language = unsafe { tree_sitter_bash() };
TreeSitterConfig {
Expand Down
1 change: 1 addition & 0 deletions translation/zh-CN/manual-zh-CN/src/languages_supported.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| 语言 | 使用的解析器 |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Bash | [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) |
| Apex | [aheber/tree-sitter-sfapex](https://github.com/aheber/tree-sitter-sfapex) |
| C | [tree-sitter/tree-sitter-c](https://github.com/tree-sitter/tree-sitter-c) |
| C++ | [tree-sitter/tree-sitter-cpp](https://github.com/tree-sitter/tree-sitter-cpp) |
| C# | [tree-sitter/tree-sitter-c-sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) |
Expand Down
Loading
Loading