public SQDeclaration Parse(ITextBuffer buffer, out bool newversion)
        {
            string filepath = SQLanguageServiceEX.GetFileName(buffer);

            SQDeclaration.SQFile file = (SQDeclaration.SQFile)RegisterFileDeclaration(filepath);
            if (file != null)
            {
                var    snapshot   = buffer.CurrentSnapshot;
                int    version    = snapshot.Version.VersionNumber;
                int    oldversion = file.FileVersion;
                string src        = snapshot.GetText();
                if (file.FileVersion < version)
                {
                    //Compile(src, ref error);
                    file.Parse(src, version);
                }
                newversion = oldversion != file.FileVersion;
            }
            else
            {
                newversion = false;
            }

            return(file);
        }
        public bool Compile(ITextBuffer buffer, ref SQCompileError error)
        {
            bool   result   = _instance.Compile(buffer.CurrentSnapshot.GetText(), ref error);
            string filepath = SQLanguageServiceEX.GetFileName(buffer);

            RegisterError(true, null, filepath, ref error);
            return(result);
        }
        public SQDeclaration Dive(ITextBuffer buffer, int line, int lineindex)
        {
            string filename = SQLanguageServiceEX.GetFileName(buffer);
            int    id       = this.Children.FindIndex(x => { return(x.Key == filename); });

            if (id != -1)
            {
                return(this.Children[id].Value.Dive(line, lineindex));
            }
            return(null);
        }
        public SQDeclaration Parse(ITextBuffer buffer, out bool isnewversion)
        {
            if (_instance == null)
            {
                _instance = new SQInstance(SquirrelVersion.Squirrel3);
            }

            isnewversion = false;
            string filepath = SQLanguageServiceEX.GetFileName(buffer);

            int           version = _instance.GetVersion(filepath);
            SQDeclaration d       = _instance.Parse(buffer, out isnewversion);

            if (d != null)
            {
                MapObjects(GetNode(filepath), d);
            }
            //RegisterError(isnewversion, d, filepath, null);
            return(d);
        }