internal ExpressionAnalysis(VsProjectAnalyzer analyzer, string expression, ModuleAnalysis analysis, int index, ITrackingSpan span, ITextSnapshot snapshot) {
     _expr = expression;
     _analysis = analysis;
     _index = index;
     _span = span;
     _analyzer = analyzer;
     _snapshot = snapshot;
 }
Exemple #2
0
        private void Parse(bool enqueOnly, CancellationToken cancel)
        {
            JsAst           tree;
            IAnalysisCookie cookie;

            GetTreeAndCookie(out tree, out cookie);
            if (tree == null)
            {
                return;
            }

            if (String.Equals(Path.GetFileName(FilePath), "gruntfile.js", StringComparison.OrdinalIgnoreCase))
            {
                _unit = new GruntfileAnalysisUnit(tree, EnvironmentRecord);
            }
            else
            {
                _unit = new AnalysisUnit(tree, EnvironmentRecord);
            }
            _moduleDeps.EnqueueDependents();

            if (EnvironmentRecord.HasChildren)
            {
                EnvironmentRecord.Children.Clear();
            }
            EnvironmentRecord.ClearNodeEnvironments();
            EnvironmentRecord.ClearNodeValues();
#if FALSE
            MyScope.ClearUnresolvedModules();
#endif
            foreach (var wrapper in _proxies)
            {
                wrapper.NewVersion();
            }
            _proxies.Clear();

            _unit.Enqueue();

            InitNodejsVariables();

            // collect top-level definitions first
            var walker = new OverviewWalker(this, _unit, tree);
            tree.Walk(walker);


            if (!enqueOnly)
            {
                _analyzer.AnalyzeQueuedEntries(cancel);
            }

            // publish the analysis now that it's complete
            _currentAnalysis = new ModuleAnalysis(
                _unit,
                ((ModuleEnvironmentRecord)_unit.Environment).CloneForPublish(),
                cookie);
        }
        private void Parse(bool enqueOnly, CancellationToken cancel) {
            JsAst tree;
            IAnalysisCookie cookie;
            GetTreeAndCookie(out tree, out cookie);
            if (tree == null) {
                return;
            }

            if (String.Equals(Path.GetFileName(FilePath), "gruntfile.js", StringComparison.OrdinalIgnoreCase)) {
                _unit = new GruntfileAnalysisUnit(tree, EnvironmentRecord);
            } else {
                _unit = new AnalysisUnit(tree, EnvironmentRecord);
            }
            _moduleDeps.EnqueueDependents();

            if (EnvironmentRecord.HasChildren) {
                EnvironmentRecord.Children.Clear();
            }
            EnvironmentRecord.ClearNodeEnvironments();
            EnvironmentRecord.ClearNodeValues();
#if FALSE
            MyScope.ClearUnresolvedModules();
#endif
            foreach (var wrapper in _proxies) {
                wrapper.NewVersion();
            }
            _proxies.Clear();

            _unit.Enqueue();

            InitNodejsVariables();

            // collect top-level definitions first
            var walker = new OverviewWalker(this, _unit, tree);
            tree.Walk(walker);


            if (!enqueOnly) {
                _analyzer.AnalyzeQueuedEntries(cancel);
            }

            // publish the analysis now that it's complete
            _currentAnalysis = new ModuleAnalysis(
                _unit,
                ((ModuleEnvironmentRecord)_unit.Environment).CloneForPublish(),
                cookie);
        }
        private void DumpMembers(ModuleAnalysis moduleAnalysis, string memberCode, int depth) {
            var moduleMembers = moduleAnalysis.GetMembersByIndex(memberCode, 0).ToArray();
            Array.Sort(moduleMembers, (x, y) => String.Compare(x.Name, y.Name));

            if (depth < _dumpMembers.Value) {
                foreach (var member in moduleMembers) {
                    Console.WriteLine("    {0} {1}", new string(' ', depth * 4), member.Name);

                    DumpMembers(moduleAnalysis, memberCode + "." + member.Completion, depth + 1);
                }
            }
        }
        public static int TranslateIndex(int index, ITextSnapshot fromSnapshot, ModuleAnalysis toAnalysisSnapshot) {
            var snapshotCookie = toAnalysisSnapshot.AnalysisCookie as SnapshotCookie;
            // TODO: buffers differ in the REPL window case, in the future we should handle this better
            if (snapshotCookie != null &&
                fromSnapshot != null &&
                snapshotCookie.Snapshot.TextBuffer == fromSnapshot.TextBuffer) {

                index = new SnapshotPoint(fromSnapshot, index).TranslateTo(
                    snapshotCookie.Snapshot,
                    PointTrackingMode.Negative
                ).Position;
            }
            return index;
        }
 private static IEnumerable<string> GetMemberNames(ModuleAnalysis analysis, string name) {
     return analysis.GetMembersByIndex(name, 0).Select(x => x.Name);
 }
        private static string[] GetSignatures(ModuleAnalysis analysis, string name, int index) {
            List<string> sigs = new List<string>();

            foreach (var sig in analysis.GetSignaturesByIndex(name, index)) {
                sigs.Add(
                    String.Join(
                        ", ",
                        sig.Parameters.Select(x => x.Name + " " + x.Type)
                    )
                );
            }
            return sigs.ToArray();
        }