Task CreateParseTypeScriptFileTask(CodeEditor editor)
        {
            ITextBuffer       fileContent = editor.DocumentAdapter.CreateSnapshot();
            TypeScriptProject project     = TypeScriptService.GetProjectForFile(editor.FileName);

            return(Task
                   .Factory
                   .StartNew(() => ParseTypeScriptFile(editor.FileName, fileContent, project))
                   .ContinueWith(task => UpdateParseInformation(task.Result), TaskScheduler.FromCurrentSynchronizationContext()));
        }
        void FileSaved(object sender, FileNameEventArgs e)
        {
            if (!TypeScriptFileExtensions.IsTypeScriptFileName(e.FileName))
            {
                return;
            }

            TypeScriptProject project = TypeScriptService.GetProjectForFile(e.FileName);

            if (project == null)
            {
                return;
            }

            if (project.CompileOnSave)
            {
                var action = new CompileTypeScriptOnSaveFileAction();
                TypeScriptContext context = TypeScriptService.ContextProvider.GetContext(e.FileName);
                action.Compile(e.FileName, project, context);
            }
        }