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


C# ISyntaxFactsService类代码示例

本文整理汇总了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;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:25,代码来源:TupleConstructionSignatureHelpProvider.cs

示例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));
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:AbstractIndentationService.AbstractIndenter.cs

示例3: TryGetNameWithoutAttributeSuffix

 protected static bool TryGetNameWithoutAttributeSuffix(
     string name,
     ISyntaxFactsService syntaxFacts,
     out string result)
 {
     return name.TryGetWithoutAttributeSuffix(syntaxFacts.IsCaseSensitive, out result);
 }
开发者ID:tralivali1234,项目名称:roslyn,代码行数:7,代码来源:AbstractReferenceFinder.cs

示例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);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:CSharpIndentationService.cs

示例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);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:TestGenerateTypeOptionsService.cs

示例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;
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:9,代码来源:AttributeSignatureHelpProvider.cs

示例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);
 }
开发者ID:sebgod,项目名称:roslyn,代码行数:13,代码来源:SyntaxTreeExtensions.cs

示例8: AbstractTokenBraceCompletionSession

 protected AbstractTokenBraceCompletionSession(
     ISyntaxFactsService syntaxFactsService,
     int openingTokenKind,
     int closingTokenKind)
 {
     _syntaxFactsService = syntaxFactsService;
     this.OpeningTokenKind = openingTokenKind;
     this.ClosingTokenKind = closingTokenKind;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:9,代码来源:AbstractTokenBraceCompletionSession.cs

示例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;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:ConstructorInitializerSignatureHelpProvider.cs

示例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;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:13,代码来源:MethodExtractor.Analyzer.SymbolMapBuilder.cs

示例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;
                }
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:51,代码来源:VisualStudioGenerateTypeOptionsServiceFactory.cs

示例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));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:FindReferenceCache.cs

示例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;
                }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:16,代码来源:MethodExtractor.Analyzer.SymbolMapBuilder.cs

示例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;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:16,代码来源:ObjectCreationExpressionSignatureHelpProvider.cs

示例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();
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:16,代码来源:FindReferenceCache.cs


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