Exemple #1
0
        async Task RunFirstTimeFoldUpdate(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            ParsedDocument parsedDocument = null;

            var foldingParser = TypeSystemService.GetFoldingParser(textEditor.MimeType);

            if (foldingParser != null)
            {
                parsedDocument = foldingParser.Parse(textEditor.FileName, text);
            }
            else
            {
                var normalParser = TypeSystemService.GetParser(textEditor.MimeType);
                if (normalParser != null)
                {
                    parsedDocument = await normalParser.Parse(
                        new MonoDevelop.Ide.TypeSystem.ParseOptions {
                        FileName = textEditor.FileName,
                        Content  = new StringTextSource(text),
                        Project  = Project
                    });
                }
            }
            if (parsedDocument != null)
            {
                await UpdateFoldings(parsedDocument, textEditor.CaretLocation, true);
            }
        }
Exemple #2
0
        async Task RunFirstTimeFoldUpdate(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            try {
                ParsedDocument parsedDocument = null;

                var foldingParser = TypeSystemService.GetFoldingParser(textEditor.MimeType);
                if (foldingParser != null)
                {
                    parsedDocument = foldingParser.Parse(textEditor.FileName, text);
                }
                else
                {
                    var normalParser = TypeSystemService.GetParser(textEditor.MimeType);
                    if (normalParser != null)
                    {
                        parsedDocument = await normalParser.Parse(
                            new TypeSystem.ParseOptions {
                            FileName = textEditor.FileName,
                            Content  = new StringTextSource(text),
                            Project  = Project
                        });
                    }
                }
                if (parsedDocument != null)
                {
                    await FoldingTextEditorExtension.UpdateFoldings(textEditor, parsedDocument, textEditor.CaretLocation, true);
                }
            } catch (Exception e) {
                LoggingService.LogError("Error running first time fold update", e);
            }
        }