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
18
18
/// </summary>
19
19
public SemanticModel GetModel ( SyntaxNode node )
20
20
{
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 )
25
22
{
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 ) ;
27
34
}
28
35
29
- return cachedModel ;
36
+ return cachedModelForOtherTrees ;
30
37
}
31
38
32
- private SemanticModel ? cachedModel ;
39
+ private SemanticModel ? cachedModelForTree ;
40
+ private SemanticModel ? cachedModelForOtherTrees ;
33
41
34
42
/// <summary>
35
43
/// The current compilation unit.
You can’t perform that action at this time.
0 commit comments