public AnalysisVariable(IVariableDefinition variable, VariableType type, ILocationInfo location, int?version = null)
 {
     Variable = variable;
     Location = location;
     Type     = type;
     Version  = version;
 }
        public AstPythonFunction(
            FunctionDefinition fd,
            IPythonModule declaringModule,
            IPythonType declaringType,
            ILocationInfo loc
            ) : base(fd.Name, declaringModule, fd.Documentation, loc,
                     declaringType != null ? BuiltinTypeId.Method : BuiltinTypeId.Function, true)
        {
            FunctionDefinition = fd;
            DeclaringType      = declaringType;

            if (Name == "__init__")
            {
                _doc = declaringType?.Documentation;
            }

            foreach (var dec in (FunctionDefinition.Decorators?.Decorators).MaybeEnumerate().ExcludeDefault().OfType <NameExpression>())
            {
                if (dec.Name == "classmethod")
                {
                    IsClassMethod = true;
                }
                else if (dec.Name == "staticmethod")
                {
                    IsStatic = true;
                }
            }
        }
예제 #3
0
        public AstPythonFunction(
            PythonAst ast,
            IPythonModule declModule,
            IPythonType declType,
            FunctionDefinition def,
            ILocationInfo loc
            )
        {
            DeclaringModule = declModule ?? throw new ArgumentNullException(nameof(declModule));
            DeclaringType   = declType;

            Name = def.Name;
            if (Name == "__init__")
            {
                _doc = declType?.Documentation;
            }

            foreach (var dec in (def.Decorators?.Decorators).MaybeEnumerate().ExcludeDefault().OfType <NameExpression>())
            {
                if (dec.Name == "classmethod")
                {
                    IsClassMethod = true;
                }
                else if (dec.Name == "staticmethod")
                {
                    IsStatic = true;
                }
            }

            _overloads = new List <IPythonFunctionOverload>();

            Locations = loc != null ? new[] { loc } : Array.Empty <ILocationInfo>();
        }
 public AstPythonFunctionOverload(
     IEnumerable <IParameterInfo> parameters,
     ILocationInfo loc
     )
 {
     _parameters = parameters?.ToArray() ?? throw new ArgumentNullException(nameof(parameters));
     Locations   = loc != null ? new[] { loc } : Array.Empty <ILocationInfo>();
 }
예제 #5
0
 public AstPythonProperty(
     PythonAst ast,
     FunctionDefinition getter,
     ILocationInfo location
     )
 {
     Documentation = getter.Documentation;
     IsReadOnly    = true;
     Locations     = new[] { location };
 }
예제 #6
0
 public AstPythonClass(
     ClassDefinition classDefinition,
     IPythonModule declaringModule,
     string doc,
     ILocationInfo loc,
     BuiltinTypeId builtinTypeId = BuiltinTypeId.Type
     ) : base(classDefinition.Name, declaringModule, doc, loc, builtinTypeId, false)
 {
     ClassDefinition = classDefinition;
 }
예제 #7
0
        public bool Equals(ILocationInfo other)
        {
            if (other == null)
            {
                return(false);
            }

            // currently we filter only to line & file - so we'll only show 1 ref per each line
            // This works nicely for get and call which can both add refs and when they're broken
            // apart you still see both refs, but when they're together you only see 1.
            return(StartLine == other.StartLine &&
                   FilePath == other.FilePath);
        }
예제 #8
0
 public AstPythonType(
     string name,
     IPythonModule declaringModule,
     string doc,
     ILocationInfo loc,
     BuiltinTypeId typeId = BuiltinTypeId.Unknown,
     bool isTypeFactory   = false
     ) : this(name, typeId, isTypeFactory)
 {
     Documentation   = doc;
     DeclaringModule = declaringModule;
     Locations       = loc != null ? new[] { loc } : Array.Empty <ILocationInfo>();
     IsTypeFactory   = isTypeFactory;
 }
        public AstPythonType(
            PythonAst ast,
            IPythonModule declModule,
            ClassDefinition def,
            string doc,
            ILocationInfo loc
            )
        {
            _members = new Dictionary <string, IMember>();

            _name           = def?.Name ?? throw new ArgumentNullException(nameof(def));
            Documentation   = doc;
            DeclaringModule = declModule ?? throw new ArgumentNullException(nameof(declModule));
            Locations       = loc != null ? new[] { loc } : Array.Empty <ILocationInfo>();
            StartIndex      = def?.StartIndex ?? 0;
        }
예제 #10
0
 public DefinitionList(ILocationInfo location)
 {
     _location = location;
 }
 public AnalysisVariable(VariableType type, ILocationInfo location, int?version = null)
 {
     Location = location;
     Type     = type;
     Version  = version;
 }
 public AstPythonProperty(FunctionDefinition fd, IPythonModule declaringModule, IPythonType declaringType, ILocationInfo location)
     : base(fd.Name, declaringModule, null, location)
 {
     FunctionDefinition = fd;
     DeclaringType      = declaringType;
 }