Пример #1
0
        public SemanticModel semanticModel => document.GetSemanticModelAsync().Result;         //only first time slow

        /// <summary>
        /// Initializes all fields except document.
        /// For <b>sci</b> uses <b>Panels.Editor.ZActiveDoc</b>.
        /// </summary>
        /// <param name="pos">If -1, gets current position. If -2, gets selection start.</param>
        public Context(int pos)
        {
            Debug.Assert(Environment.CurrentManagedThreadId == 1);

            sci      = Panels.Editor.ZActiveDoc;
            code     = sci.zText;
            this.pos = pos switch { -1 => sci.zCurrentPos16, -2 => sci.zSelectionStart16, _ => pos };
            if (isCodeFile = sci.ZFile.IsCodeFile)
            {
                meta = MetaComments.FindMetaComments(code);
            }
        }
Пример #2
0
    public EdMetaCommentsParser(string code)
    {
        int endOf = MetaComments.FindMetaComments(code);

        if (endOf == 0)
        {
            return;
        }
        EndOfMetaComments = endOf;
        foreach (var t in MetaComments.EnumOptions(code, endOf))
        {
            _ParseOption(t.Name(), t.Value());
        }
    }
Пример #3
0
    public MetaCommentsParser(string code)
    {
        var meta = MetaComments.FindMetaComments(code);

        if (meta.end == 0)
        {
            return;
        }
        MetaRange = meta;
        foreach (var t in MetaComments.EnumOptions(code, meta))
        {
            _ParseOption(t.Name(), t.Value());
        }
        _multiline = code[meta.start..meta.end].Contains('\n');
Пример #4
0
    private void _bOK_Click(object sender, EventArgs e)
    {
        if (Program.Model.CurrentFile != _f && !Program.Model.SetCurrentFile(_f))
        {
            return;
        }
        var doc   = Panels.Editor.ZActiveDoc;
        var t     = doc.Z;
        var code  = doc.Text;
        int endOf = MetaComments.FindMetaComments(code);

        if (!_GetGrid())
        {
            this.DialogResult = DialogResult.None; return;
        }
        ;

        string append = null; if (endOf == 0)
        {
            append = (_f.IsScript && code.Starts("//.\r")) ? " " : "\r\n";
        }
        var s = _meta.Format(append);

        if (s.Length == 0)
        {
            if (endOf == 0)
            {
                return;
            }
            while (endOf < code.Length && code[endOf] <= ' ')
            {
                endOf++;
            }
        }
        else if (s.Length == endOf)
        {
            if (s == t.RangeText(true, 0, endOf))
            {
                return;                                              //did not change
            }
        }

        t.ReplaceRange(true, 0, endOf, s);
    }