Example #1
0
        private IPythonParse ParseWorker(IDocument doc, PythonLanguageVersion languageVersion)
        {
            IPythonParse result = null;

            if (doc is IExternalProjectEntry externalEntry)
            {
                using (var r = doc.ReadDocument(0, out var version)) {
                    if (r == null)
                    {
                        throw new FileNotFoundException("failed to parse file", externalEntry.FilePath);
                    }
                    result = new StaticPythonParse(null, new VersionCookie(version));
                    externalEntry.ParseContent(r, result.Cookie);
                }
            }
            else if (doc is IPythonProjectEntry pyEntry)
            {
                var lastParse = pyEntry.GetCurrentParse();
                result = ParsePythonEntry(pyEntry, languageVersion, lastParse?.Cookie as VersionCookie);
            }
            else
            {
                Debug.Fail($"Don't know how to parse {doc.GetType().FullName}");
            }
            return(result);
        }
Example #2
0
            public ParseTask(ParseQueue queue, IDocument document, PythonLanguageVersion languageVersion)
            {
                _queue           = queue;
                _document        = document;
                _languageVersion = languageVersion;

                _queue._parsingInProgress.Increment();
                _parse = (_document as IPythonProjectEntry)?.BeginParse();

                _tcs = new TaskCompletionSource <IAnalysisCookie>();
            }