1010overlay [ local]
1111predicate isOverlay ( ) { databaseMetadata ( "isOverlay" , "true" ) }
1212
13+ overlay [ local]
14+ private string getLocationFilePath ( @location_default loc ) {
15+ exists ( @file file | locations_default ( loc , file , _, _, _, _) | files ( file , result ) )
16+ }
17+
1318/**
1419 * An abstract base class for all elements that can be discarded from the base.
1520 */
1621overlay [ local]
17- abstract private class DiscardableEntity extends @locatable {
22+ private class DiscardableEntity extends @locatable {
1823 /** Gets the path to the file in which this element occurs. */
19- abstract string getPath ( ) ;
24+ string getFilePath ( ) {
25+ exists ( @location_default loc | result = getLocationFilePath ( loc ) |
26+ expr_location ( this , loc ) or
27+ stmt_location ( this , loc ) or
28+ using_directive_location ( this , loc ) or
29+ namespace_declaration_location ( this , loc ) or
30+ preprocessor_directive_location ( this , loc ) or
31+ type_location ( this , loc ) or
32+ attribute_location ( this , loc ) or
33+ type_parameter_constraints_location ( this , loc ) or
34+ property_location ( this , loc ) or
35+ indexer_location ( this , loc ) or
36+ accessor_location ( this , loc ) or
37+ event_location ( this , loc ) or
38+ event_accessor_location ( this , loc ) or
39+ operator_location ( this , loc ) or
40+ method_location ( this , loc ) or
41+ constructor_location ( this , loc ) or
42+ destructor_location ( this , loc ) or
43+ field_location ( this , loc ) or
44+ localvar_location ( this , loc ) or
45+ param_location ( this , loc ) or
46+ type_mention_location ( this , loc ) or
47+ commentline_location ( this , loc ) or
48+ commentblock_location ( this , loc ) or
49+ diagnostics ( this , _, _, _, _, loc ) or
50+ extractor_messages ( this , _, _, _, _, loc , _)
51+ )
52+ }
2053
2154 /** Holds if this element exists in the base variant. */
2255 predicate existsInBase ( ) { not isOverlay ( ) and exists ( this ) }
@@ -34,74 +67,39 @@ abstract private class DiscardableEntity extends @locatable {
3467 */
3568overlay [ local]
3669private class StarEntity =
37- @expr or @stmt or @diagnostic or @extractor_message or @using_directive or @type_mention;
70+ @expr or @stmt or @diagnostic or @extractor_message or @using_directive or @type_mention or
71+ @local_variable;
3872
3973overlay [ discard_entity]
4074private predicate discardStarEntity ( @locatable e ) {
4175 e instanceof StarEntity and
4276 // Entities with *-ids can exist either in base or overlay, but not both.
43- exists ( DiscardableEntity de | de = e |
44- overlayChangedFiles ( de .getPath ( ) ) and
45- de .existsInBase ( )
46- )
77+ e =
78+ any ( DiscardableEntity de |
79+ overlayChangedFiles ( de .getFilePath ( ) ) and
80+ de .existsInBase ( )
81+ )
4782}
4883
4984overlay [ discard_entity]
5085private predicate discardNamedEntity ( @locatable e ) {
5186 not e instanceof StarEntity and
5287 // Entities with named IDs can exist both in base, overlay, or both.
53- exists ( DiscardableEntity de | de = e |
54- overlayChangedFiles ( de .getPath ( ) ) and
55- not de .existsInOverlay ( )
56- )
57- }
58-
59- overlay [ local]
60- private string getLocationPath ( @location_default loc ) {
61- exists ( @file file | locations_default ( loc , file , _, _, _, _) | files ( file , result ) )
88+ e =
89+ any ( DiscardableEntity de |
90+ overlayChangedFiles ( de .getFilePath ( ) ) and
91+ not de .existsInOverlay ( )
92+ )
6293}
6394
6495overlay [ local]
6596private predicate discardableLocation ( @location_default loc , string path ) {
6697 not isOverlay ( ) and
67- path = getLocationPath ( loc )
98+ path = getLocationFilePath ( loc )
6899}
69100
70101// Discard locations that are in changed files from the base variant.
71102overlay [ discard_entity]
72103private predicate discardLocation ( @location_default loc ) {
73104 exists ( string path | discardableLocation ( loc , path ) | overlayChangedFiles ( path ) )
74105}
75-
76- overlay [ local]
77- private class PossibleDiscardableEntity extends DiscardableEntity instanceof @locatable {
78- override string getPath ( ) {
79- exists ( @location_default loc | result = getLocationPath ( loc ) |
80- expr_location ( this , loc ) or
81- stmt_location ( this , loc ) or
82- using_directive_location ( this , loc ) or
83- namespace_declaration_location ( this , loc ) or
84- preprocessor_directive_location ( this , loc ) or
85- type_location ( this , loc ) or
86- attribute_location ( this , loc ) or
87- type_parameter_constraints_location ( this , loc ) or
88- property_location ( this , loc ) or
89- indexer_location ( this , loc ) or
90- accessor_location ( this , loc ) or
91- event_location ( this , loc ) or
92- event_accessor_location ( this , loc ) or
93- operator_location ( this , loc ) or
94- method_location ( this , loc ) or
95- constructor_location ( this , loc ) or
96- destructor_location ( this , loc ) or
97- field_location ( this , loc ) or
98- localvar_location ( this , loc ) or
99- param_location ( this , loc ) or
100- type_mention_location ( this , loc ) or
101- commentline_location ( this , loc ) or
102- commentblock_location ( this , loc ) or
103- diagnostics ( this , _, _, _, _, loc ) or
104- extractor_messages ( this , _, _, _, _, loc , _)
105- )
106- }
107- }
0 commit comments