IEnumerable <SuggestItem> SuggestDesignerProperty(DataType valueType)
        {
            _codeReader.ReadTokenReverse();
            var nameAttributes = StandardAttributesSuggestion.FindUXNameAttributes(_codeReader);
            var dataTypes      = StandardAttributesSuggestion.ResolveNamesAndTypes(_dataTypes,
                                                                                   nameAttributes,
                                                                                   _namespaceDeclarations);

            var attributeValue = StandardAttributesSuggestion.ParseTokenText(_codeReader);

            if (!attributeValue.Contains("."))
            {
                return(dataTypes.Select(n => SuggestionHelper.Suggest(SuggestItemType.Variable, n.Value, n.Key)));
            }

            var valuePieces = attributeValue.Split('.');
            var dataType    = dataTypes.FirstOrDefault(d => d.Key == valuePieces[0]).Value;

            if (dataType == null)
            {
                return(null);
            }

            var properties            = PropertyHelper.GetAllWriteableProperties(dataType);
            var propertiesOfRightType = properties.Where(p => p.ReturnType == valueType.GenericArguments[0]);

            return(propertiesOfRightType.Select(p => SuggestionHelper.Suggest(SuggestItemType.Property, p, valuePieces[0] + "." + p.Name)));
        }
 IEnumerable <SuggestItem> SuggestBool(DataType dataType)
 {
     return(new List <SuggestItem>()
     {
         SuggestionHelper.Suggest(SuggestItemType.Keyword, dataType, "true"),
         SuggestionHelper.Suggest(SuggestItemType.Keyword, dataType, "false")
     });
 }
