Esempio n. 1
0
        public static void WritePdbAnnotations(IndexerState state, string pdbStrPath)
        {
            foreach (var file in state.SymbolFiles.Values)
            {
                var tmpFile = Path.GetFullPath(Path.GetTempFileName());
                try
                {
                    using (var sw = File.CreateText(tmpFile))
                    {
                        if (!WriteAnnotations(file, sw))
                            continue; // Temp file is deleted in finally
                    }

                    var psi = new ProcessStartInfo(pdbStrPath)
                    {
                        Arguments = string.Format("-w -s:srcsrv -p:\"{0}\" -i:\"{1}\"", file.FullName, tmpFile),
                        UseShellExecute = false,
                        RedirectStandardError = true,
                        RedirectStandardOutput = true
                    };

                    using (var p = Process.Start(psi))
                    {
                        p.StandardOutput.ReadToEnd();
                        p.StandardError.ReadToEnd();

                        p.WaitForExit();
                    }
                }
                finally
                {
                    File.Delete(tmpFile);
                }
            }
        }
Esempio n. 2
0
        public static void WritePdbAnnotations(IndexerState state, string pdbStrPath)
        {
            foreach (SymbolFile file in state.SymbolFiles.Values)
            {
                string tmpFile = Path.GetFullPath(Path.GetTempFileName());
                try
                {
                    using (StreamWriter sw = File.CreateText(tmpFile))
                    {
                        sw.NewLine = "\n";
                        if (!WriteAnnotations(state, file, sw))
                            continue; // Temp file is deleted in finally
                    }

                    ProcessStartInfo psi = new ProcessStartInfo(pdbStrPath);
                    psi.Arguments = string.Format("-w -s:srcsrv -p:\"{0}\" -i:\"{1}\"", file.FullName, tmpFile);
                    psi.UseShellExecute = false;

                    psi.RedirectStandardError = true;
                    psi.RedirectStandardOutput = true;
                    using (Process p = Process.Start(psi))
                    {
                        p.StandardOutput.ReadToEnd();
                        p.StandardError.ReadToEnd();

                        p.WaitForExit();
                    }
                }
                finally
                {
                    File.Delete(tmpFile);
                }
            }
        }
Esempio n. 3
0
        public IndexerResult Exec()
        {
            var state = new IndexerState();

            foreach (var symbolFile in this.SymbolFiles.Select(pdbFile => new SymbolFile(pdbFile)))
            {
                if (!symbolFile.Exists)
                {
                    throw new FileNotFoundException("Symbol file not found", symbolFile.FullName);
                }

                state.SymbolFiles.Add(symbolFile.FullName, symbolFile);
            }

            this.ReadSourceFilesFromPdbs(state);             // Check if there are files to index for this pdb file

            state.ResolverData = this.ResolverData;

            this.LoadProviders(state);
            ResolveFiles(state);

            this.WritePdbAnnotations(state);

            return(CreateResultData(state));
        }
Esempio n. 4
0
 void UpdateFeedbackText()
 {
     if (indexerState == IndexerState.Unfocused)
     {
         feedbackText.text = "Press L-CTRL to Index";
     }
     else if (indexerState == IndexerState.Focused)
     {
         if (nameField.text == "")
         {
             feedbackText.text = "Enter Name";
         }
         else if (typeField.text.ToLower() != "place" && typeField.text.ToLower() != "character" && typeField.text.ToLower() != "item")
         {
             feedbackText.text = "Enter Type";
         }
         else if (locationField.text == "")
         {
             // TODO: check if enter location exists!
             feedbackText.text = "Enter location or '-'";
         }
         else if (descriptionField.text == "")
         {
             feedbackText.text = "Enter description then press ENTER";
         }
         else
         {
             feedbackText.text = "Press LCTRL to save or overwrite!";
             indexerState      = IndexerState.ReadyToSave;
         }
     }
 }
