当前位置: 首页>>代码示例>>C#>>正文


C# ImmutableArray.Add方法代码示例

本文整理汇总了C#中ImmutableArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.Add方法的具体用法?C# ImmutableArray.Add怎么用?C# ImmutableArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImmutableArray的用法示例。


在下文中一共展示了ImmutableArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryAddSnippetInvocationPart

        private async Task<ImmutableArray<TaggedText>> TryAddSnippetInvocationPart(
            Document document, CompletionItem item, 
            ImmutableArray<TaggedText> parts, CancellationToken cancellationToken)
        {
            var languageServices = document.Project.LanguageServices;
            var snippetService = languageServices.GetService<ISnippetInfoService>();
            if (snippetService != null)
            {
                var change = await GetTextChangeAsync(document, item, ch: '\t', cancellationToken: cancellationToken).ConfigureAwait(false) ??
                    new TextChange(item.Span, item.DisplayText);
                var insertionText = change.NewText;

                if (snippetService != null && snippetService.SnippetShortcutExists_NonBlocking(insertionText))
                {
                    var note = string.Format(FeaturesResources.Note_colon_Tab_twice_to_insert_the_0_snippet, insertionText);

                    if (parts.Any())
                    {
                        parts = parts.Add(new TaggedText(TextTags.LineBreak, Environment.NewLine));
                    }

                    parts = parts.Add(new TaggedText(TextTags.Text, note));
                }
            }

            return parts;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:CommonCompletionProvider.cs

示例2: Create

        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            bool preselect = false,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            bool isArgumentName = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.IsDefault ? ImmutableArray<string>.Empty : tags;

            if (glyph != null)
            {
                // put glyph tags first
                tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            }

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            if (isArgumentName)
            {
                tags = tags.Add(CompletionTags.ArgumentName);
            }

            properties = properties ?? ImmutableDictionary<string, string>.Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithPreselect(preselect)
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                span: span,
                properties: properties,
                tags: tags,
                rules: rules);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:52,代码来源:CommonCompletionItem.cs

示例3: AddNode

        private void AddNode(ImmutableArray<NavInfoNode>.Builder builder, string name, uint type)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            builder.Add(new NavInfoNode(name, type));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:9,代码来源:NavInfoList.cs

示例4: Create

        public static CompletionItem Create(
            string displayText,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            int? matchPriority = null,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.NullToEmpty();

            if (glyph != null)
            {
                // put glyph tags first
                tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            }

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            properties = properties ?? ImmutableDictionary<string, string>.Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithMatchPriority(matchPriority.GetValueOrDefault())
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                properties: properties,
                tags: tags,
                rules: rules);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:44,代码来源:CommonCompletionItem.cs

