Ejemplo n.º 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 TypeSystem.ParseOptions {
                        FileName = textEditor.FileName,
                        Content  = new StringTextSource(text),
                        Project  = Project
                    });
                }
            }
            if (parsedDocument != null)
            {
                await FoldingTextEditorExtension.UpdateFoldings(textEditor, parsedDocument, textEditor.CaretLocation, true);
            }
        }
Ejemplo n.º 2
0
        async Task RunFirstTimeFoldUpdate(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            try {
                ParsedDocument parsedDocument = null;

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