Skip to content

Commit

Permalink
android: skip extracting abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Jul 20, 2024
1 parent 8457a40 commit 32655bf
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@
* ]
*/
export function extractClassDeclarationForPackage(file: string) {
const nativeModuleMatch = file.match(
/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/
);
// We first check for implementation of ReactPackage to find native modules
// and then for subclasses of TurboReactPackage to find turbo modules.
if (nativeModuleMatch) {
return nativeModuleMatch;
} else {
return file.match(

const classDeclMatches =
file.match(
/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/
) ||
file.match(
/class\s+(\w+[^(\s]*)[\s\w():]*(\s+extends\s+|:)[\s\w():,]*[^{]*TurboReactPackage/
);
}

if (
classDeclMatches &&
new RegExp(`abstract\\s+class\\s+${classDeclMatches[1]}`).test(file)
)
return;

return classDeclMatches;
}

0 comments on commit 32655bf

Please sign in to comment.