mirror of
https://github.com/github/codeql.git
synced 2026-04-23 15:55:18 +02:00
C#: Share qualified name module for model editor queries
This commit is contained in:
@@ -269,7 +269,7 @@ private predicate elementSpec(
|
||||
UnboundValueOrRefType t
|
||||
) {
|
||||
elementSpec(namespace, type, subtypes, name, signature, ext) and
|
||||
QN::hasQualifiedName(t, namespace, type)
|
||||
hasQualifiedTypeName(t, namespace, type)
|
||||
}
|
||||
|
||||
private class UnboundValueOrRefType extends ValueOrRefType {
|
||||
@@ -337,7 +337,7 @@ Declaration interpretBaseDeclaration(string namespace, string type, string name,
|
||||
exists(UnboundValueOrRefType t | elementSpec(namespace, type, _, name, signature, _, t) |
|
||||
result =
|
||||
any(Declaration d |
|
||||
QN::hasQualifiedName(d, namespace, type, name) and
|
||||
hasQualifiedMethodName(d, namespace, type, name) and
|
||||
(
|
||||
signature = ""
|
||||
or
|
||||
@@ -439,6 +439,19 @@ private module QualifiedNameInput implements QualifiedNameInputSig {
|
||||
|
||||
private module QN = QualifiedName<QualifiedNameInput>;
|
||||
|
||||
/** Holds if declaration `d` has the qualified name `qualifier`.`name`. */
|
||||
predicate hasQualifiedTypeName(Type t, string namespace, string type) {
|
||||
QN::hasQualifiedName(t, namespace, type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if declaration `d` has name `name` and is defined in type `type`
|
||||
* with namespace `namespace`.
|
||||
*/
|
||||
predicate hasQualifiedMethodName(Declaration d, string namespace, string type, string name) {
|
||||
QN::hasQualifiedName(d, namespace, type, name)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private string parameterQualifiedType(Parameter p) {
|
||||
exists(string qualifier, string name |
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/** Provides classes and predicates related to handling APIs for the VS Code extension. */
|
||||
|
||||
private import csharp
|
||||
private import semmle.code.csharp.commons.QualifiedName
|
||||
private import semmle.code.csharp.dataflow.FlowSummary
|
||||
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
||||
@@ -121,22 +120,12 @@ string methodClassification(Call method) {
|
||||
* Gets the fully qualified name of the type `t`.
|
||||
*/
|
||||
private string qualifiedTypeName(string namespace, Type t) {
|
||||
exists(string type | QN::hasQualifiedName(t, namespace, type) | result = type)
|
||||
exists(string type | hasQualifiedTypeName(t, namespace, type) | result = type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fully qualified name of the callable `c`.
|
||||
*/
|
||||
private string qualifiedCallableName(string namespace, string type, Callable c) {
|
||||
exists(string name | QN::hasQualifiedName(c, namespace, type, name) | result = name)
|
||||
exists(string name | hasQualifiedMethodName(c, namespace, type, name) | result = name)
|
||||
}
|
||||
|
||||
private module QualifiedNameInput implements QualifiedNameInputSig {
|
||||
string getUnboundGenericSuffix(UnboundGeneric ug) {
|
||||
result =
|
||||
"<" + strictconcat(int i, string s | s = ug.getTypeParameter(i).getName() | s, "," order by i)
|
||||
+ ">"
|
||||
}
|
||||
}
|
||||
|
||||
private module QN = QualifiedName<QualifiedNameInput>;
|
||||
|
||||
Reference in New Issue
Block a user