Esempio n. 5
0
 void ResolveFiles(IndexerState state)
 {
     foreach (SourceResolver sp in state.Resolvers)
     {
         sp.ResolveFiles();
     }
 }
Esempio n. 6
0
 private static void ResolveFiles(IndexerState state)
 {
     foreach (var sp in state.Resolvers)
     {
         sp.ResolveFiles();
     }
 }
Esempio n. 7
0
        protected SourceProvider(IndexerState state, string name)
        {
            if (state == null)
                throw new ArgumentNullException("state");

            this.state = state;
            this.Id = state.AssignId(this, name);
        }
        /// <summary>
        /// Initializes a new <see cref="SourceProvider"/> with the specified name
        /// </summary>
        /// <param name="state"></param>
        /// <param name="name"></param>
        /// <remarks>Generates a unique <see cref="Id"/> by stripping invalid chars of the name, and making it unique by adding extra characters</remarks>
        protected SourceProvider(IndexerState state, string name)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            _state = state;
            _id    = name;
        }
Esempio n. 9
0
        protected SourceProvider(IndexerState state, string name)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            this.state = state;
            this.Id    = state.AssignId(this, name);
        }
Esempio n. 10
0
    void OpenIndexer()
    {
        nameField.readOnly        = false;
        typeField.readOnly        = false;
        locationField.readOnly    = false;
        descriptionField.readOnly = false;
        justStartedIndexing       = true;
        indexerState = IndexerState.Focused;
        GetComponent <Image>().sprite = hiSprite;
        nameField.ActivateInputField();

        UpdateFeedbackText();
    }
Esempio n. 11
0
        IndexerResult CreateResultData(IndexerState state)
        {
            int nSources = 0;

            foreach (SourceFile sf in state.SourceFiles.Values)
            {
                if (sf.SourceReference != null)
                {
                    nSources++;
                }
            }

            return(new IndexerResult(true, state.SymbolFiles.Count, nSources, state.SourceFiles.Count, state.Resolvers.Count));
        }
Esempio n. 12
0
 void CloseIndexer()
 {
     nameField.readOnly            = true;
     typeField.readOnly            = true;
     locationField.readOnly        = true;
     descriptionField.readOnly     = true;
     GetComponent <Image>().sprite = loSprite;
     chapterContentField.ActivateInputField();
     //   chapterContentField.text = chapterText + nameField.text;
     nameField.text        = "";
     typeField.text        = "";
     locationField.text    = "";
     descriptionField.text = "";
     indexerState          = IndexerState.Unfocused;
     UpdateFeedbackText();
 }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexerResult Exec()
        {
            Uri    codeBase = new Uri(typeof(SourceServerIndexer).Assembly.CodeBase);
            string myDir    = Path.GetDirectoryName(codeBase.LocalPath);

            _srcToolPath = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "srctool.exe"));
            _pdbStrPath  = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "pdbstr.exe"));

            if (!File.Exists(_srcToolPath))
            {
                throw new FileNotFoundException("SRCTOOL.EXE not found", _srcToolPath);
            }
            if (!File.Exists(_srcToolPath))
            {
                throw new FileNotFoundException("PDBSTR.EXE not found", _pdbStrPath);
            }

            IndexerState state = new IndexerState();

            foreach (string pdbFile in SymbolFiles)
            {
                SymbolFile symbolFile = new SymbolFile(pdbFile);

                if (!symbolFile.Exists)
                {
                    throw new FileNotFoundException(string.Format("Symbol {0} file not found", symbolFile.FullName), symbolFile.FullName);
                }

                state.SymbolFiles.Add(symbolFile.FullName, symbolFile);
            }

            ReadSourceFilesFromPdbs(state); // Check if there are files to index for this pdb file

            PerformExclusions(state);

            ResolveFiles(state);

            WritePdbAnnotations(state);

            return(CreateResultData(state));
        }
