Ejemplo n.º 1
0
 /**
  * Checks a global function to determine if it is the main() function.
  *
  * @param element the function handle to be checked.
  */
 private void CheckForMain(VCCodeFunction function)
 {
     if (function.Name == "main")
     {
         mainExists = true;
     }
 }
Ejemplo n.º 2
0
            public IClassMethodElement GetMethodFromFilePos(int lineNum, int linePos)
            {
                VCCodeFunction targetFunc = GetMethodFromFilePos(projItem.FileCodeModel, lineNum, linePos);

                if (targetFunc != null)
                {
                    ClassMethodElement method = new ClassMethodElement(targetFunc, this);
                    return(method);
                }

                return(null);
            }
        public TestSuiteGenerator(HierarchyItem project,
			string suiteName, HierarchyItem headerUnderTest,
			string superclass, bool createSetUp, bool createTearDown,
			VCCodeFunction[] functions)
        {
            this.project = project;
            this.suiteName = suiteName;
            this.headerUnderTest = headerUnderTest;
            this.superclass = superclass;
            this.createSetUp = createSetUp;
            this.createTearDown = createTearDown;
            this.functions = functions;

            GenerateUniqueStubNames();
        }
Ejemplo n.º 4
0
        private bool IsElementAcceptableType(VCCodeElement element)
        {
            switch (element.Kind)
            {
            case vsCMElement.vsCMElementFunction:
                VCCodeFunction function = (VCCodeFunction)element;

                if (element.Name.StartsWith("~") ||
                    function.Access != vsCMAccess.vsCMAccessPublic)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            case vsCMElement.vsCMElementClass:
                VCCodeClass klass = (VCCodeClass)element;

                if (klass.Access != vsCMAccess.vsCMAccessPublic)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            case vsCMElement.vsCMElementNamespace:
                return(true);

            case vsCMElement.vsCMElementStruct:
                VCCodeStruct strukt = (VCCodeStruct)element;

                if (strukt.Access != vsCMAccess.vsCMAccessPublic)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            default:
                return(false);
            }
        }
Ejemplo n.º 5
0
            private VCCodeFunction GetMethodFromFilePos(FileCodeModel fcm, int lineNum, int linePos)
            {
                if (fcm == null)
                {
                    return(null);
                }
                foreach (CodeElement codeElem in fcm.CodeElements)
                {
                    VCCodeFunction theMethod = GetMethodFromFilePos(codeElem, lineNum, linePos);
                    if (theMethod != null)
                    {
                        return(theMethod);
                    }
                }

                return(null);
            }
Ejemplo n.º 6
0
        /**
         * A convenience function to check if a function takes no arguments
         * (CDT's DOM treats a function with no arguments differently from one
         * with a single "void" argument).
         *
         * @param element the method handle to check.
         *
         * @return true if the function has no arguments; otherwise, false.
         */
        private bool IsMethodParameterless(VCCodeFunction function)
        {
            if (function.Parameters.Count == 0)
            {
                return(true);
            }
            else if (function.Parameters.Count > 1)
            {
                return(false);
            }
            else
            {
                VCCodeParameter parameter =
                    (VCCodeParameter)function.Parameters.Item(1);

                return(parameter.Type.AsString == "void");
            }
        }
