Ejemplo n.º 1
0
        /// <summary>
        /// Gets the current AST and the code string for the project entry and returns the current code.
        /// </summary>
        public static PythonAst GetVerbatimAstAndCode(this IPythonProjectEntry projectFile, PythonLanguageVersion langVersion, int bufferId, out int version, out string code)
        {
            ParserOptions options = new ParserOptions {
                BindReferences = true, Verbatim = true
            };

            code = projectFile.GetCurrentCode(bufferId, out version);
            if (code != null)
            {
                var parser = Parser.CreateParser(
                    new StringReader(code),
                    langVersion,
                    options
                    );

                return(parser.ParseFile());
            }
            return(null);
        }