public ParseInformation Parse(
            FileName fileName,
            ITextSource fileContent,
            TypeScriptProject project,
            IEnumerable <TypeScriptFile> files)
        {
            try {
                using (TypeScriptContext context = contextFactory.CreateContext()) {
                    context.AddFile(fileName, fileContent.Text);
                    context.RunInitialisationScript();

                    NavigationBarItem[] navigation = context.GetNavigationInfo(fileName);
                    var unresolvedFile             = new TypeScriptUnresolvedFile(fileName);
                    unresolvedFile.AddNavigation(navigation, fileContent);

                    if (project != null)
                    {
                        context.AddFiles(files);
                        var          document    = new TextDocument(fileContent);
                        Diagnostic[] diagnostics = context.GetDiagnostics(fileName, project.GetOptions());
                        TypeScriptService.TaskService.Update(diagnostics, fileName);
                    }

                    return(new ParseInformation(unresolvedFile, fileContent.Version, true));
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
                LoggingService.Debug(ex.ToString());
            }

            return(new ParseInformation(
                       new TypeScriptUnresolvedFile(fileName),
                       fileContent.Version,
                       true));
        }
        public ICompilationUnit Parse(
            IProjectContent projectContent,
            string fileName,
            ITextBuffer fileContent,
            IEnumerable <TypeScriptFile> files)
        {
            try {
                using (TypeScriptContext context = contextFactory.CreateContext()) {
                    var file = new FileName(fileName);
                    context.AddFile(file, fileContent.Text);
                    context.RunInitialisationScript();

                    NavigationBarItem[] navigation = context.GetNavigationInfo(file);
                    var unit = new TypeScriptCompilationUnit(projectContent)
                    {
                        FileName = fileName
                    };
                    unit.AddNavigation(navigation, fileContent);

                    var typeScriptProjectContent = projectContent as TypeScriptProjectContent;
                    if (typeScriptProjectContent != null)
                    {
                        context.AddFiles(files);
                        IDocument    document    = DocumentUtilitites.LoadReadOnlyDocumentFromBuffer(fileContent);
                        Diagnostic[] diagnostics = context.GetDiagnostics(file, typeScriptProjectContent.Options);
                        TypeScriptService.TaskService.Update(diagnostics, file, document);
                    }

                    return(unit);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
                LoggingService.Debug(ex.ToString());
            }
            return(new DefaultCompilationUnit(projectContent));
        }