diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml
index 2c8b080..9da5a48 100644
--- a/.github/workflows/rust.yaml
+++ b/.github/workflows/rust.yaml
@@ -28,12 +28,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: stable
- override: true
- name: Test
uses: actions-rs/cargo@v1
with:
diff --git a/crates/does-it-throw/src/fixtures/importIdentifiers.ts b/crates/does-it-throw/src/fixtures/importIdentifiers.ts
new file mode 100644
index 0000000..3443c85
--- /dev/null
+++ b/crates/does-it-throw/src/fixtures/importIdentifiers.ts
@@ -0,0 +1,52 @@
+//@ts-nocheck
+import { resolve } from 'path'
+import { SomeThrow, SomeThrow as SomeThrow2, Something, testing as Test, testing as Test2 } from './something'
+import Testing from './something3'
+import { SomethingElse } from './somethingElse'
+import { SomethingElse as SomethingElse2 } from './somethingElse2'
+
+export function test() {
+ try {
+ SomethingElse()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ SomethingElse2()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ Testing()
+ } catch (e) {
+ console.log(e)
+ }
+ resolve()
+ try {
+ SomeThrow()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ Test()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ SomeThrow2()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ Test2()
+ } catch (e) {
+ console.log(e)
+ }
+ try {
+ Something()
+ } catch (e) {
+ console.log(e)
+ }
+}
+
+
diff --git a/crates/does-it-throw/src/fixtures/jsx.jsx b/crates/does-it-throw/src/fixtures/jsx.jsx
new file mode 100644
index 0000000..6b8833a
--- /dev/null
+++ b/crates/does-it-throw/src/fixtures/jsx.jsx
@@ -0,0 +1,32 @@
+export const someThrow = () => {
+ throw new Error('some error')
+}
+export function someThrow2() {
+ throw new Error('some error')
+}
+
+export const someTsx = () => {
+ if (something) {
+ throw new Error()
+ }
+ return
some tsx
+}
+
+export async function someAsyncTsx() {
+ if (something) {
+ throw new Error()
+ }
+ return some tsx
+}
+
+export async function callToThrow() {
+ someThrow()
+ someThrow2()
+ return some tsx
+}
+
+export const someTsxWithJsx = async () => {
+ someThrow()
+ someThrow2()
+ return some tsx
+}
diff --git a/crates/does-it-throw/src/fixtures/tsx.tsx b/crates/does-it-throw/src/fixtures/tsx.tsx
new file mode 100644
index 0000000..a8683c5
--- /dev/null
+++ b/crates/does-it-throw/src/fixtures/tsx.tsx
@@ -0,0 +1,33 @@
+// @ts-nocheck
+export const someThrow = () => {
+ throw new Error('some error')
+}
+export function someThrow2() {
+ throw new Error('some error')
+}
+
+export const someTsx = () => {
+ if (something) {
+ throw new Error()
+ }
+ return some tsx
+}
+
+export async function someAsyncTsx({ something }: { something: boolean }) {
+ if (something) {
+ throw new Error()
+ }
+ return some tsx
+}
+
+export async function callToThrow() {
+ someThrow()
+ someThrow2()
+ return some tsx
+}
+
+export const someTsxWithJsx = async () => {
+ someThrow()
+ someThrow2()
+ return some tsx
+}
diff --git a/crates/does-it-throw/src/main.rs b/crates/does-it-throw/src/main.rs
index be0d0e4..1245a38 100644
--- a/crates/does-it-throw/src/main.rs
+++ b/crates/does-it-throw/src/main.rs
@@ -454,4 +454,160 @@ mod integration_tests {
.iter()
.for_each(|f| assert!(calls_to_throws_contains(&calls_to_throws, f)));
}
+
+ #[test]
+ fn test_tsx() {
+ let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ let file_path = format!("{}/src/fixtures/tsx.tsx", manifest_dir);
+ // Read sample code from file
+ let sample_code = fs::read_to_string(file_path).expect("Something went wrong reading the file");
+ let cm: Lrc = Default::default();
+
+ let (result, _cm) = analyze_code(&sample_code, cm);
+
+ // general result assertions
+ assert_eq!(result.functions_with_throws.len(), 4);
+ assert_eq!(result.calls_to_throws.len(), 4);
+ assert_eq!(result.imported_identifier_usages.len(), 0);
+ assert_eq!(result.import_sources.len(), 0);
+
+ // function names
+ let function_names: Vec = result
+ .functions_with_throws
+ .iter()
+ .map(|f| f.function_or_method_name.clone())
+ .collect();
+ fn function_names_contains(function_names: &Vec, function_name: &str) -> bool {
+ function_names.iter().any(|f| f == function_name)
+ }
+
+ ["someTsx", "someThrow2", "someThrow", "someAsyncTsx"]
+ .iter()
+ .for_each(|f| assert!(function_names_contains(&function_names, f)));
+
+ // calls to throws
+ let calls_to_throws: Vec = result
+ .calls_to_throws
+ .iter()
+ .map(|c| c.id.clone())
+ .collect();
+
+ fn calls_to_throws_contains(calls_to_throws: &Vec, call_to_throw: &str) -> bool {
+ calls_to_throws.iter().any(|c| c == call_to_throw)
+ }
+ [
+ "NOT_SET-callToThrow",
+ "NOT_SET-someTsxWithJsx",
+ "NOT_SET-callToThrow",
+ "NOT_SET-someTsxWithJsx",
+ ]
+ .iter()
+ .for_each(|f| assert!(calls_to_throws_contains(&calls_to_throws, f)));
+ }
+
+ #[test]
+ fn test_jsx() {
+ let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ let file_path = format!("{}/src/fixtures/jsx.jsx", manifest_dir);
+ // Read sample code from file
+ let sample_code = fs::read_to_string(file_path).expect("Something went wrong reading the file");
+ let cm: Lrc = Default::default();
+
+ let (result, _cm) = analyze_code(&sample_code, cm);
+
+ // general result assertions
+ assert_eq!(result.functions_with_throws.len(), 4);
+ assert_eq!(result.calls_to_throws.len(), 4);
+ assert_eq!(result.imported_identifier_usages.len(), 0);
+ assert_eq!(result.import_sources.len(), 0);
+
+ // function names
+ let function_names: Vec = result
+ .functions_with_throws
+ .iter()
+ .map(|f| f.function_or_method_name.clone())
+ .collect();
+ fn function_names_contains(function_names: &Vec, function_name: &str) -> bool {
+ function_names.iter().any(|f| f == function_name)
+ }
+
+ ["someTsx", "someThrow2", "someThrow", "someAsyncTsx"]
+ .iter()
+ .for_each(|f| assert!(function_names_contains(&function_names, f)));
+
+ // calls to throws
+ let calls_to_throws: Vec = result
+ .calls_to_throws
+ .iter()
+ .map(|c| c.id.clone())
+ .collect();
+
+ fn calls_to_throws_contains(calls_to_throws: &Vec, call_to_throw: &str) -> bool {
+ calls_to_throws.iter().any(|c| c == call_to_throw)
+ }
+ [
+ "NOT_SET-callToThrow",
+ "NOT_SET-someTsxWithJsx",
+ "NOT_SET-callToThrow",
+ "NOT_SET-someTsxWithJsx",
+ ]
+ .iter()
+ .for_each(|f| assert!(calls_to_throws_contains(&calls_to_throws, f)));
+ }
+
+ #[test]
+ fn imported_identifiers() {
+ let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ let file_path = format!("{}/src/fixtures/importIdentifiers.ts", manifest_dir);
+ // Read sample code from file
+ let sample_code = fs::read_to_string(file_path).expect("Something went wrong reading the file");
+ let cm: Lrc = Default::default();
+
+ let (result, _cm) = analyze_code(&sample_code, cm);
+
+ // general result assertions
+ assert_eq!(result.functions_with_throws.len(), 0);
+ assert_eq!(result.calls_to_throws.len(), 0);
+ assert_eq!(result.imported_identifier_usages.len(), 5);
+ assert_eq!(result.import_sources.len(), 5);
+
+ let imported_identifier_usages = result
+ .imported_identifier_usages
+ .into_iter()
+ .map(|i| i.id)
+ .collect::>();
+ fn function_names_contains(function_names: &Vec, function_name: &str) -> bool {
+ function_names.iter().any(|f| f == function_name)
+ }
+ [
+ "NOT_SET-Something",
+ "NOT_SET-Testing",
+ "NOT_SET-SomethingElse",
+ "NOT_SET-resolve",
+ "NOT_SET-SomeThrow",
+ ]
+ .iter()
+ .for_each(|f| assert!(function_names_contains(&imported_identifier_usages, f)));
+
+ println!("Import sources {:?}", result.import_sources);
+
+ let import_sources = result
+ .import_sources
+ .into_iter()
+ .map(|i| i)
+ .collect::>();
+ fn import_sources_contains(import_sources: &Vec, import_source: &str) -> bool {
+ import_sources.iter().any(|f| f == import_source)
+ }
+ println!("Import sources {:?}", import_sources);
+ [
+ "./something3",
+ "path",
+ "./somethingElse2",
+ "./something",
+ "./somethingElse",
+ ]
+ .iter()
+ .for_each(|f| assert!(import_sources_contains(&import_sources, f)));
+ }
}