Exemplo n.º 1
0
 // function to retrieve an ASTNode instance given an id
 public ASTNode retrieveASTNodethroughID(int id)
 {
     if (IdToNodeMap.ContainsKey(id))
     {
         return(IdToNodeMap[id]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public bool TryGetParent(TimelineRecord record, [NotNullWhen(true)] out TimelineRecord?parent)
        {
            if (IdToNodeMap.TryGetValue(record.Id, out var node) &&
                node.ParentNode is object)
            {
                parent = node.ParentNode.TimelineRecord;
                return(true);
            }

            parent = null;
            return(false);
        }
Exemplo n.º 3
0
        private bool TryFindUp(string id, Func <TimelineNode, bool> predicate, [NotNullWhen(true)] out TimelineNode?node)
        {
            node = null;
            if (!IdToNodeMap.TryGetValue(id, out var current))
            {
                return(false);
            }

            do
            {
                if (predicate(current))
                {
                    node = current;
                    return(true);
                }

                current = current.ParentNode;
            } while (current is object);

            return(false);
        }
Exemplo n.º 4
0
 public ASTNode GetASTNodeById(int id)
 {
     Debug.Assert(IdToNodeMap.ContainsKey(id), $"Unknown id: {id}");
     return(IdToNodeMap[id]);
 }
Exemplo n.º 5
0
 public bool HasASTNodeId(int id)
 {
     return(IdToNodeMap.ContainsKey(id));
 }
Exemplo n.º 6
0
 public bool TryGetNode(TimelineRecord record, [NotNullWhen(true)] out TimelineNode?node) =>
 IdToNodeMap.TryGetValue(record.Id, out node);
Exemplo n.º 7
0
 public bool TryGetNode(string id, [NotNullWhen(true)] out TimelineNode?node) =>
 IdToNodeMap.TryGetValue(id, out node);
Exemplo n.º 8
0
 public bool IsPhase(string id) =>
 IdToNodeMap.TryGetValue(id, out var node) &&
 node.TimelineRecord.Type == "Phase";