Exemplo n.º 1
0
        public LocationPreviewItem(FilePreviewItem parent, LocationInfo locationInfo, VariableType type)
        {
            _lineNo   = locationInfo.Line;
            _columnNo = locationInfo.Column;
            _parent   = parent;
            string text    = locationInfo.ProjectEntry.GetLine(locationInfo.Line);
            string trimmed = text.TrimStart(_whitespace);

            _text = trimmed;
            _type = type;
            _span = new Span(_columnNo - (text.Length - trimmed.Length) - 1, parent.Engine.OriginalName.Length);
            if (String.Compare(_text, _span.Start, parent.Engine.OriginalName, 0, parent.Engine.OriginalName.Length) != 0)
            {
                // we are renaming a name mangled name (or we have a bug where the names aren't lining up).
                Debug.Assert(_text.Substring(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length) == "_" + parent.Engine.PrivatePrefix + parent.Engine.OriginalName);


                if (parent.Engine.Request.Name.StartsWith("__"))
                {
                    // if we're renaming to a private prefix name then we just rename the non-prefixed portion
                    _span      = new Span(_span.Start + 1 + parent.Engine.PrivatePrefix.Length, _span.Length);
                    _columnNo += 1 + parent.Engine.PrivatePrefix.Length;
                }
                else
                {
                    // otherwise we renmae the prefixed and non-prefixed portion
                    _span = new Span(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length);
                }
            }
        }
Exemplo n.º 2
0
        private List <FilePreviewItem> CreatePreviewItems()
        {
            Dictionary <string, FilePreviewItem> files = new Dictionary <string, FilePreviewItem>();
            Dictionary <FilePreviewItem, HashSet <LocationInfo> > allItems = new Dictionary <FilePreviewItem, HashSet <LocationInfo> >();

            foreach (var variable in _variables)
            {
                switch (variable.Type)
                {
                case VariableType.Definition:
                case VariableType.Reference:
                    string                 file = variable.Location.FilePath;
                    FilePreviewItem        fileItem;
                    HashSet <LocationInfo> curLocations;
                    if (!files.TryGetValue(file, out fileItem))
                    {
                        files[file]        = fileItem = new FilePreviewItem(this, file);
                        allItems[fileItem] = curLocations = new HashSet <LocationInfo>(LocationInfo.FullComparer);
                    }
                    else
                    {
                        curLocations = allItems[fileItem];
                    }

                    if (!curLocations.Contains(variable.Location))
                    {
                        fileItem.Items.Add(new LocationPreviewItem(fileItem, variable.Location, variable.Type));
                        curLocations.Add(variable.Location);
                    }
                    break;
                }
            }

            List <FilePreviewItem> fileItems = new List <FilePreviewItem>(files.Values);

            foreach (var fileItem in fileItems)
            {
                fileItem.Items.Sort(LocationComparer);
            }

            fileItems.Sort(FileComparer);
            return(fileItems);
        }
Exemplo n.º 3
0
 private static int FileComparer(FilePreviewItem left, FilePreviewItem right)
 {
     return(String.Compare(left.Filename, right.Filename, StringComparison.OrdinalIgnoreCase));
 }