• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISyntaxFactsService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISyntaxFactsService的典型用法代码示例。如果您正苦于以下问题:C# ISyntaxFactsService类的具体用法?C# ISyntaxFactsService怎么用?C# ISyntaxFactsService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISyntaxFactsService类属于命名空间,在下文中一共展示了ISyntaxFactsService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GetExtractInterfaceOptions

 public ExtractInterfaceOptionsResult GetExtractInterfaceOptions(ISyntaxFactsService syntaxFactsService,
     INotificationService notificationService, List<ISymbol> extractableMembers, string defaultInterfaceName,
     List<string> conflictingTypeNames, string defaultNamespace, string generatedNameTypeParameterSuffix, string languageName)
 {
     var viewModel = new ExtractInterfaceDialogViewModel(syntaxFactsService, defaultInterfaceName, extractableMembers, conflictingTypeNames, defaultNamespace, generatedNameTypeParameterSuffix, languageName, languageName == LanguageNames.CSharp ? ".cs" : ".vb");
     var dialog = new ExtractInterfaceDialog(viewModel);
     dialog.SetOwnerToActive();
     var options = dialog.ShowDialog() == true
         ? new ExtractInterfaceOptionsResult(
             isCancelled: false,
             includedMembers: viewModel.MemberContainers.Where(c => c.IsChecked).Select(c => c.MemberSymbol),
             interfaceName: viewModel.InterfaceName.Trim(),
             fileName: viewModel.FileName.Trim())
         : ExtractInterfaceOptionsResult.Cancelled;
     return options;
 }
开发者ID:mjheitland,项目名称:TableTweaker,代码行数:16,代码来源:ExtractInterfaceOptionsService.cs


示例17: GetOuterMostParenthesizedExpressionInSpan

        private bool GetOuterMostParenthesizedExpressionInSpan(SyntaxNode root, int position,
         ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken, out ParenthesizedExpressionSyntax result)
        {
            result = null;
            while (TryGetParenthesizedExpression(SignatureHelpTriggerReason.InvokeSignatureHelpCommand,
                root, position, syntaxFacts, cancellationToken, out var expression))
            {
                if (!currentSpan.Contains(expression.Span))
                {
                    break;
                }

                result = expression;
                position = expression.SpanStart;
            }

            return result != null;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:TupleConstructionSignatureHelpProvider.cs


示例18: TryGetGenericIdentifier

        protected virtual bool TryGetGenericIdentifier(
            SyntaxNode root, int position,
            ISyntaxFactsService syntaxFacts,
            SignatureHelpTriggerReason triggerReason,
            CancellationToken cancellationToken,
            out SyntaxToken genericIdentifier, out SyntaxToken lessThanToken)
        {
            if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out GenericNameSyntax name))
            {
                genericIdentifier = name.Identifier;
                lessThanToken = name.TypeArgumentList.LessThanToken;
                return true;
            }

            genericIdentifier = default(SyntaxToken);
            lessThanToken = default(SyntaxToken);
            return false;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:GenericNameSignatureHelpProvider.cs


示例19: GetConstructorInitializerTokens

        public static IEnumerable<SyntaxToken> GetConstructorInitializerTokens(
            ISyntaxFactsService syntaxFacts, SemanticModel model, SyntaxNode root, CancellationToken cancellationToken)
        {
            // this one will only get called when we know given document contains constructor initializer.
            // no reason to use text to check whether it exist first.
            var entry = GetCachedEntry(model);
            if (entry == null)
            {
                return GetConstructorInitializerTokens(syntaxFacts, root, cancellationToken);
            }

            if (entry.ConstructorInitializerCache == null)
            {
                var initializers = GetConstructorInitializerTokens(syntaxFacts, root, cancellationToken);
                Interlocked.CompareExchange(ref entry.ConstructorInitializerCache, initializers, null);
            }

            return entry.ConstructorInitializerCache;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:19,代码来源:FindReferenceCache.cs


示例20: GetExtractInterfaceOptions

        public ExtractInterfaceOptionsResult GetExtractInterfaceOptions(
            ISyntaxFactsService syntaxFactsService,
            INotificationService notificationService,
            List<ISymbol> extractableMembers,
            string defaultInterfaceName,
            List<string> allTypeNames,
            string defaultNamespace,
            string generatedNameTypeParameterSuffix,
            string languageName)
        {
            var viewModel = new ExtractInterfaceDialogViewModel(
                syntaxFactsService,
                _glyphService,
                notificationService,
                defaultInterfaceName,
                extractableMembers,
                allTypeNames,
                defaultNamespace,
                generatedNameTypeParameterSuffix,
                languageName,
                languageName == LanguageNames.CSharp ? ".cs" : ".vb");

            var dialog = new ExtractInterfaceDialog(viewModel);
            var result = dialog.ShowModal();

            if (result.HasValue && result.Value)
            {
                return new ExtractInterfaceOptionsResult(
                    isCancelled: false,
                    includedMembers: viewModel.MemberContainers.Where(c => c.IsChecked).Select(c => c.MemberSymbol),
                    interfaceName: viewModel.InterfaceName.Trim(),
                    fileName: viewModel.FileName.Trim());
            }
            else
            {
                return ExtractInterfaceOptionsResult.Cancelled;
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:38,代码来源:VisualStudioExtractInterfaceOptionsService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISyntaxHighlightOutput类代码示例发布时间:2022-05-24
下一篇:
C# ISyndicationExtension类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap