Exemplo n.º 1
0
        private static CMakeItemDeclarations CreateGetXPropertyDeclarations(
            CMakeCommandId id, ParseRequest req, Source source,
            List <string> priorParameters)
        {
            int priorParameterCount =
                priorParameters != null ? priorParameters.Count : 0;

            if (priorParameterCount == CMakeProperties.GetPropertyParameterIndex(id))
            {
                IEnumerable <string> properties = CMakeProperties.GetPropertiesForCommand(id);
                if (properties != null)
                {
                    CMakeItemDeclarations decls = new CMakeItemDeclarations();
                    decls.AddItems(properties, CMakeItemDeclarations.ItemType.Property);
                    if (id == CMakeCommandId.GetDirectoryProperty)
                    {
                        // The DIRECTORY keyword can be specified before the property
                        // to set a property of a different directory.
                        decls.AddItem("DIRECTORY",
                                      CMakeItemDeclarations.ItemType.Command);
                    }
                    return(decls);
                }
            }
            else if (priorParameterCount == CMakeProperties.GetObjectParameterIndex(id))
            {
                CMakePropertyType type = CMakeProperties.GetPropertyTypeFromCommand(id);
                if (_propObjMethods.ContainsKey(type))
                {
                    CMakeItemDeclarations decls = _propObjMethods[type](id, req, source,
                                                                        priorParameters);
                    return(decls);
                }
            }
            else if (id == CMakeCommandId.GetDirectoryProperty &&
                     priorParameterCount == 2 && priorParameters[1] == "DIRECTORY")
            {
                return(CreateSubdirectoryDeclarations(id, req, source, priorParameters));
            }
            else if (id == CMakeCommandId.GetDirectoryProperty &&
                     priorParameterCount == 3 && priorParameters[1] == "DIRECTORY")
            {
                IEnumerable <string> properties = CMakeProperties.GetPropertiesForCommand(
                    CMakeCommandId.GetDirectoryProperty);
                if (properties != null)
                {
                    CMakeItemDeclarations decls = new CMakeItemDeclarations();
                    decls.AddItems(properties, CMakeItemDeclarations.ItemType.Property);
                    return(decls);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private static CMakeItemDeclarations CreateSetXPropertyDeclarations(
            CMakeCommandId id, ParseRequest req, Source source,
            List <string> priorParameters)
        {
            bool afterPropsKeyword = false;

            if (priorParameters != null)
            {
                int index = priorParameters.FindIndex(x => x.Equals("PROPERTIES"));
                if (index >= 0)
                {
                    afterPropsKeyword = true;
                    if ((priorParameters.Count - index) % 2 == 1)
                    {
                        IEnumerable <string> properties =
                            CMakeProperties.GetPropertiesForCommand(id);
                        if (properties != null)
                        {
                            CMakeItemDeclarations decls = new CMakeItemDeclarations();
                            decls.AddItems(properties,
                                           CMakeItemDeclarations.ItemType.Property);
                            return(decls);
                        }
                    }
                }
            }
            if (!afterPropsKeyword)
            {
                CMakeItemDeclarations decls;
                CMakePropertyType     type = CMakeProperties.GetPropertyTypeFromCommand(id);
                if (_propObjMethods.ContainsKey(type))
                {
                    decls = _propObjMethods[type](id, req, source, priorParameters);
                }
                else
                {
                    decls = new CMakeItemDeclarations();
                }
                if ((priorParameters != null && priorParameters.Count > 0) ||
                    id == CMakeCommandId.SetSourceFilesProperties ||
                    id == CMakeCommandId.SetDirectoryProperties)
                {
                    // The PROPERTIES can appear in the SET_SOURCE_FILES_PROPERTIES and
                    // SET_DIRECTORY_PROPERTIES command without another parameter before
                    // it.
                    decls.AddItem("PROPERTIES", CMakeItemDeclarations.ItemType.Command);
                }
                return(decls);
            }
            return(null);
        }