Exemple #1
0
        /// <summary>
        /// Creates a new interpreter factory with the specified options. This
        /// interpreter always includes a cached completion database.
        /// </summary>
        public static IPythonInterpreterFactory CreateInterpreterFactory(InterpreterConfiguration configuration, InterpreterFactoryCreationOptions options = null)
        {
            options = options?.Clone() ?? new InterpreterFactoryCreationOptions();

            if (string.IsNullOrEmpty(options.DatabasePath))
            {
                options.DatabasePath = Path.Combine(
                    PythonTypeDatabase.CompletionDatabasePath,
                    GetRelativePathForConfigurationId(configuration.Id)
                    );
            }

            if (options.NoDatabase)
            {
                // Use the (currenty experimental) non-database backed factory
                var fact = new Ast.AstPythonInterpreterFactory(configuration, options);
                return(fact);
            }
            else
            {
                // Use the database-backed factory
                var fact = new CPythonInterpreterFactory(configuration, options);
                if (options.WatchFileSystem)
                {
                    fact.BeginRefreshIsCurrent();
                }
                return(fact);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new interpreter factory with the specified options. This
        /// interpreter always includes a cached completion database.
        /// </summary>
        public static IPythonInterpreterFactory CreateInterpreterFactory(
            InterpreterConfiguration configuration,
            InterpreterFactoryCreationOptions options = null
            )
        {
            options = options?.Clone() ?? new InterpreterFactoryCreationOptions();

            return(new Ast.AstPythonInterpreterFactory(configuration, options));
        }
        /// <summary>
        /// Creates a new interpreter factory with the specified options. This
        /// interpreter always includes a cached completion database.
        /// </summary>
        public static PythonInterpreterFactoryWithDatabase CreateInterpreterFactory(InterpreterConfiguration configuration, InterpreterFactoryCreationOptions options = null)
        {
            options = options?.Clone() ?? new InterpreterFactoryCreationOptions();

            if (string.IsNullOrEmpty(options.DatabasePath))
            {
                options.DatabasePath = Path.Combine(
                    PythonTypeDatabase.CompletionDatabasePath,
                    GetRelativePathForConfigurationId(configuration.Id)
                    );
            }

            var fact = new CPythonInterpreterFactory(configuration, options);

            if (options.WatchFileSystem)
            {
                fact.BeginRefreshIsCurrent();
            }
            return(fact);
        }
Exemple #4
0
        /// <summary>
        /// Creates a new interpreter factory with the specified options. This
        /// interpreter always includes a cached completion database.
        /// </summary>
        public static PythonInterpreterFactoryWithDatabase CreateInterpreterFactory(InterpreterConfiguration configuration, InterpreterFactoryCreationOptions options = null)
        {
            options = options?.Clone() ?? new InterpreterFactoryCreationOptions();

            if (string.IsNullOrEmpty(options.DatabasePath))
            {
                var subpath = configuration.Id.Replace('|', '\\');
                if (!PathUtils.IsValidPath(subpath))
                {
                    subpath = Convert.ToBase64String(new UTF8Encoding(false).GetBytes(configuration.Id));
                }
                options.DatabasePath = Path.Combine(PythonTypeDatabase.CompletionDatabasePath, subpath);
            }

            var fact = new CPythonInterpreterFactory(configuration, options);

            if (options.WatchFileSystem)
            {
                fact.BeginRefreshIsCurrent();
            }
            return(fact);
        }