Skip to content

Commit e177f87

Browse files
committed
C#: Share qualified name module for model editor queries
1 parent ea504cd commit e177f87

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private predicate elementSpec(
269269
UnboundValueOrRefType t
270270
) {
271271
elementSpec(namespace, type, subtypes, name, signature, ext) and
272-
QN::hasQualifiedName(t, namespace, type)
272+
hasQualifiedTypeName(t, namespace, type)
273273
}
274274

275275
private class UnboundValueOrRefType extends ValueOrRefType {
@@ -337,7 +337,7 @@ Declaration interpretBaseDeclaration(string namespace, string type, string name,
337337
exists(UnboundValueOrRefType t | elementSpec(namespace, type, _, name, signature, _, t) |
338338
result =
339339
any(Declaration d |
340-
QN::hasQualifiedName(d, namespace, type, name) and
340+
hasQualifiedMethodName(d, namespace, type, name) and
341341
(
342342
signature = ""
343343
or
@@ -439,6 +439,19 @@ private module QualifiedNameInput implements QualifiedNameInputSig {
439439

440440
private module QN = QualifiedName<QualifiedNameInput>;
441441

442+
/** Holds if declaration `d` has the qualified name `qualifier`.`name`. */
443+
predicate hasQualifiedTypeName(Type t, string namespace, string type) {
444+
QN::hasQualifiedName(t, namespace, type)
445+
}
446+
447+
/**
448+
* Holds if declaration `d` has name `name` and is defined in type `type`
449+
* with namespace `namespace`.
450+
*/
451+
predicate hasQualifiedMethodName(Declaration d, string namespace, string type, string name) {
452+
QN::hasQualifiedName(d, namespace, type, name)
453+
}
454+
442455
pragma[nomagic]
443456
private string parameterQualifiedType(Parameter p) {
444457
exists(string qualifier, string name |

csharp/ql/src/utils/modeleditor/ModelEditor.qll

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** Provides classes and predicates related to handling APIs for the VS Code extension. */
22

33
private import csharp
4-
private import semmle.code.csharp.commons.QualifiedName
54
private import semmle.code.csharp.dataflow.FlowSummary
65
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
76
private import semmle.code.csharp.dataflow.internal.ExternalFlow
@@ -121,22 +120,12 @@ string methodClassification(Call method) {
121120
* Gets the fully qualified name of the type `t`.
122121
*/
123122
private string qualifiedTypeName(string namespace, Type t) {
124-
exists(string type | QN::hasQualifiedName(t, namespace, type) | result = type)
123+
exists(string type | hasQualifiedTypeName(t, namespace, type) | result = type)
125124
}
126125

127126
/**
128127
* Gets the fully qualified name of the callable `c`.
129128
*/
130129
private string qualifiedCallableName(string namespace, string type, Callable c) {
131-
exists(string name | QN::hasQualifiedName(c, namespace, type, name) | result = name)
130+
exists(string name | hasQualifiedMethodName(c, namespace, type, name) | result = name)
132131
}
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

Comments
 (0)