public SequenceBuiltinClassInfo(IPythonType classObj, PythonAnalyzer projectState) : base(classObj, projectState) { var seqType = classObj as IPythonSequenceType; if (seqType != null && seqType.IndexTypes != null) { _indexTypes = projectState.GetAnalysisSetFromObjects(seqType.IndexTypes).GetInstanceType(); } else { _indexTypes = AnalysisSet.Empty; } }
public GeneratorInfo(PythonAnalyzer projectState, IPythonProjectEntry entry) : base(projectState.ClassInfos[BuiltinTypeId.Generator]) { _declaringModule = entry; _declaringVersion = entry.AnalysisVersion; Yields = new VariableDef(); Sends = new VariableDef(); Returns = new VariableDef(); }
public CoroutineInfo(PythonAnalyzer projectState, IPythonProjectEntry entry) : base(projectState.ClassInfos[BuiltinTypeId.Generator]) { // Internally, coroutines are represented by generators with a CO_* // flag on the code object. Here we represent it as a separate info, // but reuse the underlying class info. _declaringModule = entry; _declaringVersion = entry.AnalysisVersion; Returns = new VariableDef(); }
public static ConstantInfo Create(PythonAnalyzer state, object value) { var constant = value as IPythonConstant; var constantType = constant?.Type; var av = state.GetAnalysisValueFromObjectsThrowOnNull(constantType ?? state.GetTypeFromObject(value)); var ci = av as ConstantInfo; if (ci != null) { return ci; } var bci = av as BuiltinClassInfo; if (bci != null) { return new ConstantInfo(bci, value, constant?.MemberType ?? PythonMemberType.Constant); } return null; }
private static void SignatureTest(int location, string sourceCode, string expectedExpression, int paramIndex) { if (location < 0) { location = sourceCode.Length + location; } var analyzer = new PythonAnalyzer(new MockDlrRuntimeHost(), new MockErrorProviderFactory()); var buffer = new MockTextBuffer(sourceCode); var snapshot = (MockTextSnapshot)buffer.CurrentSnapshot; var context = analyzer.GetSignatures(snapshot, buffer, new MockTrackingSpan(snapshot, location, 1)); AreEqual(context.Text, expectedExpression); AreEqual(context.ParameterIndex, paramIndex); }
public ConstantInfo(IPythonConstant value, PythonAnalyzer projectState) : base((BuiltinClassInfo)projectState.GetAnalysisValueFromObjects(value.Type)) { _value = value; _memberType = value.MemberType; _builtinInfo = ((BuiltinClassInfo)projectState.GetAnalysisValueFromObjects(value.Type)).Instance; }
public RangeInfo(IPythonType seqType, PythonAnalyzer state) : base(state.ClassInfos[BuiltinTypeId.List]) { }
public ConstantInfo(object value, PythonAnalyzer projectState) : base((BuiltinClassInfo)projectState.GetAnalysisValueFromObjectsThrowOnNull(projectState.GetTypeFromObject(value))) { _value = value; _memberType = PythonMemberType.Constant; _builtinInfo = ((BuiltinClassInfo)projectState.GetAnalysisValueFromObjects(_type)).Instance; }
public BuiltinModule(IPythonModule module, PythonAnalyzer projectState) : base(module, projectState) { _interpreterModule = module; }
public SetInfo(PythonAnalyzer projectState, Node node, ProjectEntry entry) : base(VariableDef.EmptyArray, projectState.ClassInfos[BuiltinTypeId.Set], node, entry) { }
public DictBuiltinClassInfo(IPythonType classObj, PythonAnalyzer projectState) : base(classObj, projectState) { }
public BuiltinPropertyInfo(IBuiltinProperty value, PythonAnalyzer projectState) : base(value.Type, projectState) { _value = value; _doc = null; }
private static ExpressionAnalysis AnalyzeExpression(int location, string sourceCode) { if (location < 0) { location = sourceCode.Length + location; } var analyzer = new PythonAnalyzer(new MockDlrRuntimeHost(), new MockErrorProviderFactory()); var buffer = new MockTextBuffer(sourceCode); var textView = new MockTextView(buffer); var item = analyzer.AnalyzeTextView(textView); while (item.IsAnalyzed) { Thread.Sleep(100); } var snapshot = (MockTextSnapshot)buffer.CurrentSnapshot; return analyzer.AnalyzeExpression(snapshot, buffer, new MockTrackingSpan(snapshot, location, 0)); }
public void Register(PythonAnalyzer analyzer) { _analyzer = analyzer; }
private PythonAnalyzer MakeTestAnalyzer() { return(PythonAnalyzer.CreateAsync(InterpreterFactoryCreator.CreateAnalysisInterpreterFactory(new Version(2, 7))).GetAwaiter().GetResult()); }
public ReloadModulesQueueItem(PythonAnalyzer analyzer) { _analyzer = analyzer; }
internal static string GetDefaultValue(PythonAnalyzer state, Parameter curParam, PythonAst tree) { if (curParam.DefaultValue != null) { // TODO: Support all possible expressions for default values, we should // probably have a PythonAst walker for expressions or we should add ToCodeString() // onto Python ASTs so they can round trip ConstantExpression defaultValue = curParam.DefaultValue as ConstantExpression; if (defaultValue != null) { return(defaultValue.GetConstantRepr(state.LanguageVersion)); } else { NameExpression nameExpr = curParam.DefaultValue as NameExpression; if (nameExpr != null) { return(nameExpr.Name); } else { DictionaryExpression dict = curParam.DefaultValue as DictionaryExpression; if (dict != null) { if (dict.Items.Count == 0) { return("{}"); } else { return("{...}"); } } else { ListExpression list = curParam.DefaultValue as ListExpression; if (list != null) { if (list.Items.Count == 0) { return("[]"); } else { return("[...]"); } } else { TupleExpression tuple = curParam.DefaultValue as TupleExpression; if (tuple != null) { if (tuple.Items.Count == 0) { return("()"); } else { return("(...)"); } } else { return(curParam.DefaultValue.ToCodeString(tree).Trim()); } } } } } } return(null); }
public EnumInstanceInfo(object value, PythonAnalyzer projectState) : base(value, projectState) { }
public void Initialize(PythonAnalyzer state) { }
internal static string UnaryOpToString(PythonAnalyzer state, PythonOperator operation) { string op = null; switch (operation) { case PythonOperator.Not: op = state.LanguageVersion.Is3x() ? "__bool__" : "__nonzero__"; break; case PythonOperator.Pos: op = "__pos__"; break; case PythonOperator.Invert: op = "__invert__"; break; case PythonOperator.Negate: op = "__neg__"; break; } return op; }
public EnumInstanceInfo(object value, PythonAnalyzer projectState) : base(projectState.ClassInfos[BuiltinTypeId.Int], value, PythonMemberType.EnumInstance) { }