Skip to content

Commit 6e93100

Browse files
committed
JS: Rewrite docs for API::Node#getInstance()
1 parent d829dd4 commit 6e93100

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,23 @@ module API {
241241
}
242242

243243
/**
244-
* Gets a node representing an instance of this API component, that is, an object whose
245-
* constructor is the function represented by this node.
244+
* Gets a node representing an instance of the class represented by this node.
245+
* This includes instances of subclasses.
246246
*
247-
* For example, if this node represents a use of some class `A`, then there might be a node
248-
* representing instances of `A`, typically corresponding to expressions `new A()` at the
249-
* source level.
247+
* For example:
248+
* ```js
249+
* import { C } from "foo";
250+
*
251+
* new C(); // API::moduleImport("foo").getMember("C").getInstance()
250252
*
251-
* This predicate may have multiple results when there are multiple constructor calls invoking this API component.
252-
* Consider using `getAnInstantiation()` if there is a need to distinguish between individual constructor calls.
253+
* class D extends C {
254+
* m() {
255+
* this; // API::moduleImport("foo").getMember("C").getInstance()
256+
* }
257+
* }
258+
*
259+
* new D(); // API::moduleImport("foo").getMember("C").getInstance()
260+
* ```
253261
*/
254262
cached
255263
Node getInstance() {

0 commit comments

Comments
 (0)