Skip to content

Commit 56b80ae

Browse files
committed
C#: Add getALocation() for namespaces and namespace declarations
1 parent 936094d commit 56b80ae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

csharp/ql/src/semmle/code/csharp/Namespace.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,12 @@ class Namespace extends DotNet::Namespace, TypeContainer, @namespace {
112112

113113
override predicate fromLibrary() { not this.fromSource() }
114114

115-
/** Gets the URL of this namespace (which is empty in this case). */
116-
string getURL() { result = "" }
115+
/** Gets a declaration of this namespace, if any. */
116+
NamespaceDeclaration getADeclaration() { result.getNamespace() = this }
117+
118+
override Location getALocation() {
119+
result = this.getADeclaration().getALocation()
120+
}
117121
}
118122

119123
/**
@@ -193,7 +197,7 @@ class NamespaceDeclaration extends Element, @namespace_declaration {
193197
*/
194198
ValueOrRefType getATypeDeclaration() { parent_namespace_declaration(result, this) }
195199

196-
override Location getALocation() { none() }
200+
override Location getALocation() { namespace_declaration_location(this, result) }
197201

198202
override string toString() { result = "namespace ... { ... }" }
199203
}

0 commit comments

Comments
 (0)