Esempio n. 14
0
        private void LoadProviders(IndexerState state)
        {
            var providers = new List <SourceResolver>();

            foreach (var provider in this.Providers)
            {
                Type providerType;
                try
                {
                    providerType = Type.GetType(provider, true, true);
                }
                catch (Exception e)
                {
                    throw new SourceIndexException(string.Format("Can't load provider '{0}'", provider), e);
                }

                if (!typeof(SourceResolver).IsAssignableFrom(providerType) || providerType.IsAbstract)
                {
                    throw new SourceIndexException(string.Format("Provider '{0}' is not a valid SourceProvider", providerType.FullName));
                }

                try
                {
                    providers.Add((SourceResolver)Activator.CreateInstance(providerType, new object[] { state }));
                }
                catch (Exception e)
                {
                    throw new SourceIndexException(string.Format("Can't initialize provider '{0}'", providerType.FullName), e);
                }
            }

            foreach (var sp in from sp in providers
                     let detector = sp as ISourceProviderDetector
                                    where (detector != null) && !state.Resolvers.Contains(sp)
                                    where sp.Available && detector.CanProvideSources(state)
                                    select sp)
            {
                state.Resolvers.Add(sp);
            }
        }
Esempio n. 15
0
    void SaveFromIndexer()
    {
        // overwrite if exists. otherwise save new.
        bool existsInDB = Databaser.Instance.DoesNameExistInTable(nameField.text, typeField.text);

        string feedbackString = "";

        if (existsInDB == true)
        {
            Databaser.Instance.OverwriteElement(nameField.text, typeField.text, locationField.text, descriptionField.text);
            feedbackString += "Overwrote ";
        }
        else
        {
            Databaser.Instance.CreateNewElement(nameField.text, typeField.text, locationField.text, descriptionField.text);
            feedbackString += "Saved ";
        }
        indexerState    = IndexerState.JustSaved;
        feedbackString += nameField.text + "! ";
        CloseIndexer();
        feedbackText.text = feedbackString;
    }
        public IndexerResult Exec()
        {
            var state = new IndexerState();

            foreach (var symbolFile in this.SymbolFiles.Select(pdbFile => new SymbolFile(pdbFile)))
            {
                if (!symbolFile.Exists)
                    throw new FileNotFoundException("Symbol file not found", symbolFile.FullName);

                state.SymbolFiles.Add(symbolFile.FullName, symbolFile);
            }

            this.ReadSourceFilesFromPdbs(state); // Check if there are files to index for this pdb file

            state.ResolverData = this.ResolverData;

            this.LoadProviders(state);
            ResolveFiles(state);

            this.WritePdbAnnotations(state);

            return CreateResultData(state);
        }
 private void ReadSourceFilesFromPdbs(IndexerState state)
 {
     PdbReader.ReadSourceFilesFromPdbs(state, this.SourceServerSdkDir, false);
 }
 private void WritePdbAnnotations(IndexerState state)
 {
     PdbWriter.WritePdbAnnotations(state, this.SourceServerSdkDir);
 }
