Skip to content

Commit 1579859

Browse files
authored
Merge pull request #2555 from github/koesie10/nested-name-csharp
Add `nestedName` function for C#
2 parents 8297751 + 8af0ba7 commit 1579859

File tree

1 file changed

+16
-1
lines changed
  • extensions/ql-vscode/src/data-extensions-editor/queries

1 file changed

+16
-1
lines changed

extensions/ql-vscode/src/data-extensions-editor/queries/csharp.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class CallableMethod extends DotNet::Declaration {
104104
bindingset[this]
105105
private string getSignature() {
106106
result =
107-
this.getDeclaringType().getUnboundDeclaration() + "." + this.getName() + "(" +
107+
nestedName(this.getDeclaringType().getUnboundDeclaration()) + "." + this.getName() + "(" +
108108
parameterQualifiedTypeNamesToString(this) + ")"
109109
}
110110
@@ -178,6 +178,21 @@ boolean isSupported(CallableMethod callableMethod) {
178178
not callableMethod.isSupported() and
179179
result = false
180180
}
181+
182+
/**
183+
* Gets the nested name of the declaration.
184+
*
185+
* If the declaration is not a nested type, the result is the same as \`getName()\`.
186+
* Otherwise the name of the nested type is prefixed with a \`+\` and appended to
187+
* the name of the enclosing type, which might be a nested type as well.
188+
*/
189+
private string nestedName(Declaration declaration) {
190+
not exists(declaration.getDeclaringType().getUnboundDeclaration()) and
191+
result = declaration.getName()
192+
or
193+
nestedName(declaration.getDeclaringType().getUnboundDeclaration()) + "+" + declaration.getName() =
194+
result
195+
}
181196
`,
182197
},
183198
};

0 commit comments

Comments
 (0)