public OverviewWalker(ProjectEntry entry, AnalysisUnit topAnalysis, JsAst tree, bool isNested = false) {
            _entry = entry;
            _curUnit = topAnalysis;
            _isNested = isNested;
            _tree = tree;

            _scope = topAnalysis.Environment;
        }
Esempio n. 2
0
 public void Format(JsAst ast) {
     RemoveTrailingWhiteSpace(ast.GetStartIndex(_tree.LocationResolver));
     WalkStatements(ast, ast.Block.Statements, false);
     if (ast.Block.Count > 0) {
         FixStatementIndentation(ast.Block[ast.Block.Count - 1].GetEndIndex(_tree.LocationResolver), ast.GetEndIndex(_tree.LocationResolver));
     }
     ReplacePreceedingWhiteSpace(ast.GetEndIndex(_tree.LocationResolver));
 }
Esempio n. 3
0
        internal GlobalScope(JsAst node, ErrorSink errorSink)
            : base(node, null, errorSink)
        {
            // define the Global object's properties, and methods
            m_globalProperties = new HashSet<string>(new[] { 
                "Infinity", "NaN", "undefined", "window", "Image", "JSON", "Math", "XMLHttpRequest", "DOMParser",
                "applicationCache", "clientInformation", "clipboardData", "closed", "console", "document", "event", "external", "frameElement", "frames", "history", "length", "localStorage", "location", "name", "navigator", "opener", "parent", "screen", "self", "sessionStorage", "status", "top"});

            m_globalFunctions = new HashSet<string>(new[] {
                "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "importScripts", "isNaN", "isFinite", "parseFloat", "parseInt", "unescape", "ActiveXObject", "Array", "Boolean", "Date", "Error", "EvalError", "EventSource", "File", "FileList", "FileReader", "Function", "GeckoActiveXObject", "HTMLElement", "Number", "Object", "Proxy", "RangeError", "ReferenceError", "RegExp", "SharedWorker", "String", "SyntaxError", "TypeError", "URIError", "WebSocket", "Worker",
                "addEventListener", "alert", "attachEvent", "blur", "clearInterval", "clearTimeout", "close", "confirm", "createPopup", "detachEvent", "dispatchEvent", "execScript", "focus", "getComputedStyle", "getSelection", "moveBy", "moveTo", "navigate", "open", "postMessage", "prompt", "removeEventListener", "resizeBy", "resizeTo", "scroll", "scrollBy", "scrollTo", "setActive", "setInterval", "setTimeout", "showModalDialog", "showModelessDialog" });
        }
Esempio n. 4
0
        internal GlobalScope(JsAst node, ErrorSink errorSink)
            : base(node, null, errorSink)
        {
            // define the Global object's properties, and methods
            m_globalProperties = new HashSet <string>(new[] {
                "Infinity", "NaN", "undefined", "window", "Image", "JSON", "Math", "XMLHttpRequest", "DOMParser",
                "applicationCache", "clientInformation", "clipboardData", "closed", "console", "document", "event", "external", "frameElement", "frames", "history", "length", "localStorage", "location", "name", "navigator", "opener", "parent", "screen", "self", "sessionStorage", "status", "top"
            });

            m_globalFunctions = new HashSet <string>(new[] {
                "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "importScripts", "isNaN", "isFinite", "parseFloat", "parseInt", "unescape", "ActiveXObject", "Array", "Boolean", "Date", "Error", "EvalError", "EventSource", "File", "FileList", "FileReader", "Function", "GeckoActiveXObject", "HTMLElement", "Number", "Object", "Proxy", "RangeError", "ReferenceError", "RegExp", "SharedWorker", "String", "SyntaxError", "TypeError", "URIError", "WebSocket", "Worker",
                "addEventListener", "alert", "attachEvent", "blur", "clearInterval", "clearTimeout", "close", "confirm", "createPopup", "detachEvent", "dispatchEvent", "execScript", "focus", "getComputedStyle", "getSelection", "moveBy", "moveTo", "navigate", "open", "postMessage", "prompt", "removeEventListener", "resizeBy", "resizeTo", "scroll", "scrollBy", "scrollTo", "setActive", "setInterval", "setTimeout", "showModalDialog", "showModelessDialog"
            });
        }
Esempio n. 5
0
 public override bool Walk(JsAst jsAst) { return true; }
