|
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 semmle.code.csharp.commons.QualifiedName |
4 | 5 | private import semmle.code.csharp.dataflow.FlowSummary
|
5 | 6 | private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
|
6 | 7 | private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
@@ -34,7 +35,17 @@ class Endpoint extends Callable {
|
34 | 35 | * Gets the unbound type name of this endpoint.
|
35 | 36 | */
|
36 | 37 | bindingset[this]
|
37 |
| - string getTypeName() { result = nestedName(this.getDeclaringType().getUnboundDeclaration()) } |
| 38 | + string getTypeName() { |
| 39 | + result = qualifiedTypeName(this.getNamespace(), this.getDeclaringType().getUnboundDeclaration()) |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Gets the qualified method name of this endpoint. |
| 44 | + */ |
| 45 | + bindingset[this] |
| 46 | + string getMethodName() { |
| 47 | + result = qualifiedCallableName(this.getNamespace(), this.getTypeName(), this) |
| 48 | + } |
38 | 49 |
|
39 | 50 | /**
|
40 | 51 | * Gets the parameter types of this endpoint.
|
@@ -107,15 +118,25 @@ string methodClassification(Call method) {
|
107 | 118 | }
|
108 | 119 |
|
109 | 120 | /**
|
110 |
| - * Gets the nested name of the type `t`. |
111 |
| - * |
112 |
| - * If the type is not a nested type, the result is the same as `getName()`. |
113 |
| - * Otherwise the name of the nested type is prefixed with a `+` and appended to |
114 |
| - * the name of the enclosing type, which might be a nested type as well. |
| 121 | + * Gets the fully qualified name of the type `t`. |
115 | 122 | */
|
116 |
| -private string nestedName(Type t) { |
117 |
| - not exists(t.getDeclaringType().getUnboundDeclaration()) and |
118 |
| - result = t.getName() |
119 |
| - or |
120 |
| - nestedName(t.getDeclaringType().getUnboundDeclaration()) + "+" + t.getName() = result |
| 123 | +private string qualifiedTypeName(string namespace, Type t) { |
| 124 | + exists(string type | QN::hasQualifiedName(t, namespace, type) | result = type) |
121 | 125 | }
|
| 126 | + |
| 127 | +/** |
| 128 | + * Gets the fully qualified name of the callable `c`. |
| 129 | + */ |
| 130 | +private string qualifiedCallableName(string namespace, string type, Callable c) { |
| 131 | + exists(string name | QN::hasQualifiedName(c, namespace, type, name) | result = name) |
| 132 | +} |
| 133 | + |
| 134 | +private module QualifiedNameInput implements QualifiedNameInputSig { |
| 135 | + string getUnboundGenericSuffix(UnboundGeneric ug) { |
| 136 | + result = |
| 137 | + "<" + strictconcat(int i, string s | s = ug.getTypeParameter(i).getName() | s, "," order by i) |
| 138 | + + ">" |
| 139 | + } |
| 140 | +} |
| 141 | + |
| 142 | +private module QN = QualifiedName<QualifiedNameInput>; |
0 commit comments