Class CommonQueries
- java.lang.Object
-
- com.ensoftcorp.open.java.commons.analysis.CommonQueries
-
public final class CommonQueries extends java.lang.Object
Common queries which are useful for writing larger Java analysis programs, and for using on the shell.- Author:
- Ben Holland, Tom Deering, Jon Mathews
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static com.ensoftcorp.atlas.core.query.Q
advancedIntersection(com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String[] nodeTags, java.lang.String[] edgeTags)
Given two query expressions, intersects the given node and edge kinds to produce a new expression.static com.ensoftcorp.atlas.core.query.Q
called(com.ensoftcorp.atlas.core.query.Q origin)
Returns the subset of the given functions which are called.static com.ensoftcorp.atlas.core.query.Q
called(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the subset of the given functions which are called.static com.ensoftcorp.atlas.core.query.Q
calledBy(com.ensoftcorp.atlas.core.query.Q callers, com.ensoftcorp.atlas.core.query.Q called)
Returns the given functions which were called by the given callers.static com.ensoftcorp.atlas.core.query.Q
calledBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q callers, com.ensoftcorp.atlas.core.query.Q called)
Returns the given functions which were called by the given callers.static com.ensoftcorp.atlas.core.query.Q
callers(com.ensoftcorp.atlas.core.query.Q origin)
Returns the direct callers of the given functions.static com.ensoftcorp.atlas.core.query.Q
callers(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the direct callers of the given functions.static com.ensoftcorp.atlas.core.query.Q
cfg(com.ensoftcorp.atlas.core.db.graph.Node function)
static com.ensoftcorp.atlas.core.query.Q
cfg(com.ensoftcorp.atlas.core.query.Q functions)
static com.ensoftcorp.atlas.core.query.Q
classLiterals(com.ensoftcorp.atlas.core.query.Q types)
Returns all references to class literals (Type.class) for the given types.static com.ensoftcorp.atlas.core.query.Q
classLiterals(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q types)
Returns all references to class literals (Type.class) for the given types.static com.ensoftcorp.atlas.core.query.Q
conditionsAbove(com.ensoftcorp.atlas.core.query.Q origin)
Returns the control flow graph between conditional nodes and the given origin.static com.ensoftcorp.atlas.core.query.Q
conditionsAbove(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the control flow graph between conditional nodes and the given origin.static com.ensoftcorp.atlas.core.query.Q
conservativeDynamicDispatch(com.ensoftcorp.atlas.core.query.Q typeToSearch, com.ensoftcorp.atlas.core.query.Q methodSignature)
Given a type to search and a method signature, determine possible method definitions which could be called.static com.ensoftcorp.atlas.core.query.Q
declarations(com.ensoftcorp.atlas.core.query.Q origin)
Produces a declarations (contains) graph.static com.ensoftcorp.atlas.core.query.Q
declarations(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Produces a declarations (contains) graph.static com.ensoftcorp.atlas.core.query.Q
dfg(com.ensoftcorp.atlas.core.db.graph.Node function)
static com.ensoftcorp.atlas.core.query.Q
dfg(com.ensoftcorp.atlas.core.query.Q functions)
static com.ensoftcorp.atlas.core.query.Q
dynamicDispatch(com.ensoftcorp.atlas.core.query.Q runtimeTypes, com.ensoftcorp.atlas.core.query.Q methodSignature)
Resolves invocation for a runtime type and method signature.static long
edgeSize(com.ensoftcorp.atlas.core.query.Q toCount)
Returns the number of edges contained.static com.ensoftcorp.atlas.core.query.Q
excfg(com.ensoftcorp.atlas.core.db.graph.Node function)
static com.ensoftcorp.atlas.core.query.Q
excfg(com.ensoftcorp.atlas.core.query.Q functions)
static com.ensoftcorp.atlas.core.query.Q
firstDeclarator(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q declared, java.lang.String... declaratorTypes)
Returns the first declaring node of the given Q which is tagged with one of the given types.static com.ensoftcorp.atlas.core.query.Q
firstDeclarator(com.ensoftcorp.atlas.core.query.Q declared, java.lang.String... declaratorTypes)
Returns the first declaring node of the given Q which is tagged with one of the given types.static com.ensoftcorp.atlas.core.db.graph.Node
getContainingControlFlowNode(com.ensoftcorp.atlas.core.db.graph.Node node)
Returns the nearest parent that is a control flow nodestatic com.ensoftcorp.atlas.core.db.graph.Node
getContainingMethod(com.ensoftcorp.atlas.core.db.graph.Node node)
Returns the containing method of a given graph element or null if one is not foundstatic com.ensoftcorp.atlas.core.query.Q
getContainingMethods(com.ensoftcorp.atlas.core.query.Q nodes)
Returns the containing method of a given Q or empty if one is not foundstatic com.ensoftcorp.atlas.core.db.graph.Node
getContainingNode(com.ensoftcorp.atlas.core.db.graph.Node node, java.lang.String containingTag)
Find the next immediate containing node with the given tag.static com.ensoftcorp.atlas.core.db.graph.Edge
getEdgeByAddress(java.lang.String address)
Selects the Atlas edge graph element given a serialized graph element address Returns null if the address does not correspond to a edgestatic com.ensoftcorp.atlas.core.db.graph.GraphElement
getGraphElementByAddress(java.lang.String address)
Selects the Atlas graph element given a serialized graph element address Returns null if the address does not correspond to a graph elementstatic com.ensoftcorp.atlas.core.db.graph.Node
getNodeByAddress(java.lang.String address)
Selects the Atlas node graph element given a serialized graph element address Returns null if the address does not correspond to a nodestatic java.lang.String
getQualifiedClassName(com.ensoftcorp.atlas.core.db.graph.Node type)
Helper function to get the stringified qualified name of the classstatic java.lang.String
getQualifiedMethodName(com.ensoftcorp.atlas.core.db.graph.Node function)
Helper function to get the stringified qualified name of the functionstatic java.lang.String
getQualifiedName(com.ensoftcorp.atlas.core.db.graph.Node node)
Helper function to get the stringified qualified name of the functionstatic java.lang.String
getQualifiedName(com.ensoftcorp.atlas.core.db.graph.Node node, java.lang.String... stopAfterTags)
Helper function to get the stringified qualified name of the class Stop after tags specify parent containers to stop qualifying at (example packages or jars)static com.ensoftcorp.atlas.core.query.Q
interactions(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String... edgeTags)
Deprecated.use com.ensoftcorp.open.commons.analysis.CommonQueries.interactionsstatic com.ensoftcorp.atlas.core.query.Q
interactions(com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String... edgeTags)
Deprecated.use com.ensoftcorp.open.commons.analysis.CommonQueries.interactionsstatic boolean
isEmpty(com.ensoftcorp.atlas.core.query.Q test)
Returns whether the given Q is empty.static boolean
isNotEmpty(com.ensoftcorp.atlas.core.query.Q test)
Returns whether the given Q is not emptystatic com.ensoftcorp.atlas.core.db.graph.Node
leastCommonAncestor(com.ensoftcorp.atlas.core.db.graph.Node child1, com.ensoftcorp.atlas.core.db.graph.Node child2, com.ensoftcorp.atlas.core.db.graph.Graph graph)
Returns the least common ancestor of both child1 and child2 within the given graphstatic com.ensoftcorp.atlas.core.db.graph.Node
leastCommonAncestor(com.ensoftcorp.atlas.core.db.graph.Node child1, com.ensoftcorp.atlas.core.db.graph.Node child2, com.ensoftcorp.atlas.core.query.Q graph)
Returns the least common ancestor of both child1 and child2 within the given graphstatic com.ensoftcorp.atlas.core.query.Q
libraryDeclarations()
Returns those nodes which are declared by a library.static com.ensoftcorp.atlas.core.query.Q
libraryDeclarations(com.ensoftcorp.atlas.core.query.Q context)
Returns those nodes which are declared by a library.static com.ensoftcorp.atlas.core.query.Q
libraryDeclarations(com.ensoftcorp.atlas.core.query.Q context, java.lang.String name)
Returns those nodes which are declared by a library with the given name.static com.ensoftcorp.atlas.core.query.Q
libraryDeclarations(java.lang.String name)
Returns those nodes which are declared by a library with the given name.static com.ensoftcorp.atlas.core.query.Q
localDeclarations(com.ensoftcorp.atlas.core.query.Q functions)
All nodes declared under the given functions, but NOT declared under additional functions or types.static com.ensoftcorp.atlas.core.query.Q
localDeclarations(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q functions)
All nodes declared under the given functions, but NOT declared under additional functions or types.static com.ensoftcorp.atlas.core.query.Q
methodParameter(com.ensoftcorp.atlas.core.query.Q methods)
Returns the parameters of the given methods.static com.ensoftcorp.atlas.core.query.Q
methodParameter(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the parameters of the given methods.static com.ensoftcorp.atlas.core.query.Q
methodParameter(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods, java.lang.Integer... index)
Returns the parameters of the given methods at the given indices.static com.ensoftcorp.atlas.core.query.Q
methodParameter(com.ensoftcorp.atlas.core.query.Q methods, java.lang.Integer... index)
Returns the parameters of the given methods at the given indices.static com.ensoftcorp.atlas.core.query.Q
methodReturn(com.ensoftcorp.atlas.core.query.Q methods)
Returns the return nodes for the given methods.static com.ensoftcorp.atlas.core.query.Q
methodReturn(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the return nodes for the given methods.static com.ensoftcorp.atlas.core.query.Q
methodsOf(com.ensoftcorp.atlas.core.query.Q types)
Returns the methods declared by the given types.static com.ensoftcorp.atlas.core.query.Q
methodsOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q types)
Returns the methods declared by the given types.static com.ensoftcorp.atlas.core.query.Q
methodThis(com.ensoftcorp.atlas.core.query.Q methods)
Returns the 'this' identity nodes for the given methods.static com.ensoftcorp.atlas.core.query.Q
methodThis(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the 'this' identity nodes for the given methods.static com.ensoftcorp.atlas.core.query.Q
mutatedBy(com.ensoftcorp.atlas.core.query.Q mutators, com.ensoftcorp.atlas.core.query.Q origin)
Returns those elements in the origin which were called by or written by elements in the mutators set.static com.ensoftcorp.atlas.core.query.Q
mutatedBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q mutators, com.ensoftcorp.atlas.core.query.Q origin)
Returns those elements in the origin which were called by or written by elements in the mutators set.static com.ensoftcorp.atlas.core.query.Q
mutators(com.ensoftcorp.atlas.core.query.Q origin)
Given a Q containing methods or data flow nodes, returns a Q of things which write to or call things in the Q.static com.ensoftcorp.atlas.core.query.Q
mutators(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Given a Q containing methods or data flow nodes, returns a Q of things which write to or call things in the Q.static com.ensoftcorp.atlas.core.query.Q
nodesContaining(com.ensoftcorp.atlas.core.query.Q context, java.lang.String substring)
Returns the nodes whose names contain the given string within the given context.static com.ensoftcorp.atlas.core.query.Q
nodesContaining(java.lang.String substring)
Returns the nodes whose names contain the given string.static com.ensoftcorp.atlas.core.query.Q
nodesEndingWith(com.ensoftcorp.atlas.core.query.Q context, java.lang.String suffix)
Returns the nodes whose names end with the given string within the given context.static com.ensoftcorp.atlas.core.query.Q
nodesEndingWith(java.lang.String suffix)
Returns the nodes whose names end with the given string.static long
nodeSize(com.ensoftcorp.atlas.core.query.Q toCount)
Returns the number of nodes contained.static com.ensoftcorp.atlas.core.query.Q
nodesMatchingRegex(com.ensoftcorp.atlas.core.query.Q context, java.lang.String regex)
Returns the nodes whose names match the given regular expression within the given context.static com.ensoftcorp.atlas.core.query.Q
nodesMatchingRegex(java.lang.String regex)
Returns the nodes whose names match the given regular expression.static com.ensoftcorp.atlas.core.query.Q
nodesStartingWith(com.ensoftcorp.atlas.core.query.Q context, java.lang.String prefix)
Returns the nodes whose names start with the given string within the given context.static com.ensoftcorp.atlas.core.query.Q
nodesStartingWith(java.lang.String prefix)
Returns the nodes whose names start with the given string.static com.ensoftcorp.atlas.core.query.Q
nodesWithSelfEdges(com.ensoftcorp.atlas.core.query.Q context)
Returns those nodes in the context which have self edges.static com.ensoftcorp.atlas.core.query.Q
readBy(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes from which nodes in the origin read.static com.ensoftcorp.atlas.core.query.Q
readBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes from which nodes in the origin read.static com.ensoftcorp.atlas.core.query.Q
readersOf(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly read from nodes in origin.static com.ensoftcorp.atlas.core.query.Q
readersOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly read from nodes in origin.static com.ensoftcorp.atlas.core.query.Q
writersOf(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly write to nodes in origin.static com.ensoftcorp.atlas.core.query.Q
writersOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly write to nodes in origin.static com.ensoftcorp.atlas.core.query.Q
writtenBy(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes to which nodes in origin write.static com.ensoftcorp.atlas.core.query.Q
writtenBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes to which nodes in origin write.
-
-
-
Method Detail
-
classLiterals
public static com.ensoftcorp.atlas.core.query.Q classLiterals(com.ensoftcorp.atlas.core.query.Q types)
Returns all references to class literals (Type.class) for the given types. Equivalent to classLiterals(index(), types).- Parameters:
types
-- Returns:
- the query expression
-
classLiterals
public static com.ensoftcorp.atlas.core.query.Q classLiterals(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q types)
Returns all references to class literals (Type.class) for the given types.- Parameters:
types
-- Returns:
- the query expression
-
conservativeDynamicDispatch
public static com.ensoftcorp.atlas.core.query.Q conservativeDynamicDispatch(com.ensoftcorp.atlas.core.query.Q typeToSearch, com.ensoftcorp.atlas.core.query.Q methodSignature)
Given a type to search and a method signature, determine possible method definitions which could be called.- Parameters:
typeToSearch
-methodSignature
-- Returns:
-
declarations
public static com.ensoftcorp.atlas.core.query.Q declarations(com.ensoftcorp.atlas.core.query.Q origin)
Produces a declarations (contains) graph. Equivalent to declarations(index(), origin).- Parameters:
origin
-- Returns:
- the query expression
-
declarations
public static com.ensoftcorp.atlas.core.query.Q declarations(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Produces a declarations (contains) graph. Uses only the given context for the traversal.- Parameters:
context
-origin
-- Returns:
- the query expression
-
dynamicDispatch
public static com.ensoftcorp.atlas.core.query.Q dynamicDispatch(com.ensoftcorp.atlas.core.query.Q runtimeTypes, com.ensoftcorp.atlas.core.query.Q methodSignature)
Resolves invocation for a runtime type and method signature.- Parameters:
runtimeTypes
-methodSignature
-- Returns:
-
interactions
@Deprecated public static com.ensoftcorp.atlas.core.query.Q interactions(com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String... edgeTags)
Deprecated.use com.ensoftcorp.open.commons.analysis.CommonQueries.interactionsReturns direct edges of the given kinds which lay immediately between the first group and second group of nodes.- Parameters:
first
-second
-edgeTags
-- Returns:
- the query expression
-
interactions
@Deprecated public static com.ensoftcorp.atlas.core.query.Q interactions(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String... edgeTags)
Deprecated.use com.ensoftcorp.open.commons.analysis.CommonQueries.interactionsReturns direct edges of the given kinds which lay immediately between the first group and second group of nodes.- Parameters:
context
-first
-second
-edgeTags
-- Returns:
- the query expression
-
libraryDeclarations
public static com.ensoftcorp.atlas.core.query.Q libraryDeclarations()
Returns those nodes which are declared by a library.- Returns:
- the query expression
-
libraryDeclarations
public static com.ensoftcorp.atlas.core.query.Q libraryDeclarations(com.ensoftcorp.atlas.core.query.Q context)
Returns those nodes which are declared by a library. Results are only returned if they are within the given context. Equivalent to libraryDeclarations(index())- Parameters:
context
-- Returns:
- the query expression
-
libraryDeclarations
public static com.ensoftcorp.atlas.core.query.Q libraryDeclarations(java.lang.String name)
Returns those nodes which are declared by a library with the given name.- Parameters:
name
-- Returns:
- the query expression
-
libraryDeclarations
public static com.ensoftcorp.atlas.core.query.Q libraryDeclarations(com.ensoftcorp.atlas.core.query.Q context, java.lang.String name)
Returns those nodes which are declared by a library with the given name. Results are only returned if they are within the given context. Equivalent to libraryDeclarations(index(), name)- Parameters:
context
-name
-- Returns:
- the query expression
-
methodParameter
public static com.ensoftcorp.atlas.core.query.Q methodParameter(com.ensoftcorp.atlas.core.query.Q methods)
Returns the parameters of the given methods. Equivalent to methodParameter(index(), methods)- Parameters:
methods
-- Returns:
- the query expression
-
methodParameter
public static com.ensoftcorp.atlas.core.query.Q methodParameter(com.ensoftcorp.atlas.core.query.Q methods, java.lang.Integer... index)
Returns the parameters of the given methods at the given indices. Equivalent to methodParameter(index(), methods, index)- Parameters:
methods
-index
-- Returns:
- the query expression
-
methodParameter
public static com.ensoftcorp.atlas.core.query.Q methodParameter(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the parameters of the given methods. Results are only returned if they are within the given context.- Parameters:
context
-methods
-- Returns:
- the query expression
-
methodParameter
public static com.ensoftcorp.atlas.core.query.Q methodParameter(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods, java.lang.Integer... index)
Returns the parameters of the given methods at the given indices. Results are only returned if they are within the given context.- Parameters:
context
-methods
-index
-- Returns:
- the query expression
-
methodReturn
public static com.ensoftcorp.atlas.core.query.Q methodReturn(com.ensoftcorp.atlas.core.query.Q methods)
Returns the return nodes for the given methods. Equivalent to methodReturn(index(), methods).- Parameters:
methods
-- Returns:
- the query expression
-
methodReturn
public static com.ensoftcorp.atlas.core.query.Q methodReturn(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the return nodes for the given methods.- Parameters:
context
-methods
-- Returns:
- the query expression
-
methodsOf
public static com.ensoftcorp.atlas.core.query.Q methodsOf(com.ensoftcorp.atlas.core.query.Q types)
Returns the methods declared by the given types. Equivalent to methodsOf(index(), types).- Parameters:
params
-- Returns:
- the query expression
-
methodsOf
public static com.ensoftcorp.atlas.core.query.Q methodsOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q types)
Returns the methods declared by the given types.- Parameters:
context
-types
-- Returns:
- the query expression
-
methodThis
public static com.ensoftcorp.atlas.core.query.Q methodThis(com.ensoftcorp.atlas.core.query.Q methods)
Returns the 'this' identity nodes for the given methods. Equivalent to methodThis(index(), methods).- Parameters:
methods
-- Returns:
- the query expression
-
methodThis
public static com.ensoftcorp.atlas.core.query.Q methodThis(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q methods)
Returns the 'this' identity nodes for the given methods.- Parameters:
context
-methods
-- Returns:
- the query expression
-
nodesContaining
public static com.ensoftcorp.atlas.core.query.Q nodesContaining(java.lang.String substring)
Returns the nodes whose names contain the given string. Equivalent to nodesContaining(index(), substring).- Parameters:
substring
-- Returns:
- the query expression
-
nodesContaining
public static com.ensoftcorp.atlas.core.query.Q nodesContaining(com.ensoftcorp.atlas.core.query.Q context, java.lang.String substring)
Returns the nodes whose names contain the given string within the given context.- Parameters:
context
-substring
-- Returns:
- the query expression
-
nodesEndingWith
public static com.ensoftcorp.atlas.core.query.Q nodesEndingWith(java.lang.String suffix)
Returns the nodes whose names end with the given string. Equivalent to nodesEndingWith(index(), suffix).- Parameters:
substring
-- Returns:
- the query expression
-
nodesEndingWith
public static com.ensoftcorp.atlas.core.query.Q nodesEndingWith(com.ensoftcorp.atlas.core.query.Q context, java.lang.String suffix)
Returns the nodes whose names end with the given string within the given context.- Parameters:
context
-substring
-- Returns:
- the query expression
-
nodesMatchingRegex
public static com.ensoftcorp.atlas.core.query.Q nodesMatchingRegex(java.lang.String regex)
Returns the nodes whose names match the given regular expression. Equivalent to nodesMatchingRegex(index(), regex).- Parameters:
substring
-- Returns:
- the query expression
-
nodesMatchingRegex
public static com.ensoftcorp.atlas.core.query.Q nodesMatchingRegex(com.ensoftcorp.atlas.core.query.Q context, java.lang.String regex)
Returns the nodes whose names match the given regular expression within the given context.- Parameters:
context
-substring
-- Returns:
- the query expression
-
nodesStartingWith
public static com.ensoftcorp.atlas.core.query.Q nodesStartingWith(java.lang.String prefix)
Returns the nodes whose names start with the given string. Equivalent to nodesStartingWith(index(), prefix).- Parameters:
substring
-- Returns:
- the query expression
-
nodesStartingWith
public static com.ensoftcorp.atlas.core.query.Q nodesStartingWith(com.ensoftcorp.atlas.core.query.Q context, java.lang.String prefix)
Returns the nodes whose names start with the given string within the given context.- Parameters:
context
-substring
-- Returns:
- the query expression
-
edgeSize
public static long edgeSize(com.ensoftcorp.atlas.core.query.Q toCount)
Returns the number of edges contained.- Parameters:
toCount
-- Returns:
-
nodeSize
public static long nodeSize(com.ensoftcorp.atlas.core.query.Q toCount)
Returns the number of nodes contained.- Parameters:
toCount
-- Returns:
-
isEmpty
public static boolean isEmpty(com.ensoftcorp.atlas.core.query.Q test)
Returns whether the given Q is empty.- Parameters:
test
-- Returns:
-
isNotEmpty
public static boolean isNotEmpty(com.ensoftcorp.atlas.core.query.Q test)
Returns whether the given Q is not empty- Parameters:
test
-- Returns:
-
getGraphElementByAddress
public static com.ensoftcorp.atlas.core.db.graph.GraphElement getGraphElementByAddress(java.lang.String address)
Selects the Atlas graph element given a serialized graph element address Returns null if the address does not correspond to a graph element- Parameters:
address
-- Returns:
-
getNodeByAddress
public static com.ensoftcorp.atlas.core.db.graph.Node getNodeByAddress(java.lang.String address)
Selects the Atlas node graph element given a serialized graph element address Returns null if the address does not correspond to a node- Parameters:
address
-- Returns:
-
getEdgeByAddress
public static com.ensoftcorp.atlas.core.db.graph.Edge getEdgeByAddress(java.lang.String address)
Selects the Atlas edge graph element given a serialized graph element address Returns null if the address does not correspond to a edge- Parameters:
address
-- Returns:
-
localDeclarations
public static com.ensoftcorp.atlas.core.query.Q localDeclarations(com.ensoftcorp.atlas.core.query.Q functions)
All nodes declared under the given functions, but NOT declared under additional functions or types. Retrieves declarations of only this function. Results are only returned if they are within the given context.- Parameters:
functions
-- Returns:
-
localDeclarations
public static com.ensoftcorp.atlas.core.query.Q localDeclarations(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q functions)
All nodes declared under the given functions, but NOT declared under additional functions or types. Retrieves declarations of only this function. Results are only returned if they are within the given context.- Parameters:
context
-functions
-- Returns:
-
callers
public static com.ensoftcorp.atlas.core.query.Q callers(com.ensoftcorp.atlas.core.query.Q origin)
Returns the direct callers of the given functions. Operates in the index context.- Parameters:
origin
-- Returns:
-
callers
public static com.ensoftcorp.atlas.core.query.Q callers(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the direct callers of the given functions. Operates in the given context.- Parameters:
context
-origin
-- Returns:
-
called
public static com.ensoftcorp.atlas.core.query.Q called(com.ensoftcorp.atlas.core.query.Q origin)
Returns the subset of the given functions which are called. Operates in the index context.- Parameters:
origin
-- Returns:
-
called
public static com.ensoftcorp.atlas.core.query.Q called(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the subset of the given functions which are called. Results are only returned if they are within the given context.- Parameters:
context
-origin
-- Returns:
-
calledBy
public static com.ensoftcorp.atlas.core.query.Q calledBy(com.ensoftcorp.atlas.core.query.Q callers, com.ensoftcorp.atlas.core.query.Q called)
Returns the given functions which were called by the given callers. Operates in the index context.- Parameters:
callers
-called
-- Returns:
-
calledBy
public static com.ensoftcorp.atlas.core.query.Q calledBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q callers, com.ensoftcorp.atlas.core.query.Q called)
Returns the given functions which were called by the given callers. Results are only returned if they are within the given context.- Parameters:
context
-callers
-called
-- Returns:
-
dfg
public static com.ensoftcorp.atlas.core.query.Q dfg(com.ensoftcorp.atlas.core.query.Q functions)
- Parameters:
functions
-- Returns:
- the data flow graph under the function
-
dfg
public static com.ensoftcorp.atlas.core.query.Q dfg(com.ensoftcorp.atlas.core.db.graph.Node function)
- Parameters:
function
-- Returns:
- the data flow graph under the function
-
cfg
public static com.ensoftcorp.atlas.core.query.Q cfg(com.ensoftcorp.atlas.core.query.Q functions)
- Parameters:
functions
-- Returns:
- the control flow graph under the function
-
cfg
public static com.ensoftcorp.atlas.core.query.Q cfg(com.ensoftcorp.atlas.core.db.graph.Node function)
- Parameters:
function
-- Returns:
- the control flow graph under the function
-
excfg
public static com.ensoftcorp.atlas.core.query.Q excfg(com.ensoftcorp.atlas.core.query.Q functions)
- Parameters:
functions
-- Returns:
- the control flow graph (including exceptional control flow) under the function
-
excfg
public static com.ensoftcorp.atlas.core.query.Q excfg(com.ensoftcorp.atlas.core.db.graph.Node function)
- Parameters:
function
-- Returns:
- the control flow graph (including exceptional control flow) under the function
-
firstDeclarator
public static com.ensoftcorp.atlas.core.query.Q firstDeclarator(com.ensoftcorp.atlas.core.query.Q declared, java.lang.String... declaratorTypes)
Returns the first declaring node of the given Q which is tagged with one of the given types. Operates in the index context.- Parameters:
declared
-declaratorTypes
-- Returns:
-
firstDeclarator
public static com.ensoftcorp.atlas.core.query.Q firstDeclarator(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q declared, java.lang.String... declaratorTypes)
Returns the first declaring node of the given Q which is tagged with one of the given types. Results are only returned if they are within the given context.- Parameters:
context
-declared
-declaratorTypes
-- Returns:
-
advancedIntersection
public static com.ensoftcorp.atlas.core.query.Q advancedIntersection(com.ensoftcorp.atlas.core.query.Q first, com.ensoftcorp.atlas.core.query.Q second, java.lang.String[] nodeTags, java.lang.String[] edgeTags)
Given two query expressions, intersects the given node and edge kinds to produce a new expression.- Parameters:
first
-second
-nodeTags
-edgeTags
-- Returns:
-
readersOf
public static com.ensoftcorp.atlas.core.query.Q readersOf(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly read from nodes in origin. Operates in the index context.- Parameters:
origin
-- Returns:
-
readersOf
public static com.ensoftcorp.atlas.core.query.Q readersOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly read from nodes in origin. Operates in the given context.- Parameters:
context
-origin
-- Returns:
-
writersOf
public static com.ensoftcorp.atlas.core.query.Q writersOf(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly write to nodes in origin. Operates in the index context.- Parameters:
origin
-- Returns:
-
writersOf
public static com.ensoftcorp.atlas.core.query.Q writersOf(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes which directly write to nodes in origin. Operates in the given context.- Parameters:
context
-origin
-- Returns:
-
readBy
public static com.ensoftcorp.atlas.core.query.Q readBy(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes from which nodes in the origin read. Operates in the index context.- Parameters:
origin
-- Returns:
-
readBy
public static com.ensoftcorp.atlas.core.query.Q readBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes from which nodes in the origin read. Operates in the given context.- Parameters:
context
-origin
-- Returns:
-
writtenBy
public static com.ensoftcorp.atlas.core.query.Q writtenBy(com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes to which nodes in origin write. Operates in the index context.- Parameters:
origin
-- Returns:
-
writtenBy
public static com.ensoftcorp.atlas.core.query.Q writtenBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the nodes to which nodes in origin write. Operates in the given context.- Parameters:
context
-origin
-- Returns:
-
leastCommonAncestor
public static com.ensoftcorp.atlas.core.db.graph.Node leastCommonAncestor(com.ensoftcorp.atlas.core.db.graph.Node child1, com.ensoftcorp.atlas.core.db.graph.Node child2, com.ensoftcorp.atlas.core.db.graph.Graph graph)
Returns the least common ancestor of both child1 and child2 within the given graph- Parameters:
child1
-child2
-graph
-- Returns:
-
leastCommonAncestor
public static com.ensoftcorp.atlas.core.db.graph.Node leastCommonAncestor(com.ensoftcorp.atlas.core.db.graph.Node child1, com.ensoftcorp.atlas.core.db.graph.Node child2, com.ensoftcorp.atlas.core.query.Q graph)
Returns the least common ancestor of both child1 and child2 within the given graph- Parameters:
child1
-child2
-graph
-- Returns:
-
getContainingMethods
public static com.ensoftcorp.atlas.core.query.Q getContainingMethods(com.ensoftcorp.atlas.core.query.Q nodes)
Returns the containing method of a given Q or empty if one is not found- Parameters:
nodes
-- Returns:
-
getContainingControlFlowNode
public static com.ensoftcorp.atlas.core.db.graph.Node getContainingControlFlowNode(com.ensoftcorp.atlas.core.db.graph.Node node)
Returns the nearest parent that is a control flow node- Parameters:
node
-- Returns:
-
getContainingMethod
public static com.ensoftcorp.atlas.core.db.graph.Node getContainingMethod(com.ensoftcorp.atlas.core.db.graph.Node node)
Returns the containing method of a given graph element or null if one is not found- Parameters:
node
-- Returns:
-
getContainingNode
public static com.ensoftcorp.atlas.core.db.graph.Node getContainingNode(com.ensoftcorp.atlas.core.db.graph.Node node, java.lang.String containingTag)
Find the next immediate containing node with the given tag.- Parameters:
node
-containingTag
-- Returns:
- the next immediate containing node, or null if none exists; never returns the given node
-
conditionsAbove
public static com.ensoftcorp.atlas.core.query.Q conditionsAbove(com.ensoftcorp.atlas.core.query.Q origin)
Returns the control flow graph between conditional nodes and the given origin. Operates within the index context.- Parameters:
origin
-- Returns:
-
conditionsAbove
public static com.ensoftcorp.atlas.core.query.Q conditionsAbove(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Returns the control flow graph between conditional nodes and the given origin. Operates within the given context.- Parameters:
context
-origin
-- Returns:
-
mutators
public static com.ensoftcorp.atlas.core.query.Q mutators(com.ensoftcorp.atlas.core.query.Q origin)
Given a Q containing methods or data flow nodes, returns a Q of things which write to or call things in the Q. Operates within the index context.- Parameters:
origin
-- Returns:
-
nodesWithSelfEdges
public static com.ensoftcorp.atlas.core.query.Q nodesWithSelfEdges(com.ensoftcorp.atlas.core.query.Q context)
Returns those nodes in the context which have self edges.- Parameters:
context
-- Returns:
-
mutators
public static com.ensoftcorp.atlas.core.query.Q mutators(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q origin)
Given a Q containing methods or data flow nodes, returns a Q of things which write to or call things in the Q. Operates within the index context.- Parameters:
context
-origin
-- Returns:
-
mutatedBy
public static com.ensoftcorp.atlas.core.query.Q mutatedBy(com.ensoftcorp.atlas.core.query.Q mutators, com.ensoftcorp.atlas.core.query.Q origin)
Returns those elements in the origin which were called by or written by elements in the mutators set. Operates within the index context.- Parameters:
mutators
-origin
-- Returns:
-
mutatedBy
public static com.ensoftcorp.atlas.core.query.Q mutatedBy(com.ensoftcorp.atlas.core.query.Q context, com.ensoftcorp.atlas.core.query.Q mutators, com.ensoftcorp.atlas.core.query.Q origin)
Returns those elements in the origin which were called by or written by elements in the mutators set. Operates within the given context.- Parameters:
context
-mutators
-origin
-- Returns:
-
getQualifiedClassName
public static java.lang.String getQualifiedClassName(com.ensoftcorp.atlas.core.db.graph.Node type)
Helper function to get the stringified qualified name of the class- Parameters:
type
-- Returns:
-
getQualifiedMethodName
public static java.lang.String getQualifiedMethodName(com.ensoftcorp.atlas.core.db.graph.Node function)
Helper function to get the stringified qualified name of the function- Parameters:
function
-- Returns:
-
getQualifiedName
public static java.lang.String getQualifiedName(com.ensoftcorp.atlas.core.db.graph.Node node)
Helper function to get the stringified qualified name of the function- Parameters:
function
-- Returns:
-
getQualifiedName
public static java.lang.String getQualifiedName(com.ensoftcorp.atlas.core.db.graph.Node node, java.lang.String... stopAfterTags)
Helper function to get the stringified qualified name of the class Stop after tags specify parent containers to stop qualifying at (example packages or jars)- Parameters:
node
-- Returns:
-
-