Ejemplo n.º 7
0
            private VCCodeFunction GetMethodFromFilePos(CodeElement codeElem, int lineNum, int linePos)
            {
                if (codeElem.Kind == vsCMElement.vsCMElementFunction)
                {
                    VCCodeFunction targetFunc = codeElem as VCCodeFunction;
                    if (targetFunc != null)
                    {
                        TextPoint startFuncBody = targetFunc.StartPointOf[vsCMPart.vsCMPartBody, vsCMWhere.vsCMWhereDefinition];
                        TextPoint endFuncBody   = targetFunc.EndPointOf[vsCMPart.vsCMPartBody, vsCMWhere.vsCMWhereDefinition];
                        EditPoint startPnt      = startFuncBody.CreateEditPoint();
                        EditPoint endPnt        = endFuncBody.CreateEditPoint();
                        startPnt.FindPattern("{", (int)vsFindOptions.vsFindOptionsBackwards);
                        endPnt.FindPattern("}");
                        if ((lineNum > startPnt.Line && lineNum < endPnt.Line) ||
                            (lineNum == startPnt.Line && linePos >= startPnt.LineCharOffset) ||
                            (lineNum == endPnt.Line && linePos <= endPnt.LineCharOffset))
                        {
                            return(targetFunc);
                        }
                    }

                    //if ((lineNum > codeElem.StartPoint.Line && lineNum < codeElem.EndPoint.Line) ||
                    //  (lineNum == codeElem.StartPoint.Line && linePos >= codeElem.StartPoint.LineCharOffset) ||
                    //  (lineNum == codeElem.EndPoint.Line && linePos <= codeElem.EndPoint.LineCharOffset))
                    //{
                    //  VCCodeFunction targetFunc = (VCCodeFunction)codeElem;
                    //  if (targetFunc != null)
                    //    return targetFunc;
                    //}
                }
                else
                {
                    foreach (CodeElement classCodeElem in codeElem.Children)
                    {
                        VCCodeFunction theMethod = GetMethodFromFilePos(classCodeElem, lineNum, linePos);
                        if (theMethod != null)
                        {
                            return(theMethod);
                        }
                    }
                }

                return(null);
            }
