//Variable does not need parsing public void TestInspectionParser11() { string variable = "variable"; parser = new InspectionParser(variable); List <string> parsedResult = parser.GetParsedCommands(); Assert.IsTrue(parser.NeedsParsing() == false); }
//Invalid variable sent for parsing public void TestInspectionParser09() { string variable = ".variable.check"; parser = new InspectionParser(variable); List <string> parsedResult = parser.GetParsedCommands(); Assert.IsTrue(parser.IsValid == false); Assert.IsTrue(parser.NeedsParsing() == true); }
public void TestInspectionParser03() { string variable = "class.property"; parser = new InspectionParser(variable); List<string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "class"); Assert.AreEqual(parsedResult[1], ".property"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }
//Class property public void TestInspectionParser03() { string variable = "class.property"; parser = new InspectionParser(variable); List <string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "class"); Assert.AreEqual(parsedResult[1], ".property"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }
public void TestInspectionParser02() { string variable = "array[0][1][2]"; parser = new InspectionParser(variable); List<string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "array"); Assert.AreEqual(parsedResult[1], "[0]"); Assert.AreEqual(parsedResult[2], "[1]"); Assert.AreEqual(parsedResult[3], "[2]"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }
//Multidimensional arrays public void TestInspectionParser02() { string variable = "array[0][1][2]"; parser = new InspectionParser(variable); List <string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "array"); Assert.AreEqual(parsedResult[1], "[0]"); Assert.AreEqual(parsedResult[2], "[1]"); Assert.AreEqual(parsedResult[3], "[2]"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }
//Class-class-array-class-multidimensional array-class-array public void TestInspectionParser08() { string variable = "classA.propertyA[3].propertyB[1][0].propertyC[1]"; parser = new InspectionParser(variable); List <string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "classA"); Assert.AreEqual(parsedResult[1], ".propertyA"); Assert.AreEqual(parsedResult[2], "[3]"); Assert.AreEqual(parsedResult[3], ".propertyB"); Assert.AreEqual(parsedResult[4], "[1]"); Assert.AreEqual(parsedResult[5], "[0]"); Assert.AreEqual(parsedResult[6], ".propertyC"); Assert.AreEqual(parsedResult[7], "[1]"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }
/// <summary> /// Method to add new inspection data to the Watch Window/ToolTip /// This method uses the CreateInspectionData method to populate the information /// </summary> /// <param name="variableName"> Name of the variable to be added </param> /// <returns> /// True - if successfully added /// False - if exception was thrown /// </returns> public bool AddInspectionData(string variableName, bool isToolTip) { inspectionToolTip = isToolTip; if (false != inspectionToolTip) dataCollection.Clear(); if (string.IsNullOrWhiteSpace(variableName)) return false; // Always leave last item as blank data InspectionData data = new InspectionData(variableName); if (dataCollection.Count == 0) dataCollection.Add(data); else dataCollection.Insert(dataCollection.Count - 1, data); // Inspection tool tip requires immediate validation. if (false != inspectionToolTip) CreateDataRecursive(data, GetStackValue(variableName)); return true; #if false if (isToolTip) { toolTips = true; dataCollection.Clear(); } if (string.IsNullOrWhiteSpace(variableName)) return false; ProtoCore.Lang.Obj stackValue = null; InspectionParser parser = new InspectionParser(variableName); variableName = variableName.Trim(); bool limit = false; int limitValue = 0; if (parser.NeedsParsing()) { List<string> parsedCommands = parser.GetParsedCommands(); if (parser.IsValid == true) { stackValue = GetParsedObject(parsedCommands, out limit); if (limit) { string val = parsedCommands[parsedCommands.Count - 1].Replace(",", string.Empty); limitValue = Convert.ToInt32(val); } } else stackValue = null; } else { stackValue = GetStackValue(variableName); } if (stackValue == null) { //Throw exceptions string n = variableName; string v = GetStackValuePayload(n); string t = GetStackValueType(n); // Always leave last item as blank data if (dataCollection.Count != 0) dataCollection.Insert(dataCollection.Count - 1, new InspectionData(n, v, t)); else dataCollection.Add(new InspectionData(n, v, t)); return false; } else { //Get actual data InspectionData inspectedData; inspectedData = CreateInspectionData(stackValue, variableName); if (dataCollection.Count != 0) dataCollection.Insert(dataCollection.Count - 1, inspectedData); else dataCollection.Add(inspectedData); return true; } #endif }
/// <summary> /// This method is hit on one condition: the variable CAN be expanded by pressing the [+] /// symbol in the watch window. This means some sort of expansion should replace the silly old /// 'This is dummy' and populate it. This method goes about populating the selectedData.Derivations /// for arrays and classes (which are the only expandable variables in a watch window). /// For arrays, this method also tests if the array is larger than a certain value, indicating to /// the user that it may take some time to expand. /// </summary> /// <param name="selectedData"> InspectionData object of the variable that is to be expanded</param> public void ExpandInspection(InspectionData selectedData) { selectedData.IsExpanded = true; string qualifiedName = selectedData.GetQualifiedName(); ProtoCore.Lang.Obj stackValue = GetStackValue(qualifiedName); CreateDataRecursive(selectedData, stackValue); #if false ProtoCore.Lang.Obj dataObj = null; // Use Inspection Parser to parse the string to decipher what kind of expansion required InspectionParser parser = new InspectionParser(selectedData.Name); bool limit = false; int limitValue = 0; List<string> parsedCommands = null; // An inspection variable needs parsing when it contains: // [] (array) and/or // '.' (class properties) and/or // ',' (limit) if (parser.NeedsParsing()) { parsedCommands = parser.GetParsedCommands(); if (parser.IsValid == true) { // Use GetParsedObject method to decipher Obj from parsed string dataObj = GetParsedObject(parsedCommands, out limit); // A limit is indicated by a comma (,) if (limit) { // The limit should ALWAYS be the last item in parsed commands string val = parsedCommands[parsedCommands.Count - 1].Replace(",", string.Empty); limitValue = Convert.ToInt32(val); } } else dataObj = null; } else { dataObj = GetInnerInspectionObject(selectedData); } // If, from any level above the dataObj is null, throw an exception if (dataObj == null) { //Throw exceptions string n = selectedData.Name; string v = GetStackValuePayload(n); string t = GetStackValueType(n); // Replace the current data with the exceptions relevant for it RemoveInspectionData(selectedData); dataCollection.Insert(dataCollection.Count - 1, new InspectionData(n, v, t)); } // Otherwise expand it by one more level yo! else { if (selectedData.Type == "array") ExpandArrayInspectionData(selectedData, limit); else ExpandClassInspectionData(selectedData); } #endif }
public void TestInspectionParser11() { string variable = "variable"; parser = new InspectionParser(variable); List<string> parsedResult = parser.GetParsedCommands(); Assert.IsTrue(parser.NeedsParsing() == false); }
public void TestInspectionParser09() { string variable = ".variable.check"; parser = new InspectionParser(variable); List<string> parsedResult = parser.GetParsedCommands(); Assert.IsTrue(parser.IsValid == false); Assert.IsTrue(parser.NeedsParsing() == true); }
public void TestInspectionParser08() { string variable = "classA.propertyA[3].propertyB[1][0].propertyC[1]"; parser = new InspectionParser(variable); List<string> parsedResult = parser.GetParsedCommands(); Assert.AreEqual(parsedResult[0], "classA"); Assert.AreEqual(parsedResult[1], ".propertyA"); Assert.AreEqual(parsedResult[2], "[3]"); Assert.AreEqual(parsedResult[3], ".propertyB"); Assert.AreEqual(parsedResult[4], "[1]"); Assert.AreEqual(parsedResult[5], "[0]"); Assert.AreEqual(parsedResult[6], ".propertyC"); Assert.AreEqual(parsedResult[7], "[1]"); Assert.IsTrue(parser.IsValid == true); Assert.IsTrue(parser.NeedsParsing() == true); }