Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public void GetTreeAndCookie(out JsAst tree, out IAnalysisCookie cookie)
 {
     lock (this) {
         tree   = _tree;
         cookie = _cookie;
     }
 }
 /// <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);
 }
 /// <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);
 }
Ejemplo n.º 6
0
        public OverviewWalker(ProjectEntry entry, AnalysisUnit topAnalysis, JsAst tree, bool isNested = false)
        {
            _entry    = entry;
            _curUnit  = topAnalysis;
            _isNested = isNested;
            _tree     = tree;

            _scope = topAnalysis.Environment;
        }
Ejemplo n.º 7
0
        internal AnalysisUnit(Statement ast, JsAst tree, EnvironmentRecord environment)
        {
            Ast  = ast;
            Tree = tree;
            _env = environment;
            _id  = Interlocked.Increment(ref _idCount);

            if (environment != null && !ForEval)
            {
                ProjectEntry.Analyzer.Log.NewUnit(this);
            }
        }
Ejemplo n.º 8
0
        public override bool Walk(JsAst node)
        {
#if FALSE
            ModuleReference existingRef;
#endif
            //Debug.Assert(node == _unit.Ast);
#if FALSE
            if (!ProjectState.Modules.TryGetValue(_unit.DeclaringModule.Name, out existingRef))
            {
                // publish our module ref now so that we don't collect dependencies as we'll be fully processed
                ProjectState.Modules[_unit.DeclaringModule.Name] = new ModuleReference(_unit.DeclaringModule);
            }
#endif

            return(base.Walk(node));
        }
 public override int GetStop(JsAst ast)
 {
     return(_endIndex);
 }
 public override int GetBodyStart(JsAst ast)
 {
     return(_startIndex);
 }
Ejemplo n.º 11
0
 public override bool Walk(JsAst jsAst)
 {
     return(true);
 }
 public override int GetBodyStart(JsAst ast)
 {
     return(((FunctionObject)Node).Body.GetStartIndex(ast.LocationResolver));
 }
Ejemplo n.º 13
0
 public RangeVisitor(char typedChar, int position, JsAst tree)
 {
     _typedChar = typedChar;
     _position  = position;
     _tree      = tree;
 }
Ejemplo n.º 14
0
 public ParseTreeWalker(JsAst tree)
 {
     _tree = tree;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Gets the index in the file/buffer that this scope ends at.
 /// </summary>
 public abstract int GetStop(JsAst ast);
Ejemplo n.º 16
0
 public override int GetStop(JsAst ast)
 {
     return(ast.IndexToLocation(_endIndex).Index);
 }
Ejemplo n.º 17
0
 public virtual void PostWalk(JsAst jsAst)
 {
 }
Ejemplo n.º 18
0
 /// <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 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));
 }
Ejemplo n.º 20
0
 public virtual bool Walk(JsAst jsAst) { return true; }
Ejemplo n.º 21
0
 public virtual void PostWalk(JsAst jsAst) { }
Ejemplo n.º 22
0
 internal AnalysisUnit(JsAst ast, EnvironmentRecord environment)
     : this(ast, ast, environment)
 {
 }
Ejemplo n.º 23
0
 public virtual bool Walk(JsAst jsAst)
 {
     return(true);
 }
Ejemplo n.º 24
0
 public OutliningVisitor(JsAst ast, ITextSnapshot snapshot)
 {
     _ast              = ast;
     _snapshot         = snapshot;
     OutliningTagSpans = new List <ITagSpan <IOutliningRegionTag> >();
 }
Ejemplo n.º 25
0
 public override int GetStart(JsAst ast)
 {
     return(ast.IndexToLocation(_startIndex).Index);
 }
Ejemplo n.º 26
0
                private static TagSpan GetFunctionSpan(JsAst ast, ITextSnapshot snapshot, FunctionObject functionObject)
                {
                    IndexSpan indexSpan = functionObject.Body.GetSpan(ast.LocationResolver);

                    return(GetTagSpan(snapshot, indexSpan.Start, indexSpan.End, functionObject.ParameterEnd));
                }
Ejemplo n.º 27
0
 internal EvalAnalysisUnit(Statement ast, JsAst tree, EnvironmentRecord scope)
     : base(ast, tree, scope)
 {
 }