public EventHandlerSymbolFilter(EventHandlerArgumentMode mode, string type, IPsiModule psiModule)
        {
            myMode = mode;
            if (mode == EventHandlerArgumentMode.UnityType && type != null)
            {
                myType = TypeFactory.CreateTypeByCLRName(type, psiModule);
            }
            else if (mode != EventHandlerArgumentMode.None)
            {
                var predefinedTypes = psiModule.GetPredefinedType();
                switch (mode)
                {
                case EventHandlerArgumentMode.Int:
                    myType = predefinedTypes.Int;
                    break;

                case EventHandlerArgumentMode.Float:
                    myType = predefinedTypes.Float;
                    break;

                case EventHandlerArgumentMode.String:
                    myType = predefinedTypes.String;
                    break;

                case EventHandlerArgumentMode.Bool:
                    myType = predefinedTypes.Bool;
                    break;
                }
            }
        }
Пример #2
0
        public EventHandlerSymbolFilter(EventHandlerArgumentMode mode, string type, IPsiModule psiModule)
        {
            myTypes = new FrugalLocalList <IType>();

            myMode = mode;
            var predefinedTypes = psiModule.GetPredefinedType();

            switch (mode)
            {
            case EventHandlerArgumentMode.EventDefined:
                if (type != null)
                {
                    // Find the UnityEvent base type, and use the type parameters as the required arguments
                    // This only works for scenes serialised in Unity 2018.3 and below. The field was removed in 2018.4
                    var eventType             = TypeFactory.CreateTypeByCLRName(type, psiModule);
                    var unityEventType        = GetUnityEventType(eventType);
                    var unityEventTypeElement = unityEventType?.GetTypeElement();
                    if (unityEventType != null && unityEventTypeElement != null)
                    {
                        var(_, substitution) = unityEventType.Resolve();
                        var typeParameters = unityEventTypeElement.TypeParameters;
                        foreach (var t in typeParameters)
                        {
                            myTypes.Add(substitution.Apply(t));
                        }
                    }
                }
                break;

            case EventHandlerArgumentMode.UnityObject:
                myTypes.Add(type == null
                        ? TypeFactory.CreateTypeByCLRName(KnownTypes.Object, NullableAnnotation.Unknown, psiModule)
                        : TypeFactory.CreateTypeByCLRName(type, psiModule));
                break;

            case EventHandlerArgumentMode.Int:
                myTypes.Add(predefinedTypes.Int);
                break;

            case EventHandlerArgumentMode.Float:
                myTypes.Add(predefinedTypes.Float);
                break;

            case EventHandlerArgumentMode.String:
                myTypes.Add(predefinedTypes.String);
                break;

            case EventHandlerArgumentMode.Bool:
                myTypes.Add(predefinedTypes.Bool);
                break;
            }
        }
Пример #3
0
        public IDeclaredType GetByClrTypeName(IClrTypeName typeName, IPsiModule module)
        {
            var type = module.GetPredefinedType().TryGetType(typeName, NullableAnnotation.Unknown);

            if (type != null)
            {
                return(type);
            }

            // Make sure the type is still valid before handing it out. It might be invalid if the module used to create
            // it has been changed
            type = myTypes.AddOrUpdate(typeName, name => TypeFactory.CreateTypeByCLRName(name, module),
                                       (name, existingValue) => existingValue.Module.IsValid()
                    ? existingValue
                    : TypeFactory.CreateTypeByCLRName(name, module));
            return(type);
        }
Пример #4
0
 private IDeclaredType GetVoidType(IPsiModule module)
 {
     return module.GetPredefinedType().Void;
 }
 protected PredefinedType GetPredefinedType()
 {
     Contract.Ensures(Contract.Result <PredefinedType>() != null);
     return(_psiModule.GetPredefinedType());
 }
 private IDeclaredType GetVoidType(IPsiModule module)
 {
     return(module.GetPredefinedType().Void);
 }
 private IDeclaredType GetVoidType(IPsiModule module)
 {
     return(module.GetPredefinedType(module.GetContextFromModule()).Void);
 }