Esempio n. 1
0
        public static void SetTrackedSymbols(HashSet <string> symbolPaths)
        {
            if (DoxygenExec == null)
            {
                return;
            }

            // obtain symbols locations set
            var symbolsLocations = new HashSet <string>();

            symbolPaths.Select(symbol => DoxygenDbCache.GetSymbolLocation(symbol)).ToList().ForEach(
                location =>
            {
                if (!symbolsLocations.Contains(location))
                {
                    symbolsLocations.Add(location);
                }
            });


            var locationsToDisableTracking = new HashSet <string>(_trackedLocations);

            locationsToDisableTracking.ExceptWith(symbolsLocations);

            var locationsToEnableTracking = new HashSet <string>(symbolsLocations);

            locationsToEnableTracking.ExceptWith(_trackedLocations);

            _trackedLocations = symbolsLocations;

            foreach (var locationToDisable in locationsToDisableTracking)
            {
                DoxygenDbCache.DisableTracking(locationToDisable);
            }

            foreach (var locationToEnable in locationsToEnableTracking)
            {
                DoxygenDbCache.EnableTracking(locationToEnable);
            }
        }
Esempio n. 2
0
        public static string GetSymbolDescriptionAndCatchExceptionIntoMarkdownErrors(string path, string originalUserEntry, DescriptionType descriptionType,
                                                                                     TransformationData transformationDataForThisRun, Markdown parser, HashSet <string> foundSymbolPaths = null)
        {
            var outputText = "";
            var isError    = false;
            var isInfo     = false;
            var errorId    = 0;

            try
            {
                var match = SymbolPathPattern.Match(path);

                if (!match.Success)
                {
                    throw new InvalidDoxygenPath(path);
                }

                var symbolPath   = match.Groups["symbolPath"].Value;
                var overloadSpec = match.Groups["overloadSpecification"].Value;

                var symbol = DoxygenDbCache.GetSymbolFromPath(symbolPath);

                if (foundSymbolPaths != null)
                {
                    foundSymbolPaths.Add(symbolPath);
                }

                if (symbol.IsOverloadedMember)
                {
                    if (string.IsNullOrWhiteSpace(overloadSpec))
                    {
                        throw new DoxygenAmbiguousSymbolException(path, symbol.GetOverloadSpecificationOptions());
                    }

                    outputText = symbol.GetSymbolDescription(descriptionType, overloadSpec);
                }
                else
                {
                    outputText = symbol.GetSymbolDescription(descriptionType);
                }
            }
            catch (Exception e)
            {
                errorId = transformationDataForThisRun.ErrorList.Count;
                transformationDataForThisRun.ErrorList.Add(
                    Markdown.GenerateError(
                        Language.Message("DoxygenQueryError", e.Message),
                        MessageClass.Error, originalUserEntry, errorId, transformationDataForThisRun));

                isError = true;

                // rethrowing if not known exception
                if (!(e is InvalidDoxygenPath) && !(e is SymbolNotFoundInDoxygenXmlFile) && !(e is DoxygenAmbiguousSymbolException))
                {
                    throw;
                }
            }

            if (parser.ThisIsPreview && (isInfo || isError))
            {
                return(Templates.ErrorHighlight.Render(Hash.FromAnonymousObject(
                                                           new
                {
                    errorId = errorId,
                    errorText = outputText
                })));
            }

            return(outputText);
        }
        public static void InvalidateDbCache()
        {
            if (_doxygenDbCache == null)
            {
                return;
            }

            _doxygenDbCache.Dispose();
            _doxygenDbCache = null;
        }