當前位置: 首頁>>代碼示例>>C#>>正文


C# AbstractSyntaxContext類代碼示例

本文整理匯總了C#中AbstractSyntaxContext的典型用法代碼示例。如果您正苦於以下問題:C# AbstractSyntaxContext類的具體用法?C# AbstractSyntaxContext怎麽用?C# AbstractSyntaxContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractSyntaxContext類屬於命名空間,在下文中一共展示了AbstractSyntaxContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateItem

        /// <summary>
        /// Given a Symbol, creates the completion item for it.
        /// </summary>
        private CompletionItem CreateItem(
            string displayText, 
            string insertionText,
            int position,
            List<ISymbol> symbols,
            AbstractSyntaxContext context,
            Dictionary<ISymbol, List<ProjectId>> invalidProjectMap,
            List<ProjectId> totalProjects,
            bool preselect)
        {
            Contract.ThrowIfNull(symbols);

            SupportedPlatformData supportedPlatformData = null;
            if (invalidProjectMap != null)
            {
                List<ProjectId> invalidProjects = null;
                foreach (var symbol in symbols)
                {
                    if (invalidProjectMap.TryGetValue(symbol, out invalidProjects))
                    {
                        break;
                    }
                }

                if (invalidProjects != null)
                {
                    supportedPlatformData = new SupportedPlatformData(invalidProjects, totalProjects, context.Workspace);
                }
            }

            return CreateItem(displayText, insertionText, position, symbols, context, preselect, supportedPlatformData);
        }
開發者ID:vslsnap,項目名稱:roslyn,代碼行數:35,代碼來源:AbstractSymbolCompletionProvider.cs

示例2: SymbolCompletionItem

 public SymbolCompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     string insertionText,
     string filterText,
     TextSpan filterSpan,
     int position,
     List<ISymbol> symbols,
     string sortText,
     AbstractSyntaxContext context,
     Glyph glyph,
     bool preselect = false,
     SupportedPlatformData supportedPlatforms = null,
     CompletionItemRules rules = null)
 : base(completionProvider, displayText, filterSpan,
    descriptionFactory: null, glyph: glyph,
    sortText: sortText, filterText: filterText, preselect: preselect, showsWarningIcon: supportedPlatforms != null, rules: rules,
    filters: GetFilters(symbols))
 {
     this.InsertionText = insertionText;
     this.Position = position;
     this.Symbols = symbols;
     this.Context = context;
     _supportedPlatforms = supportedPlatforms;
 }
開發者ID:Eyas,項目名稱:roslyn,代碼行數:25,代碼來源:SymbolCompletionItem.cs

示例3: GetDisplayAndInsertionText

        protected override ValueTuple<string, string> GetDisplayAndInsertionText(ISymbol symbol, AbstractSyntaxContext context)
        {
            var insertionText = ItemRules.GetInsertionText(symbol, context);
            var displayText = symbol.GetArity() == 0 ? insertionText : string.Format("{0}<>", insertionText);

            return ValueTuple.Create(displayText, insertionText);
        }
開發者ID:SoumikMukherjeeDOTNET,項目名稱:roslyn,代碼行數:7,代碼來源:SymbolCompletionProvider.cs

示例4: LookupCandidateSymbols

        protected override IEnumerable<INamedTypeSymbol> LookupCandidateSymbols(AbstractSyntaxContext context, INamedTypeSymbol declaredSymbol, CancellationToken cancellationToken)
        {
            var candidates = base.LookupCandidateSymbols(context, declaredSymbol, cancellationToken);

            // The base class applies a broad filter when finding candidates, but since C# requires
            // that all parts have the "partial" modifier, the results can be trimmed further here.
            return candidates?.Where(symbol => symbol.DeclaringSyntaxReferences.Any(reference => IsPartialTypeDeclaration(reference.GetSyntax(cancellationToken))));
        }
開發者ID:vslsnap,項目名稱:roslyn,代碼行數:8,代碼來源:PartialTypeCompletionProvider.cs

示例5: GetDisplayAndInsertionText

        protected override ValueTuple<string, string> GetDisplayAndInsertionText(ISymbol symbol, AbstractSyntaxContext context)
        {
            if (symbol is IAliasSymbol)
            {
                return ValueTuple.Create(symbol.Name, symbol.Name);
            }

            return base.GetDisplayAndInsertionText(symbol, context);
        }
