Class ItemNode
An item that may be referred to by a path, and which is a node in the item graph.
The item graph is a labeled directed graph, where an edge
item1 --name,kind--> item2
means that:
-
item2is available inside the scope ofitem1under the namename, whenkindis eitherinternalorboth, and -
item2is available externally fromitem1under the namename, whenkindis eitherexternalorboth.
For example, if we have
pub mod m1 {
pub mod m2 { }
}
then there is an edge mod m1 --m2,both--> mod m2.
Associated items are example of externally visible items (inside the
declaring item they must be Self prefixed), while type parameters are
examples of internally visible items. For example, for
mod m {
pub trait<T> Trait {
fn foo(&self) -> T;
}
}
we have the following edges
mod m --Trait,both--> trait Trait
trait Trait --foo,external --> fn foo
trait Trait --T,internal --> T
Source files are also considered nodes in the item graph, and for
each source file f there is an edge f --name,both--> item when f
declares item with the name name.
For imports like
mod m1 {
mod m2;
use m2::foo;
}
we first generate an edge mod m2 --name,kind--> f::item, where item is
any item (named name) inside the imported source file f, and kind is
either external or both. Using this edge, m2::foo can resolve to
f::foo, which results in the edge use m2 --foo,internal--> f::foo
(would have been external if it was pub use m2::foo). Lastly, all edges
out of use nodes are lifted to predecessors in the graph, so we get
an edge mod m1 --foo,internal--> f::foo.
References:
Import path
import codeql.rust.internal.PathResolutionDirect supertypes
Indirect supertypes
Known direct subtypes
Predicates
| getAChild | Gets a child item of this item, if any. |
| getADescendant | Gets an element that has this item as immediately enclosing item. |
| getASuccessor | Gets an external successor named |
| getASuccessor | Gets a successor named |
| getAnAttr | |
| getAttr | |
| getCanonicalPath | Gets the canonical path of this item, if any. |
| getCanonicalPathPrefix | Gets the canonical path prefix of this node, if any. |
| getCanonicalPathPrefixFor | Gets the canonical path prefix that this node provides for |
| getImmediateParent | Gets the immediately enclosing item of this item, if any. |
| getImmediateParentModule | Gets the immediately enclosing module (or source file) of this item. |
| getLocation | Gets the location of this item. |
| getName | Gets the (original) name of this item. |
| getNamespace | Gets the namespace that this item belongs to, if any. |
| getTypeParam | Gets the |
| getVisibility | Gets the visibility of this item, if any. |
| hasAttr | |
| hasCanonicalPath | Holds if this item has a canonical path belonging to the crate |
| hasCanonicalPathPrefix | Holds if this node has a canonical path prefix in crate |
| isPublic | Holds if this item is public. |
| providesCanonicalPathPrefixFor | Holds if this node provides a canonical path prefix for |
Inherited predicates
| fromSource | Holds if this element is from source code. | from Locatable |
| getAPrimaryQlClass | Gets the name of a primary CodeQL class to which this element belongs. | from Element |
| getFile | Gets the primary file where this element occurs. | from Locatable |
| getPrimaryQlClasses | Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. | from Element |
| getResolveStep | Gets the most immediate element that should substitute this element in the explicit AST, if any. Classes can override this to indicate this node should be in the “hidden” AST, mostly reserved for conversions and syntactic sugar nodes like parentheses. | from Element |
| isUnknown | from Element | |
| resolve | Gets the element that should substitute this element in the explicit AST, applying | from Element |
| toAbbreviatedString | INTERNAL: Do not use. | from Element |
| toString | Gets the string representation of this element. | from Element |
| toStringImpl | INTERNAL: Do not use. | from Element |