Skip to content

Commit

Permalink
fix: Fix null refs when mapping syntax in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir Boulema committed Oct 21, 2021
1 parent 4d04dbc commit 40ff717
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CodeNav.Shared/Helpers/FindHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public static class FindHelper
{
public static CodeItem FindCodeItem(IEnumerable<CodeItem> items, string id)
{
if (items == null || !items.Any() || string.IsNullOrEmpty(id))
if (items?.Any() != true ||
string.IsNullOrEmpty(id))
{
return null;
}
Expand All @@ -23,6 +24,7 @@ public static CodeItem FindCodeItem(IEnumerable<CodeItem> items, string id)
if (item is IMembers hasMembersItem && hasMembersItem.Members.Any())
{
var found = FindCodeItem(hasMembersItem.Members, id);

if (found != null)
{
return found;
Expand Down
4 changes: 1 addition & 3 deletions CodeNav.Shared/Mappers/JavaScript/SyntaxMapperJS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public static List<CodeItem> MapMember(Node member)

private static List<CodeItem> MapMembers(TypeScriptAST ast)
{
if (ast == null ||
ast.RootNode == null ||
ast.RootNode.Children == null)
if (ast?.RootNode?.Children?.Any() != true)
{
return new List<CodeItem>();
}
Expand Down

0 comments on commit 40ff717

Please sign in to comment.