public static List <CodeItem> MapFunction(Node function, NodeArray <ParameterDeclaration> parameters, string id, ICodeViewUserControl control) { if (function == null) { return(null); } List <CodeItem> children; try { children = function.Children .FirstOrDefault(c => c.Kind == SyntaxKind.Block)?.Children .SelectMany(SyntaxMapperJS.MapMember) .ToList(); } catch (NullReferenceException) { return(new List <CodeItem>()); } if (children != null && children.Any()) { SyntaxMapper.FilterNullItems(children); var item = BaseMapperJS.MapBase <CodeClassItem>(function, id, control); item.BorderColor = Colors.DarkGray; item.Kind = CodeItemKindEnum.Method; item.Parameters = $"({string.Join(", ", parameters.Select(p => p.IdentifierStr))})"; item.Tooltip = TooltipMapper.Map(item.Access, null, item.Name, item.Parameters); item.Id = IdMapper.MapId(item.FullName, parameters); item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access); item.Members = children; return(new List <CodeItem> { item }); } CodeFunctionItem functionItem = BaseMapperJS.MapBase <CodeFunctionItem>(function, id, control); functionItem.Kind = CodeItemKindEnum.Method; functionItem.Parameters = $"({string.Join(", ", parameters.Select(p => p.IdentifierStr))})"; functionItem.Tooltip = TooltipMapper.Map(functionItem.Access, null, functionItem.Name, functionItem.Parameters); functionItem.Id = IdMapper.MapId(functionItem.FullName, parameters); functionItem.Moniker = IconMapper.MapMoniker(functionItem.Kind, functionItem.Access); return(new List <CodeItem> { functionItem }); }
public void ShouldMapMethodOk(CodeItemAccessEnum access, string type, string name, string extra, string expected) { var tooltip = TooltipMapper.Map(access, type, name, extra); Assert.AreEqual(expected, tooltip); }