internal PythonDbModule CreateDbModule(ModuleModel model, string modulePath) { var dbModule = new PythonDbModule(model, modulePath, Services); dbModule.Construct(model); return(dbModule); }
public async Task MemberLocations() { const string code = @" x = 'str' def sum(a, b): return a + b class B: x: int class C: def __init__(self): pass def methodC(self): pass @property def propertyB(self): return 1 def methodB2(self): return 2 "; var analysis = await GetAnalysisAsync(code); var model = ModuleModel.FromAnalysis(analysis, Services, AnalysisCachingLevel.Library); //var json = ToJson(model); //Baseline.CompareToFile(BaselineFileName, json); using (var dbModule = new PythonDbModule(model, analysis.Document.FilePath, Services)) { dbModule.Construct(model); var sum = dbModule.GetMember("sum") as IPythonFunctionType; sum.Should().NotBeNull(); sum.Definition.Span.Should().Be(4, 5, 4, 8); var b = dbModule.GetMember("B") as IPythonClassType; b.Should().NotBeNull(); b.Definition.Span.Should().Be(7, 7, 7, 8); var c = b.GetMember("C") as IPythonClassType; c.Should().NotBeNull(); c.Definition.Span.Should().Be(10, 11, 10, 12); var methodC = c.GetMember("methodC") as IPythonFunctionType; methodC.Should().NotBeNull(); methodC.Definition.Span.Should().Be(13, 13, 13, 20); var propertyB = b.GetMember("propertyB") as IPythonPropertyType; propertyB.Should().NotBeNull(); propertyB.Definition.Span.Should().Be(17, 9, 17, 18); var methodB2 = b.GetMember("methodB2") as IPythonFunctionType; methodB2.Should().NotBeNull(); methodB2.Definition.Span.Should().Be(20, 9, 20, 17); } }
internal PythonDbModule CreateDbModule(ModuleModel model, string modulePath) { var dbModule = new PythonDbModule(model, modulePath, Services); Services.GetService <IPythonAnalyzer>().InvalidateAnalysis(dbModule); dbModule.Construct(model); return(dbModule); }
public async Task Builtins() { var analysis = await GetAnalysisAsync(string.Empty); var builtins = analysis.Document.Interpreter.ModuleResolution.BuiltinsModule; var model = ModuleModel.FromAnalysis(builtins.Analysis, Services, AnalysisCachingLevel.Library); var json = ToJson(model); Baseline.CompareToFile(BaselineFileName, json); using (var dbModule = new PythonDbModule(model, null, Services)) { dbModule.Construct(model); dbModule.Should().HaveSameMembersAs(builtins); } }