Files
swift-mirror/test/SourceKit/ActiveRegions/nested.swift
Louis D'hauwe 876682fb12 [SourceKit] Add "Active Regions" request
`source.request.activeregions` is a new request that reports all
`#if`, `#else` and `#elseif` decls in the response with an `is_active` flag.
This is mainly useful for a client to know which branches are active,
but for completeness sake, the active decls are also reported.

Note: it only reports the positions of the decls, not the entire ranges.
It's up to clients to map this to the syntactic structure of a tree.
Reporting the ranges of the decls could be confusing in the case
of nested `#if`s, where the ranges can overlap.
2023-03-01 14:13:58 -08:00

48 lines
1.3 KiB
Swift

#if FLAG_1
class Foo {
#if FLAG_2
func debugOnly() {
}
#endif
}
#elseif FLAG_3
class GracefulFallback {
}
#else
class Fallback {
}
#endif
// RUN: %sourcekitd-test -req=active-regions %s -- -D FLAG_1 -module-name active_regions %s | %FileCheck -check-prefix=CHECK1 %s
// CHECK1: START IF CONFIGS
// CHECK1-NEXT: 1:1 - active
// CHECK1-NEXT: 3:5 - inactive
// CHECK1-NEXT: 9:1 - inactive
// CHECK1-NEXT: 13:1 - inactive
// CHECK1-NEXT: END IF CONFIGS
// RUN: %sourcekitd-test -req=active-regions %s -- -D FLAG_2 -module-name active_regions %s | %FileCheck -check-prefix=CHECK2 %s
// CHECK2: START IF CONFIGS
// CHECK2-NEXT: 1:1 - inactive
// CHECK2-NEXT: 9:1 - inactive
// CHECK2-NEXT: 13:1 - active
// CHECK2-NEXT: END IF CONFIGS
// RUN: %sourcekitd-test -req=active-regions %s -- -D FLAG_1 -D FLAG_2 -module-name active_regions %s | %FileCheck -check-prefix=CHECK3 %s
// CHECK3: START IF CONFIGS
// CHECK3-NEXT: 1:1 - active
// CHECK3-NEXT: 3:5 - active
// CHECK3-NEXT: 9:1 - inactive
// CHECK3-NEXT: 13:1 - inactive
// CHECK3-NEXT: END IF CONFIGS
// RUN: %sourcekitd-test -req=active-regions %s -- -D FLAG_3 -module-name active_regions %s | %FileCheck -check-prefix=CHECK4 %s
// CHECK4: START IF CONFIGS
// CHECK4-NEXT: 1:1 - inactive
// CHECK4-NEXT: 9:1 - active
// CHECK4-NEXT: 13:1 - inactive
// CHECK4-NEXT: END IF CONFIGS