Beispiel #3
0
        public IEnumerable <SuggestItem> Suggest()
        {
            if (_lastElement == null)
            {
                yield break;
            }

            yield return(SuggestionHelper.Suggest(SuggestItemType.Property, null, _lastElement.Name, null, null, AutoCompletePropertyOnCommit));
        }
        IEnumerable <SuggestItem> PossibleEvents(DataType dataType)
        {
            var validEvents = MemberHelper.GetAllPublicEvents(dataType)
                              .Where(e => IsAttributeNotDefinedAlready(e.Name) && IsMemberNotHidden(e));

            var suggestItems = validEvents
                               .Select(e => SuggestionHelper.Suggest(SuggestItemType.Event, e, e.Name, null, null, AutoCompletePropertyOnCommit));

            return(suggestItems);
        }
        IEnumerable <SuggestItem> PossibleProperties(DataType dataType)
        {
            var properties      = PropertyHelper.GetAllWriteableProperties(dataType);
            var validAttributes = properties.Where(p => IsAttributeNotDefinedAlready(p.Name) && IsMemberNotHidden(p));

            var suggestItems = validAttributes
                               .Select(p => SuggestionHelper.Suggest(SuggestItemType.Property, p, p.Name, null, null, AutoCompletePropertyOnCommit));

            return(suggestItems);
        }
 IEnumerable <SuggestItem> ConvertNamescopesToSuggestions(IEnumerable <Namescope> dataTypes)
 {
     return(dataTypes.Select(d =>
     {
         var itemType = SuggestItemType.Class;
         if (d is Namespace)
         {
             itemType = SuggestItemType.Namespace;
         }
         return SuggestionHelper.Suggest(itemType, d, TypeAliases.HasAlias(d.QualifiedName) ? d.FullName : d.Name);
     }));
 }
        IEnumerable <SuggestItem> SuggestBindingValues()
        {
            var dataType = _parentElement.ToDataType(_dataTypes.AccessibleUxTypes, _namespaces);

            if (dataType == null)
            {
                return(null);
            }

            var properties = PropertyHelper.GetAllWriteableProperties(dataType);

            return(properties.Select(p => SuggestionHelper.Suggest(SuggestItemType.Property, p, p.Name)));
        }
        IEnumerable <SuggestItem> PossibleStandardAttribs()
        {
            var standardSuggestions = StandardAttributesSuggestion.StandardAttributeNames.Where(IsAttributeNotDefinedAlready);
            var suggestItems        = standardSuggestions.Select(
                s =>
                SuggestionHelper.Suggest(
                    SuggestItemType.Property,
                    null,
                    s,
                    null,
                    null,
                    AutoCompletePropertyOnCommit));

            return(suggestItems);
        }
        IEnumerable <SuggestItem> PossibleArguments(DataType dataType)
        {
            var args        = PropertyHelper.GetAllConstructorArguments(dataType);
            var uxParameter = args.Select(p => p.Attributes.FirstOrDefault(a => a.ReturnType.IsOfType(typeof(UXParameterAttribute))));

            var uxParameterValue = uxParameter.Where(p => p != null)
                                   .Select(p => p.Arguments[0].ActualValue as Constant)
                                   .Where(p => p != null)
                                   .Select(p => (string)p.Value);

            var validArgs = uxParameterValue.Where(p => IsAttributeNotDefinedAlready(p));

            var suggestItems = validArgs
                               .Select(uxParam => SuggestionHelper.Suggest(SuggestItemType.Property, uxParameter, uxParam, null, null, AutoCompletePropertyOnCommit));

            return(suggestItems);
        }
        public IEnumerable <SuggestItem> Suggest()
        {
            if (_parentElement == null)
            {
                var dataTypes = DataTypeHelper.GetDataTypesForElement(_targetElement, _dataTypes, _namespaceDeclarations);
                return(ConvertNamescopesToSuggestions(dataTypes));
            }

            var allTypes      = _dataTypes.AccessibleUxTypes;
            var concreteTypes = allTypes.Where(dataType => !dataType.Modifiers.HasFlag(Modifiers.Abstract))
                                .ToArray();

            var parentDataType = _parentElement.ToDataType(_parentElement.Name == "App" ? allTypes : concreteTypes, _namespaceDeclarations);

            if (parentDataType == null)
            {
                return(Enumerable.Empty <SuggestItem>());
            }

            var parentPublicProperties = Task.Run(() => PropertyHelper.GetAllComponentPrimaryOrContentProperties(parentDataType));

            var hasPrefix = HasTargetNamespacePrefix();

            if (hasPrefix)
            {
                return(HandleNamespacePrefix(concreteTypes, parentPublicProperties));
            }

            var ns    = DataTypeHelper.GetQualifiedNamespaceForElement(_targetElement);
            var types = HandleNonNamespacePrefix(DataTypeHelper.GetDataTypesForElement(_targetElement, _dataTypes, _namespaceDeclarations).ToArray(), parentPublicProperties);

            if (ns != null)
            {
                return(types.Concat(ConvertNamescopesToSuggestions(GetNamespacesInNamespace(ns))));
            }
            else
            {
                return(types
                       .Concat(ConvertNamescopesToSuggestions(GetNamespacesInRoot()))
                       .Concat(_namespaceDeclarations.Values.Where(nss => nss != "")
                               .Select(nss => SuggestionHelper.Suggest(SuggestItemType.Namespace, null, nss + ":"))));
            }
        }
 IEnumerable <SuggestItem> SuggestEnumLiterals(EnumType enumType)
 {
     return(enumType.Literals.Select(l => SuggestionHelper.Suggest(SuggestItemType.Constant, l, l.Name)));
 }
        IEnumerable <SuggestItem> SuggestReferenceValue()
        {
            var nameAttributes   = FindUXNameAttributes(_codeReader);
            var namesToDataTypes = ResolveNamesAndTypes(_dataTypes, nameAttributes, _namespaces);

            var elementDataType = _targetElement.ToDataType(_dataTypes.AccessibleUxTypes, _namespaces);

            if (elementDataType == null)
            {
                return(null);
            }

            return(namesToDataTypes.Where(d => d.Value == elementDataType).Select(n => SuggestionHelper.Suggest(SuggestItemType.Variable, n.Value, n.Key)));
        }