/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/VisualBasic/Test/Syntax/IncrementalParser/SyntaxDifferences.vb
39 строк
1 KB
Tomáš Matoušek
Refactoring of extension methods in source packages (#78620) - take 2 (#78894)
26 июн 2025, 18:42
Не верифицирован
26 июн 2025, 18:42
05fc006
Код
Авторство
О чём код?
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis.PooledObjects Friend Module SyntaxDifferences Public Function GetRebuiltNodes(oldTree As SyntaxTree, newTree As SyntaxTree) As ImmutableArray(Of SyntaxNodeOrToken) Dim hashSet = New HashSet(Of GreenNode) GatherNodes(oldTree.GetRoot(), hashSet) Dim nodes = ArrayBuilder(Of SyntaxNodeOrToken).GetInstance() GetRebuiltNodes(newTree.GetRoot(), hashSet, nodes) Return nodes.ToImmutableAndFree() End Function Private Sub GetRebuiltNodes(newNode As SyntaxNodeOrToken, hashSet As HashSet(Of GreenNode), nodes As ArrayBuilder(Of SyntaxNodeOrToken)) If hashSet.Contains(newNode.UnderlyingNode) Then Return End If nodes.Add(newNode) For Each child In newNode.ChildNodesAndTokens() GetRebuiltNodes(child, hashSet, nodes) Next End Sub Private Sub GatherNodes(node As SyntaxNodeOrToken, hashSet As HashSet(Of GreenNode)) hashSet.Add(node.UnderlyingNode) For Each child In node.ChildNodesAndTokens() GatherNodes(child, hashSet) Next End Sub End Module