Beispiel #1
0
        private bool TryGetSourceFile(string uri, out ISourceFile sourceFile, out string error)
        {
            // We first check if the requested file is already part of the workspace, so we don't have to parse it again
            // Things like configuration files are not part of the workspace, but could be part of the VSCode workspace
            if (TryFindSourceFile(uri, out sourceFile))
            {
                error = null;
                return(true);
            }

            var pathToDocument = uri.ToAbsolutePath(PathTable);

            var content = m_engineAbstraction.GetFileContentAsync(pathToDocument).GetAwaiter().GetResult();

            if (!content.Succeeded)
            {
                sourceFile = null;
                error      = content.Failure.Describe();
                return(false);
            }

            var parser = new Parser();

            sourceFile = parser.ParseSourceFileContent(
                pathToDocument.ToString(PathTable),
                content.Result.GetContentAsString(),
                ParsingOptions.DefaultParsingOptions);

            error = null;
            return(true);
        }
 /// <summary>
 /// <see cref="FrontEndEngineAbstraction.GetFileContentAsync"/>.
 /// </summary>
 public Task <Possible <FileContent, RecoverableExceptionFailure> > TryGetFileContentAsync(AbsolutePath path)
 {
     return(m_engine.GetFileContentAsync(path));
 }