Esempio n. 19
0
        void PerformExclusions(IndexerState state)
        {
            #region - Apply SourceRoots
            if (SourceRoots.Count > 0)
            {
                List <string> rootList = new List <string>();

                foreach (string root in SourceRoots)
                {
                    string nRoot = state.NormalizePath(root);

                    if (!nRoot.EndsWith("\\"))
                    {
                        nRoot += "\\";
                    }

                    rootList.Add(nRoot);
                }

                string[] roots = rootList.ToArray();
                Array.Sort <string>(roots, StringComparer.InvariantCultureIgnoreCase);

                foreach (SourceFile sf in state.SourceFiles.Values)
                {
                    string fileName = sf.FullName;

                    int n = Array.BinarySearch <string>(roots, fileName, StringComparer.InvariantCultureIgnoreCase);

                    if (n >= 0)
                    {
                        continue; // Exact match found
                    }
                    n = ~n;

                    if ((n > 0) && (n <= roots.Length))
                    {
                        if (fileName.StartsWith(roots[n - 1], StringComparison.InvariantCultureIgnoreCase))
                        {
                            continue; // Root found
                        }
                        sf.NoSourceAvailable = true;
                        continue;
                    }
                    else
                    {
                        sf.NoSourceAvailable = true;
                    }
                }
            }
            #endregion - Apply SourceRoots
            #region - Apply ExcludeSourceRoots
            if (ExcludeSourceRoots.Count > 0)
            {
                List <string> rootList = new List <string>();

                foreach (string root in ExcludeSourceRoots)
                {
                    string nRoot = state.NormalizePath(root);

                    if (!nRoot.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        nRoot += Path.DirectorySeparatorChar;
                    }

                    rootList.Add(nRoot);
                }

                string[] roots = rootList.ToArray();
                Array.Sort <string>(roots, StringComparer.InvariantCultureIgnoreCase);

                foreach (SourceFile sf in state.SourceFiles.Values)
                {
                    string fileName = sf.FullName;

                    int n = Array.BinarySearch <string>(roots, fileName, StringComparer.InvariantCultureIgnoreCase);

                    if (n >= 0)
                    {
                        continue; // Exact match found
                    }
                    n = ~n;

                    if ((n > 0) && (n <= roots.Length))
                    {
                        if (fileName.StartsWith(roots[n - 1], StringComparison.InvariantCultureIgnoreCase))
                        {
                            sf.NoSourceAvailable = true;
                        }
                    }
                }
            }
            #endregion
        }
        private void LoadProviders(IndexerState state)
        {
            var providers = new List<SourceResolver>();
            foreach (var provider in this.Providers)
            {
                Type providerType;
                try
                {
                    providerType = Type.GetType(provider, true, true);
                }
                catch (Exception e)
                {
                    throw new SourceIndexException(string.Format("Can't load provider '{0}'", provider), e);
                }

                if (!typeof(SourceResolver).IsAssignableFrom(providerType) || providerType.IsAbstract)
                    throw new SourceIndexException(string.Format("Provider '{0}' is not a valid SourceProvider", providerType.FullName));

                try
                {
                    providers.Add((SourceResolver)Activator.CreateInstance(providerType, new object[] { state }));
                }
                catch (Exception e)
                {
                    throw new SourceIndexException(string.Format("Can't initialize provider '{0}'", providerType.FullName), e);
                }
            }

            foreach (var sp in from sp in providers
                               let detector = sp as ISourceProviderDetector
                               where (detector != null) && !state.Resolvers.Contains(sp)
                               where sp.Available && detector.CanProvideSources(state)
                               select sp)
                state.Resolvers.Add(sp);
        }
 public NetworkShareResolver(IndexerState state)
     : base(state, "NetworkShare")
 {
 }
Esempio n. 22
0
        private static IndexerResult CreateResultData(IndexerState state)
        {
            var sources = state.SourceFiles.Values.Count(sf => sf.SourceReference != null);

            return(new IndexerResult(true, state.SymbolFiles.Count, sources, state.Resolvers.Count));
        }
 public bool CanProvideSources(IndexerState state)
 {
     return state.SourceFiles.Any(x => File.Exists(x.Key));
 }
Esempio n. 24
0
 protected SourceResolver(IndexerState state, string name)
     : base(state, name)
 {
     this.name = name;
 }
Esempio n. 25
0
 public bool CanProvideSources(IndexerState state)
 {
     return(state.SourceFiles.Any(x => File.Exists(x.Key)));
 }
