本文整理汇总了C#中AbstractSyntaxContext类的典型用法代码示例。如果您正苦于以下问题:C# AbstractSyntaxContext类的具体用法?C# AbstractSyntaxContext怎么用?C# AbstractSyntaxContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractSyntaxContext类属于命名空间,在下文中一共展示了AbstractSyntaxContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: LookupCandidateSymbols
protected virtual IEnumerable<INamedTypeSymbol> LookupCandidateSymbols(AbstractSyntaxContext context, INamedTypeSymbol declaredSymbol, CancellationToken cancellationToken)
{
if (declaredSymbol == null)
{
throw new ArgumentNullException(nameof(declaredSymbol));
}
SemanticModel semanticModel = context.SemanticModel;
INamespaceOrTypeSymbol containingSymbol = declaredSymbol.ContainingSymbol as INamespaceOrTypeSymbol;
if (containingSymbol == null)
{
return SpecializedCollections.EmptyEnumerable<INamedTypeSymbol>();
}
return semanticModel.LookupNamespacesAndTypes(context.Position, containingSymbol)
.OfType<INamedTypeSymbol>()
.Where(symbol => declaredSymbol.TypeKind == symbol.TypeKind &&
NotNewDeclaredMember(symbol, context) &&
InSameProject(symbol, semanticModel.Compilation));
}
开发者ID:vslsnap,项目名称:roslyn,代码行数:22,代码来源:AbstractPartialTypeCompletionProvider.cs
示例17: GetPreselectedSymbolsWorker
protected override async Task<IEnumerable<ISymbol>> GetPreselectedSymbolsWorker(AbstractSyntaxContext context, int position, OptionSet options, CancellationToken cancellationToken)
{
var recommender = context.GetLanguageService<IRecommendationService>();
var typeInferrer = context.GetLanguageService<ITypeInferenceService>();
var inferredTypes = typeInferrer.InferTypes(context.SemanticModel, position, cancellationToken)
.Where(t => t.SpecialType != SpecialType.System_Void)
.ToSet();
if (inferredTypes.Count == 0)
{
return SpecializedCollections.EmptyEnumerable<ISymbol>();
}
var symbols = await recommender.GetRecommendedSymbolsAtPositionAsync(
context.Workspace,
context.SemanticModel,
position,
options,
cancellationToken).ConfigureAwait(false);
// Don't preselect intrinsic type symbols so we can preselect their keywords instead.
return symbols.Where(s => inferredTypes.Contains(GetSymbolType(s)) && !IsInstrinsic(s));
}
开发者ID:vslsnap,项目名称:roslyn,代码行数:23,代码来源:AbstractRecommendationServiceBasedCompletionProvider.cs
示例18: GetDisplayAndInsertionText
protected override ValueTuple<string, string> GetDisplayAndInsertionText(ISymbol symbol, AbstractSyntaxContext context)
{
var displayService = context.GetLanguageService<ISymbolDisplayService>();
var displayString = displayService.ToMinimalDisplayString(context.SemanticModel, context.Position, symbol);
return ValueTuple.Create(displayString, displayString);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:6,代码来源:AbstractObjectCreationCompletionProvider.cs
示例19: GetInsertionText
protected abstract string GetInsertionText(ISymbol symbol, AbstractSyntaxContext context, char ch);
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:1,代码来源:AbstractSymbolCompletionProvider.cs
示例20: GetDisplayAndInsertionText
protected abstract ValueTuple<string, string> GetDisplayAndInsertionText(ISymbol symbol, AbstractSyntaxContext context);
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:1,代码来源:AbstractSymbolCompletionProvider.cs
注:本文中的AbstractSyntaxContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论