Пример #1
0
            public int CompareTo(Document document, Reference other)
            {
                var diff = ComparerWithState.CompareTo(this, other, document, s_comparers);

                if (diff != 0)
                {
                    return(diff);
                }

                // Both our names need to change.  Sort by the name we're
                // changing to.
                diff = StringComparer.OrdinalIgnoreCase.Compare(
                    SearchResult.DesiredName,
                    other.SearchResult.DesiredName
                    );
                if (diff != 0)
                {
                    return(diff);
                }

                // If the weights are the same and no names changed, just order
                // them based on the namespace we're adding an import for.
                return(INamespaceOrTypeSymbolExtensions.CompareNameParts(
                           SearchResult.NameParts,
                           other.SearchResult.NameParts,
                           placeSystemNamespaceFirst: true
                           ));
            }
 private SymbolResult(INamespaceOrTypeSymbol symbol, int weight, INamespaceOrTypeSymbol?originalSymbol)
 {
     Symbol         = symbol;
     Weight         = weight;
     NameParts      = INamespaceOrTypeSymbolExtensions.GetNameParts(symbol);
     OriginalSymbol = originalSymbol;
 }
Пример #3
0
 public SearchResult(SymbolResult <INamespaceOrTypeSymbol> result)
     : this(
         result.DesiredName,
         result.NameNode,
         INamespaceOrTypeSymbolExtensions.GetNameParts(result.Symbol),
         result.Weight
         )
 {
 }
            public int CompareTo(SymbolResult other)
            {
                Debug.Assert(this.Symbol is INamespaceSymbol || !((INamedTypeSymbol)this.Symbol).IsGenericType);
                Debug.Assert(other.Symbol is INamespaceSymbol || !((INamedTypeSymbol)other.Symbol).IsGenericType);

                var diff = this.Weight - other.Weight;
                if (diff != 0)
                {
                    return diff;
                }

                return INamespaceOrTypeSymbolExtensions.CompareNameParts(
                    this.NameParts, other.NameParts, placeSystemNamespaceFirst: true);
            }
Пример #5
0
            public int CompareTo(SymbolResult other)
            {
                Contract.Requires(this.Symbol is INamespaceSymbol || !((INamedTypeSymbol)this.Symbol).IsGenericType);
                Contract.Requires(other.Symbol is INamespaceSymbol || !((INamedTypeSymbol)other.Symbol).IsGenericType);

                var diff = this.Weight - other.Weight;

                if (diff != 0)
                {
                    return(diff);
                }

                return(INamespaceOrTypeSymbolExtensions.CompareNameParts(
                           this.NameParts, other.NameParts, placeSystemNamespaceFirst: true));
            }
Пример #6
0
            public int CompareTo(Document document, Reference other)
            {
                // If references have different weights, order by the ones with lower weight (i.e.
                // they are better matches).
                if (SearchResult.Weight < other.SearchResult.Weight)
                {
                    return(-1);
                }

                if (SearchResult.Weight > other.SearchResult.Weight)
                {
                    return(1);
                }

                if (SearchResult.DesiredNameMatchesSourceName(document))
                {
                    if (!other.SearchResult.DesiredNameMatchesSourceName(document))
                    {
                        // Prefer us as our name doesn't need to change.
                        return(-1);
                    }
                }
                else
                {
                    if (other.SearchResult.DesiredNameMatchesSourceName(document))
                    {
                        // Prefer them as their name doesn't need to change.
                        return(1);
                    }
                    else
                    {
                        // Both our names need to change.  Sort by the name we're
                        // changing to.
                        var diff = StringComparer.OrdinalIgnoreCase.Compare(
                            SearchResult.DesiredName, other.SearchResult.DesiredName);
                        if (diff != 0)
                        {
                            return(diff);
                        }
                    }
                }

                // If the weights are the same and no names changed, just order
                // them based on the namespace we're adding an import for.
                return(INamespaceOrTypeSymbolExtensions.CompareNameParts(
                           SearchResult.NameParts, other.SearchResult.NameParts,
                           placeSystemNamespaceFirst: true));
            }
            public int CompareTo(SymbolReference other)
            {
                // If references have different weights, order by the ones with lower weight (i.e.
                // they are better matches).
                if (this.SearchResult.Weight < other.SearchResult.Weight)
                {
                    return(-1);
                }

                if (this.SearchResult.Weight > other.SearchResult.Weight)
                {
                    return(1);
                }

                // If the weight are the same, just order them based on their names.
                return(INamespaceOrTypeSymbolExtensions.CompareNamespaceOrTypeSymbols(this.SearchResult.Symbol, other.SearchResult.Symbol));
            }
 public SymbolResult(INamespaceOrTypeSymbol symbol, int weight)
 {
     Symbol    = symbol;
     Weight    = weight;
     NameParts = INamespaceOrTypeSymbolExtensions.GetNameParts(symbol);
 }
 public int CompareTo(SymbolReference other)
 {
     return(INamespaceOrTypeSymbolExtensions.CompareNamespaceOrTypeSymbols(this.Symbol, other.Symbol));
 }