Esempio n. 26
0
        /// <summary>
        /// Reads all sourcefiles referenced from a PDB, and adds these to the indexerstate
        /// </summary>
        /// <param name="state"></param>
        /// <param name="srcToolPath"></param>
        /// <param name="reIndexPreviouslyIndexedSymbols"></param>
        public static void ReadSourceFilesFromPdbs(IndexerState state, string srcToolPath, bool reIndexPreviouslyIndexedSymbols)
        {
            List <SymbolFile> pdbsToRemove = null;

            foreach (SymbolFile pdb in state.SymbolFiles.Values)
            {
                ProcessStartInfo psi = new ProcessStartInfo(srcToolPath);

                psi.WorkingDirectory = pdb.File.DirectoryName;

                psi.UseShellExecute        = false;
                psi.RedirectStandardError  = true;
                psi.RedirectStandardOutput = true;

                string output;
                string errors;

                if (!reIndexPreviouslyIndexedSymbols)
                {
                    psi.Arguments = string.Format("-c \"{0}\"", pdb.FullName);

                    using (Process p = Process.Start(psi))
                    {
                        output = p.StandardOutput.ReadToEnd();
                        errors = p.StandardError.ReadToEnd();

                        p.WaitForExit();
                    }

                    if (output.Contains("source files are indexed") ||
                        errors.Contains("source files are indexed") ||
                        output.Contains("source file is indexed") ||
                        errors.Contains("source file is indexed"))
                    {
                        // No need to change annotation; it is already indexed
                        if (pdbsToRemove == null)
                        {
                            pdbsToRemove = new List <SymbolFile>();
                        }

                        pdbsToRemove.Add(pdb);
                        continue;
                    }
                }

                psi.Arguments = string.Format("-r \"{0}\"", pdb.FullName);

                using (Process p = Process.Start(psi))
                {
                    output = p.StandardOutput.ReadToEnd();
                    errors = p.StandardError.ReadToEnd();

                    p.WaitForExit();
                }

                if (!string.IsNullOrEmpty(errors))
                {
                    throw new SourceIndexToolException("SRCTOOL", errors.Trim());
                }

                bool foundOne = false;
                foreach (string item in output.Split('\r', '\n'))
                {
                    string fileName = item.Trim();

                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;                       // We split on \r and \n
                    }
                    if ((fileName.IndexOf('*') >= 0) || // C++ Compiler internal file
                        ((fileName.Length > 2) && (fileName.IndexOf(':', 2) >= 0)))
                    {
                        // Some compiler internal filenames of C++ start with a *
                        // and/or have a :123 suffix

                        continue; // Skip never existing files
                    }

                    if (!File.Exists(fileName))
                    {
                        continue;
                    }

                    SourceFile file;

                    if (!state.SourceFiles.TryGetValue(fileName, out file))
                    {
                        file = new SourceFile(fileName);
                        state.SourceFiles.Add(fileName, file);
                    }

                    pdb.AddSourceFile(file);
                    file.AddContainer(pdb);
                    foundOne = true;
                }

                if (!foundOne)
                {
                    if (pdbsToRemove == null)
                    {
                        pdbsToRemove = new List <SymbolFile>();
                    }

                    pdbsToRemove.Add(pdb);
                }
            }

            if (pdbsToRemove != null)
            {
                foreach (SymbolFile s in pdbsToRemove)
                {
                    state.SymbolFiles.Remove(s.FullName);
                }
            }
        }
Esempio n. 27
0
 private void WritePdbAnnotations(IndexerState state)
 {
     PdbWriter.WritePdbAnnotations(state, this.SourceServerSdkDir);
 }
