示例#1
0
        public int get_OutputGroups(uint celt, IVsOutputGroup[] rgpcfg, uint[] pcActual = null)
        {
            IVsProjectCfg2 projCfg = _pythonCfg as IVsProjectCfg2;

            if (projCfg != null)
            {
                return(projCfg.get_OutputGroups(celt, rgpcfg, pcActual));
            }
            return(VSConstants.E_NOTIMPL);
        }
示例#2
0
        private static IEnumerable <string> EnumerateOutputs(IVsProjectCfg2 config, string canonicalName)
        {
            var actual = new uint[1];

            ErrorHandler.ThrowOnFailure(config.get_OutputGroups(0, null, actual));
            var groups = new IVsOutputGroup[actual[0]];

            ErrorHandler.ThrowOnFailure(config.get_OutputGroups((uint)groups.Length, groups, actual));

            var group = groups.FirstOrDefault(g =>
            {
                string name;
                ErrorHandler.ThrowOnFailure(g.get_CanonicalName(out name));
                return(canonicalName.Equals(name, StringComparison.OrdinalIgnoreCase));
            });

            if (group == null)
            {
                return(Enumerable.Empty <string>());
            }

            string keyName;

            if (!ErrorHandler.Succeeded(group.get_KeyOutput(out keyName)))
            {
                keyName = null;
            }

            try
            {
                ErrorHandler.ThrowOnFailure(group.get_Outputs(0, null, actual));
            }
            catch (NotImplementedException)
            {
                if (CommonUtils.IsValidPath(keyName))
                {
                    return(Enumerable.Repeat(keyName, 1));
                }
                throw;
            }
            var outputs = new IVsOutput2[actual[0]];

            ErrorHandler.ThrowOnFailure(group.get_Outputs((uint)outputs.Length, outputs, actual));

            string keyResult = null;
            var    results   = new List <string>();

            foreach (var o in outputs)
            {
                string name;
                if (keyName != null &&
                    ErrorHandler.Succeeded(o.get_CanonicalName(out name)) &&
                    keyName.Equals(name, StringComparison.OrdinalIgnoreCase)
                    )
                {
                    keyResult = GetFilenameFromOutput(o);
                }
                else
                {
                    results.Add(GetFilenameFromOutput(o));
                }
            }

            if (keyResult != null)
            {
                results.Insert(0, keyResult);
            }
            return(results);
        }
示例#3
0
        private static IEnumerable<string> EnumerateOutputs(IVsProjectCfg2 config, string canonicalName) {
            var actual = new uint[1];
            ErrorHandler.ThrowOnFailure(config.get_OutputGroups(0, null, actual));
            var groups = new IVsOutputGroup[actual[0]];
            ErrorHandler.ThrowOnFailure(config.get_OutputGroups((uint)groups.Length, groups, actual));

            var group = groups.FirstOrDefault(g => {
                string name;
                ErrorHandler.ThrowOnFailure(g.get_CanonicalName(out name));
                return canonicalName.Equals(name, StringComparison.OrdinalIgnoreCase);
            });
            if (group == null) {
                return Enumerable.Empty<string>();
            }

            string keyName;
            if (!ErrorHandler.Succeeded(group.get_KeyOutput(out keyName))) {
                keyName = null;
            }

            try {
                ErrorHandler.ThrowOnFailure(group.get_Outputs(0, null, actual));
            } catch (NotImplementedException) {
                if (CommonUtils.IsValidPath(keyName)) {
                    return Enumerable.Repeat(keyName, 1);
                }
                throw;
            }
            var outputs = new IVsOutput2[actual[0]];
            ErrorHandler.ThrowOnFailure(group.get_Outputs((uint)outputs.Length, outputs, actual));

            string keyResult = null;
            var results = new List<string>();

            foreach (var o in outputs) {
                string name;
                if (keyName != null &&
                    ErrorHandler.Succeeded(o.get_CanonicalName(out name)) &&
                    keyName.Equals(name, StringComparison.OrdinalIgnoreCase)
                ) {
                    keyResult = GetFilenameFromOutput(o);
                } else {
                    results.Add(GetFilenameFromOutput(o));
                }
            }

            if (keyResult != null) {
                results.Insert(0, keyResult);
            }
            return results;
        }