/// <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); } }
private SaveLoadResult SaveLoad(params AnalysisModule[] modules) { IPythonProjectEntry[] entries = new IPythonProjectEntry[modules.Length]; var state = new PythonAnalyzer(Interpreter, PythonLanguageVersion.V27); for (int i = 0; i < modules.Length; i++) { entries[i] = state.AddModule(modules[i].ModuleName, modules[i].Filename); Prepare(entries[i], new StringReader(modules[i].Code), PythonLanguageVersion.V27); } for (int i = 0; i < modules.Length; i++) { entries[i].Analyze(); } string tmpFolder = Path.Combine(Path.GetTempPath(), "6666d700-a6d8-4e11-8b73-3ba99a61e27b" /*Guid.NewGuid().ToString()*/); Directory.CreateDirectory(tmpFolder); new SaveAnalysis().Save(state, tmpFolder); File.Copy(Path.Combine(CPythonInterpreterFactory.GetBaselineDatabasePath(), "__builtin__.idb"), Path.Combine(tmpFolder, "__builtin__.idb"), true); return(new SaveLoadResult( new PythonAnalyzer(new CPythonInterpreter(new TypeDatabase(tmpFolder)), PythonLanguageVersion.V27), tmpFolder )); }
/// <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); }
/// <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); }
public BaseAnalysisTest() : this(new CPythonInterpreter(CPythonInterpreterFactory.MakeDefaultTypeDatabase())) { }