Esempio n. 28
0
        static bool WriteAnnotations(IndexerState state, SymbolFile file, StreamWriter sw)
        {
            SortedList<string, SourceProvider> providers = new SortedList<string, SourceProvider>();
            int itemCount = 1;

            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                if (providers.ContainsKey(provider.Id))
                    continue;

                providers.Add(provider.Id, provider);

                if (provider.SourceEntryVariableCount > itemCount)
                    itemCount = provider.SourceEntryVariableCount;
            }

            if (providers.Count == 0)
                return false;

            sw.WriteLine("SRCSRV: ini ------------------------------------------------");
            sw.WriteLine("VERSION=1");
            sw.Write("VERCTRL=SharpSvn.PdbAnnotate");
            foreach (SourceProvider sp in providers.Values)
            {
                if (!string.IsNullOrEmpty(sp.Name))
                {
                    sw.Write('+');
                    sw.Write(sp.Name);
                }
            }
            sw.WriteLine();
            sw.WriteLine("SRCSRV: variables ------------------------------------------");
            sw.WriteLine("DATETIME=" + DateTime.Now.ToUniversalTime().ToString("u"));
            sw.WriteLine("SRCSRVTRG=%fnvar%(%VAR2%__TRG)");
            sw.WriteLine("SRCSRVCMD=%fnvar%(%VAR2%__CMD)");
            //sw.WriteLine("SRCSRVENV=PATH=%PATH%\\bSystemDrive=%SystemDrive%\\bSystemRoot=%SystemRoot%\\bProgramFiles=%ProgramFiles%\\bProgramData=%ProgramData%\\b%fnvar%(%VAR2%__ENV)");
            foreach (SourceProvider sp in providers.Values)
            {
                sp.WriteEnvironment(sw);
            }
            sw.WriteLine("SRCSRV: source files ---------------------------------------");

            // Note: the sourcefile block must be written in the order they are found by the PdbReader
            //	otherwise SrcTool skips all sourcefiles which don't exist locally and are out of order
            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                sw.Write(sf.FullName);
                sw.Write('*');

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                sw.Write(provider.Id);
                sw.Write('*');

                string[] strings = sr.GetSourceEntries();

                if (strings != null)
                    for (int i = 0; i < itemCount; i++)
                    {
                        if (i < strings.Length)
                            sw.Write(strings[i]);

                        sw.Write('*');
                    }
                else
                {
                    for (int i = 0; i < itemCount; i++)
                        sw.Write('*');
                }

                // Note: We defined the variables upto itemCount+2 (filename, type, itemcount),
                // All variables above this index are reserved for future extensions

                sw.WriteLine();
            }

            sw.WriteLine("SRCSRV: end ------------------------------------------------");

            return true;
        }
Esempio n. 29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 void ReadSourceFilesFromPdbs(IndexerState state)
 {
     PdbReader.ReadSourceFilesFromPdbs(state, _srcToolPath, ReIndexPreviouslyIndexedSymbols);
 }
 private static IndexerResult CreateResultData(IndexerState state)
 {
     var sources = state.SourceFiles.Values.Count(sf => sf.SourceReference != null);
     return new IndexerResult(true, state.SymbolFiles.Count, sources, state.Resolvers.Count);
 }
 /// <summary>
 ///
 /// </summary>
 public SubversionResolver(IndexerState state)
     : base(state, "SVN")
 {
     //GC.KeepAlive(null);
 }
 private static void ResolveFiles(IndexerState state)
 {
     foreach (var sp in state.Resolvers)
         sp.ResolveFiles();
 }
