11/** Provides classes and predicates related to handling APIs for the VS Code extension. */
22
33private import csharp
4- private import dotnet
4+ private import semmle.code.csharp.dataflow.FlowSummary
55private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
66private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
77private import semmle.code.csharp.frameworks.Test
88private import Telemetry.TestLibrary
99
1010/** Holds if the given callable is not worth supporting. */
11- private predicate isUninteresting ( DotNet :: Callable c ) {
11+ private predicate isUninteresting ( Callable c ) {
1212 c .getDeclaringType ( ) instanceof TestLibrary or
1313 c .( Constructor ) .isParameterless ( ) or
1414 c .getDeclaringType ( ) instanceof AnonymousClass
@@ -17,7 +17,7 @@ private predicate isUninteresting(DotNet::Callable c) {
1717/**
1818 * A callable method or accessor from either the C# Standard Library, a 3rd party library, or from the source.
1919 */
20- class Endpoint extends DotNet :: Callable {
20+ class Endpoint extends Callable {
2121 Endpoint ( ) {
2222 [ this .( Modifiable ) , this .( Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
2323 not isUninteresting ( this ) and
@@ -64,7 +64,7 @@ class Endpoint extends DotNet::Callable {
6464
6565 /** Holds if this API has a supported summary. */
6666 pragma [ nomagic]
67- abstract predicate hasSummary ( ) ;
67+ predicate hasSummary ( ) { this instanceof SummarizedCallable }
6868
6969 /** Holds if this API is a known source. */
7070 pragma [ nomagic]
@@ -88,10 +88,7 @@ class Endpoint extends DotNet::Callable {
8888}
8989
9090boolean 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
9592}
9693
9794string supportedType ( Endpoint endpoint ) {
@@ -114,16 +111,15 @@ string methodClassification(Call method) {
114111}
115112
116113/**
117- * Gets the nested name of the declaration .
114+ * Gets the nested name of the type `t` .
118115 *
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()`.
120117 * Otherwise the name of the nested type is prefixed with a `+` and appended to
121118 * the name of the enclosing type, which might be a nested type as well.
122119 */
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 ( )
126123 or
127- nestedName ( declaration .getDeclaringType ( ) .getUnboundDeclaration ( ) ) + "+" + declaration .getName ( ) =
128- result
124+ nestedName ( t .getDeclaringType ( ) .getUnboundDeclaration ( ) ) + "+" + t .getName ( ) = result
129125}
0 commit comments