public static void SortResourceEntries(IServiceProvider serviceProvider, Document document)
        {
            var textDocument = (TextDocument)document.Object("TextDocument");

            EditPoint startPoint = textDocument.StartPoint.CreateEditPoint();
            EditPoint endPoint   = textDocument.EndPoint.CreateEditPoint();

            string content = startPoint.GetText(textDocument.EndPoint);

            try
            {
                content = ResXHelper.SortResX(content);
                startPoint.ReplaceText(endPoint, content, 0);
            }
            catch (Exception ex)
            {
                ErrorHandler.LogException(ex);
                ErrorHandler.ShowErrorMessage(serviceProvider, "See log for details..");
            }
        }
Example #2
0
        protected override void InternalLoadData(IProducerConsumerCollection <ResourceSearchResult> result, CancellationToken cancellationToken)
        {
            result.TryAdd(CreateFromSymbol(_designerPropertySymbol));

            string           resourceName  = _designerPropertySymbol.Name;
            INamedTypeSymbol designerClass = _designerPropertySymbol.ContainingType;

            SyntaxTree syntaxTree = designerClass.Locations.First().SourceTree;
            string     filePath   = syntaxTree?.FilePath;

            foreach (string resx in DocumentHelper.GetRelatedResXFiles(filePath, designerClass.Name))
            {
                var dataElement = ResXHelper.FindResourceEntryElement(resx, resourceName);
                var lineInfo    = dataElement as IXmlLineInfo;

                if (lineInfo != null && lineInfo.HasLineInfo())
                {
                    result.TryAdd(CreateFromXmlElement(resx, dataElement));
                }
            }
        }