Esempio n. 33
0
        public static void ReadSourceFilesFromPdbs(
            IndexerState state, string srcToolPath, bool reIndexPreviouslyIndexedSymbols)
        {
            List<SymbolFile> pdbsToRemove = null;
            foreach (var pdb in state.SymbolFiles.Values)
            {
                var psi = new ProcessStartInfo(srcToolPath)
                {
                    WorkingDirectory = pdb.File.DirectoryName,
                    UseShellExecute = false,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true
                };

                string output;
                string errors;

                if (!reIndexPreviouslyIndexedSymbols)
                {
                    psi.Arguments = string.Format("-c \"{0}\"", pdb.FullName);

                    using (var p = Process.Start(psi))
                    {
                        output = p.StandardOutput.ReadToEnd();
                        errors = p.StandardError.ReadToEnd();

                        p.WaitForExit();
                    }

                    if (output.Contains("source files are indexed") ||
                        errors.Contains("source files are indexed") ||
                        output.Contains("source file is indexed") ||
                        errors.Contains("source file is indexed"))
                    {
                        // No need to change annotation; it is already indexed
                        if (pdbsToRemove == null)
                            pdbsToRemove = new List<SymbolFile>();

                        pdbsToRemove.Add(pdb);
                        continue;
                    }
                }

                psi.Arguments = string.Format("-r \"{0}\"", pdb.FullName);

                using (var p = Process.Start(psi))
                {
                    output = p.StandardOutput.ReadToEnd();
                    errors = p.StandardError.ReadToEnd();

                    p.WaitForExit();
                }

                if (!string.IsNullOrEmpty(errors))
                    throw new SourceIndexToolException("SRCTOOL", errors.Trim());

                var foundOne = false;
                foreach (var item in output.Split('\r', '\n'))
                {
                    var fileName = item.Trim();

                    if (string.IsNullOrEmpty(fileName))
                        continue; // We split on \r and \n

                    if ((fileName.IndexOf('*') >= 0) || // C++ Compiler internal file
                        ((fileName.Length > 2) && (fileName.IndexOf(':', 2) >= 0)))
                    {
                        // Some compiler internal filenames of C++ start with a *
                        // and/or have a :123 suffix

                        continue; // Skip never existing files
                    }

                    fileName = state.NormalizePath(fileName);

                    SourceFile file;

                    if (!state.SourceFiles.TryGetValue(fileName, out file))
                    {
                        file = new SourceFile(fileName);
                        state.SourceFiles.Add(fileName, file);
                    }

                    pdb.AddSourceFile(file);
                    file.AddContainer(pdb);
                    foundOne = true;
                }

                if (foundOne)
                    continue;

                if (pdbsToRemove == null)
                    pdbsToRemove = new List<SymbolFile>();

                pdbsToRemove.Add(pdb);
            }

            if (pdbsToRemove == null)
                return;

            foreach (var s in pdbsToRemove)
                state.SymbolFiles.Remove(s.FullName);
        }
Esempio n. 34
0
 private void ReadSourceFilesFromPdbs(IndexerState state)
 {
     PdbReader.ReadSourceFilesFromPdbs(state, this.SourceServerSdkDir, false);
 }
Esempio n. 35
0
 protected SourceResolver(IndexerState state, string name)
     : base(state, name)
 {
     this.name = name;
 }
