Пример #1
0
        internal static void AugmentQuickInfoWorker(ExpressionAnalysis vars, System.Collections.Generic.IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) {
            applicableToSpan = vars.Span;
            if (applicableToSpan == null || String.IsNullOrWhiteSpace(vars.Expression)) {
                return;
            }

            bool first = true;
            var result = new StringBuilder();
            int count = 0;
            List<AnalysisValue> listVars = new List<AnalysisValue>(vars.Values);
            HashSet<string> descriptions = new HashSet<string>();
            bool multiline = false;
            foreach (var v in listVars) {
                string description = null;
                if (listVars.Count == 1) {
                    if (!String.IsNullOrWhiteSpace(v.Description)) {
                        description = v.Description;
                    }
                } else {
                    if (!String.IsNullOrWhiteSpace(v.ShortDescription)) {
                        description = v.ShortDescription;
                    }
                }

                description = description.LimitLines();

                if (description != null && descriptions.Add(description)) {
                    if (first) {
                        first = false;
                    } else {
                        if (result.Length == 0 || result[result.Length - 1] != '\n') {
                            result.Append(", ");
                        } else {
                            multiline = true;
                        }
                    }
                    result.Append(description);
                    count++;
                }
            }

            string expr = vars.Expression;
            if (expr.Length > 4096) {
                expr = expr.Substring(0, 4093) + "...";
            }
            if (multiline) {
                result.Insert(0, expr + ": " + Environment.NewLine);
            } else if (result.Length > 0) {
                result.Insert(0, expr + ": ");
            } else {
                result.Append(expr);
                result.Append(": ");
                result.Append("<unknown type>");
            }

            quickInfoContent.Add(result.ToString());
        }
Пример #2
0
 public PreviewChangesEngine(IServiceProvider serviceProvider, IRenameVariableInput input, ExpressionAnalysis analysis, RenameVariableRequest request, string originalName, string privatePrefix, VsProjectAnalyzer analyzer, IEnumerable<IAnalysisVariable> variables) {
     _serviceProvider = serviceProvider;
     _analysis = analysis;
     _analyzer = analyzer;
     _renameReq = request;
     _originalName = originalName;
     _privatePrefix = privatePrefix;
     _variables = variables;
     _input = input;
     _list = new PreviewList(CreatePreviewItems().ToArray());
 }
Пример #3
0
        public override IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria) {
            var node = _hierarchy as PythonFileNode;
            if(node != null) {
                var analysis = node.GetProjectEntry() as IPythonProjectEntry;

                if (analysis != null) {
                    var exprAnalysis = new ExpressionAnalysis(
                        ((PythonProjectNode)node.ProjectMgr).GetAnalyzer(),
                        criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1),
                        analysis.Analysis,
                        0,
                        null,
                        null
                    );

                    return EditFilter.GetFindRefLocations(_hierarchy.ProjectMgr.Site, exprAnalysis);
                }
            }
            
            return null;
        }
Пример #4
0
        internal static void AugmentQuickInfoWorker(ExpressionAnalysis vars, System.Collections.Generic.IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = vars.Span;
            if (applicableToSpan == null || String.IsNullOrWhiteSpace(vars.Expression))
            {
                return;
            }

            bool first  = true;
            var  result = new StringBuilder();
            int  count  = 0;
            List <AnalysisValue> listVars     = new List <AnalysisValue>(vars.Values);
            HashSet <string>     descriptions = new HashSet <string>();
            bool multiline = false;

            foreach (var v in listVars)
            {
                string description = null;
                if (listVars.Count == 1)
                {
                    if (!String.IsNullOrWhiteSpace(v.Description))
                    {
                        description = v.Description;
                    }
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(v.ShortDescription))
                    {
                        description = v.ShortDescription;
                    }
                }

                description = description.LimitLines();

                if (description != null && descriptions.Add(description))
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        if (result.Length == 0 || result[result.Length - 1] != '\n')
                        {
                            result.Append(", ");
                        }
                        else
                        {
                            multiline = true;
                        }
                    }
                    result.Append(description);
                    count++;
                }
            }

            string expr = vars.Expression;

            if (expr.Length > 4096)
            {
                expr = expr.Substring(0, 4093) + "...";
            }
            if (multiline)
            {
                result.Insert(0, expr + ": " + Environment.NewLine);
            }
            else if (result.Length > 0)
            {
                result.Insert(0, expr + ": ");
            }
            else
            {
                result.Append(expr);
                result.Append(": ");
                result.Append("<unknown type>");
            }

            quickInfoContent.Add(result.ToString());
        }