示例5: ReferenceFinders

 static ReferenceFinders()
 {
     DefaultRenameReferenceFinders = ImmutableArray.Create(
         Constructor,
         Destructor,
         Event,
         ExplicitInterfaceMethod,
         Field,
         Label,
         LinkedFiles,
         Local,
         MethodTypeParameter,
         NamedType,
         Namespace,
         Operator,
         OrdinaryMethod,
         Parameter,
         Property,
         PropertyAccessor,
         RangeVariable,
         TypeParameter);
     DefaultReferenceFinders = DefaultRenameReferenceFinders.Add(ConstructorInitializer);
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:23,代码来源:ReferenceFinders.cs

示例6: GetEffectiveIncludesCore

        private void GetEffectiveIncludesCore(ImmutableArray<string>.Builder arrayBuilder)
        {
            arrayBuilder.Add(this.FilePath);

            foreach (var ruleSetInclude in _includes)
            {
                var ruleSet = ruleSetInclude.LoadRuleSet(this);

                // If we couldn't load the ruleset file, then there's nothing to do.
                if (ruleSet == null)
                {
                    continue;
                }

                // If this file has already been included don't recurse into it.
                if (!arrayBuilder.Contains(ruleSet.FilePath, StringComparer.OrdinalIgnoreCase))
                {
                    ruleSet.GetEffectiveIncludesCore(arrayBuilder);
                }
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:21,代码来源:RuleSet.cs

示例7: AddAnalyzerCommentRegularExpression

 private void AddAnalyzerCommentRegularExpression(ImmutableArray<DiagnosticAnalyzer>.Builder builder)
 {
     if (!AnalyzerIds.Contains(CommentRegularExpression.DiagnosticId))
     {
         return;
     }
     var rules = ImmutableArray.CreateBuilder<CommentRegularExpressionRule>();
     foreach (var parameters in Parameters[CommentRegularExpression.DiagnosticId])
     {
         rules.Add(
             new CommentRegularExpressionRule
             {
                 // TODO: Add rule description
                 Descriptor = CommentRegularExpression.CreateDiagnosticDescriptor(parameters["RuleKey"], parameters["message"]),
                 RegularExpression = parameters["regularExpression"]
             });
     }
     var analyzer = new CommentRegularExpression {RuleInstances = rules.ToImmutable()};
     builder.Add(analyzer);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:20,代码来源:Configuration.cs

示例8: ProcessReferencedSymbol

        private void ProcessReferencedSymbol(
            Solution solution,
            ReferencedSymbol referencedSymbol,
            ImmutableArray<DefinitionItem>.Builder definitions,
            ImmutableArray<SourceReferenceItem>.Builder references,
            HashSet<DocumentSpan> uniqueSpans)
        {
            // See if this is a symbol we even want to present to the user.  If not,
            // ignore it entirely (including all its reference locations).
            if (!referencedSymbol.ShouldShow())
            {
                return;
            }

            var definitionItem = referencedSymbol.Definition.ToDefinitionItem(solution, uniqueSpans);
            definitions.Add(definitionItem);

            // Now, create the SourceReferenceItems for all the reference locations
            // for this definition.
            CreateReferences(referencedSymbol, references, definitionItem, uniqueSpans);

            // Finally, see if there are any third parties that want to add their
            // own result to our collection.
            var thirdPartyItem = GetThirdPartyDefinitionItem(solution, referencedSymbol.Definition);
            if (thirdPartyItem != null)
            {
                definitions.Add(thirdPartyItem);
            }
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:29,代码来源:IDefinitionsAndReferencesFactory.cs

示例9: FillNodeList

        private void FillNodeList(NavInfoList navInfoList, bool isObjectBrowser, bool isCanonical, ImmutableArray<IVsNavInfoNode>.Builder builder)
        {
            var index = 0;

            // In some cases, Class View presentation NavInfo objects will have extra nodes (LLT_PACKAGE & LLT_HIERARCHY) up front.
            // When this NavInfo is consumed by Object Browser (for 'Browse to Definition'), we need to skip first two nodes
            if (isObjectBrowser && !isCanonical)
            {
                if (navInfoList.Count >= 2 && navInfoList[1].ListType == (uint)_LIB_LISTTYPE.LLT_HIERARCHY)
                {
                    index = 2;
                }
            }

            while (index < navInfoList.Count)
            {
                if (!isCanonical || navInfoList[index].ListType != (uint)_LIB_LISTTYPE.LLT_HIERARCHY)
                {
                    builder.Add(navInfoList[index]);
                }

                index++;
            }
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:24,代码来源:NavInfo.cs

示例10: ParseGenericTypeInstance

        private static void ParseGenericTypeInstance(ImmutableArray<byte>.Builder builder, Stream stream)
        {
            ParseType(builder, stream);

            // Generic type parameters
            int argumentCount = stream.ReadByte();
            builder.Add((byte)argumentCount);
            for (int i = 0; i < argumentCount; i++)
            {
                ParseType(builder, stream);
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:12,代码来源:MemberDescriptor.cs

示例11: CollectCommentRegions

        public static void CollectCommentRegions(
            SyntaxTriviaList triviaList, ImmutableArray<BlockSpan>.Builder spans)
        {
            if (triviaList.Count > 0)
            {
                SyntaxTrivia? startComment = null;
                SyntaxTrivia? endComment = null;

                Action completeSingleLineCommentGroup = () =>
                {
                    if (startComment != null)
                    {
                        var singleLineCommentGroupRegion = CreateCommentRegion(startComment.Value, endComment.Value);
                        spans.Add(singleLineCommentGroupRegion);
                        startComment = null;
                        endComment = null;
                    }
                };

                // Iterate through trivia and collect the following:
                //    1. Groups of contiguous single-line comments that are only separated by whitespace
                //    2. Multi-line comments
                foreach (var trivia in triviaList)
                {
                    if (trivia.IsSingleLineComment())
                    {
                        startComment = startComment ?? trivia;
                        endComment = trivia;
                    }
                    else if (trivia.IsMultiLineComment())
                    {
                        completeSingleLineCommentGroup();

                        var multilineCommentRegion = CreateCommentRegion(trivia, trivia);
                        spans.Add(multilineCommentRegion);
                    }
                    else if (!trivia.MatchesKind(SyntaxKind.WhitespaceTrivia,
                                                 SyntaxKind.EndOfLineTrivia,
                                                 SyntaxKind.EndOfFileToken))
                    {
                        completeSingleLineCommentGroup();
                    }
                }

                completeSingleLineCommentGroup();
            }
        }
开发者ID:natidea,项目名称:roslyn,代码行数:47,代码来源:CSharpStructureHelpers.cs

示例12: AddAnalyzerFileLines

 private void AddAnalyzerFileLines(ImmutableArray<DiagnosticAnalyzer>.Builder builder)
 {
     var analyzer = new FileLines();
     if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id))
     {
         return;
     }
     analyzer.Maximum = int.Parse(
         Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["maximumFileLocThreshold"],
         NumberStyles.None, CultureInfo.InvariantCulture);
     builder.Add(analyzer);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:Configuration.cs

示例13: ParseMethodOrPropertySignature

        private static void ParseMethodOrPropertySignature(ImmutableArray<byte>.Builder builder, Stream stream)
        {
            int paramCount = stream.ReadByte();
            builder.Add((byte)paramCount);

            // Return type
            ParseType(builder, stream);

            // Parameters
            for (int i = 0; i < paramCount; i++)
            {
                ParseType(builder, stream, allowByRef: true);
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:14,代码来源:MemberDescriptor.cs

示例14: AddAnalyzerMagicNumber

 private void AddAnalyzerMagicNumber(ImmutableArray<DiagnosticAnalyzer>.Builder builder)
 {
     var analyzer = new MagicNumber();
     if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id))
     {
         return;
     }
     analyzer.Exceptions =
         Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["exceptions"]
             .Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries)
             .Select(e => e.Trim())
             .ToImmutableHashSet();
     builder.Add(analyzer);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:14,代码来源:Configuration.cs

示例15: AddAnalyzerExpressionCOmplexity

 private void AddAnalyzerExpressionCOmplexity(ImmutableArray<DiagnosticAnalyzer>.Builder builder)
 {
     var analyzer = new ExpressionComplexity();
     if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id))
     {
         return;
     }
     analyzer.Maximum = int.Parse(
         Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["max"],
         NumberStyles.None, CultureInfo.InvariantCulture);
     builder.Add(analyzer);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:Configuration.cs


注:本文中的ImmutableArray.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。