Esempio n. 36
0
        void AddIndexer()
        {
            // indexer args are parsed by a (sub-) state machine with four
            // states.  The string is a comma-separated list of params, each
            // of which has two parts:  a "paren string" and a "value string"
            // (both parts are optional).  The character ^ can be used to
            // escape any of the special characters:  comma, parens, ], ^,
            // and white space.

            int start = ++_index;       // skip over initial [
            int level = 1;              // level of nested []

            bool escaped   = false;     // true if current char is escaped
            bool trimRight = false;     // true if value string has trailing white space

            StringBuilder parenStringBuilder = new StringBuilder();
            StringBuilder valueStringBuilder = new StringBuilder();

            FrugalObjectList <IndexerParamInfo> paramList = new FrugalObjectList <IndexerParamInfo>();

            IndexerState state = IndexerState.BeginParam;

            while (state != IndexerState.Done)
            {
                if (_index >= _n)
                {
                    SetError(SRID.UnmatchedBracket, _path.Substring(start - 1));
                    return;
                }

                Char c = _path[_index++];

                // handle the escape character - set the flag for the next character
                if (c == EscapeChar && !escaped)
                {
                    escaped = true;
                    continue;
                }

                switch (state)
                {
                case IndexerState.BeginParam:       // look for optional (...)
                    if (escaped)
                    {
                        // no '(', go parse the value
                        state = IndexerState.ValueString;
                        goto case IndexerState.ValueString;
                    }
                    else if (c == '(')
                    {
                        // '(' introduces optional paren string
                        state = IndexerState.ParenString;
                    }
                    else if (Char.IsWhiteSpace(c))
                    {
                        // ignore leading white space
                    }
                    else
                    {
                        // no '(', go parse the value
                        state = IndexerState.ValueString;
                        goto case IndexerState.ValueString;
                    }
                    break;

                case IndexerState.ParenString:      // parse (...)
                    if (escaped)
                    {
                        // add an escaped character without question
                        parenStringBuilder.Append(c);
                    }
                    else if (c == ')')
                    {
                        // end of (...), start to parse value
                        state = IndexerState.ValueString;
                    }
                    else
                    {
                        // add normal characters inside (...)
                        parenStringBuilder.Append(c);
                    }
                    break;

                case IndexerState.ValueString:      // parse value
                    if (escaped)
                    {
                        // add an escaped character without question
                        valueStringBuilder.Append(c);
                        trimRight = false;
                    }
                    else if (level > 1)
                    {
                        // inside nested [], add characters without question
                        valueStringBuilder.Append(c);
                        trimRight = false;

                        if (c == ']')
                        {
                            --level;
                        }
                    }
                    else if (Char.IsWhiteSpace(c))
                    {
                        // add white space, but trim it later if it's trailing
                        valueStringBuilder.Append(c);
                        trimRight = true;
                    }
                    else if (c == ',' || c == ']')
                    {
                        // end of current paramater - assemble the two parts
                        string parenString = parenStringBuilder.ToString();
                        string valueString = valueStringBuilder.ToString();
                        if (trimRight)
                        {
                            valueString = valueString.TrimEnd();
                        }

                        // add the parts to the final result
                        paramList.Add(new IndexerParamInfo(parenString, valueString));

                        // reset for the next parameter
                        parenStringBuilder.Length = 0;
                        valueStringBuilder.Length = 0;
                        trimRight = false;

                        // after ',' parse next parameter;  after ']' we're done
                        state = (c == ']') ? IndexerState.Done : IndexerState.BeginParam;
                    }
                    else
                    {
                        // add normal characters
                        valueStringBuilder.Append(c);
                        trimRight = false;

                        // keep track of nested []
                        if (c == '[')
                        {
                            ++level;
                        }
                    }
                    break;
                }

                // after processing each character, clear the escape flag
                escaped = false;
            }

            // assemble the final result
            SourceValueInfo info = new SourceValueInfo(
                SourceValueType.Indexer,
                _drillIn, paramList);

            _al.Add(info);

            StartNewLevel();
        }
Esempio n. 37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 void WritePdbAnnotations(IndexerState state)
 {
     PdbWriter.WritePdbAnnotations(state, _pdbStrPath);
 }
Esempio n. 38
0
        public static IndexerExecutionResult IndexerExecutionResult(IndexerExecutionStatus status = default, IndexerExecutionStatusDetail?statusDetail = null, IndexerState currentState = null, string errorMessage = null, DateTimeOffset?startTime = null, DateTimeOffset?endTime = null, IEnumerable <SearchIndexerError> errors = null, IEnumerable <SearchIndexerWarning> warnings = null, int itemCount = default, int failedItemCount = default, string initialTrackingState = null, string finalTrackingState = null)
        {
            errors ??= new List <SearchIndexerError>();
            warnings ??= new List <SearchIndexerWarning>();

            return(new IndexerExecutionResult(status, statusDetail, currentState, errorMessage, startTime, endTime, errors?.ToList(), warnings?.ToList(), itemCount, failedItemCount, initialTrackingState, finalTrackingState));
        }
Esempio n. 39
0
 public NetworkShareResolver(IndexerState state)
     : base(state, "NetworkShare")
 {
 }