開發者ID:SoumikMukherjeeDOTNET,項目名稱:roslyn,代碼行數:9,代碼來源:ObjectCreationCompletionProvider.cs

示例6: GetInsertionText

            protected override string GetInsertionText(ISymbol symbol, AbstractSyntaxContext context, char ch)
            {
                if (symbol is IAliasSymbol)
                {
                    return ((IAliasSymbol)symbol).Name;
                }

                var displayService = context.GetLanguageService<ISymbolDisplayService>();
                return displayService.ToMinimalDisplayString(context.SemanticModel, context.Position, symbol);
            }
開發者ID:rjmurillo,項目名稱:roslyn,代碼行數:10,代碼來源:ObjectCreationCompletionProvider.ItemRules.cs

示例7: CreateCompletionItem

        private CompletionItem CreateCompletionItem(INamedTypeSymbol symbol, TextSpan textSpan, int position, AbstractSyntaxContext context)
        {
            var displayAndInsertionText = GetDisplayAndInsertionText(symbol, context);

            return SymbolCompletionItem.Create(
                displayText: displayAndInsertionText.Item1,
                insertionText: displayAndInsertionText.Item2,
                symbol: symbol,
                contextPosition: context.Position,
                descriptionPosition: position,
                rules: CompletionItemRules.Default);
        }
開發者ID:vslsnap,項目名稱:roslyn,代碼行數:12,代碼來源:AbstractPartialTypeCompletionProvider.cs

示例8: GetPreselectedSymbolsWorker

        protected override async Task<IEnumerable<ISymbol>> GetPreselectedSymbolsWorker(AbstractSyntaxContext context, int position, OptionSet options, CancellationToken cancellationToken)
        {
            var result = await base.GetPreselectedSymbolsWorker(context, position, options, cancellationToken).ConfigureAwait(false);
            if (result.Any())
            {
                var type = (ITypeSymbol)result.Single();
                var alias = await type.FindApplicableAlias(position, context.SemanticModel, cancellationToken).ConfigureAwait(false);
                if (alias != null)
                {
                    return SpecializedCollections.SingletonEnumerable(alias);
                }
            }

            return result;
        }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:15,代碼來源:ObjectCreationCompletionProvider.cs

示例9: CreateItem

 protected override CompletionItem CreateItem(string displayText, string insertionText, int position, List<ISymbol> symbols, AbstractSyntaxContext context, TextSpan span, bool preselect, SupportedPlatformData supportedPlatformData)
 {
     return SymbolCompletionItem.Create(
         displayText: displayText,
         insertionText: insertionText,
         filterText: GetFilterText(symbols[0], displayText, context),
         span: span,
         contextPosition: context.Position,
         descriptionPosition: position,
         symbols: symbols,
         supportedPlatforms: supportedPlatformData,
         preselect: preselect,
         tags: s_Tags,
         rules: GetCompletionItemRules(symbols, context));
 }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:15,代碼來源:AbstractObjectCreationCompletionProvider.cs

示例10: GetInsertionText

        public static string GetInsertionText(ISymbol symbol, AbstractSyntaxContext context)
        {
            string name;

            if (CommonCompletionUtilities.TryRemoveAttributeSuffix(symbol, context.IsAttributeNameContext, context.GetLanguageService<ISyntaxFactsService>(), out name))
            {
                // Cannot escape Attribute name with the suffix removed. Only use the name with
                // the suffix removed if it does not need to be escaped.
                if (name.Equals(name.EscapeIdentifier()))
                {
                    return name;
                }
            }

            return symbol.Name.EscapeIdentifier(isQueryContext: context.IsInQuery);
        }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:16,代碼來源:SymbolCompletionProvider.cs

示例11: CreateItems

        /// <summary>
        /// Given a list of symbols, creates the list of completion items for them.
        /// </summary>
        protected IEnumerable<CompletionItem> CreateItems(
            int position,
            IEnumerable<ISymbol> symbols,
            AbstractSyntaxContext context,
            Dictionary<ISymbol, List<ProjectId>> invalidProjectMap,
            List<ProjectId> totalProjects,
            bool preselect)
        {
            var tree = context.SyntaxTree;

            var q = from symbol in symbols
                    let texts = GetDisplayAndInsertionText(symbol, context)
                    group symbol by texts into g
                    select this.CreateItem(g.Key.Item1, g.Key.Item2, position, g.ToList(), context, invalidProjectMap, totalProjects, preselect);

            return q.ToList();
        }
