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


C# SyntaxNodeOrToken.GetLocation方法代码示例

本文整理汇总了C#中SyntaxNodeOrToken.GetLocation方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNodeOrToken.GetLocation方法的具体用法?C# SyntaxNodeOrToken.GetLocation怎么用?C# SyntaxNodeOrToken.GetLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyntaxNodeOrToken的用法示例。


在下文中一共展示了SyntaxNodeOrToken.GetLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SyntaxNodeOrTokenListItem

        public SyntaxNodeOrTokenListItem(SyntaxNodeOrToken syntaxNodeOrToken)
        {
            _lineSpan = syntaxNodeOrToken.GetLocation().GetLineSpan();

            Content = $"{_lineSpan}: {syntaxNodeOrToken.Kind()} {Truncate(syntaxNodeOrToken.ToString())}";
            ToolTip = syntaxNodeOrToken.ToString();
        }
开发者ID:FrankBakkerNl,项目名称:IntelliFind,代码行数:7,代码来源:SyntaxNodeOrTokenListItem.cs

示例2: ReportDiagnosticsIfObsoleteInternal

        /// <returns>
        /// True if the symbol is definitely obsolete.
        /// False if the symbol is definitely not obsolete.
        /// Unknown if the symbol may be obsolete.
        /// 
        /// NOTE: The return value reflects obsolete-ness, not whether or not the diagnostic was reported.
        /// </returns>
        private static ThreeState ReportDiagnosticsIfObsoleteInternal(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol containingMember, BinderFlags location)
        {
            Debug.Assert(diagnostics != null);

            if (symbol.ObsoleteState == ThreeState.False)
            {
                return ThreeState.False;
            }

            var data = symbol.ObsoleteAttributeData;
            if (data == null)
            {
                // Obsolete attribute has errors.
                return ThreeState.False;
            }

            // If we haven't cracked attributes on the symbol at all or we haven't
            // cracked attribute arguments enough to be able to report diagnostics for
            // ObsoleteAttribute, store the symbol so that we can report diagnostics at a 
            // later stage.
            if (symbol.ObsoleteState == ThreeState.Unknown)
            {
                diagnostics.Add(new LazyObsoleteDiagnosticInfo(symbol, containingMember, location), node.GetLocation());
                return ThreeState.Unknown;
            }

            // After this point, always return True.

            var inObsoleteContext = ObsoleteAttributeHelpers.GetObsoleteContextState(containingMember);

            // If we are in a context that is already obsolete, there is no point reporting
            // more obsolete diagnostics.
            if (inObsoleteContext == ThreeState.True)
            {
                return ThreeState.True;
            }
            // If the context is unknown, then store the symbol so that we can do this check at a
            // later stage
            else if (inObsoleteContext == ThreeState.Unknown)
            {
                diagnostics.Add(new LazyObsoleteDiagnosticInfo(symbol, containingMember, location), node.GetLocation());
                return ThreeState.True;
            }

            // We have all the information we need to report diagnostics right now. So do it.
            var diagInfo = ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, location);
            if (diagInfo != null)
            {
                diagnostics.Add(diagInfo, node.GetLocation());
                return ThreeState.True;
            }

            return ThreeState.True;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:61,代码来源:Binder.cs

示例3: Error

 internal static void Error(DiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax, params object[] args)
 {
     Error(diagnostics, code, syntax.GetLocation(), args);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:Binder.cs

示例4: AddMapping

        public void AddMapping(SyntaxNodeOrToken node, Position pos)
        {
            var srcPos = node.GetLocation().GetLineSpan().StartLinePosition;
            if (_line == pos.Line)
            {
                if (_mapping.Length > 0 && _mapping[_mapping.Length - 1] != ';')
                    _mapping.Append(',');
            }
            else
            {
                while (_line < pos.Line)
                {
                    _mapping.Append(';');
                    _line++;
                }
            }

            _mapping.Append(Base64VLQEncoding.Encode(pos.Column));
            _mapping.Append(Base64VLQEncoding.Encode(_srcIdx));
            _mapping.Append(Base64VLQEncoding.Encode(srcPos.Line));
            _mapping.Append(Base64VLQEncoding.Encode(srcPos.Character));
        }
开发者ID:rexzh,项目名称:SharpJs,代码行数:22,代码来源:SourceMapOutput.cs


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