public static BaseInfo GetResolvedReference(this MSBuildResolveResult rr, MSBuildRootDocument doc)
        {
            switch (rr.ReferenceKind)
            {
            case MSBuildReferenceKind.Item:
                return(doc.GetItem((string)rr.Reference));

            case MSBuildReferenceKind.Metadata:
                var m = rr.ReferenceAsMetadata;
                return(doc.GetMetadata(m.itemName, m.metaName, true));

            case MSBuildReferenceKind.Property:
                return(doc.GetProperty((string)rr.Reference));

            case MSBuildReferenceKind.Task:
                return(doc.GetTask((string)rr.Reference));

            case MSBuildReferenceKind.Target:
                return(doc.GetTarget((string)rr.Reference));

            case MSBuildReferenceKind.Keyword:
                return((BaseInfo)rr.Reference);

            case MSBuildReferenceKind.KnownValue:
                return((BaseInfo)rr.Reference);

            case MSBuildReferenceKind.TargetFramework:
                return(ResolveFramework((string)rr.Reference));

            case MSBuildReferenceKind.TargetFrameworkIdentifier:
                return(BestGuessResolveFrameworkIdentifier((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkVersion:
                return(BestGuessResolveFrameworkVersion((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkProfile:
                return(BestGuessResolveFrameworkProfile((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TaskParameter:
                var p = rr.ReferenceAsTaskParameter;
                return(doc.GetTaskParameter(p.taskName, p.paramName));
            }
            return(null);
        }
        public static BaseInfo GetResolvedReference(this MSBuildResolveResult rr, MSBuildRootDocument doc)
        {
            switch (rr.ReferenceKind)
            {
            case MSBuildReferenceKind.Item:
                return(doc.GetItem((string)rr.Reference));

            case MSBuildReferenceKind.Metadata:
                var m = rr.ReferenceAsMetadata;
                if (Builtins.Metadata.TryGetValue(m.metaName, out var builtinMeta))
                {
                    return(builtinMeta);
                }
                return(doc.GetMetadata(m.itemName, m.metaName, true));

            case MSBuildReferenceKind.Property:
                var propName = (string)rr.Reference;
                if (Builtins.Properties.TryGetValue(propName, out var builtinProp))
                {
                    return(builtinProp);
                }
                return(doc.GetProperty(propName));

            case MSBuildReferenceKind.Task:
                return(doc.GetTask((string)rr.Reference));

            case MSBuildReferenceKind.Target:
                return(doc.GetTarget((string)rr.Reference));

            case MSBuildReferenceKind.Keyword:
                return((BaseInfo)rr.Reference);

            case MSBuildReferenceKind.KnownValue:
                return((BaseInfo)rr.Reference);

            case MSBuildReferenceKind.TargetFramework:
                return(ResolveFramework((string)rr.Reference));

            case MSBuildReferenceKind.TargetFrameworkIdentifier:
                return(BestGuessResolveFrameworkIdentifier((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkVersion:
                return(BestGuessResolveFrameworkVersion((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkProfile:
                return(BestGuessResolveFrameworkProfile((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TaskParameter:
                var p = rr.ReferenceAsTaskParameter;
                return(doc.GetTaskParameter(p.taskName, p.paramName));

            case MSBuildReferenceKind.ItemFunction:
                //FIXME: attempt overload resolution
                return(FunctionCompletion.GetItemFunctionInfo((string)rr.Reference));

            case MSBuildReferenceKind.StaticPropertyFunction:
                //FIXME: attempt overload resolution
                (string className, string name) = ((string, string))rr.Reference;
                return(FunctionCompletion.GetStaticPropertyFunctionInfo(className, name));

            case MSBuildReferenceKind.PropertyFunction:
                //FIXME: attempt overload resolution
                (MSBuildValueKind kind, string funcName) = ((MSBuildValueKind, string))rr.Reference;
                return(FunctionCompletion.GetPropertyFunctionInfo(kind, funcName));

            case MSBuildReferenceKind.ClassName:
                return(FunctionCompletion.GetClassInfo((string)rr.Reference));

            case MSBuildReferenceKind.Enum:
                return(FunctionCompletion.GetEnumInfo((string)rr.Reference));
            }
            return(null);
        }
示例#3
0
        public static ISymbol GetResolvedReference(this MSBuildResolveResult rr, MSBuildRootDocument doc, IFunctionTypeProvider functionTypeProvider)
        {
            switch (rr.ReferenceKind)
            {
            case MSBuildReferenceKind.Item:
                return(doc.GetItem((string)rr.Reference));

            case MSBuildReferenceKind.Metadata:
                var m = rr.ReferenceAsMetadata;
                return(doc.GetMetadata(m.itemName, m.metaName, true));

            case MSBuildReferenceKind.Property:
                return(doc.GetProperty((string)rr.Reference, true));

            case MSBuildReferenceKind.Task:
                return(doc.GetTask((string)rr.Reference));

            case MSBuildReferenceKind.Target:
                return(doc.GetTarget((string)rr.Reference));

            case MSBuildReferenceKind.Keyword:
                return((ISymbol)rr.Reference);

            case MSBuildReferenceKind.KnownValue:
                return((ISymbol)rr.Reference);

            case MSBuildReferenceKind.TargetFramework:
                return(ResolveFramework((string)rr.Reference));

            case MSBuildReferenceKind.TargetFrameworkIdentifier:
                return(BestGuessResolveFrameworkIdentifier((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkVersion:
                return(BestGuessResolveFrameworkVersion((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TargetFrameworkProfile:
                return(BestGuessResolveFrameworkProfile((string)rr.Reference, doc.Frameworks));

            case MSBuildReferenceKind.TaskParameter:
                var p = rr.ReferenceAsTaskParameter;
                return(doc.GetTaskParameter(p.taskName, p.paramName));

            case MSBuildReferenceKind.ItemFunction:
                //FIXME: attempt overload resolution
                return(functionTypeProvider.GetItemFunctionInfo((string)rr.Reference));

            case MSBuildReferenceKind.StaticPropertyFunction:
                //FIXME: attempt overload resolution
                (string className, string name) = ((string, string))rr.Reference;
                return(functionTypeProvider.GetStaticPropertyFunctionInfo(className, name));

            case MSBuildReferenceKind.PropertyFunction:
                //FIXME: attempt overload resolution
                (MSBuildValueKind kind, string funcName) = ((MSBuildValueKind, string))rr.Reference;
                return(functionTypeProvider.GetPropertyFunctionInfo(kind, funcName));

            case MSBuildReferenceKind.ClassName:
                return(functionTypeProvider.GetClassInfo((string)rr.Reference));

            case MSBuildReferenceKind.Enum:
                return(functionTypeProvider.GetEnumInfo((string)rr.Reference));

            case MSBuildReferenceKind.ConditionFunction:
                if (Builtins.ConditionFunctions.TryGetValue((string)rr.Reference, out var conditionFunctionName))
                {
                    return(conditionFunctionName);
                }
                return(null);
            }
            return(null);
        }