開發者ID:vslsnap,項目名稱:roslyn,代碼行數:20,代碼來源:AbstractSymbolCompletionProvider.cs

示例12: SymbolCompletionItem

 public SymbolCompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     string insertionText,
     TextSpan filterSpan,
     int position,
     List<ISymbol> symbols,
     AbstractSyntaxContext context,
     bool preselect = false,
     SupportedPlatformData supportedPlatforms = null)
     : this(completionProvider,
           displayText,
           insertionText,
           filterText: displayText.Length > 0 && displayText[0] == '@' ? displayText : symbols[0].Name,
           filterSpan: filterSpan,
           position: position, symbols: symbols, context: context, preselect: preselect, supportedPlatforms: supportedPlatforms)
 {
 }
開發者ID:CarbonBasedDudeform,項目名稱:roslyn,代碼行數:18,代碼來源:SymbolCompletionItem.cs

示例13: CreateItemsAsync

        /// <summary>
        /// Given a list of symbols, creates the list of completion items for them.
        /// </summary>
        protected async Task<IEnumerable<CompletionItem>> CreateItemsAsync(
            int position,
            IEnumerable<ISymbol> symbols,
            AbstractSyntaxContext context,
            Dictionary<ISymbol, List<ProjectId>> invalidProjectMap,
            List<ProjectId> totalProjects,
            bool preselect,
            CancellationToken cancellationToken)
        {
            var tree = context.SyntaxTree;

            var text = await context.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
            var textChangeSpan = this.GetTextChangeSpan(text, position);
            var q = from symbol in symbols
                    let texts = GetDisplayAndInsertionText(symbol, context)
                    group symbol by texts into g
                    select this.CreateItem(g.Key, position, g.ToList(), context, textChangeSpan, invalidProjectMap, totalProjects, preselect, cancellationToken);

            return q.ToList();
        }
開發者ID:elemk0vv,項目名稱:roslyn-1,代碼行數:23,代碼來源:AbstractSymbolCompletionProvider.cs

示例14: CreateItem

        protected override CompletionItem CreateItem(string displayText, string insertionText, int position, List<ISymbol> symbols, AbstractSyntaxContext context, bool preselect, SupportedPlatformData supportedPlatformData)
        {
            var matchPriority = preselect ? ComputeSymbolMatchPriority(symbols[0]) : MatchPriority.Default;
            var rules = GetCompletionItemRules(symbols, context, preselect);
            if (preselect)
            {
                rules = rules.WithSelectionBehavior(PreselectedItemSelectionBehavior);
            }

            return SymbolCompletionItem.Create(
                displayText: displayText,
                insertionText: insertionText,
                filterText: GetFilterText(symbols[0], displayText, context),
                contextPosition: context.Position,
                descriptionPosition: position,
                symbols: symbols,
                supportedPlatforms: supportedPlatformData,
                matchPriority: matchPriority,
                rules: rules);
        }
開發者ID:vslsnap,項目名稱:roslyn,代碼行數:20,代碼來源:AbstractRecommendationServiceBasedCompletionProvider.cs

示例15: SymbolCompletionItem

 public SymbolCompletionItem(
     ICompletionProvider completionProvider,
     string displayText,
     string insertionText,
     string filterText,
     TextSpan filterSpan,
     int position,
     List<ISymbol> symbols,
     AbstractSyntaxContext context,
     bool preselect = false,
     SupportedPlatformData supportedPlatforms = null)
 : base(completionProvider, displayText, filterSpan,
    descriptionFactory: null, glyph: symbols[0].GetGlyph(),
    sortText: symbols[0].Name, filterText: filterText, preselect: preselect, showsWarningIcon: supportedPlatforms != null)
 {
     this.InsertionText = insertionText;
     this.Position = position;
     this.Symbols = symbols;
     this.Context = context;
     _supportedPlatorms = supportedPlatforms;
 }
開發者ID:ehsansajjad465,項目名稱:roslyn,代碼行數:21,代碼來源:SymbolCompletionItem.cs


注:本文中的AbstractSyntaxContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。