Esempio n. 1
0
        public bool Contains(XRefIdentifer aIdentifier)
        {
            bool ret = false;

            //
            foreach (XRefIdentifer identifier in iIdentifiers)
            {
                if (identifier.Identifier == aIdentifier.Identifier)
                {
                    ret = true;
                    break;
                }
            }
            //
            return(ret);
        }
Esempio n. 2
0
        public void Launch(XRefIdentifer aIdentifier, XRefSettings aSettings)
        {
            string url = aSettings.ServerRootPath + "ident?i=" + aIdentifier.Identifier;

            System.Diagnostics.Process.Start(url);
        }
        private static List <XRefIdentifer> ExtractSearchableElements(string aFunction)
        {
            List <string> workingData = new List <string>();

            // See if this entry contains parameter data?
            if (ContainsParameters(aFunction))
            {
                // This call modifies aFunction so that the parameters are removed
                string parameters = ExtractParameters(ref aFunction);

                // Now we get the individual parameter elements from the arguments
                SplitParameters(parameters, ref workingData);
            }

            // Extract class & method names if present
            string[] classAndMethodData = aFunction.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
            if (classAndMethodData.Length > 0)
            {
                foreach (string identifiedEntry in classAndMethodData)
                {
                    workingData.Add(identifiedEntry);
                }
            }
            else
            {
                // Not a class & method - so just take the entire text as a
                // global function name
                workingData.Add(aFunction);
            }

            // Recursively check for any more class types, e.g. in the following entry:
            //
            // CServer2::CServer2__sub_object(int, CServer2::TServerType)
            //
            // We also need to extract CServer2 and TServerType as individual elements
            for (int i = workingData.Count - 1; i >= 0; i--)
            {
                string   entry        = workingData[i];
                string[] furtherSplit = IdentifyFurtherClassAndMethodInformation(entry);
                if (furtherSplit != null && furtherSplit.Length > 1)
                {
                    foreach (string furtherEntry in furtherSplit)
                    {
                        workingData.Add(furtherEntry);
                    }

                    // Remove defunct entry
                    workingData.RemoveAt(i);
                }
            }

            // Clean up phase
            List <string> cleanedEntries = new List <string>();

            foreach (string identifiedEntry in workingData)
            {
                string entry = identifiedEntry;

                // Now go through the identified entries and ensure they don't include
                // any pointer (*), reference (&) or bracketry.
                int pos = entry.IndexOfAny(new char[] { '*', '+', '&', '[', ']', '<', '>', '(', ')' });
                if (pos >= 0)
                {
                    entry = entry.Substring(0, pos);
                }

                // Strip any reserved keywords
                if (entry.Length > 0)
                {
                    entry = entry.Replace("const", string.Empty);
                    entry = entry.Replace("static", string.Empty);
                    entry = entry.Replace("public", string.Empty);
                    entry = entry.Replace("protected", string.Empty);
                    entry = entry.Replace("private", string.Empty);
                    entry = entry.Replace("__sub_object", string.Empty);
                    //
                    if (!cleanedEntries.Contains(entry))
                    {
                        cleanedEntries.Add(entry.Trim());
                    }
                }
            }

            // Convert to XRefIdentifiers
            List <XRefIdentifer> finalEntries = new List <XRefIdentifer>();

            foreach (string cleanedEntry in cleanedEntries)
            {
                XRefIdentifer item = new XRefIdentifer(cleanedEntry);
                finalEntries.Add(item);
            }
            //
            return(finalEntries);
        }