Ejemplo n.º 8
0
        /**
         * Checks a method inside a test suite class to determine if it
         * is a valid test method (void return value, no arguments, name
         * begins with "test"). If so, it is added to the suite's list of
         * tests.
         *
         * @param element the method handle to be checked.
         */
        private void CheckMethod(VCCodeFunction function)
        {
            string name     = function.Name;
            int    lineNum  = function.StartPoint.Line;
            bool   isStatic = function.IsShared;

            if (name.StartsWith("Test") || name.StartsWith("test"))
            {
                if (function.Type.AsString == "void" &&
                    IsMethodParameterless(function))
                {
                    testCases.Add(new TestCase(function));
                }
            }
            else if (name == "createSuite")
            {
                if (isStatic &&
                    function.Type.AsString.IndexOf('*') >= 0 &&
                    IsMethodParameterless(function))
                {
                    createLineNumber = lineNum;
                }
            }
            else if (name == "destroySuite")
            {
                CodeElements parameters = function.Parameters;

                if (parameters.Count == 1)
                {
                    VCCodeParameter parameter =
                        (VCCodeParameter)parameters.Item(1);

                    if (isStatic &&
                        parameter.Type.AsString.IndexOf('*') >= 0 &&
                        function.Type.AsString == "void")
                    {
                        destroyLineNumber = lineNum;
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public void CalcInjectionPoints(CPClassLayout cpClassLayout, CPTraceVar traceVar, bool needDeclare)
 {
     if (needDeclare)
     {
         // find all places, where this file included
         CodeElement theFunc = null;
         // find & store all constructors init points of this class
         foreach (CodeElement _func in ent.Functions)
         {
             if (_func.Name == ent.Name)
             {
                 theFunc = _func;
                 VCCodeFunction vcFunc = (VCCodeFunction)_func;
                 EditPoint      pnt    = _func.StartPoint.CreateEditPoint();
                 if (pnt.FindPattern("{"))
                 {
                     traceVar.traceVarInitPos.Add(new FilePosPnt()
                     {
                         fileName = _func.ProjectItem.Name,
                         pos      = { lineNum = pnt.Line - 1, linePos = pnt.LineCharOffset }
                     });
                 }
             }
         }
         // if no constructor found add default one
         if (traceVar.traceVarInitPos.Count == 0)
         {
             EditPoint pnt = ent.StartPoint.CreateEditPoint();
             if (pnt.FindPattern("{"))
             {
                 traceVar.injConstructorPos = new FilePosPnt()
                 {
                     fileName = ent.ProjectItem.Name,
                     pos      = { lineNum = pnt.Line - 1, linePos = pnt.LineCharOffset }
                 };
             }
         }
     }
 }
        private TreeNode FindNodeForTestCase(object parent, VCCodeFunction function)
        {
            TreeNode suiteNode = FindNodeForTestSuite(parent);

            if (suiteNode == null)
            {
                return(null);
            }

            string testName = ((CodeElement2)function).Name;

            foreach (TreeNode testNode in suiteNode.Nodes)
            {
                TestCase testCase = (TestCase)testNode.Tag;
                if (testCase.Name == testName)
                {
                    return(testNode);
                }
            }

            return(null);
        }
        public void DeleteElement(object parent, CodeElement element)
        {
            if (element is VCCodeClass || element is VCCodeStruct)
            {
                TreeNode node = FindNodeForTestSuite(element);

                if (node != null)
                {
                    node.Remove();
                }
            }
            else if (element is VCCodeFunction)
            {
                VCCodeFunction function = (VCCodeFunction)element;

                TreeNode node = FindNodeForTestCase(parent, function);

                if (node != null)
                {
                    node.Remove();
                }
            }
        }
        public void AddElement(CodeElement element)
        {
            if (testsTreeView.Nodes.Count == 0)
            {
                return;
            }

            if (element is VCCodeClass || element is VCCodeStruct)
            {
                TestSuiteCollector collector = new TestSuiteCollector();
                collector.Process(element);

                foreach (TestSuite suite in collector.Suites)
                {
                    AddTestSuiteToNode(suite, testsTreeView.Nodes[0], null);
                }

                testsTreeView.Sort();
            }
            else if (element is VCCodeFunction)
            {
                VCCodeFunction function = (VCCodeFunction)element;

                TreeNode suiteNode = FindNodeForTestSuite(function.Parent);

                TestCaseCollector collector = new TestCaseCollector();
                collector.Process((CodeElement)function);

                foreach (TestCase testCase in collector.TestCases)
                {
                    AddTestCaseToNode((TestSuite)suiteNode.Tag, testCase, suiteNode, null);
                }

                testsTreeView.Sort();
            }
        }
Ejemplo n.º 13
0
            public ICheckCPPoint CheckCursorPos()
            {
                ICheckCPPoint checkPnt  = null;
                Document      activeDoc = ChartPoints.Globals.dte.ActiveDocument;
                string        projName  = activeDoc.ProjectItem.ContainingProject.Name;
                TextSelection sel       = (TextSelection)activeDoc.Selection;
                TextPoint     caretPnt  = (TextPoint)sel.ActivePoint;
                VCCodeElement targetClassElem;

                for (;;)
                {
                    // checks if we are in text document
                    if (activeDoc == null)
                    {
                        break;
                    }
                    var textDoc = activeDoc.Object() as TextDocument;
                    if (textDoc == null)
                    {
                        break;
                    }
                    // we work only with project items
                    ProjectItem projItem = activeDoc.ProjectItem;
                    if (projItem == null)
                    {
                        break;
                    }
                    // only c++ items
                    FileCodeModel fcModel = projItem.FileCodeModel;
                    if (fcModel == null)
                    {
                        break;
                    }
                    if (fcModel.Language != CodeModelLanguageConstants.vsCMLanguageVC)
                    {
                        break;
                    }
                    vcCodeModel.Synchronize();// !!! MOVE TO METHOD ???
                    // chartpoint allowed only in class methods
                    CodeElement elem = fcModel.CodeElementFromPoint(caretPnt, vsCMElement.vsCMElementFunction);
                    if (elem == null)
                    {
                        break;
                    }
                    if (elem.Kind != vsCMElement.vsCMElementFunction)
                    {
                        break;
                    }
                    VCCodeFunction targetFunc = (VCCodeFunction)elem;
                    if (targetFunc == null)
                    {
                        break;
                    }
                    // check that we are in method definition (not declaration) in case of declaration in one file & definition in other
                    if (!targetFunc.File.Equals(activeDoc.FullName, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                    // we are working only with class methods not global function
                    targetFunc.CodeModel.Synchronize();
                    targetFunc.CodeModel.SynchronizeFiles();
                    foreach (CodeElement _cl in targetFunc.CodeModel.Classes)
                    {
                        foreach (CodeElement _f in _cl.Children)
                        {
                            if (targetFunc.FullName.Equals(_f.FullName, StringComparison.OrdinalIgnoreCase))
                            {
                                targetFunc = (VCCodeFunction)_f;
                                break;
                            }
                        }
                    }
                    targetClassElem = (VCCodeElement)targetFunc.Parent;
                    if (targetClassElem == null)
                    {
                        break;
                    }
                    if (targetClassElem.Kind != vsCMElement.vsCMElementClass)
                    {
                        targetClassElem = null;
                        break;
                    }
                    VCCodeClass ownerClass = (VCCodeClass)targetClassElem;

                    TextPoint startFuncBody = targetFunc.StartPointOf[vsCMPart.vsCMPartBody, vsCMWhere.vsCMWhereDefinition];
                    TextPoint endFuncBody   = targetFunc.EndPointOf[vsCMPart.vsCMPartBody, vsCMWhere.vsCMWhereDefinition];
                    EditPoint startPnt      = startFuncBody.CreateEditPoint();
                    EditPoint endPnt        = endFuncBody.CreateEditPoint();
                    startPnt.FindPattern("{", (int)vsFindOptions.vsFindOptionsBackwards);
                    endPnt.FindPattern("}");
                    if ((caretPnt.Line > startPnt.Line && caretPnt.Line < endPnt.Line) ||
                        (caretPnt.Line == startPnt.Line && caretPnt.LineCharOffset >= startPnt.LineCharOffset) ||
                        (caretPnt.Line == endPnt.Line && caretPnt.LineCharOffset <= endPnt.LineCharOffset))
                    {
                        // Oh, oh you're in the body, now.. (c)
                        int linePos = (caretPnt.Line == startPnt.Line ? startPnt.LineCharOffset + 1 : 1 /*0*/);
                        checkPnt = new CheckCPPoint(ownerClass, projName, activeDoc.Name, System.IO.Path.GetFullPath(activeDoc.FullName).ToLower(), caretPnt.Line, linePos);

                        return(checkPnt);
                    }
                    break;
                }

                return(checkPnt);
            }
        /**
         * A convenience function to check if a function takes no arguments
         * (CDT's DOM treats a function with no arguments differently from one
         * with a single "void" argument).
         *
         * @param element the method handle to check.
         *
         * @return true if the function has no arguments; otherwise, false.
         */
        private bool IsMethodParameterless(VCCodeFunction function)
        {
            if (function.Parameters.Count == 0)
            {
                return true;
            }
            else if (function.Parameters.Count > 1)
            {
                return false;
            }
            else
            {
                VCCodeParameter parameter =
                    (VCCodeParameter)function.Parameters.Item(1);

                return (parameter.Type.AsString == "void");
            }
        }
Ejemplo n.º 15
0
 //~ Constructor ......................................................
 // ------------------------------------------------------
 /// <summary>
 /// Creates a new test case from the specified code model function.
 /// </summary>
 /// <param name="function">
 /// The VC code model function object from which to create the test
 /// case.
 /// </param>
 public TestCase(VCCodeFunction function)
 {
     this.function = function;
 }
        /**
         * Checks a method inside a test suite class to determine if it
         * is a valid test method (void return value, no arguments, name
         * begins with "test"). If so, it is added to the suite's list of
         * tests.
         *
         * @param element the method handle to be checked.
         */
        private void CheckMethod(VCCodeFunction function)
        {
            string name = function.Name;
            int lineNum = function.StartPoint.Line;
            bool isStatic = function.IsShared;

            if (name.StartsWith("Test") || name.StartsWith("test"))
            {
                if (function.Type.AsString == "void" &&
                    IsMethodParameterless(function))
                {
                    testCases.Add(new TestCase(function));
                }
            }
            else if (name == "createSuite")
            {
                if (isStatic &&
                    function.Type.AsString.IndexOf('*') >= 0 &&
                    IsMethodParameterless(function))
                {
                    createLineNumber = lineNum;
                }
            }
            else if (name == "destroySuite")
            {
                CodeElements parameters = function.Parameters;

                if (parameters.Count == 1)
                {
                    VCCodeParameter parameter =
                        (VCCodeParameter)parameters.Item(1);

                    if (isStatic &&
                        parameter.Type.AsString.IndexOf('*') >= 0 &&
                        function.Type.AsString == "void")
                    {
                        destroyLineNumber = lineNum;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        //~ Constructor ......................................................

        // ------------------------------------------------------
        /// <summary>
        /// Creates a new test case from the specified code model function.
        /// </summary>
        /// <param name="function">
        /// The VC code model function object from which to create the test
        /// case.
        /// </param>
        public TestCase(VCCodeFunction function)
        {
            this.function = function;
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            try
            {
                if (VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider))
                {
                    return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
                }

                // make a copy of this so we can look at it after forwarding some commands
                uint commandID = nCmdID;
                char typedChar = char.MinValue;

                // make sure the input is a char before getting it
                if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
                {
                    typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
                }

                // check for the triple slash
                if (typedChar == '!' && m_dte != null)
                {
                    var currentILine = m_textView.TextSnapshot.GetLineFromPosition(
                        m_textView.Caret.Position.BufferPosition.Position);
                    int    len             = m_textView.Caret.Position.BufferPosition.Position - currentILine.Start.Position;
                    string currentLine     = m_textView.TextSnapshot.GetText(currentILine.Start.Position, len);
                    string currentLineFull = currentILine.GetText();

                    if ((currentLine + typedChar).Trim() == "/*!")
                    {
                        // Calculate how many spaces
                        string        spaces    = currentLine.Replace(currentLine.TrimStart(), "");
                        TextSelection ts        = m_dte.ActiveDocument.Selection as TextSelection;
                        int           oldLine   = ts.ActivePoint.Line;
                        int           oldOffset = ts.ActivePoint.LineCharOffset;

                        if (!currentLineFull.Contains("*/"))
                        {
                            ts.Insert("*/");
                        }
                        ts.LineDown();
                        ts.EndOfLine();

                        CodeElement   codeElement = null;
                        FileCodeModel fcm         = m_dte.ActiveDocument.ProjectItem.FileCodeModel;
                        if (fcm != null)
                        {
                            while (codeElement == null)
                            {
                                codeElement = fcm.CodeElementFromPoint(ts.ActivePoint, vsCMElement.vsCMElementFunction);

                                if (codeElement == null)
                                {
                                    ts.LineDown();
                                }
                            }
                        }

                        var cls  = codeElement as VCCodeClass;
                        var cls2 = codeElement as CodeClass;
                        var fnc  = codeElement as VCCodeFunction;

                        var kind = codeElement.Kind;

                        if (codeElement != null && codeElement is CodeFunction)
                        {
                            VCCodeFunction function = codeElement as VCCodeFunction;
                            StringBuilder  sb       = new StringBuilder("!\r\n" + spaces + " * \r\n" + spaces + " * ");
                            foreach (CodeElement child in codeElement.Children)
                            {
                                CodeParameter parameter = child as CodeParameter;
                                if (parameter != null)
                                {
                                    sb.AppendFormat("\r\n" + spaces + " * \\param {0}", parameter.Name);
                                }
                            }

                            if (function.Type.AsString != "void")
                            {
                                sb.AppendFormat("\r\n" + spaces + " * \\return ");
                            }

                            sb.AppendFormat("\r\n" + spaces + " ");

                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.Insert(sb.ToString());
                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.LineDown();
                            ts.EndOfLine();
                            return(VSConstants.S_OK);
                        }
                        else if (codeElement != null && codeElement is VCCodeClass)
                        {
                            VCCodeClass   function = codeElement as VCCodeClass;
                            StringBuilder sb       = new StringBuilder("!\r\n" + spaces + " * \r\n" + spaces + " * ");

                            foreach (CodeElement child in function.TemplateParameters)
                            {
                                CodeParameter parameter = child as CodeParameter;
                                if (parameter != null)
                                {
                                    sb.AppendFormat("\r\n" + spaces + " * \\tparam {0}", parameter.Name);
                                }
                            }

                            sb.AppendFormat("\r\n" + spaces + " ");

                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.Insert(sb.ToString());
                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.LineDown();
                            ts.EndOfLine();
                            return(VSConstants.S_OK);
                        }
                        else
                        {
                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.Insert("!\r\n" + spaces + " * \r\n" + spaces + " * \r\n" + spaces + " ");
                            ts.MoveToLineAndOffset(oldLine, oldOffset);
                            ts.LineDown();
                            ts.EndOfLine();
                            return(VSConstants.S_OK);
                        }
                    }
                }

                if (m_session != null && !m_session.IsDismissed)
                {
                    // check for a commit character

                    if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN ||
                        nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB)
                    {
                        // check for a selection
                        // if the selection is fully selected, commit the current session
                        if (m_session.SelectedCompletionSet.SelectionStatus.IsSelected)
                        {
                            string selectedCompletion = m_session.SelectedCompletionSet.SelectionStatus.Completion.DisplayText;
                            m_session.Commit();

                            // also, don't add the character to the buffer
                            return(VSConstants.S_OK);
                        }
                        else
                        {
                            // if there is no selection, dismiss the session
                            m_session.Dismiss();
                        }
                    }
                }
                else
                {
                    if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN)
                    {
                        string currentLine = m_textView.TextSnapshot.GetLineFromPosition(
                            m_textView.Caret.Position.BufferPosition.Position).GetText();
                        if (currentLine.TrimStart().StartsWith("*"))
                        {
                            TextSelection ts     = m_dte.ActiveDocument.Selection as TextSelection;
                            string        spaces = currentLine.Replace(currentLine.TrimStart(), "");
                            ts.Insert("\r\n" + spaces + "* ");
                            return(VSConstants.S_OK);
                        }
                    }
                }

                // pass along the command so the char is added to the buffer
                int retVal = m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                if (typedChar == '\\')
                {
                    string currentLine = m_textView.TextSnapshot.GetLineFromPosition(
                        m_textView.Caret.Position.BufferPosition.Position).GetText();
                    if (currentLine.TrimStart().StartsWith("*"))
                    {
                        if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion
                        {
                            if (this.TriggerCompletion())
                            {
                                m_session.SelectedCompletionSet.SelectBestMatch();
                                m_session.SelectedCompletionSet.Recalculate();
                                return(VSConstants.S_OK);
                            }
                        }
                    }
                }
                else if (
                    commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE ||
                    commandID == (uint)VSConstants.VSStd2KCmdID.DELETE ||
                    char.IsLetter(typedChar))
                {
                    if (m_session != null && !m_session.IsDismissed) // the completion session is already active, so just filter
                    {
                        m_session.SelectedCompletionSet.SelectBestMatch();
                        m_session.SelectedCompletionSet.Recalculate();
                        return(VSConstants.S_OK);
                    }
                }

                return(retVal);
            }
            catch
            {
            }

            return(VSConstants.E_FAIL);
        }
        private TreeNode FindNodeForTestCase(object parent, VCCodeFunction function)
        {
            TreeNode suiteNode = FindNodeForTestSuite(parent);

            if (suiteNode == null)
                return null;

            string testName = ((CodeElement2)function).Name;

            foreach (TreeNode testNode in suiteNode.Nodes)
            {
                TestCase testCase = (TestCase)testNode.Tag;
                if (testCase.Name == testName)
                    return testNode;
            }

            return null;
        }
 /**
  * Checks a global function to determine if it is the main() function.
  *
  * @param element the function handle to be checked.
  */
 private void CheckForMain(VCCodeFunction function)
 {
     if (function.Name == "main")
         mainExists = true;
 }