Esempio n. 6
0
 public ParseTreeWalker(JsAst tree) {
     _tree = tree;
 }
 public void GetTreeAndCookie(out JsAst tree, out IAnalysisCookie cookie) {
     lock (this) {
         tree = _tree;
         cookie = _cookie;
     }
 }
 public override int GetStop(JsAst ast) {
     return ast.IndexToLocation(_endIndex).Index;
 }
Esempio n. 9
0
 internal EvalAnalysisUnit(Statement ast, JsAst tree, EnvironmentRecord scope)
     : base(ast, tree, scope) {
 }
 public override int GetStop(JsAst ast) {
     return _endIndex;
 }
 /// <summary>
 /// Gets the index in the file/buffer that the scope actually starts on.  This is the index where the colon
 /// is on for the start of the body if we're a function or class definition.
 /// </summary>
 public override int GetBodyStart(JsAst ast) {
     return GetStart(ast);
 }
 /// <summary>
 /// Gets the index in the file/buffer that this scope starts at.  This is the index which includes
 /// the definition it's self (e.g. def fob(...) or class fob(...)).
 /// </summary>
 public abstract int GetStart(JsAst ast);
 /// <summary>
 /// Gets the index in the file/buffer that this scope ends at.
 /// </summary>
 public abstract int GetStop(JsAst ast);
 public RangeVisitor(char typedChar, int position, JsAst tree) {
     _typedChar = typedChar;
     _position = position;
     _tree = tree;
 }
 private static List<Edit> GetEdits(string code, FormattingOptions options, JsAst ast, bool onEnter = false) {
     var visitor = new FormattingVisitor(code, ast, options, onEnter);
     visitor.Format(ast);
     return visitor.Edits;
 }
 public override int GetBodyStart(JsAst ast) {
     return ((FunctionObject)Node).Body.GetStartIndex(ast.LocationResolver);
 }
 /// <summary>
 /// Gets the index in the file/buffer that this scope starts at.  This is the index which includes
 /// the definition it's self (e.g. def fob(...) or class fob(...)).
 /// </summary>
 public sealed override int GetStart(JsAst ast) {
     if (_node == null) {
         return 1;
     }
     return _node.GetStart(ast.LocationResolver).Index;
 }
 public override int GetBodyStart(JsAst ast) {
     return _startIndex;
 }
 /// <summary>
 /// Gets the index in the file/buffer that this scope ends at.
 /// </summary>
 public sealed override int GetStop(JsAst ast) {
     if (_node == null) {
         return int.MaxValue;
     }
     return _node.GetEnd(ast.LocationResolver).Index;
 }
 public override int GetStart(JsAst ast) {
     return ast.IndexToLocation(_startIndex).Index;
 }
Esempio n. 21
0
 public override bool Walk(JsAst jsAst)
 {
     return(true);
 }
        private void ParseNodejsCode(TextReader content, out JsAst ast, out CollectingErrorSink errorSink) {
            ast = null;
            errorSink = new CollectingErrorSink();

            var parser = CreateParser(content, errorSink);
            ast = ParseOneFile(ast, parser);
        }
        private JsAst ParseOneFile(JsAst ast, JSParser parser) {
            if (parser != null) {
                try {
                    ast = parser.Parse(_codeSettings);
                } catch (Exception e) {
                    if (e.IsCriticalException()) {
                        throw;
                    }
                    Debug.Assert(false, String.Format("Failure in JavaScript parser: {0}", e.ToString()));
                }

            }
            return ast;
        }
        public void UpdateTree(JsAst newAst, IAnalysisCookie newCookie) {
            lock (this) {
                if (_updatesPending > 0) {
                    _updatesPending--;
                }
                if (newAst == null) {
                    // there was an error in parsing, just let the waiter go...
                    if (_curWaiter != null) {
                        _curWaiter.Set();
                    }
                    _tree = null;
                    return;
                }

                _tree = newAst;
                _cookie = newCookie;

                if (_curWaiter != null) {
                    _curWaiter.Set();
                }
            }

            OnNewParseTree(this, EventArgs.Empty);
        }
Esempio n. 25
0
 public FormattingVisitor(string code, JsAst tree, FormattingOptions options = null, bool onEnter = false) {
     _code = code;
     _options = options ?? new FormattingOptions();
     _onEnter = onEnter;
     _tree = tree;
 }