本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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))));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}
示例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();
}
示例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)
{
}
示例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();
}
示例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);
}
示例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;
}