Ejemplo n.º 1
0
        /// <summary>
        /// Called before executing script f. If returns true, don't need to compile.
        /// </summary>
        /// <param name="f"></param>
        /// <param name="r">Receives file path and execution options.</param>
        /// <param name="projFolder">Project folder or null. If not null, f must be its main file.</param>
        public bool IsCompiled(FileNode f, out CompResults r, FileNode projFolder)
        {
            r = new CompResults();

            if (_data == null && !_Open())
            {
                return(false);
            }

            if (!_data.TryGetValue(f.Id, out string value))
            {
                return(false);
            }
            //Debug_.Print(value);
            int iPipe = 0;

            bool isScript = f.IsScript;

            r.role = MetaComments.DefaultRole(isScript);

            string asmFile;

            if (r.notInCache = value?.Starts("|=") ?? false)
            {
                iPipe = value.IndexOf('|', 2); if (iPipe < 0)
                {
                    iPipe = value.Length;
                }
                asmFile = value[2..iPipe];
Ejemplo n.º 2
0
 static void _Uncache()
 {
     //AOutput.Write("_Uncache");
     CurrentWorkspace = null;
     _solution        = null;
     _projectId       = null;
     _documentId      = null;
     _document        = null;
     _meta            = null;
     _metaText        = null;
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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());
        }
    }
Ejemplo n.º 5
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');
Ejemplo n.º 6
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);
    }