Esempio n. 1
0
        public BaseItem GetFileItem(string filename)
        {
            // A factory method to return a file item for a specific file,
            // for this plugin, which will be held as a reference in the UI.
            JSFileItem item = new JSFileItem(filename, null);

            return(item);
        }
Esempio n. 2
0
        public bool ReadItem(BaseItem item, bool unload)
        {
            lock (_lockObj)
            {
                JSFileItem jsFileItem = (JSFileItem)item;

                ReadJSFileItem(jsFileItem, unload);
            }
            return(true);
        }
Esempio n. 3
0
        private void ReadJSFileItem(JSFileItem item, bool unload)
        {
            try
            {
                // Check if we've already read this file.
                if (item.Block != null)
                {
                    // Clear the caches.
                    item.Classes.Clear();
                    item.Methods.Clear();
                    _classLookup.Clear();
                    _currentMethodStack.Clear();

                    // Remove structure from the IProjectBrowser lookup dictionary.
                    _invert = true;
                    ParseAstList(item.Block.src_elems.elems, string.Empty);
                }

                if (!unload)
                {
                    //todo common
                    // Clear the caches.
                    item.Classes.Clear();
                    item.Methods.Clear();
                    _classLookup.Clear();
                    _currentMethodStack.Clear();

                    // Create the AST using our JS parser.
                    string      filename = item.ItemPath;
                    string      text     = File.ReadAllText(filename);
                    ScriptBlock block    = (ScriptBlock)_parser.Parse(text, filename, 0);

                    // Add structure to the IProjectBrowser lookup dictionary.
                    _fileItem = item;
                    _invert   = false;
                    ParseAstList(block.src_elems.elems, string.Empty);

                    _fileItem.Block = block;
                }
            }
            catch (Exception exc)
            {
                _logView.LogExcStr(exc, "ReadJSFileItem failed :" + item.ItemPath);
            }
        }
Esempio n. 4
0
        private void ReadJSFileItem(JSFileItem item, bool unload)
        {
            try
            {
                // Check if we've already read this file.
                if (item.Block != null)
                {
                    // Clear the caches.
                    item.Classes.Clear();
                    item.Methods.Clear();
                    _classLookup.Clear();
                    _currentMethodStack.Clear();

                    // Remove structure from the IProjectBrowser lookup dictionary.
                    _invert = true;
                    ParseAstList(item.Block.src_elems.elems, string.Empty);
                }

                if (!unload)
                {
                    //todo common
                    // Clear the caches.
                    item.Classes.Clear();
                    item.Methods.Clear();
                    _classLookup.Clear();
                    _currentMethodStack.Clear();

                    // Create the AST using our JS parser.
                    string filename = item.ItemPath;
                    string text = File.ReadAllText(filename);
                    ScriptBlock block = (ScriptBlock)_parser.Parse(text, filename, 0);

                    // Add structure to the IProjectBrowser lookup dictionary.
                    _fileItem = item;
                    _invert = false;
                    ParseAstList(block.src_elems.elems, string.Empty);

                    _fileItem.Block = block;
                }
            }
            catch (Exception exc)
            {
                _logView.LogExcStr(exc, "ReadJSFileItem failed :" + item.ItemPath);
            }
        }
Esempio n. 5
0
        public BaseItem GetFileItem(string filename)
        {
            // A factory method to return a file item for a specific file,
            // for this plugin, which will be held as a reference in the UI.
            JSFileItem item = new JSFileItem(filename, null);

            return item;
        }