本文整理汇总了C#中ISyntaxFactsService类的典型用法代码示例。如果您正苦于以下问题:C# ISyntaxFactsService类的具体用法?C# ISyntaxFactsService怎么用?C# ISyntaxFactsService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISyntaxFactsService类属于命名空间,在下文中一共展示了ISyntaxFactsService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentArgumentState
public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken)
{
if (GetOuterMostTupleExpressionInSpan(root, position, syntaxFacts, currentSpan, cancellationToken, out var expression))
{
return CommonSignatureHelpUtilities.GetSignatureHelpState(expression, position,
getOpenToken: s_getOpenToken,
getCloseToken: s_getCloseToken,
getArgumentsWithSeparators: s_getArgumentsWithSeparators,
getArgumentNames: s_getArgumentNames);
}
if (GetOuterMostParenthesizedExpressionInSpan(root, position, syntaxFacts, currentSpan, cancellationToken, out var parenthesizedExpression))
{
if (currentSpan.Start == parenthesizedExpression.SpanStart)
{
return new SignatureHelpState(
argumentIndex: 0,
argumentCount: 0,
argumentName: string.Empty,
argumentNames: null);
}
}
return null;
}
示例2: AbstractIndenter
public AbstractIndenter(
ISyntaxFactsService syntaxFacts,
SyntaxTree syntaxTree,
IEnumerable<IFormattingRule> rules,
OptionSet optionSet,
TextLine lineToBeIndented,
CancellationToken cancellationToken)
{
var syntaxRoot = syntaxTree.GetRoot(cancellationToken);
this._syntaxFacts = syntaxFacts;
this.OptionSet = optionSet;
this.Tree = syntaxTree;
this.LineToBeIndented = lineToBeIndented;
this.TabSize = this.OptionSet.GetOption(FormattingOptions.TabSize, syntaxRoot.Language);
this.CancellationToken = cancellationToken;
this.Rules = rules;
this.Finder = new BottomUpBaseIndentationFinder(
new ChainedFormattingRules(this.Rules, OptionSet),
this.TabSize,
this.OptionSet.GetOption(FormattingOptions.IndentationSize, syntaxRoot.Language),
tokenStream: null,
lastToken: default(SyntaxToken));
}
示例3: TryGetNameWithoutAttributeSuffix
protected static bool TryGetNameWithoutAttributeSuffix(
string name,
ISyntaxFactsService syntaxFacts,
out string result)
{
return name.TryGetWithoutAttributeSuffix(syntaxFacts.IsCaseSensitive, out result);
}
示例4: GetIndenter
protected override AbstractIndenter GetIndenter(
ISyntaxFactsService syntaxFacts, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable<IFormattingRule> formattingRules, OptionSet optionSet, CancellationToken cancellationToken)
{
return new Indenter(
syntaxFacts, syntaxTree, formattingRules,
optionSet, lineToBeIndented, cancellationToken);
}
示例5: GetGenerateTypeOptions
public GenerateTypeOptionsResult GetGenerateTypeOptions(
string className,
GenerateTypeDialogOptions generateTypeDialogOptions,
Document document,
INotificationService notificationService,
IProjectManagementService projectManagementService,
ISyntaxFactsService syntaxFactsService)
{
// Storing the actual values
ClassName = className;
GenerateTypeDialogOptions = generateTypeDialogOptions;
if (DefaultNamespace == null)
{
DefaultNamespace = projectManagementService.GetDefaultNamespace(Project, Project?.Solution.Workspace);
}
return new GenerateTypeOptionsResult(
accessibility: Accessibility,
typeKind: TypeKind,
typeName: TypeName,
project: Project,
isNewFile: IsNewFile,
newFileName: NewFileName,
folders: Folders,
fullFilePath: FullFilePath,
existingDocument: ExistingDocument,
areFoldersValidIdentifiers: AreFoldersValidIdentifiers,
defaultNamespace: DefaultNamespace,
isCancelled: IsCancelled);
}
示例6: TryGetAttributeExpression
private bool TryGetAttributeExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out AttributeSyntax attribute)
{
if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out attribute))
{
return false;
}
return attribute.ArgumentList != null;
}
示例7: GetTouchingWordAsync
/// <summary>
/// Returns the identifier, keyword, contextual keyword or preprocessor keyword touching this
/// position, or a token of Kind = None if the caret is not touching either.
/// </summary>
public static Task<SyntaxToken> GetTouchingWordAsync(
this SyntaxTree syntaxTree,
int position,
ISyntaxFactsService syntaxFacts,
CancellationToken cancellationToken,
bool findInsideTrivia = false)
{
return GetTouchingTokenAsync(syntaxTree, position, syntaxFacts.IsWord, cancellationToken, findInsideTrivia);
}
示例8: AbstractTokenBraceCompletionSession
protected AbstractTokenBraceCompletionSession(
ISyntaxFactsService syntaxFactsService,
int openingTokenKind,
int closingTokenKind)
{
_syntaxFactsService = syntaxFactsService;
this.OpeningTokenKind = openingTokenKind;
this.ClosingTokenKind = closingTokenKind;
}
示例9: TryGetConstructorInitializer
private bool TryGetConstructorInitializer(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ConstructorInitializerSyntax expression)
{
if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression))
{
return false;
}
return expression.ArgumentList != null;
}
示例10: SymbolMapBuilder
private SymbolMapBuilder(
ISyntaxFactsService service,
SemanticModel semanticModel,
TextSpan span,
CancellationToken cancellationToken)
: base(SyntaxWalkerDepth.Token)
{
_semanticModel = semanticModel;
_service = service;
_span = span;
_symbolMap = new Dictionary<ISymbol, List<SyntaxToken>>();
_cancellationToken = cancellationToken;
}
示例11: GetGenerateTypeOptions
public GenerateTypeOptionsResult GetGenerateTypeOptions(
string typeName,
GenerateTypeDialogOptions generateTypeDialogOptions,
Document document,
INotificationService notificationService,
IProjectManagementService projectManagementService,
ISyntaxFactsService syntaxFactsService)
{
var viewModel = new GenerateTypeDialogViewModel(
document,
notificationService,
projectManagementService,
syntaxFactsService,
_generatedCodeService,
generateTypeDialogOptions,
typeName,
document.Project.Language == LanguageNames.CSharp ? ".cs" : ".vb",
_isNewFile,
_accessSelectString,
_typeKindSelectString);
var dialog = new GenerateTypeDialog(viewModel);
var result = dialog.ShowModal();
if (result.HasValue && result.Value)
{
// Retain choice
_isNewFile = viewModel.IsNewFile;
_accessSelectString = viewModel.SelectedAccessibilityString;
_typeKindSelectString = viewModel.SelectedTypeKindString;
var defaultNamespace = projectManagementService.GetDefaultNamespace(viewModel.SelectedProject, viewModel.SelectedProject?.Solution.Workspace);
return new GenerateTypeOptionsResult(
accessibility: viewModel.SelectedAccessibility,
typeKind: viewModel.SelectedTypeKind,
typeName: viewModel.TypeName,
project: viewModel.SelectedProject,
isNewFile: viewModel.IsNewFile,
newFileName: viewModel.FileName.Trim(),
folders: viewModel.Folders,
fullFilePath: viewModel.FullFilePath,
existingDocument: viewModel.SelectedDocument,
defaultNamespace: defaultNamespace,
areFoldersValidIdentifiers: viewModel.AreFoldersValidIdentifiers);
}
else
{
return GenerateTypeOptionsResult.Cancelled;
}
}
示例12: GetIdentifierOrGlobalNamespaceTokensWithText
public static IEnumerable<SyntaxToken> GetIdentifierOrGlobalNamespaceTokensWithText(
ISyntaxFactsService syntaxFacts, Document document, VersionStamp version, SemanticModel model, SyntaxNode root, SourceText sourceText,
string text, CancellationToken cancellationToken)
{
var normalized = syntaxFacts.IsCaseSensitive ? text : text.ToLowerInvariant();
var entry = GetCachedEntry(model);
if (entry == null)
{
return GetIdentifierOrGlobalNamespaceTokensWithText(syntaxFacts, document, version, root, sourceText, normalized, cancellationToken);
}
return entry.IdentifierCache.GetOrAdd(normalized, key => GetIdentifierOrGlobalNamespaceTokensWithText(syntaxFacts, document, version, root, sourceText, key, cancellationToken));
}
示例13: Build
public static Dictionary<ISymbol, List<SyntaxToken>> Build(
ISyntaxFactsService service,
SemanticModel semanticModel,
SyntaxNode root,
TextSpan span,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(semanticModel);
Contract.ThrowIfNull(service);
Contract.ThrowIfNull(root);
var builder = new SymbolMapBuilder(service, semanticModel, span, cancellationToken);
builder.Visit(root);
return builder._symbolMap;
}
示例14: GetCurrentArgumentState
public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken)
{
if (TryGetObjectCreationExpression(
root,
position,
syntaxFacts,
SignatureHelpTriggerReason.InvokeSignatureHelpCommand,
cancellationToken,
out var expression) &&
currentSpan.Start == SignatureHelpUtilities.GetSignatureHelpSpan(expression.ArgumentList).Start)
{
return SignatureHelpUtilities.GetSignatureHelpState(expression.ArgumentList, position);
}
return null;
}
示例15: GetIdentifierOrGlobalNamespaceTokensWithText
private static ImmutableArray<SyntaxToken> GetIdentifierOrGlobalNamespaceTokensWithText(
ISyntaxFactsService syntaxFacts, Document document, VersionStamp version, SyntaxNode root, SourceText sourceText,
string text, CancellationToken cancellationToken)
{
Func<SyntaxToken, bool> candidate = t =>
syntaxFacts.IsGlobalNamespaceKeyword(t) || (syntaxFacts.IsIdentifier(t) && syntaxFacts.TextMatch(t.ValueText, text));
// identifier is not escaped
if (sourceText != null)
{
return GetTokensFromText(syntaxFacts, document, version, root, sourceText, text, candidate, cancellationToken);
}
// identifier is escaped
return root.DescendantTokens(descendIntoTrivia: true).Where(candidate).ToImmutableArray();
}