예제 #1
0
        public static void Prepare(IJsProjectEntry entry, TextReader sourceUnit)
        {
            var parser = new JSParser(sourceUnit.ReadToEnd());
            var ast    = parser.Parse(new CodeSettings());

            entry.UpdateTree(ast, null);
        }
예제 #2
0
 /// <summary>
 /// Called when we race and are not actually re-parsing a buffer, balances the calls
 /// of BeginParsingTree when we aren't parsing.
 /// </summary>
 private void NotReparsing()
 {
     lock (this) {
         IJsProjectEntry pyEntry = _currentProjEntry as IJsProjectEntry;
         if (pyEntry != null)
         {
             pyEntry.UpdateTree(null, null);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Parses the specified file on disk.
        /// </summary>
        /// <param name="filename"></param>
        private void EnqueueFile(IProjectEntry projEntry, string filename)
        {
            // get the current snapshot from the UI thread

            EnqueWorker(() => {
                for (int i = 0; i < 10; i++)
                {
                    try {
                        if (!File.Exists(filename))
                        {
                            break;
                        }

                        var cookie = new FileCookie(filename);
                        var reader = new StreamReader(
                            new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)
                            );

                        using (reader) {
                            ParseFile(projEntry, filename, reader, cookie);
                        }
                        return;
                    } catch (IOException) {
                        // file being copied, try again...
                        Thread.Sleep(100);
                    } catch (UnauthorizedAccessException) {
                        // file is inaccessible, try again...
                        Thread.Sleep(100);
                    }
                }

                IJsProjectEntry pyEntry = projEntry as IJsProjectEntry;
                if (pyEntry != null)
                {
                    // failed to parse, keep the UpdateTree calls balanced
                    pyEntry.UpdateTree(null, null);
                }
            });
        }
 public static void Prepare(IJsProjectEntry entry, TextReader sourceUnit) {
     var parser = new JSParser(sourceUnit.ReadToEnd());
     var ast = parser.Parse(new CodeSettings());
     entry.UpdateTree(ast, null);
 }