File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,26 @@ internal class Context : Extraction.Context
1818 /// </summary>
1919 public SemanticModel GetModel ( SyntaxNode node )
2020 {
21- // todo: when this context belongs to a SourceScope, the syntax tree can be retrieved from the scope, and
22- // the node parameter could be removed. Is there any case when we pass in a node that's not from the current
23- // tree?
24- if ( cachedModel is null || node . SyntaxTree != cachedModel . SyntaxTree )
21+ if ( node . SyntaxTree == SourceTree )
2522 {
26- cachedModel = Compilation . GetSemanticModel ( node . SyntaxTree ) ;
23+ if ( cachedModelForTree is null )
24+ {
25+ cachedModelForTree = Compilation . GetSemanticModel ( node . SyntaxTree ) ;
26+ }
27+
28+ return cachedModelForTree ;
29+ }
30+
31+ if ( cachedModelForOtherTrees is null || node . SyntaxTree != cachedModelForOtherTrees . SyntaxTree )
32+ {
33+ cachedModelForOtherTrees = Compilation . GetSemanticModel ( node . SyntaxTree ) ;
2734 }
2835
29- return cachedModel ;
36+ return cachedModelForOtherTrees ;
3037 }
3138
32- private SemanticModel ? cachedModel ;
39+ private SemanticModel ? cachedModelForTree ;
40+ private SemanticModel ? cachedModelForOtherTrees ;
3341
3442 /// <summary>
3543 /// The current compilation unit.
You can’t perform that action at this time.
0 commit comments