本文整理汇总了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;
}
示例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);
}
示例3: AddNode
private void AddNode(ImmutableArray<NavInfoNode>.Builder builder, string name, uint type)
{
if (string.IsNullOrEmpty(name))
{
return;
}
builder.Add(new NavInfoNode(name, type));
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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++;
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}