/// <summary> /// 更新语法树 /// </summary> /// <param name="oldCode">旧代码</param> /// <param name="newCode">新代码</param> /// <param name="sets">新的引用</param> public override void Update(string oldCode, string newCode, HashSet <string> sets = default) { //先移除 if (TreeCache.ContainsKey(oldCode)) { while (!TreeCache.TryRemove(oldCode, out _)) { } ; } if (sets == default) { if (ReferenceCache.ContainsKey(oldCode)) { sets = ReferenceCache[oldCode]; while (!ReferenceCache.TryRemove(oldCode, out _)) { } ; } } //再添加 AddTreeToCache(newCode); ReferenceCache[newCode] = sets; }
public override void Update(string old, string @new, HashSet <string> sets = default) { if (TreeCache.ContainsKey(old)) { while (!TreeCache.TryRemove(old, out _)) { } ; } if (sets == default) { if (ReferenceCache.ContainsKey(old)) { sets = ReferenceCache[old]; while (!ReferenceCache.TryRemove(old, out _)) { } ; } } AddTreeToCache(@new); ReferenceCache[@new] = sets; }