1
1
/** Provides classes and predicates related to handling APIs for the VS Code extension. */
2
2
3
3
private import csharp
4
- private import dotnet
4
+ private import semmle.code.csharp.dataflow.FlowSummary
5
5
private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
6
6
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
7
7
private import semmle.code.csharp.frameworks.Test
8
8
private import Telemetry.TestLibrary
9
9
10
10
/** Holds if the given callable is not worth supporting. */
11
- private predicate isUninteresting ( DotNet :: Callable c ) {
11
+ private predicate isUninteresting ( Callable c ) {
12
12
c .getDeclaringType ( ) instanceof TestLibrary or
13
13
c .( Constructor ) .isParameterless ( ) or
14
14
c .getDeclaringType ( ) instanceof AnonymousClass
@@ -17,7 +17,7 @@ private predicate isUninteresting(DotNet::Callable c) {
17
17
/**
18
18
* A callable method or accessor from either the C# Standard Library, a 3rd party library, or from the source.
19
19
*/
20
- class Endpoint extends DotNet :: Callable {
20
+ class Endpoint extends Callable {
21
21
Endpoint ( ) {
22
22
[ this .( Modifiable ) , this .( Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
23
23
not isUninteresting ( this ) and
@@ -64,7 +64,7 @@ class Endpoint extends DotNet::Callable {
64
64
65
65
/** Holds if this API has a supported summary. */
66
66
pragma [ nomagic]
67
- abstract predicate hasSummary ( ) ;
67
+ predicate hasSummary ( ) { this instanceof SummarizedCallable }
68
68
69
69
/** Holds if this API is a known source. */
70
70
pragma [ nomagic]
@@ -88,10 +88,7 @@ class Endpoint extends DotNet::Callable {
88
88
}
89
89
90
90
boolean isSupported ( Endpoint endpoint ) {
91
- endpoint .isSupported ( ) and result = true
92
- or
93
- not endpoint .isSupported ( ) and
94
- result = false
91
+ if endpoint .isSupported ( ) then result = true else result = false
95
92
}
96
93
97
94
string supportedType ( Endpoint endpoint ) {
@@ -114,16 +111,15 @@ string methodClassification(Call method) {
114
111
}
115
112
116
113
/**
117
- * Gets the nested name of the declaration .
114
+ * Gets the nested name of the type `t` .
118
115
*
119
- * If the declaration is not a nested type, the result is the same as `getName()`.
116
+ * If the type is not a nested type, the result is the same as `getName()`.
120
117
* Otherwise the name of the nested type is prefixed with a `+` and appended to
121
118
* the name of the enclosing type, which might be a nested type as well.
122
119
*/
123
- private string nestedName ( Declaration declaration ) {
124
- not exists ( declaration .getDeclaringType ( ) .getUnboundDeclaration ( ) ) and
125
- result = declaration .getName ( )
120
+ private string nestedName ( Type t ) {
121
+ not exists ( t .getDeclaringType ( ) .getUnboundDeclaration ( ) ) and
122
+ result = t .getName ( )
126
123
or
127
- nestedName ( declaration .getDeclaringType ( ) .getUnboundDeclaration ( ) ) + "+" + declaration .getName ( ) =
128
- result
124
+ nestedName ( t .getDeclaringType ( ) .getUnboundDeclaration ( ) ) + "+" + t .getName ( ) = result
129
125
}
0 commit comments