- Checkmarx Documentation
- Checkmarx One
- Checkmarx One User Guide
- Scan Management
- SAST Query Editor
- SAST Query Language APIs
SAST Query Language APIs
The following is a list of APIs in SAST to interact with its query language to find vulnerability patterns to improve the accuracy of your scans. If you are using Checkmarx SAST On-Prem, use these APIs in Audit . If you are using Checkmarx One, use them in Query Editor.
Add
Adds to the current instance the given graph node, indexed by the given id.
Expand source
public void Add(int a, IGraph b)
a Id of the node to be added to the graph node.
b Graph node to be associated to the given Id.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.Add(int, IGraph) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.Add method:
Expand source
CxList myList = All.FindByName(“a”); CSharpGraph nodeGraph = All.FindByName(“b”).GetFirstGraph(); myList.Add(nodeGraph.NodeId, nodeGraph); result = myList;
The resulting list will include the initial two “a”’s and the first b.
Add all the elements from the given CxList to the current instance.
Expand source
public void Add(CxList a)
a The CxList to be added to the current CxList instance.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.Add(CxList) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.Add method:
Expand source
CxList list_a = All.FindByName(“a”); CxList list_b = All.FindByName(“b”); list_a.Add(list_b); result = list_a;
The resulting list will contain 4 elements.
Adds to the current instance all the elements from the given CxLists.
Expand source
public void Add(IEnumerable<CxList> a)
a A list of CxLists.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.Add(IEnumerable<CxList>) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.Add method:
Expand source
CxList a = All.FindByName(“a”); CxList b = All.FindByName(“b”); CxList integers = All.FindByType(typeof(IntegerLiteral)); Result.AddRange(new List<CxList>(){a, b, integers});
The resulting list will include the two “a”’s, two “b”’s and the numbers 5, 33, 6.
Adds to the current instance all the elements from the given CxLists.
Expand source
public void Add(params CxList[] lists)
lists An array of CxLists.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.Add(params CxList[]) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.Add method:
Expand source
CxList a = All.FindByName(“a”); CxList b = All.FindByName(“b”); CxList integers = All.FindByType(typeof(IntegerLiteral)); Result.Add(a, b, integers);
The resulting list will include the two "a"'s, two "b"'s and the numbers 5, 33, 6.
Supported from 9.1.0
Add the given pair to the current CxList instance.
Expand source
public void Add((KeyValuePair<int, IGraph> dic)
dic Pair to be added to the current CxList instance.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.Add(KeyValuePair<int, IGraph>) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.Add method:
Expand source
CxList myList = All.FindByName(“a”); foreach(KeyValuePair<int, IGraph> entry in All.FindByName(“b”)) { myList.Add(entry); } result = myList;
The resulting list will contain 4 elements.
AddRange
Adds to the current instance all the elements from the given CxLists.
Expand source
public void AddRange(IEnumerable<CxList> lists)
lists A list of CxLists.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.AddRange(IEnumerable<CxList>) method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.AddRange method:
Expand source
CxList a = All.FindByName("a"); CxList b = All.FindByName("b"); CxList integers = All.FindByType(typeof(IntegerLiteral)); Result.AddRange(new List<CxList>(){a, b, integers});
The resulting list will include the two "a"'s, two "b"'s and the numbers 5, 33, 6.
Supported from 9.1.0
AddSupportForExpressionLanguageForFramework
add the support of a framework expression language
frameworkName the framework that we are mapping the marker to
AttributesIgnoreCase
Gets the elements with the specified System.Xml.Linq.XName.
doc The element.
name The System.String to match.
ignoreCase If set to true case will be ignored whilst searching for the System.Xml.Linq.XElement.
A System.Xml.Linq.XElement that matches the specified System.Xml.Linq.XName, or null.
CalcPragmaKey
function to calculate pragma unique id
nodeId None
None
CallingMethodOfAny
Returns a CxList which is a subset of “this” instance and are methods or constructors declarations which matches the given CxList elements.
Expand source
public CxList CallingMethodOfAny(CxList list)
cxList The list of elements containing the methods or constructors to look for their declaration.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.CallingMethodOfAny(CxList) method.
The input source code is:
Expand source
void foo() { int goo = 3; int boo = 5; }
The source code that uses CxList.CallingMethodOfAny method:
Expand source
result = All.CallingMethodOfAny(All.FindByName ("oo"));
The result would consist of 1 item:
Expand source
foo (in void foo())
Clear
Clears the information in “this” instance.
Expand source
public bool Clear()
This method removes all the information stored in the List.
This example demonstrates the CxList.Clear() method.
Expand source
CxList MyList = All ; MessageBox.Show(MyList.Count.ToString()); MyList.Clear(); MessageBox.Show(MyList.Count.ToString());
ClearAdditionalNodes
Clears all the data allocated in the _GraphToNodeAdditional and _NodeToGraphAdditional data members for the current thread.
ClearPaths
remove all flow
ClearTopLevelQueryFlag
Call this method at the finally clause of every query.
Clone
create duplicate of this
None
Clone the current (this) CxList
Expand source
public CxList Clone ()
CxList containing a clone of the current (this) CxList
The source code that uses CxList.Clone method:
Expand source
CxList A = All.FindByType(typeof(UnknownReference)); CxList B = A; //B points to same elements as A CxList B = A.Clone(); //B has a copy (clone) of the elements in A
Concatenate
Concatenates two nodes into a flow.
Expand source
public CxList Concatenate (CxList list)
list A CxList containing one node only. This node will be concatenated to this instance.
A flow that starts with this instance node, and ends with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
This function calls CxList.Concatenate(list, false).
If either this instance or list parameter contains more than one node or contains flows, the function return value is undefined.
This function is deprecated, use ConcatenatePath instead.
Supported from v7.1.2
Concatenates two nodes into a flow.
Expand source
public CxList Concatenate (CxList list, bool _testFlow)
list A CxList containing one node only. This node will be concatenated to this instance.
testFlow If true, searches for a flow between this instance and list. Otherwise, connects the two nodes directly (more efficient).
A flow that starts with this instance node, and ends with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
If either this instance or list parameter contains more than one node or contains flows, the function return value is undefined.
This function is deprecated, use ConcatenatePath instead.
This example demonstrates the Concatenate(CxList, bool) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; int c = a + b; printf("%d", c); }
The source code that uses CxList.Concatenate method:
Expand source
CxList one = All.FindByName("1"); CxList two = All.FindByName("2"); result = one.Concatenate(two, false);
The result would be:
Expand source
1 flow found: [1] -> [2]
Supported from 7.1.2
ConcatenateAllPaths
Concatenates all flows in this instance to all flows in list.
Expand source
public CxList ConcatenateAllPaths (CxList secondList, bool _testFlow)
secondList A CxList containing flows. These flow will be concatenated to the flows in this instance.
testFlow If true, searches for a flow between this instance and list. Otherwise, connects the two flows directly (more efficient).
A product of all flows in this instance with the ones in list parameter.
ArgumentNullException : Thrown when parameter is a null reference.
If this instance contains n flows in it and list contains m flows in it, the return set will contain nxm flows, where each flow from this instance will be concatenated to each flow from list.
This example demonstrates the ConcatenateAllPaths(CxList, bool) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenateAllPaths method:
Expand source
CxList one = All.FindByName("1"); CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); CxList flow1 = a.InfluencedBy(one); // [1] -> [a] CxList two = All.FindByName("2"); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList flow2 = b.InfluencedBy(two); // [2] -> [b] CxList flow = flow1 + flow2; result = flow.ConcatenateAllPaths(flow, false);
The result would be:
Expand source
4 flow found: [1] -> [a] -> [1] -> [a] [1] -> [a] -> [2] -> [b] [2] -> [b] -> [1] -> [a] [2] -> [b] -> [2] -> [b]
Supported from 7.1.2
Concatenates all flows in this instance to all flows in list.
Expand source
public CxList ConcatenateAllPaths (CxList secondList)
secondList A CxList containing flows. These flow will be concatenated to the flows in this instance.
A product of all flows in this instance with the ones in list parameter.
ArgumentNullException : Thrown when parameter is a null reference.
This function calls CxList.ConcatenateAllPaths(list, true).
If this instance contains n flows in it and list contains m flows in it, the return set will contain nxm flows, where each flow from this instance will be concatenated to each flow from list.
Supported from 7.1.2
ConcatenateAllSources
Concatenates the node in list to each node in this instance. Concatenation is node-to-node (doesn't support connecting flows).
Expand source
public CxList ConcatenateAllSources (CxList list, bool _testFlow)
list A CxList. It will be concatenated to each node in this instance.
testFlow If this parameter true -> test possible flow , otherwise connect directly.
Flows that starts with this instance nodes, and end with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
If the list parameter contains more than one node or contains flows or this instance contains flows, the function return value is undefined.
The number of the returned items is same as the number of items in this instance.
This function calls the Concatenate function for each item in this instance with list as parameter.
This example demonstrates the ConcatenateAllSources(CxList, bool) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenateAllSources method:
Expand source
CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList main = All.FindByShortName("main"); CxList list = a + b; result = list.ConcatenateAllSources(list, false);
The result would be:
Expand source
2 flow found: [a] -> [main] [b] -> [main]
Supported from 7.1.2
Concatenates the node in list to each node in this instance. Concatenation is node-to-node (doesn't support connecting flows).
Note: Currently is identical to calling ConcatenateAllSources with testFlow = false
Expand source
public CxList ConcatenateAllSources (CxList list)
list A CxList. It will be concatenated to each node in this instance.
Flows that starts with this instance nodes, and end with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
If the list parameter contains more than one node or contains flows or this instance contains flows, the function return value is undefined.
The number of the returned items is same as the number of items in this instance.
This function calls the Concatenate function for each item in this instance with list as parameter.
This example demonstrates the ConcatenateAllSources(CxList) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenateAllSources method:
Expand source
CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList main = All.FindByShortName("main"); CxList list = a + b; result = list.ConcatenateAllSources(list);
The result would be:
Expand source
2 flow found: [a] -> [main] [b] -> [main]
Supported from 7.1.2
ConcatenateAllTargets
Concatenates each node in list to the node in this instance. Concatenation is node-to-node (doesn't support connecting flows).
Expand source
public CxList ConcatenateAllTargets (CxList list, bool testFlow)
list A CxList. It will be concatenated to each node in this instance.
testFlow If this parameter true -> test possible flow , otherwise connect directly.
Flows that starts with this instance nodes, and end with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
1. If the this instance contains more than one node or contains flows or list contains flows, the function return value is undefined.
2. The number of the returned items is same as the number of items in list.
3. This function calls the Concatenate function for this instance with each item in list as parameter.
This example demonstrate the ConcatenateAllTargets(CxList, bool) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenateAllTargets method:
Expand source
CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList main = All.FindByShortName("main"); CxList list = a + b; result = list.ConcatenateAllTargets(list, false);
The result would be:
Expand source
2 flow found: [main] -> [a] [main] -> [b]
Supported from 7.1.2
Concatenates each node in list to the node in this instance. Concatenation is node-to-node (doesn't support connecting flows).
Note: Currently is identical to calling ConcatenateAllTargets with testFlow = false
Expand source
public CxList ConcatenateAllTargets (CxList list)
list A CxList. It will be concatenated to each node in this instance.
Flows that starts with this instance nodes, and end with the list parameter node.
ArgumentNullException : Thrown when parameter is a null reference.
If the this instance contains more than one node or contains flows or list contains flows, the function return value is undefined.
The number of the returned items is same as the number of items in list.
This function calls the Concatenate function for this instance with each item in list as parameter.
This example demonstrates the ConcatenateAllTargets(CxList) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenateAllTargets method:
Expand source
CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList main = All.FindByShortName("main"); CxList list = a + b; result = list.ConcatenateAllTargets(list);
The result would be:
Expand source
2 flow found: [main] -> [a] [main] -> [b]
Supported from 7.1.2
ConcatenatePath
Concatenates two flows into one connected flow.
Expand source
public CxList ConcatenatePath (CxList secondList, bool _testFlow)
secondList A CxList containing one flow only. This flow will be concatenated to this instance.
testFlow If true, searches for a flow between this instance and list. Otherwise, connects the two flows directly (more efficient).
A flow that starts with this instance flow, and ends with the list parameter flow.
ArgumentNullException : Thrown when parameter is a null reference.
Both this instance and list have to contain only one flow (or one node as a private case), otherwise return value is undefined.
This example demonstrates the ConcatenatePath(CxList, bool) method.
The input source code is:
Expand source
void main() { int a = 1; int b = 2; }
The source code that uses CxList.ConcatenatePath method:
Expand source
CxList one = All.FindByName("1"); CxList a = All.FindByShortName("a").FindByType(typeof(Declarator)); //Declarator is a new type defined in cXQL CxList flow1 = a.InfluencedBy(one); // [1] -> [a] CxList two = All.FindByName("2"); CxList b = All.FindByShortName("b").FindByType(typeof(Declarator)); CxList flow2 = b.InfluencedBy(two); // [2] -> [b] result = flow2.ConcatenatePath(flow1, false);
The result would be:
Expand source
1 flow found: [2] -> [b] -> [1] -> [a]
Supported from 7.1.2
Concatenates two flows into one connected flow.
Expand source
public CxList ConcatenatePath (CxList secondList)
secondList A CxList containing one flow only. This flow will be concatenated to this instance.
A flow that starts with this instance flow, and ends with the list parameter flow.
ArgumentNullException : Thrown when parameter is a null reference.
This function calls CxList.ConcatenatePath(list, true).
Both this instance and list have to contain only one flow (or one node as a private case), otherwise return value is undefined.
Supported from 7.1.2
Contained
Returns a subset of “this” instance whose elements are contained in the given list, filtered according to the given nodes type.
Expand source
public CxList Contained (CxList pathList, GetStartEndNodesType requestedType)
pathList The list where the method looks for the requested node type.
requestedType An enum matching the relevant GetStartEndNodes types, which are: EndNodesOnly, StartNodesOnly, StartAndEndNodes, AllNodes and AllButNotStartAndEnd.
A subset of “this” instance with elements from the requested nodes type.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates the CxList.Contained(CxList, GetStartEndNodesType) method.
The input source code is:
Expand source
void foo() { int b = 2, a = 5, c; if (a > b) b = 3; c = b; }
The source code that uses CxList.Contained method:
Expand source
result = All.FindByShortName("b").Contained(All.InfluencedBy(All.FindById(50)), GetStartEndNodesType.AllNodes); //Id 50 is "3" in "b = 3;"
The result would consist of 2 items:
Expand source
b (from b = 3;) b (from c = b;)
The source code that uses CxList.Contained method:
Expand source
result = All.FindByShortName("a").Contained(All.InfluencedBy(All.FindById(50)), GetStartEndNodesType.EndNodesOnly); // Id 50 is "3" in "b = 3;"
The result would consist of 0 items.
Supported from 7.1.2
Contains
return true if input parameter is root of at least one graph.
key None
None
ControlInfluencedBy
Returns a ICxListProvider which is a subset of this instance and its elements are control influenced by the specified ICxListProvider.
list ICxListProvider control-influencing on this instance.
currAlg Influence algorithm to use. An enum matching the relevant options which are: OldAlgorithm, NewAlgorithm
A subset of this instance control influenced by the specified ICxListProvider.
Returns a ICxListProvider which is a subset of this instance and its elements are control influenced by the specified ICxListProvider.
list ICxListProvider control-influencing on this instance.
A subset of this instance control influenced by the specified ICxListProvider.
ControlInfluencedByAndNotSanitized
Returns a ICxListProvider which is a subset of this instance and its elements are control influenced by the specified ICxListProvider and not sanitized by the specified ICxListProvider.
red ICxListProvider control-influencing on this instance.
green ICxListProvider of sanitizations.
currAlg Influence algorithm to use. An enum matching the relevant options which are: OldAlgorithm, NewAlgorithm
A subset of this instance control influenced by the specified ICxListProvider and not sanitized.
Returns a ICxListProvider which is a subset of this instance and its elements are control influenced by the specified ICxListProvider and not sanitized by the specified ICxListProvider.
red ICxListProvider control-influencing on this instance.
green ICxListProvider of sanitizations.
A subset of this instance control influenced by the specified ICxListProvider and not sanitized.
ControlInfluencingOn
Returns a ICxListProvider which is a subset of this instance and its elements are control influencing on the specified ICxListProvider.
list ICxListProvider control-influenced by this instance.
currAlg Influence algorithm to use. An enum matching the relevant options which are: OldAlgorithm, NewAlgorithm
A subset of this instance control influencing on the specified ICxListProvider.
Returns a ICxListProvider which is a subset of this instance and its elements are control influencing on the specified ICxListProvider.
list ICxListProvider control-influenced by this instance.
A subset of this instance control influencing on the specified ICxListProvider.
ControlInfluencingOnAndNotSanitized
Returns a ICxListProvider which is a subset of this instance and its elements are control influenced by the specified ICxListProvider and not sanitized by the specified ICxListProvider.
red ICxListProvider control-influenced by this instance.
green ICxListProvider of sanitization.
A subset of this instance control influencing on the specified ICxListProvider and not sanitized.
Count
return number of paths in current node
return number of paths
CreateXmlNode
Return a CxList composed by CxXmlNode.
Expand source
public CxList CreateXmlNodes(XPathNavigator input, CxXmlDoc xmlDoc, int language, bool save, int depth = 1)
input Provides a cursor model for navigating XML data.
xmlDoc Document where the node will be created.
language Id of the language.
save Sprecifies if the node should be saved.
depth Deapth of search. Default value is 1.
Return a CxList with CxXmlNodes for the given XPath.
Save option set to true is deprecated since 9.4.0.
None
Expand source
// create an XPathDocument object XPathDocument xmlPathDoc = new XPathDocument(xmlFileName); // create a navigator for the xpath doc XPathNavigator xNav = xmlPathDoc.CreateNavigator(); result = cxXPath.CreateXmlNodes(xNav, xmlDoc, 1, false, 1); // Returns a CxList of nodes in a given CxXmlDoc.
Supported from 8.6.0
CxListImpl
This partial class is a container for methods related to MemberAccess operations.
CxSelectDomProperty
Returns a new CxList that includes selected property that exists in DOM type <T> and define by lambda. We can achieve the same effect by using another (old) interface.
Expand source
public CxList CxSelectDomProperty<T>(Func<T,IGraph> lambda) where T:CSharpGraph
T Dom object type that this method get property from it
lambda Method that define require DOM property.
New list of requested properties.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate using of CxList.CxSelectDomProperty(Func<T, IGraph>) method.
Get all TrueStatements of type IfStmt and Statements of IterationStmt:
Expand source
CxList False = Find_Always_False(); var cond = False.GetFathers(); var falseOfIf = cond.CxSelectDomProperty<IfStmt>(x => x.TrueStatements); var falseOfIteration = cond.CxSelectDomProperty<IterationStmt>(x => x.Statements); var falseBlock = falseOfIf + falseOfIteration;
Get some data based on "Left" property of AssignExpr:
Expand source
CxList curNodes = assignsExpr.CxSelectDomProperty<AssignExpr>(x =>x.Left); left.Add(All.GetByAncs(curNodes));
Supported from v9.2.0
CxSelectElementValues
Returns list of requires property values of dom object of <TDomObject> and return list of <TOutput>. For more details see example.Main purpose of this method is hide internal CxList structure(data).
Expand source
public List<TOutput> CxSelectElementValues<TDomObject,TOutput> (Func<TDomObject,TOutput> lambda) where TDomObject:CSharpGraph
TDomObject
TOutput
lambda Method that define property to extract from require dom object.
New List of all required values.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates using of CxList.CxSelectElementValues(Func<TDomObject,TOutput>) method.
Compare parameter name of two methods (implementation and declaration) If name of parameters are different add to result method declaration and method implementation
(query “R16_04_Different_Identifiers_In_Function_Definition_And_Prototype” CPP Misra):
Expand source
var curListNames = curParams.CxSelectElementValues<ParamDecl, string>(x => x.Name); var compListNames = compParams.CxSelectElementValues<ParamDecl, string>(x => x.Name); for (int i = 0; i<curListNames.Count; i++) { if (String.Compare(curListNames[i], compListNames[i]) != 0) { result.Add(curMethodDecl + compMethodDecl); break; } }
Supported from v9.2.0
CxSelectElements
Returns a new CxList of all required elements of input CxList. Main purpose of interface is hide internal DOM and CxList structures.
Expand source
public CxList CxSelectElements<T>(Func<T,IGraph> lambda, int option) where T:CSharpGraph
T Dom object type that this method get property from it
lambda Method that define require DOM property.
option If option is -1 → iterate on all possible elements.
If option is 0 → return only first element.
New list of requested properties.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate using of CxList.CxSelectElements(Func<T, IGraph>, int) method.
Get first element of Indices of input CxList (query "Value_Shadowing" C# medium):
Expand source
CxList variables = All.FindByType(typeof(IndexerRef)); CxList problematic = variables.FindByTypes(new string[] {"Request","HttpRequest"}); result = problematic.CxSelectElements<IndexerRef>(x=>x.Indices,0);
query Find_Array_Indexes (GO, general):
Expand source
CxList arraysOrSlices = Find_IndexerRefs(); result = arraysOrSlices.CxSelectElements<IndexerRef>(x=>x.Indices);
Supported from v9.2.0
DataInfluencedBy
Returns a CxList which is a subset of this instance and its elements are data influenced by the CxList specified in the first parameter using the influence algorithm specified in the second parameter.
Expand source
public CxList DataInfluencedBy(CxList influencing, InfluenceAlgorithmCalculation algorithm)
list CxList data-influencing on “this” instance.
currAlg An enum matching the relevant InfluenceAlgorithmCalculation options which are: OldAlgorithm , NewAlgorithm.
A subset of “this” instance data influenced by the specified CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates the CxList.DataInfluencedBy(CxList, InfluenceAlgorithmCalculation) method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.DataInfluencedBy method:
Expand source
CxList five = All.FindByName("5"); result = All.DataInfluencedBy(five);
The result would be:
Expand source
6 items found: a (in a = 5), a (in a > 3), > (in a > 3), a (in b = a), = (in b = a), b (in b = a)
Returns a CxList which is a subset of “this” instance and its elements are data influenced by the CxList specified in parameter.
This call is equivalent to the following calls and it is recommended to use the short call format by default:
DataInfluencedBy(list, InfluenceAlgorithmCalculation.OldAlgorithm)
Expand source
public CxList DataInfluencedBy(CxList influencing)
list CxList data-influencing on “this” instance.
A subset of “this” instance data influenced by the specified CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates the CxList.DataInfluencedBy(CxList) method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.DataInfluencedBy method:
Expand source
CxList five = All.FindByName("5"); result = All.DataInfluencedBy(five);
The result would be:
Expand source
6 items found: a (in a = 5), a (in a > 3), > (in a > 3), a (in b = a), = (in b = a), b (in b = a)
DataInfluencingOn
Returns a CxList which is a subset of “this” instance and its elements are data influencing on the CxList specified in the first parameter using the influence algorithm specified in the second parameter.
Expand source
public CxList DataInfluencingOn(CxList influenced, InfluenceAlgorithmCalculation algorithm)
list CxList data-influenced by “this” instance.
currAlg An enum matching the relevant InfluenceAlgorithmCalculation options which are: OldAlgorithm , NewAlgorithm.
A subset of “this” instance data influencing on the specified CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.DataInfluencingOn(CxList, CxList.InfluenceAlgorithmCalculation) method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.DataInfluencingOn method:
Expand source
CxList b = All.FindByName("*.b"); result = All.DataInfluencingOn(b);
The result would be:
Expand source
3 items found: a (in b = a), a (in a = 5), 5 (in a = 5)
Returns a CxList which is a subset of “this” instance and its elements are data influencing on the CxList specified in parameter.
This call is equivalent to the following calls and it is recommended to use the short call format by default:
DataInfluencingOn(list, InfluenceAlgorithmCalculation.OldAlgorithm)
Expand source
public CxList DataInfluencingOn(CxList influenced)
list CxList data-influenced by “this” instance.
A subset of “this” instance data influencing on the specified CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.DataInfluencingOn(CxList, InfluenceAlgorithmCalculation) method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.DataInfluencingOn method:
Expand source
CxList b = All.FindByName("*.b"); result = All.DataInfluencingOn(b, CxList.InfluenceAlgorithmCalculation.NewAlgorithm);
The result would be:
Expand source
3 items found: a (in b = a), a (in a = 5), 5 (in a = 5)
DefinitionNotNullOrEmpty
Checks if a given definition is not null or empty
graphDefinition None
None
DoNotSearchInComments
Replaces comments of specific languages with spaces, distinguishing between the language comment types.
curFile The name of the file to process
fileStr The contents of the file
The contents of the file with comments replaced with white spaces
ElementsIgnoreCase
Gets the elements with the specified System.Xml.Linq.XName.
element The element.
name The System.Xml.Linq.XName to match.
ignoreCase If set to true case will be ignored whilst searching for the System.Xml.Linq.XElement.
A System.Xml.Linq.XElement that matches the specified System.Xml.Linq.XName, or null.
ExtractFromSOQL
Extracts the parameters of the given keyword from a SOQL statement into a list.
Expand source
public List<string> ExtractFromSOQL(string keyword)
keyword The SOQL keyword to extract.
A list with the parameters of the keyword.
This example demonstrates the CxList.ExtractFromSOQL() method.
The input source code is:
Expand source
int b = 0; String a = "select* from table where x=" + b; List <String> result = All.ExtractFromSOQL("select");
The source code that uses CxList.ExtractFromSOQL() method:
Expand source
result = All.CallingMethodOfAny(All.FindByName ("oo"));
The result would consist of 1 item:
Expand source
["*"]
Extracts the parameters of a SOQL statement into a dictionary.
Expand source
public Dictionary<String, List<String>> ExtractFromSOQL()
A dictionary with keys that match SOQL keywords and their relevant parameters.
This example demonstrates the CxList.ExtractFromSOQL() method.
The input source code is:
Expand source
int b = 0; String a = "select* from table where x=" + b; Dictionary <String, List<String>> result = All.ExtractFromSOQL();
The source code that uses CxList.ExtractFromSOQL() method:
Expand source
result = All.CallingMethodOfAny(All.FindByName ("oo"));
The result would consist of 3 results:
Expand source
{ "select" : "*", "from" : "table", "where" : "x=" }
FillGraphsList
Fill graphs from one root element.
Expand source
public void FillGraphsList (CSharpGraph graphRoots)
graphRoot CSharpGraph instance to be filled with Graphs.
None.
ArgumentNullException : parameter is a null reference
This example demonstrates the CxList. FillGraphsList () method.
With any Input source code, the method can be called after a Query.
Expand source
first=All.GetFirstGraph(); FillGraphsList(first);
At this point, the first is filled with the Graphs.
Filter
This method implements a new filter. It returns subset of “this”. It is very similar to “Where” of LINQ.
Expand source
public CxList Filter(Func<DOMProperties, bool> condition);
condition Lambda method that define filter condition.
A subset of "this" instance, with elements that fulfilled lambda condition in the given CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate using of CxList.Filter(Func<DOMProperties, bool>) method.
Get all Dom object with short name less than 50 characters:
Expand source
result = tempResult.Filter(x => x.ShortName.Length < 50);
This example demonstrates using of the CxList.Filter() and GetDOMPropertiesOfFirst methods.
Expand source
CxList sanitizers = All.NewCxList(); // Get all the elements that appear only after the position (line) of the header foreach(CxList header in good_content_header_methods) { int HeaderLineNumber = header.GetDOMPropertiesOfFirst().Line; CxList methods_after_header = possible_sanitizers.GetByAncs(header.GetFathers().GetFathers()); sanitizers.Add(methods_after_header.Filter(x => x.Line >= HeaderLineNumber)); }
Supported from v9.2.0
FilterByDomProperty
Returns a CxList which is a subset of “this” instance, with elements that match input lambda method.
Expand source
public CxList FilterByDomProperty<T>(Func<T, bool> condition) where T: CSharpGraph;
T Node element type
condition Lambda method that define/implement require condition.
A subset of “this” instance, with elements that fulfilled lambda condition in the given CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates using of CxList.FilterByDomProperty<(Func<T, bool>) method.
Get all AssignExpr with operator equal to AdditionAssign:
Expand source
CxList assignAdd = assignments. FilterByDomProperty<AssignExpr>(x =>x.Operator == AssignOperator.AdditionAssign);
Supported from v9.2.0
FilterPlugins
Returns a CxList which is a subset of “this” instance, with elements that are objects from CxEngine Plugins removed.
Expand source
public CxList FilterPlugins(void);
A subset of "this" instance, with elements that are declared in the CxEngine plugins removed.
The return value may be empty (Count = 0).
These examples demonstrate using of CxList.FilterPlugins() method.
Consider processing C code
Expand source
Void main(void) { Void* ptr = malloc(sizeof(int)); return 0; }
The source code that uses CxList.FilterPlugins method:
Expand source
CxList mallocDef = All.FindByType<MethodDecl>().FindByName("malloc"); // this list contains one node, the definition of malloc in stdlib.h CxList localMallocDef = mallocDef.FilterPlugin(); // this list would be empty
Supported from v9.5.1
FindAllMembers
Returns a ICxListProvider which is a subset of this instance, with elements that are members of the declarations in the specified ICxListProvider.
declarationsList List of declarations from which the members we want to find
A subset of this instance, with elements that are members of declarationsList.
Returns a CxList which is a subset of this instance, with elements that are members of the declarations in the specified CxList.
targetList List were the members will be found
declarationsList List of declarations from which the members we want to find
None
FindAllReferences
Returns a CxList which is a subset of “this” instance, with elements that are references of the given CxList, excluding elements in the second CxList.
Expand source
public CxList FindAllReferences(CxList ids, CxList exclude)
ids The CxList whose references are to be found.
exclude The CxList whose elements will be ignored and excluded.
A subset of “this” instance, with elements that are references of the given CxList.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindAllReferences() method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.FindAllReferences method:
Expand source
result = All.FindAllReferences(All.FindById(36), All.FindById(30)); //a in (a = 5), b in (int b)
The result would consist of 3 items:
Expand source
a (in a = 5) a (in a > 5) a (in b = a)
Returns a CxList which is a subset of “this” instance, with elements that are references of the given CxList.
Expand source
public abstract CxList FindAllReferences(CxList Ids)
ids The CxList whose references are to be found.
A subset of “this” instance, with elements that are references of the given CxList.
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindAllReferences() method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = a;
The source code that uses CxList.FindAllReferences method:
Expand source
result = All.FindAllReferences(All.FindById(36)); //a in (a = 5)
The result would consist of 3 items;
Expand source
a (in a = 5), a (in a > 5), a (in b = a)
Returns a ICxListProvider which is a subset of this instance, with elements that are references of the specified ICxListProvider.
ids Id of the object whose references to be found.
useOld Whether or not to use the old, less efficient algorithm. Used for comparing performance purposes only.
A subset of this instance, with elements that are references of the specified ICxListProvider.
FindByAbstractValue
Returns a CxList which is a subset of this instance whose elements have an abstract value that fulfills the criterion.
Expand source
public CxList FindByAbstractValue (Func<IAbstractValue, bool> criterion)
criterion Lambda method that can filter required items from this CxList according to their abstract value. This function have one parameter of type IAbstractValue and returns bool.
A subset of this instance whose elements have match the requested criterion.
These examples demonstrate the CxList.FindByAbstractValue(Func<IAbstractValue, bool>) method.
Find all DOM elements whose abstract value is an integer inside the interval 0,10:
Expand source
IAbstractValue intervalZeroToTen = new IntegerIntervalAbstractValue(0,10); CxList res = All.FindByAbstractValue(abstractValue => abstractValue.IncludedIn(intervalZeroToTen, true));
Find all DOM elements for which the integer 0 in inside their abstract value:
Expand source
IAbstractValue zero = new IntegerIntervalAbstractValue(0); CxList res = All.FindByAbstractValue(abstractValue => zero.IncludedIn(abstractValue));
Find all DOM elements whose abstract value has a given type:
Expand source
CxList res = All.FindByAbstractValue(abstractValue => abstractValue is StringAbstractValue);
The input source code is:
Expand source
int counter = 0; int x = counter + 5; string str = "a"; string secondStr = str + "b";
The source code that uses CxList.FindByAbstractValue method:
Expand source
CxList a = All. FindByAbstractValue(abstractValue => abstractValue is IntegerIntervalAbstractValue); CxList b = All.FindByAbstractValue(abstractValue => abstractValue is StringAbstractValue); result = a; // result now holds 0, '+', 'counter' and 5 in int counter = 0; int x = counter + 5; result = b; // result now holds "a", '+', 'str' and "b" in string str = "a"; string secondStr = str + "b";
The input source code is:
Expand source
var y; int counter = 0; int x = counter + 5; y();
The source code that uses CxList.FindByAbstractValue method:
Expand source
IAbstractValue zeroAbsValue = new IntegerIntervalAbstractValue(0); result = All. FindByAbstractValue(abstractValue => zeroAbsValue.IncludedIn(abstractValue)); /* result now holds 0 and 'counter' in int x = counter + 5; And also contains y in: (because y has AnyAbstractValue which includes 0) y(); */ result = All. FindIncludedAbstractValue(abstractValue => zeroAbsValue.IncludedIn(abstractValue,true)); // result now holds 0 and 'counter' in int x = counter + 5; // it does not contain y because we asked for strictTypeMatch
The input source code is:
Expand source
int counter = 0; int x = counter + 5; function foo() { } // void method foo();
The source code that uses CxList.FindByAbstractValue method:
Expand source
IAbstractValue zeroToFiveAbsValue = new IntegerIntervalAbstractValue(0,5); result = All.FindIncludedInAbstractValue(abstractValue => abstractValue.IncludedIn(zeroToFiveAbsValue)); /* result now holds 0, 5, 'counter' and the sum (counter + 5) in int counter = 0; int x = counter + 5; And also contains foo in: foo(); // because y has AnyAbstractValue which includes [0,5] */ result = All.FindIncludedInAbstractValue(abstractValue => abstractValue.IncludedIn(zeroToFiveAbsValue, true)); // result now holds 0, 5, 'counter' and the sum of (counter + 5) in int x = counter + 5; // it does not contain foo because we asked for strictTypeMatch
Supported from version 8.6.0
FindByAbstractValues
Returns a CxList which is a subset of this instance whose elements have an abstract value equal to the abstract value of one element in the sources CxList.
Expand source
public CxList FindByAbstractValues(CxList sources)
sources A CxList.
A subset of this instance whose elements have an abstract value equal to the abstract value of one element in the sources CxList.
These examples demonstrate the CxList.FindByAbstractValue(CxList) method.
The input source code is:
Expand source
string str = "a"; string secondStr = str + "b";
The source code that uses CxList.FindByAbstractValues method:
Expand source
result = All.FindByAbstractValues(All.FindByType(typeof(StringLiteral))); // result now holds "a", 'str' and "b" in string str = "a"; string secondStr = str + "b";
Supported from version 8.4.2
FindByAssignmentSide
Returns a ICxListProvider which is a subset of this instance and its elements are being on the specified side of an assignment expression.
side side of the assignment expression.
A subset of this instance on the specified side of an assignment expression.
FindByCustomAttribute
Returns a ICxListProvider which is a subset of this instance and its elements are custom attributes of the specified name.
name The attribute name.
A subset of this instance with custom attributes of the specified name.
FindByExactMemberAccess
Returns a ICxListProvider which is a subset of this instance and its elements are the ones which their specified member is accessed.
Expand source
public CxList FindByExactMemberAccess(string Name)
name Contains both the name of the type and the name of the accessed member in the qualified notation (eg. "CheckBoxList.SelectedValue").
A subset of “this” instance where its elements are the ones which their given member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate CxList.FindByExactMemberAccess(string) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByExactMemberAccess method:
Expand source
result = All.FindByExactMemberAccess("MyClass.DataMember");
Notice that the result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Expand source
result = All.FindByExactMemberAccess("Class.DataMember");
The result would consist of 0 items, because "Class" is not equal to "MyClass".
Supported from 8.2.0
Receives a qualified notation string (e.g. "T.M") where T is a type name and M is a member name.
Returns a CxList which is a subset of "this" instance containing the elements with name equal to M and belong to a type whose name equals T.This search allows both case-sensitive and non case-sensitive searches.
Expand source
public CxList FindByExactMemberAccess(string Name, bool caseSensitive)
name Contains both the name of the type and the name of the accessed member in qualified notation (eg. "CheckBoxList.SelectedValue").
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of “this” instance where its elements are the ones which their specified member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByExactMemberAccess(string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByExactMemberAccess method:
Expand source
result = All.FindByExactMemberAccess("MyClass.dataMember", true);
Notice that the result would consist of 0 items because the search is case-sensitive.
Expand source
result = All.FindByExactMemberAccess("MyClass.dataMember", false);
The result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Expand source
result = All.FindByExactMemberAccess("Class.dataMember", false);
The result would consist of 0 items, because “Class” is not equals to “MyClass”.
Supported from 8.2.0
Returns a CxList which is a subset of “this” instance containing the elements with name equal to the string in second parameter belong to a type whose name equals the string in the first parameter.This is a case-sensitive search by parameters.
For a non case-sensitive search, use the FindByExactMemberAccess Method(string, string, bool) instead.
Expand source
public CxList FindByExactMemberAccess(string TargetTypeName, string MemberName)
targetTypeName Contains the name of the accessed type (eg. "CheckBoxList").
memberName Contains the name of the accessed member (eg. "SelectedValue").
A subset of “this” instance where its elements are the ones which their specified member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByExactMemberAccess(string, string) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByExactMemberAccess method:
Expand source
result = All.FindByExactMemberAccess("MyClass", "DataMember");
Notice that the result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Expand source
result = All.FindByExactMemberAccess("Class", "DataMember");
The result would consist of 0 items, because "Class" is not equals to "MyClass".
Supported from 8.2.0
Returns a CxList which is a subset of “this” instance containing the elements with name equal to the string in second parameter and belong to a type whose name equals the string in the first parameter.This search allows both case-sensitive and non case-sensitive searches by both parameters.
Expand source
public CxList FindByExactMemberAccess(string TargetTypeName, string MemberName, bool CaseSensitive)
targetTypeName Contains the name of the accessed type (eg. "CheckBoxList").
memberName Contains the name of the accessed member (eg. "SelectedValue").
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of “this” instance where its elements are the ones which their specified member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByExactMemberAccess(string, string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByExactMemberAccess method:
Expand source
result = All.FindByExactMemberAccess("MyClass", "dataMember", true);
Notice that the result would consist of 0 item because it is a case-sensitive search.
Expand source
result = All.FindByExactMemberAccess("MyClass", "dataMember", false);
The result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Expand source
result = All.FindByExactMemberAccess("Class", "dataMember", false);
The result would consist of 0 items, because "Class" is not equals to "MyClass".
Supported from 8.2.0
FindByExactMemberAccesses
Returns a CxList which is a subset of "this" instance with nodes that are part of a member/target pair (typical example: target.member) and have a direct member in the CxList parameter "members". Returns a CxList which is a subset of this instance and its elements are the ones which their specified members and targets are accessed. It only works if all the Members are mutual for all the Targets (Types) e.g. myClass1.method1(); myClass1.method2(); myClass2.method1(); myClass2.method2();
targets Contains the name of the accessed target types
members Contains the name of the accessed members
caseSensitive None
A subset of this instance and its elements are the ones which their specified members and targets are accessed
Returns a CxList which is a subset of this instance and its elements are the ones which their specified members and a single target accessed. It only works if all the Members are mutual for all the Targets (Types) e.g. myClass1.method1(); myClass1.method2(); myClass1.method3();
target Contains the name of the accessed target
members Contains the name of the accessed members
caseSensitive None
A subset of this instance and its elements are the ones which their specified members and a single target accessed
Returns a CxListImpl which is a subset of this instance and its elements are MemberAccesses specified on the parameter <paramref name="names"></paramref>.
names A list of strings that contain both the name of the type and the name of the accessed member in qualified notation (eg. "CheckBoxList.SelectedValue"). Prefix and suffix wild card * are permitted.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of this instance where its elements are the ones which their specified member is accessed.
FindByExtendedType
Returns a CxList which is a subset of "this" instance and the type of its elements match the type specified as parameter.
Expand source
public CxList FindByExtendedType (string extendedType)
extendedType The extended type of the objects to be found. Prefix and postfix wildcard * are supported.
A subset of "this" instance and its elements are those with type specified by the parameter.
ArgumentException : parameter is a null reference
The return may be empty (Count = 0).
This example demonstrates the CxList.FindByExtendedType() method.
The input source code is:
Expand source
MyClass a; MyClassExtended b; int c; a.DataMember = 3; c = a.Method();
The source code that uses CxList.FindByExtendedType method:
Expand source
result = All.FindByExtendedType("MyClass*");
The result would consists of 4 items:
Expand source
a (in MyClass a) b (in MyClassExtended b) a (in a.DataMember = 3) a (in c = a.Method())
FindByFathers
Returns a ICxListProvider which is a subset of this instance and its elements are those that their CxDOM are in the specified ICxListProvider
fathers CxDOM Fathers.
A subset of this instance and its elements are those that their CxDOM-Fathers are in the specified ICxListProvider.
FindByFieldAttributes
Returns a ICxListProvider which is a subset of this instance and its elements are modified by the modifier (private, external, etc).
attributes Attribute of the fields to be found.
A subset of this instance and its elements are those with attribute attrib.
FindByFileId
Returns a ICxListProvider which is a subset of this instance and its elements are in a given source code file.
fileId Id of the file
A subset of this instance in a given file name.
FindByFileName
Returns a ICxListProvider which is a subset of this instance and its elements are in a given source code file.
fileName String of the file name.
A subset of this instance in a given file name.
FindByFileNames
Returns a CxList, which is a subset of “this” instance and its elements are in a given array of source code files.
Expand source
public CxList FindByFileNames(params string[] FileNames)
fileNames Parameters with file names.
A subset of "this” instance with elements from a given list of file names.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByFileNames(string[]) method.
Expand source
//file myCode1.cs class Cl1 { void foo() { int i; } } //file myCode2.cs class Cl2 { void bar() { int i; } }
The source code that uses CxList.FindByFileNames method:
Expand source
result = All.FindByFileNames("*myCode1.cs", "*myCode2.cs");
The result would consist of 10 items:
Expand source
Cl1 void, foo, int, i, Cl2 void, bar, int, i
Supported from 9.4
FindByFiles
Returns a subset of 'this' instance, where its DOM objects are on the same file(s) as the DOM objects in the 'source' CxList.
Expand source
public CxList FindByFiles(CxList source)
source A CxList that have DOM objects in the required files.
Returns Return a subset of 'this' instance, where its DOM objects are on the same file(s) as the DOM objects in the 'source' CxList.
ArgumentNullException : Thrown when parameter is a null reference.
This example demonstrates the CxList.FindByFiles(CxList) method.
Expand source
CxList a = All.FindByFileName("*method.js*"); CxList b = All.FindByFileName("*method.json"); result = a.FindByFiles(b); // Return a subset of 'a' where the objects are of the same file as the objects of b.
Supported from 8.4.0
FindById
Finds all objects with the specified id. This method is mainly used to find all the uses of a code element (e.g. variable, class).
Expand source
public CxList FindById (int id)
nodeId id number to be found.
A subset of "this" instance and its elements that have the specified id number.
ArgumentNullException : parameter is a null reference
The return value may be empty(Count = 0).
This example demonstrates the CxList.FindById() method.
The input source code is:
Expand source
a = 3; b = 4; if (a == 4) b = a - 1;
The source code that uses CxList.FindById method:
Expand source
result = All.FindById(60);
The result would be -
Expand source
1 item found: b ( in b = a - 1)
Finds an object with the specified ids.
nodeIds Passes as parameters directly the id numbers.
A subset of this instance with the specified id numbers.
FindByInitialization
Returns a CxList which is a subset of “this” instance and contains elements initialized by the given CxList.
Expand source
public CxList FindByInitialization(CxList InitializersList)
initializationList A CxList with initializers to search in “this” instance.
A subset of “this” instance containing declarators initialized by the specified CxList.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByInitialization(CxList) method.
The input source code is:
Expand source
int b = 5;
The source code that uses CxList.FindByInitialization method:
Expand source
CxList declarators = All.FindByType(typeof(Declarator)); result= declarators.FindByInitialization(All);
The result would consist of 1 item:
Expand source
b
Supported from v1.8.1
FindByLanguage
Returns a CxList which is a subset of “this” instance whose elements are from the given language.
Expand source
public CxList FindByLanguage (string languageName)
languageName Language name to search.
A subset of “this” instance whose elements are from the given language.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByLanguage(CxList) method.
The input source code is:
Expand source
//file myCode.cs class myCode { } //file MyCode.java class MyCode { }
The source code that uses CxList.FindByLanguage method:
Expand source
result = All.FindByLanguage ("Java");
The result would consist of 1 item:
Expand source
myCode (class MyCode)
FindByMemberAccess
Receives a qualified notation string (e.g. “T.M”) where T is a type name and M is a member name.
Returns a CxList which is a subset of “this” instance containing the elements with name equal to M and belong to a type whose name ends with T.This search allows both case-sensitive and non case-sensitive searches.
For a search by exact target type name, use FindByExactMemberAccess(string) instead.
Expand source
public CxList FindByMemberAccess(string Name, bool CaseSensitive = true)
name Contains both the name of the type and the name of the accessed member in qualified notation (eg. "CheckBoxList.SelectedValue"). Prefix and suffix wild card* are permitted.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
targetComparisonType StringComparison approach
A subset of “this” instance where its elements are the ones which their specified member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByMemberAccess(string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByMemberAccess method:
Expand source
result = All.FindByMemberAccess("MyClass.dataMember", true);
Notice that the result would consist of 0 items because the search is case-sensitive.
Expand source
result = All.FindByMemberAccess("Class.dataMember", false);
Notice that the result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
This is so, because MyClass ends with Class.
Expand source
result = All.FindByMemberAccess("MyClass.met*", true);
Notice that the result would consist of 0 items because the search is case-sensitive.
Expand source
result = All.FindByMemberAccess("Class.dataMember", false);
Notice that the result would consist of 1 item:
Expand source
a.Method(in b = a.Method())
Supported from 1.8.1
Returns a CxList which is a subset of “this” instance containing the elements with name equal to the string in the second parameter and belong to a type whose name ends with the string in the first parameter. This is a case-sensitive search by both parameters.
Expand source
public CxList FindByMemberAccess(string TargetTypeName, string MemberName, bool CaseSensitive = true)
targetTypeName Contains the name of the accessed type (eg. "CheckBoxList").
memberName Contains the name of the accessed member (eg. "SelectedValue").
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
targetComparisonType StringComparison approach
A subset of “this” instance where its elements are the ones which their specified member is accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByMemberAccess(string, string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByMemberAccess method:
Expand source
result = All.FindByMemberAccess("MyClass", "dataMember", true);
Notice that the result would consist of 0 items because the search is case-sensitive.
Expand source
result = All.FindByMemberAccess("MyClass", "dataMember", false);
The result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
This is so, because MyClass ends with Class.
Expand source
result = All.FindByMemberAccess("MyClass", "met*", true);
Notice that the result would consist of 0 items because the search is case-sensitive.
Expand source
result = All.FindByMemberAccess("MyClass", "met*", false);
the result would consist of 1 item:
Expand source
a.Method(in b = a.Method())
FindByMemberAccesses
Receives an array of qualified notation strings (e.g. “T.M”) where T is a type name and M is a member name.
Returns a CxList which is a subset of “this” instance containing the elements with name equal to M and belong to a type whose name ends with T, for any strings in the array. This search allows both case-sensitive and non case-sensitive searches.
Expand source
public CxList FindByMemberAccesses(string [] Names, bool CaseSensitive = true)
names An array of strings where each contains both the name of the type and the name of the accessed member in qualified notation (eg. "CheckBoxList.SelectedValue"). Prefix and suffix wild card* are permitted.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive. This Boolean is true by default.
targetComparisonType StringComparison approach
A subset of “this” instance where its elements are the ones which their specified members are accessed.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
These examples demonstrate the CxList.FindByMemberAccesses(string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByMemberAccesses method:
Expand source
string []memberAccesses = new string[]{“Class.dataMember”, “MyClass.Met*”} result = All.FindByMemberAccesses(memberAccesses, true);
Notice that the result would consist of 1 item because the search is case-sensitive:
Expand source
a.Method()
Expand source
result = All.FindByMemberAccesses(memberAccesses);
The result would consist of 2 items:
Expand source
a.DataMember a.Method
This is so, because MyClass ends with Class.
Supported from 8.2.0
Receives a qualified notation string (e.g. “T.M”) where T is a type name and M is a member name.
Returns a CxList which is a subset of “this” instance containing the elements with name equal to M and belong to a type whose name equals T.This is a case sensitive search.
For a non case-sensitive search, use the FindByExactMemberAccess (string, bool) instead. Returns a CxList which is a subset of this instance and its elements are the ones which their specified members and targets are accessed. It only works if all the Members are mutual for all the Targets (Types) e.g. myClass1.method1(); myClass1.method2(); myClass2.method1(); myClass2.method2();
targets Contains the name of the accessed target types
members Contains the name of the accessed members
caseSensitive Whether to perform case-sensitive search (defaults to true)
targetComparisonType StringComparison approach (defaults to StringComparison.OrdinalIgnoreCase)
A subset of this instance and its elements are the ones which their specified members and targets are accessed
Returns a CxList which is a subset of this instance and its elements are the ones which their specified members and a single target accessed. It only works if all the Members are mutual for all the Targets (Types) e.g. myClass1.method1(); myClass1.method2(); myClass1.method3();
target Contains the name of the accessed target
members Contains the name of the accessed members
caseSensitive Whether to perform case-sensitive search (defaults to true)
targetComparisonType StringComparison approach (defaults to StringComparison.OrdinalIgnoreCase)
A subset of this instance and its elements are the ones which their specified members and a single target accessed
FindByMethodReturnType
Returns a CxList which is a subset of “this” instance and its elements are method declarators of a given return type.
Expand source
public CxList FindByMethodReturnType(string type)
type The return type name string.
A subset of “this” instance with method declarators of a given return type.
ArgumentNullException : Thrown when parameter is a null reference.
1. If the this instance contains more than one node or contains flows or list contains flows, the function return value is undefined.
2. The number of the returned items is same as the number of items in list.
3. This function calls the Concatenate function for this instance with each item in list as parameter.
This example demonstrate the CxList.FindByMethodReturnType(string) method.
The input source code is:
Expand source
MyType foo() { ... }
The source code that uses CxList.FindByMethodReturnType method:
Expand source
result = All.FindByMethodReturnType("MyType");
The result would consist of 1 item:
Expand source
foo
FindByName
Returns a CxList which is a subset of “this” instance and its elements are the ones which their name is the given parameter(optionally with wildcards) and is not shorter than minLength and not longer than maxLength.
Expand source
public CxList FindByName(string nodeName, int minLength, int maxLength)
nodeName Contains the name of the objects. Prefix and postfix wildcard * are supported.
minLength Minimum length of the searched strings.
maxLength Maximum length of the searched strings.
A subset of “this” instance and its elements are the ones which their name is the given parameter, according to the given length interval.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByName(string, int, int) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName("*Me*", 3, 7);
The result would consist of 1 item:
Expand source
Method (in b = a.Method())
Supported from v2.0.5
Returns a CxList which is a subset of “this” instance and its elements are the ones which their names are equal to the given list.
Expand source
public CxList FindByName(CxList nodesList)
nodesList The list of nodes containing the names to be found.
A subset of “this” instance and its elements are the ones which the name is contained in the given list.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByName(CxList) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName(All.FindByType(typeof(MemberAccess)));
The result would consist of 3 items:
Expand source
a (in MyClass a) a (in a.DataMember = 3) a (in b = a.Method())
Returns a CxList which is a subset of “this” instance and its elements are the ones which their names are equal to the list given.
Expand source
public CxList FindByName(CxList nodesList, bool CaseSensitive)
nodesList The list of nodes containing the names to be found.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of “this” instance and its elements are the ones which their name is contained in the given list, according to the specified case sensitivity comparison criteria.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByName(CxList, bool) method.
The input source code is:
Expand source
MyClass A; int a; A.DataMember = 3; a = A.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName(All.FindByType(typeof(MemberAccess)), false));
The result would consist of 5 items:
Expand source
A (in MyClass A) a (in int a) A (in A.DataMember = 3) a (in a = A.Method()) A (in a = A.Method())
Returns a CxList which is a subset of “this” instance and its elements are the ones which their name is the given parameter.
Expand source
public CxList FindByName(string name)
nodeName The name of the objects to look for. Prefix and postfix wildcard * are supported.
A subset of “this” instance and its elements are the ones which their name is the given parameter.
ArgumentNullException : Thrown when parameter is a null reference.
1. If the this instance contains more than one node or contains flows or list contains flows, the function return value is undefined.
2. The number of the returned items is same as the number of items in list.
3. This function calls the Concatenate function for this instance with each item in list as parameter.
This example demonstrate the CxList.FindByName(string) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName("*Member*");
The result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Returns a CxList which is a subset of “this” instance and its elements are the ones which their name is the given parameter, according to the specified comparison criteria.
Expand source
public CxList FindByName(string name, bool CaseSensitive)
nodeName Contains the name of the objects. Prefix and postfix wildcard * are supported.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of “this” instance and its elements are the ones which their name is the given parameter, according to the given comparison criteria.The caseSensitive boolean value defines the ability to search using case sensitive or case insensitive comparison.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByName(string, bool) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName("*member*", true);
The result would consist of 0 items.
Expand source
result = All.FindByName("*member*", false);
The result would consist of 1 item:
Expand source
a.DataMember (in a.DataMember = 3)
Supported from v1.8.1
Returns a CxList which is a subset of “this” instance and its elements are the ones which their name is the given parameter. The comparison method specified in parameter is used for matching.
Expand source
public CxList FindByName(string name, StringComparison comparisonType)
nodeName The name of the objects to look for. Prefix and postfix wildcard * are supported.
comparisonType StringComparison type to be used in name comparison. One of the following values: CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, Ordinal, OrdinalIgnoreCase
A subset of “this” instance and its elements are the ones which their name is the given parameter.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByName(string, StringComparison) method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByName method:
Expand source
result = All.FindByName("*member*", StringComparison.OrdinalIgnoreCase));
The result would consist of 1 item:
Expand source
DataMember (in a.DataMember = 3)
Supported from v1.8.1
FindByNames
Returns a CxList which is a subset of “this” instance and its elements are the ones which their names are equal to the list given.
Expand source
public CxList FindByNames(params String[] nodeNames)
nodeNames A list of strings containing the names to be found.
A subset of “this” instance and its elements are the ones which their name is contained in the given list, according to the specified case sensitivity comparison criteria. CaseSensitive is by default is true.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByNames(params String[]) method.
The input source code is:
Expand source
MyClass A; int a; A.DataMember = 3; a = A.Method();
The source code that uses CxList.FindByNames method:
Expand source
result = All.FindByNames("*MEMBER","A.Method");
The result would consist of 3 items:
Expand source
A (in A.DataMember = 3) a (in a = A.Method()) A (in a = A.Method())
Supported from v9.4.0
Returns a CxList which is a subset of “this” instance and its elements are the ones which their names are equal to the list given.
Expand source
public CxList FindByNames(String[] nodeNames, bool CaseSensitive = true)
nodeNames A list of strings containing the names to be found.
caseSensitive Boolean which indicates to the search to be (or not) case sensitive.
A subset of “this” instance and its elements are the ones which their name is contained in the given list, according to the specified case sensitivity comparison criteria.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByNames(String[], bool) method.
The input source code is:
Expand source
MyClass A; int a; A.DataMember = 3; a = A.Method();
The source code that uses CxList.FindByNames method:
Expand source
string[] str = new string[2] {"*MEMBER","A.Method"}; result = All.FindByNames(str);
The result would consist of 3 items:
Expand source
A (in A.DataMember = 3) a (in a = A.Method()) A (in a = A.Method())
Supported from v9.4.0
Returns a CxList which is a subset of “this” instance and its elements are the ones which their names are equal to the list given.
nodeNames A list of strings containing the names to be found.
stringComparison The StringComparison type to compare strings.
A subset of “this” instance and its elements are the ones which their name is contained in the given list, according to the specified comparison method.
ArgumentNullException : Thrown when parameter is a null reference.
The return value may be empty (Count = 0).
FindByNumberOfParameters
Returns a CxList which is a subset of "this" instance and its elements are nodes (method declarations, constructor, etc) with the number of parameters given.
Expand source
public CxList FindByNumberOfParameters (int numParams)
numParams int with the number of parameters.
A subset of this instance with nodes (method declarations, constructor, etc) that has the number of parameters given.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByNumberOfParameters() method.
The input source code is:
Expand source
foo("myVar");
The source code that uses CxList.FindByNumberOfParameters method:
Expand source
CxList var = All.FindByShortName("myVar"); result = All.FindByNumberOfParameters(1);
the result would consist of 1 item:
foo
Supported from v9.4
FindByParameterName
Returns a CxList which is a subset of "this", containing only MethodInvokeExpr DOM node where their arguments are labeled according to the given value.
Expand source
public CxList FindByParameterName (string paramName)
paramName String containing the name of the parameter belonging to the resultant methods.
A subset of "this" instance where its elements are MethodInvokeExpr and ObjectCreateExpr and these contain arguments labelled according to 'paramName'.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByParameterName(string) method.
The input source code is:
Expand source
class NamedExample { static void Main(string [] args) { PrintOrderDetails(sellerName:"Gift Shop",31,productName:"Red Mug"); } }
The source code that uses CxList.FindByParameterName method:
Expand source
result = All.FindByParameterName("sellerName");
The resul would consist in 1 item:
Expand source
PrintOrderDetails
Returns a CxList which is a subset of "this", containing only MethodInvokeExpr DOM node where their arguments on a given position are labeled according to the given value.
Expand source
public CxList FindByParameterName (string paramName, int paramPosition)
paramName String containing the name of the parameter belonging to the resultant methods.
paramPosition Zero based index indicating the position of argument named 'paramName'.
A subset of "this" instance where its elements are MethodInvokeExpr and ObjectCreateExpr and these contain arguments labelled according to 'paramName' in the indicated position by 'paramPosition'.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByParameterName(string, int) method.
The input source code is;
Expand source
class NamedExample { static void Main(string [] args) { PrintOrderDetails(sellerName:"Gift Shop",31,productName:"Red Mug"); } }
The source code that uses CxList.FindByParameterName method:
Expand source
result = All.FindByParameterName ("sellerName", 1);
Would have no results because there's no argument named "sellerName" on the first position of the method call.
However,
Expand source
result = All.FindByParameterName ("productName", 1);
Would result in 1 item:
Expand source
PrintOrderDetails
Because there's an argument on the second position(zero based) called "productName"
FindByParameterValue
Returns a ICxListProvider which is a subset of this instance and its parameters values are as specified.
paramNo Zero-based index of the parameter.
paramValue The value of the parameter.
opr One of the following values: BinaryOperator.IdentityEquality, BinaryOperator.IdentityInequality.
useAbstractValue Boolean which indicates to use the string abstract value.
Returns a ICxListProvider which is a subset of this instance and its parameters values are as specified.
Returns a CxList which is a subset of “this” instance and its elements are methods whose parameters values (referred by their index) are equal(or not).
Expand source
public CxList FindByParameterValue(int paramNo1, int paramNo2, BinaryOperator opr)
paramNo1 Zero-based index of the parameter.
paramNo2 Zero-based index of the parameter.
opr One of the followings: BinaryOperator.IdentityEquality, BinaryOperator.IdentityInequality.
A subset of “this” instance whose parameter values are equal or not equal (depending on the operator chosen).
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.GetParameters() method.
The input source code is:
Expand source
foo(1, i, 1);
The source code that uses CxList.FindByParameterValue method:
Expand source
CxList methods = All.FindByType(typeof(MethodInvokeExpr)); result = All.FindByParameterValue(0, 2, BinaryOperator.IdentityEquality);
the result would consist of 1 item:
Expand source
foo (first parameter value is equal to the third one)
FindByParameters
Returns a CxList which is a subset of “this” instance and its elements are methods of the given CxList with the specified parameters.
Expand source
public CxList FindByParameters (CxList paramList)
paramList CxList of method parameters.
A subset of "this" instance with methods whose parameters are given in the list.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByParameters() method.
The input source code is:
Expand source
foo("myVar");
The source code that uses CxList.FindByParameters method:
Expand source
CxList var = All.FindByShortName("myVar"); result = All.FindByParameters(var);
The result would consist of 1 item:
Expand source
foo
FindByPointerType
Returns a CxList which is a subset of “this” instance and its elements are of the type pointer of the specified type of code element.
Expand source
public CxList FindByPointerType(string type, int maxDepth, bool caseSensitive)
type type of the parameter
maxLevels Zero-based maximum depth to look for. Default value is 0 meaning that it will look all the PointerTypeRef levels until it finds a TypeRef
caseSensitive Default value is true
A subset of "this" instance and its elements are of the type pointer of the specified type of code element.
ArgumentNullException : type is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPointerType method.
The input source code is:
Expand source
var i *int
The source code that uses CxList.FindByPointerType method:
Expand source
result = All.FindByPointerType(“int”);
the result would consist of 2 items:
Expand source
*int – pointer i – Declarator
Supported from v8.5.0
Returns a CxList which is a subset of “this” instance and its elements are of the type pointer of the specified type of code element
Expand source
public CxList FindByPointerType(string type, bool caseSensitive)
type type of the parameter
caseSensitive Default value is true
A subset of "this" instance and its elements are of the type pointer of the specified type of code element.
ArgumentNullException : type is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPointerType method.
The input source code is:
Expand source
var i *int
The source code that uses CxList.FindByPointerType method:
Expand source
result = All.FindByPointerType("int");
the result would consist of 2 items:
Expand source
*int - pointer I - Declarator
Supported from v8.5.0
FindByPointerTypes
Returns a CxList which is a subset of "this" instance and its elements are of the type pointer of the specified types of code element
Expand source
public CxList FindByPointerType(string[] type, bool caseSensitive)
types types of the parameter
caseSensitive Default value is true
A subset of "this" instance and its elements are of the type pointer of the specified types of code element.
ArgumentNullException : type is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPointerType method.
The input source code is:
Expand source
var i * int
The source code that uses CxList.FindByPointerType method:
Expand source
result = All.FindByPointerTypes(new string[]{"int","string"});
the result would consist of 2 items:
Expand source
*int - pointer i - Declarator
Supported from v8.5.0
Returns a CxList which is a subset of "this" instance and its elements are of the type pointer of the specified types of code element
Expand source
public CxList FindByPointerTypes(string[] type, int maxLevels, bool caseSensitive)
type types of the parameter
maxLevels Zero-based maximum depth to look for. Default value is 0 meaning that it will look all the PointerTypeRef levels until it finds a TypeRef
caseSensitive Default value is true
A subset of “this” instance and its elements are of the type pointer of the specified types of code element.
ArgumentNullException : type is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPointerTypes method.
The input source code is:
Expand source
var i *int
The source code that uses CxList.FindByPointerTypes method:
Expand source
result = All.FindByPointerTypes(new string[]{"int","string"});
the result would consist of 2 items:
Expand source
*int - pointer i - Declarator
Supported from v8.5.0
FindByPosition
Returns a CxList which is a subset of "this" instance and its elements are located in the given file and line number.
Expand source
public CxList FindByPosition(string file, int line)
file File name in the source code.
line Line number in the source code.
A subset of "this" instance which is located in the given file and line.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPosition() method.
The input source code is (file name "MyCode.java"):
Expand source
MyClass a; int b; a.DataMember = 5; b = a.Method();
The source code that uses CxList.FindByPosition method:
Expand source
result = All.FindByPosition (“MyCode.java”, 3);
the result would consist of 1 item:
Expand source
5 (in a.DataMember = 5)
Returns a CxList which is a subset of “this” instance and its elements are located in the given file, line and column.
Expand source
public CxList FindByPosition(string file, int line, int col)
file File name in the source code.
line Line number in the source code.
col Column number in the source code.
A subset of "this" instance which is located in the specified file, line and column.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPosition() method.file name "MyCode.java"
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 5; b = a.Method();
Expand source
result = All.FindByPosition (“MyCode.java”, 3, 16);
the result would be -
Expand source
1 item found: 5 (in a.DataMember = 5)
Returns a CxList which is a subset of "this" instance and its elements are in the given line number.
Expand source
public CxList FindByPosition(int line)
line The line number.
A subset of "this" instance with elements from the given line.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPosition() method.
The input source code is:
Expand source
int b, a = 5; if (a > 3) b = 6;
The source code that uses CxList.FindByPosition method:
Expand source
result = All.FindByPosition(2);
the result would consist of 4 items:
if
a,
>,
3
Returns a CxList which is a subset of “this” instance and its elements are located in the given line and column number.
Expand source
public CxList FindByPosition(int line, int col)
line Line number in the source code.
col Column number in the source code.
A subset of "this" instance with elements from the specified line and column.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPosition() method.
The input source code is:
Expand source
MyClass a; int b; a.DataMember = 3; b = a.Method();
The source code that uses CxList.FindByPosition method:
Expand source
result = All.FindByPosition (3, 16);
the result would consist of 1 item:
Expand source
3 (in a.DataMember = 3)
Returns a CxList which is a subset of “this” instance and its elements are in the given line/column and with the given length.
Expand source
public CxList FindByPosition(int line, int col, int length)
line The line number.
col The column number.
length The element length.
A subset of "this" instance with elements from the specified line, column and with the given length.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPosition() method.
The input source code is:
Expand source
int b, a = 5; if (a==33) b = 6;
The source code that uses CxList.FindByPosition method:
Expand source
result = All.FindByPosition(2, 5, 1);
the result would consist of 1 item:
Expand source
a
FindByPositions
Finds the elements of "this" instance at positions given in the pragmas list.
Expand source
public CxList FindByPositions(SortedList pragmas, int extendMatch, bool oneOnly)
pragmas A sorted list containing the pragmas to match.
extendMatch Defines the closeness of the matching results: 0 => ExactMatch: find exact match 1 => FindInLine: extend search to objects in closest position within same line 2 => FindClosestMatch: extend match to closest position within the same file
oneOnly If true, it returns one result per position.
The elements from "this" instance that are at the required positions.
ArgumentNullException : First parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList.FindByPositions() method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.FindByPositions method:
Expand source
CxList list = All.FindByShortName("b"); SortedList sorted = new SortedList(new PragmaComparer()); foreach (KeyValuePair<int, IGraph> dic in list.data) { sorted.Add(dic.Value.LinePragma, null); } result = All.FindByPositions(sorted, 1, true);
the result would consist of 2 items:
Expand source
b (in int b) b (in b = 6)
Finds the elements of "this" instance at positions given in the list using the proximity given in parameter.
positions A list containing the pragmas to match.
extendMatchEnum Defines the closeness of the matching results. One of the following values: ExactMatch: find exact match FindInLine: extend search to objects in closest position within same line FindClosestMatch: extend match to closest position within the same file
oneOnly If true, it returns one result per position.
The elements of "this" instance that are at the given positions.
ArgumentNullException : First parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPositions() method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.FindByPositions method:
Expand source
CxList list = All.FindByName(“b”); result = All.FindByPositions(list, CxPositionProximity.FindInLine, false);
The result would be all the elements in the 5 lines closer to lines that appear variable b:
Expand source
2 items found b (in int b) b (in b = 6)
Finds the elements of “this” instance at positions given in the pragmas list using the proximity from the parameter.
Expand source
public CxList FindByPositions(SortedList<LinePragma,object> pragmas, CxPositionProximity extendMatch, bool oneOnly)
pragmas A list containing the pragmas to match.
extendMatchEnum Defines the closeness of the matching results. One of the following values: ExactMatch: find exact match FindInLine: extend search to objects in closest position within same line FindClosestMatch: extend match to closest position within the same file
oneOnly If true, it returns one result per position.
The elements from the current instance that are at the required positions.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPositions() method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.FindByPositions method:
Expand source
CxList list = All.FindByName(“b”); SortedList<LinePragma, object> sorted = new SortedList<LinePragma, object>(new DataCollections.PragmaComparer()); foreach (KeyValuePair<int, IGraph> dic in list.data) { sorted.Add(dic.Value.LinePragma, null); } result = All.FindByPositions(sorted, CxList.CxPositionProximity.FindInLine, true);
The result would consist of 2 items:
Expand source
b (in int b) b (in b = 6)
Finds the elements of “this” instance at positions given in the pragmas list using the proximity given in parameter.
pragmas A list containing the pragmas to match.
extendMatchEnum Defines the closeness of the matching results. One of the following values: ExactMatch: find exact match FindInLine: extend search to objects in closest position within same line FindClosestMatch: extend match to closest position within the same file
oneOnly If true, it returns one result per position.
farLines Acceptable line distance to look for (the default setting is 5).
The elements from "this" instance that are at the given positions.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPositions() method.
The input source code is:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.FindByPositions method:
Expand source
CxList list = All.FindByName(“b”); SortedList<LinePragma, object> sorted = new SortedList<LinePragma, object>(new DataCollections.PragmaComparer()); foreach (KeyValuePair<int, IGraph> dic in list.data) { sorted.Add(dic.Value.LinePragma, null); } result = All.FindByPositions(sorted, CxList.CxPositionProximity.FindInLine, true, 5);
The result would consist of 2 items:
Expand source
b (in int b) b (in b = 6)
Finds the elements of "this" instance at lines of files given in parameter.
Expand source
public CxList FindByPositions(List<KeyValuePair<int, string>> lines)
lines A list of pairs line/filename to search the elements.
The subset of elements from “this” instance that are in the files given at the lines requested.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0).
This example demonstrates the CxList. FindByPositions() method.
The input source code is (file name is “MyCode.cs”:
Expand source
int b, a = 5; if (a == 33) b = 6;
The source code that uses CxList.FindByPositions method:
Expand source
KeyValuePair<int,string> position = new KeyValuePair<int, string>(3,”path\\MyCode.cs”); List<KeyValuePair<int, string>> list = new List<KeyValuePair<int, string>>(); list.Add(position); result = All.FindByPositions(list);
The result would consist of 3 items:
Expand source
b = 6
FindByRegex
return DOM objects by searching the source file with regex
expression the regex search string
cxOptions an enum matching the relevant CxRegexOptions which are: SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
regularOptions options to add to the regular expression (case sensitivity, etc.)
extendedResults is filled with the strings of the matches
farLines The line distance to look for matches in comments (the default is 5).
None
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string. This call is equivalent to the following calls and it is recommended to use the short call format by default:
FindByRegex(expression, null)
FindByRegex(expression, CxRegexOptions.None)
FindByRegex(expression, CxRegexOptions.None, RegexOptions.None)
FindByRegex(expression, CxRegexOptions.None, RegexOptions.None, null)
FindByRegex(expression, CxRegexOptions.None, RegexOptions.None, null, 5)
FindByRegex(expression, false, true, false)
FindByRegex(expression, false, true, false, null)
FindByRegex(expression, CxRegexOptions.None, null)
Expand source
public CxList FindByRegex(string expression)
expression Regular expression string.
A subset of this instance matches the given regular expression.
ArgumentNullException : parameter is a null reference
The return value may be empty (Count = 0)
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(");
The result would be -
Expand source
1 item found: foo
Supported from: CxAudit v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified flag parameters. This call is equivalent to the following calls and it is highly recommended to use the enum instead of the confusing flags:
FindByRegex(expression, searchInComments, searchInStringLiterals, recursive, null)
The 3 flags are translated to CxRegexOptions enum in the following way(bitmask supported) :
(false, false, false) => CxRegexOptions.DoNotSearchInStringLiterals
(false, false, true) => CxRegexOptions.DoNotSearchInStringLiterals | CxRegexOptions.AllowOverlaps
(false, true, false) => CxRegexOptions.None
(false, true, true) => CxRegexOptions.AllowOverlaps
(true, false, false) => CxRegexOptions.SearchInComments | CxRegexOptions.DoNotSearchInStringLiterals
(true, false, true) => CxRegexOptions.SearchInComments | CxRegexOptions.DoNotSearchInStringLiterals | CxRegexOptions.AllowOverlaps
(true, true, false) => CxRegexOptions.SearchInComments
(true, true, true) => CxRegexOptions.SearchInComments | CxRegexOptions.AllowOverlaps
After translating the flags to CxRegexOptions enum this call is equivalent to the following calls:
FindByRegex(expression, cxRegexOptions)
FindByRegex(expression, cxRegexOptions, RegexOptions.None)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, null)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, null, 5)
FindByRegex(expression, cxRegexOptions, null)
Expand source
public CxList FindByRegex(string expression , bool searchInComments, bool searchInStringLiterals, bool recursive)
expression Regular expression string.
searchInComments Positive if searching inside comments is desired.
searchInStringLiterals Positive if searching inside comments is desired.
recursive Positive if searching inside comments is desired.
A subset of this instance matches the given regular expression according to the additional parameters.
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", false, true, false);
The result would be -
Expand source
1 item found: foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified Checkmarx Regex Options defined in the second parameter.
This call is equivalent to the following calls and it is recommended to use the short call format by default:
FindByRegex(expression, cxRegexOptions, RegexOptions.None)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, null)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, null, 5)
FindByRegex(expression, cxRegexOptions, null)
Expand source
public CxList FindByRegex(string expression , CxRegexOptions cxOptions)
expression Regular expression string.
cxOptions An enum matching the relevant CxRegexOptions which are: None, SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", CxList.CxRegexOptions.None);
The result would be -
Expand source
1 item found: foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified Regex Options defined in the parameters(Checkmarx regex options and standard regex options).
This call is equivalent to the following calls and it is recommended to use the short call format by default:
FindByRegex(expression, cxRegexOptions, regexOptions, null)
FindByRegex(expression, cxRegexOptions, regexOptions, null, 5)
Expand source
public CxList FindByRegex(string expression , CxRegexOptions cxOptions, RegexOptions regularOptions)
expression Regular expression string.
cxOptions An enum matching the relevant CxRegexOptions which are: None, SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
regularOptions Options to add to the regular expression (case sensitivity, etc.) In addition to the user-defined regular-expression-options in this arguments, the algorithm also uses the following regex-options by default: RegexOptions.Multiline, RegexOptions.Singleline.
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a)
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", CxList.CxRegexOptions.None, System.Text.RegularExpressions.RegexOptions.None);
The result would be -
Expand source
1 item found: foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, and fill the extended results parameter with the strings of the matches.
This query search source files with regex, and return the closest same line DOM object to the matches. If no such object exists, returns the closest object in a successive line.
Search does not include searching inside comments and string literals, and regex matches are not allowed to overlap. The matching strings are returned in the extendedResults parameter.
This call is equivalent to the following calls:
FindByRegex(expression, CxRegexOptions.None, RegexOptions.None, cxList)
FindByRegex(expression, CxRegexOptions.None, RegexOptions.None, cxList, 5)
FindByRegex(expression, false, true, false, cxList)
Using the Boolean flags option is not recommended, use the enums instead.
FindByRegex(expression, CxRegexOptions.None, cxList)
Expand source
public CxList FindByRegex(string expression , CxList extendedResults)
expression Regular expression string.
extendedResults extendedResults parameter is filled with the strings of the matches.
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", All.NewCxList());
The result would be -
Expand source
1 item found foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified flag parameters and fill the extended results parameter with the strings of the matches: The 3 flags are translated to CxRegexOptions enum in the following way (bitmask supported):
(false, false, false) => CxRegexOptions.DoNotSearchInStringLiterals
(false, false, true) => CxRegexOptions.DoNotSearchInStringLiterals | CxRegexOptions.AllowOverlaps
(false, true, false) => CxRegexOptions.None
(false, true, true) => CxRegexOptions.AllowOverlaps
(true, false, false) => CxRegexOptions.SearchInComments | CxRegexOptions.DoNotSearchInStringLiterals
(true, false, true) => CxRegexOptions.SearchInComments | CxRegexOptions.DoNotSearchInStringLiterals | CxRegexOptions.AllowOverlaps
(true, true, false) => CxRegexOptions.SearchInComments
(true, true, true) => CxRegexOptions.SearchInComments | CxRegexOptions.AllowOverlaps
After translating the flags to CxRegexOptions enum this call is equivalent to the following calls: (It is highly recommended to use the enum instead of the confusing flags)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, cxList)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, cxList, 5)
FindByRegex(expression, cxRegexOptions, cxList)
Expand source
public CxList FindByRegex(string expression , bool searchInComments, bool searchInStringLiterals, bool recursive, CxList extendedResults)
expression Regular expression string.
searchInComments Positive if searching inside comments is desired.
searchInStringLiterals Positive if searching inside string literals is desired.
recursive Positive if searching inside string literals is desired.
extendedResults Positive if searching inside string literals is desired.
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", false, true, false, All.NewCxList());
The result would be -
Expand source
1 item found foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified Checkmarx Regex Options defined in the second parameter, and also fill the extended results parameter with the strings of the matches.
This call is equivalent to the following calls and it is recommended to use the short call format by default:
FindByRegex(expression, cxRegexOptions, RegexOptions.None, cxList)
FindByRegex(expression, cxRegexOptions, RegexOptions.None, cxList, 5)
Expand source
public CxList FindByRegex(string expression , CxRegexOptions cxOptions, CxList extendedResults)
expression Regular expression string.
cxOptions An enum matching the relevant CxRegexOptions which are: None, SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
extendedResults extendedResults parameter is filled with the strings of the matches.
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", CxList.CxRegexOptions.None, All.NewCxList());
The result item would be -
Expand source
1 item found: foo
Supported from v1.8.1
Returns a CxList which is a subset of this instance and its elements match the specified regular expression string, according to specified Regex Options defined in the parameters(Checkmarx regex options and standard regex options), and also fill the extended results parameter with the strings of the matches. This call is equivalent to the following call and it is recommended to use the short call format by default: FindByRegex(expression, cxRegexOptions, regexOptions, cxList, 5)
Expand source
public CxList FindByRegex(string expression , CxRegexOptions cxOptions, RegexOptions regularOptions, CxList extendedResults)
expression Regular expression string.
cxOptions An enum matching the relevant CxRegexOptions which are: None, SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
regularOptions Options to add to the regular expression (case sensitivity, etc.) In addition to the user-defined regular-expression-options in this arguments, the algorithm also uses the following regex-options by default: RegexOptions.Multiline, RegexOptions.Singleline.
extendedResults extendedResults parameter is filled with the strings of the matches.
A subset of this instance matches the given regular expression according to the additional parameters.
ArgumentNullException : Expression parameter is a null reference
The return value may be empty (Count = 0).
The following code example shows how you can use the FindByRegex method.
This example demonstrates the CxList.FindByRegex() method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a);
The source code that uses CxList.FindByRegex method:
Expand source
result = All.FindByRegex(@"(\s)?foo\(", CxList.CxRegexOptions.None, System.Text.RegularExpressions.RegexOptions.None, All.NewCxList());
The result would be -
Expand source
1 item found: foo
Supported from v1.8.1
return DOM objects by searching the source file with regex
expression the regex search string
cxOptions an enum matching the relevant CxRegexOptions which are: SearchInComments, DoNotSearchInStringLiterals, AllowOverlaps and SearchOnlyInComments
regularOptions options to add to the regular expression (case sensitivity, etc.)
extendedResults is filled with the strings of the matches
farLines The line distance to look for matches in comments (the default is 5).
None
FindByRegexExt
Find in files by regular expression regardless of DOM and language
expression Regular expression pattern
regFileFilter Mask of the files to search
cxOptions Search in comments
regularOptions Options for regular expression
None
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string pattern)
expression Regular expression pattern.
A list of matches for given regular expression in all project files.
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByRegexExt(string) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo");
The result would consist of 3 items:
Expand source
foo // foo /* foo
Supported from version 7.1.8 and 7.1.6HF5
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask)
expression Regular expression pattern.
fileMask File mask for search. Control characters "*" and "?" are supported.
For example: "." looks in all files and "*.aspx" looks in aspx files.
A list of matches for given regular expression in all project files.
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0).
This example demonstrate the CxList.FindByRegexExt(string, string) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo", “*.cs”);
The search would be only on *.cs files and the result would consist of 3 items:
Expand source
foo // foo /* foo
Supported from version 7.1.8 and 7.1.6HF5
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask, CxRegexOptions cxOptions)
expression Regular expression pattern.
fileMask File mask for search. Control characters "*" and "?" are supported.
For example: "." looks in all files and "*.aspx" looks in aspx files.
cxOptions An enum matching the relevant CxRegexOptions which are: None , SearchInComments , DoNotSearchInStringLiterals , AllowOverlaps and SearchOnlyInComments.
A list of matches for given regular expression in cho
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0). Default values relevant only from version 7.1.8.
This example demonstrate the CxList.FindByRegexExt(string, string, CxRegexOptions) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo", "*.*", RegexOptions.IgnoreCase);
The search would be only on *.cs files and the result would consist of 2 items:
Expand source
foo FOO
Supported from version 7.1.8 and 7.1.6HF5
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask, bool searchInComments)
expression Regular expression pattern.
fileMask File mask for search. Control characters "*" and "?" are supported.
For example: "." looks in all files and "*.aspx" looks in aspx files.
searchInComments Allow or not search in comments.
A list of matches for given regular expression in chosen project files including or excluding results in comments.
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0). Default values relevant only from version 7.1.8.
This example demonstrate the CxList.FindByRegexExt(string, string, bool) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo","*.cs",false);
The result would consist of 3 items:
Expand source
foo // foo /* foo
Supported from version 7.1.8 and 7.1.6HF5
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask = "*.*", CxList.CxRegexOptions cxOptions = CxList.CxRegexOptions.None, RegexOptions regularOptions = RegexOptions.None)
expression Regular expression pattern
fileMask Mask of the files to search
cxOptions Checkmarx regex options
regularOptions Options for regular expression
A list of matches for given regular expression in chosen project files including or excluding results in comments with regex build with specified options.
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0). Default values relevant only from version 7.1.8.
This example demonstrate the CxList.FindByRegexExt(string, string, CxRegexOptions, RegexOptions) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo", "*.*", CxRegexOptions.None, RegexOptions.IgnoreCase);
All files in the source code would be searched and the result would consist of 2 items:
Expand source
foo FOO
Supported from version 7.1.8 and 7.1.6HF5
None
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask = "*.*", bool searchInComments = true, RegexOptions regularOptions = RegexOptions.None)
expression Regular expression pattern.
fileMask Default value: ".".
File mask for search. Control characters "*" and "?" are supported.
For example: "." looks in all files and "*.aspx" looks in aspx files.
searchInComments Default value: true.
Allow or not search in comments.
regularOptions Default value: RegexOptions.None.
Options for regular expression build from first parameter.
A list of matches for given regular expression in chosen project files including or excluding results in comments with regex build with specified options.
ArgumentNullException : Thrown when parameter is a null reference.
The results are not related to DOM so they can't be compared to DOM objects returned by other functions. Results can't be used as parameters to other queries. The return value may be empty (Count = 0). Default values relevant only from version 7.1.8.
This example demonstrate the CxList.FindByRegexExt(string, string, bool, RegexOptions) method.
The input source code is:
Expand source
int a = 5; if (a > 3) foo(a); else FOO(a); // foo(a) /* foo */
The source code that uses CxList.FindByRegexExt method:
Expand source
result = All.FindByRegexExt(@"(\s)?foo","*.*","*.json",false,RegexOptions.IgnoreCase);
All files in the source code would be searched except the *.json files and the result would consist of 2 items:
Expand source
foo FOO
Supported from version 7.1.8 and 7.1.6HF5
Find by regular expression in all files of the project regardless of DOM and language.
Expand source
public CxList FindByRegexExt(string expression, string fileMask = "*.*", bool searchInComments = true, CxList.CxRegexOptions cxOptions = CxList.CxRegexOptions.None, RegexOptions regularOptions = RegexOptions.None)
expression Regular expression pattern.
fileMask Default value: ".".
File mask for search. Control characters "*" and "?" are supported.