Exemplo n.º 1
0
        public static IEnumerable <ISymbol> GetCompletionInfos(
            MSBuildResolveResult rr,
            TriggerState trigger, MSBuildValueKind kind,
            ExpressionNode triggerExpression, int triggerLength,
            MSBuildRootDocument doc, IFunctionTypeProvider functionTypeProvider)
        {
            switch (trigger)
            {
            case TriggerState.Value:
                return(MSBuildCompletionExtensions.GetValueCompletions(kind, doc, rr, triggerExpression));

            case TriggerState.ItemName:
                return(doc.GetItems());

            case TriggerState.MetadataName:
                return(doc.GetMetadata(null, true));

            case TriggerState.PropertyName:
                return(doc.GetProperties(true));

            case TriggerState.MetadataOrItemName:
                return(((IEnumerable <ISymbol>)doc.GetItems()).Concat(doc.GetMetadata(null, true)));

            case TriggerState.DirectorySeparator:
                return(MSBuildCompletionExtensions.GetFilenameCompletions(kind, doc, triggerExpression, triggerLength, rr));

            case TriggerState.PropertyFunctionName:
                return(functionTypeProvider.GetPropertyFunctionNameCompletions(triggerExpression));

            case TriggerState.ItemFunctionName:
                return(functionTypeProvider.GetItemFunctionNameCompletions());

            case TriggerState.PropertyFunctionClassName:
                return(functionTypeProvider.GetClassNameCompletions());

            case TriggerState.None:
                break;

            case TriggerState.BareFunctionArgumentValue:
                //FIXME: enum completion etc
                return(MSBuildValueKind.Bool.GetSimpleValues(true));

            case TriggerState.ConditionFunctionName:
                return(Builtins.ConditionFunctions.Values);
            }
            throw new InvalidOperationException($"Unhandled trigger type {trigger}");
        }
Exemplo n.º 2
0
        public static IEnumerable <ISymbol> GetComparandCompletions(MSBuildRootDocument doc, IReadOnlyList <ExpressionNode> variables)
        {
            var names = new HashSet <string> ();

            foreach (var variable in variables)
            {
                VariableInfo info;
                switch (variable)
                {
                case ExpressionProperty ep:
                    if (ep.IsSimpleProperty)
                    {
                        info = doc.GetProperty(ep.Name, true) ?? new PropertyInfo(ep.Name, null, false);
                        break;
                    }
                    continue;

                case ExpressionMetadata em:
                    info = doc.GetMetadata(em.ItemName, em.MetadataName, true) ?? new MetadataInfo(em.MetadataName, null, false);
                    break;

                default:
                    continue;
                }

                if (info == null)
                {
                    continue;
                }

                IEnumerable <ISymbol> cinfos;
                if (info.CustomType != null && info.CustomType.Values.Count > 0)
                {
                    cinfos = info.CustomType.Values;
                }
                else
                {
                    var kind = info.InferValueKindIfUnknown();
                    cinfos = MSBuildCompletionExtensions.GetValueCompletions(kind, doc);
                }

                if (cinfos != null)
                {
                    foreach (var ci in cinfos)
                    {
                        if (names.Add(ci.Name))
                        {
                            yield return(ci);
                        }
                    }
                }
            }
        }