Beispiel #1
0
        public void PresentDefinitionsAndReferences(DefinitionsAndReferences definitionsAndReferences)
        {
            var firstDefinition = definitionsAndReferences.Definitions.FirstOrDefault();
            var title           = firstDefinition?.DisplayParts.JoinText();

            PresentObjectList(title, new ObjectList(CreateFindReferencesItems(definitionsAndReferences), this));
        }
Beispiel #2
0
 private bool AssertResult(
     DefinitionsAndReferences definitionsAndReferences,
     params string[] definitions)
 {
     return(definitionsAndReferences.Definitions.Select(r => r.DisplayParts.JoinText())
            .SetEquals(definitions));
 }
        // internal for test purposes
        internal IList <AbstractTreeItem> CreateFindReferencesItems(
            DefinitionsAndReferences definitionsAndReferences)
        {
            var definitionDocuments =
                definitionsAndReferences.Definitions.SelectMany(d => d.SourceSpans)
                .Select(loc => loc.Document);

            var referenceDocuments =
                definitionsAndReferences.References
                .Select(r => r.SourceSpan.Document);

            var allDocuments       = definitionDocuments.Concat(referenceDocuments).WhereNotNull().ToSet();
            var commonPathElements = CountCommonPathElements(allDocuments);

            var query =
                from d in definitionsAndReferences.Definitions
                let referenceItems = CreateReferenceItems(d, definitionsAndReferences, commonPathElements)
                                     << << << < HEAD
                                     select new DefinitionTreeItem(d, referenceItems);
Beispiel #4
0
        private ImmutableArray <SourceReferenceTreeItem> CreateReferenceItems(
            DefinitionItem definitionItem,
            DefinitionsAndReferences definitionsAndReferences,
            int commonPathElements)
        {
            var result = ImmutableArray.CreateBuilder <SourceReferenceTreeItem>();

            var definitionGlyph = definitionItem.Tags.GetGlyph();

            // Skip the first definition.  We'll present it in the definition item.
            var definitionLocationsAndGlyphs =
                from loc in definitionItem.SourceLocations.Skip(1)
                select ValueTuple.Create(loc, definitionGlyph);

            var referenceLocationsAndGlyphs =
                from r in definitionsAndReferences.References
                where r.Definition == definitionItem
                select ValueTuple.Create(r.Location, Glyph.Reference);

            var allLocationsAndGlyphs = definitionLocationsAndGlyphs.Concat(referenceLocationsAndGlyphs);

            foreach (var locationAndGlyph in allLocationsAndGlyphs)
            {
                var documentLocation = locationAndGlyph.Item1;
                var glyph            = locationAndGlyph.Item2;
                result.Add(new SourceReferenceTreeItem(
                               documentLocation.Document,
                               documentLocation.SourceSpan,
                               glyph.GetGlyphIndex(),
                               commonPathElements));
            }

            var linkedReferences = result.GroupBy(r => r.DisplayText.ToLowerInvariant()).Where(g => g.Count() > 1).SelectMany(g => g);

            foreach (var linkedReference in linkedReferences)
            {
                linkedReference.AddProjectNameDisambiguator();
            }

            result.Sort();
            return(result.ToImmutable());
        }
Beispiel #5
0
 public void DisplayResult(DefinitionsAndReferences definitionsAndReferences)
 {
     _manager.PresentDefinitionsAndReferences(definitionsAndReferences);
 }
 public void DisplayResult(DefinitionsAndReferences definitionsAndReferences)
 {
     DefinitionsAndReferences = definitionsAndReferences;
 }