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


C# SourceUnit.GetCodeLine方法代码示例

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


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

示例1: Add

        public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) {
            if (severity == Severity.Warning && !ReportWarning(_context.Verbose, errorCode)) {
                return;
            }

            CountError(severity);

            string path;
            string codeLine;
            int line = span.Start.Line;
            if (sourceUnit != null) {
                path = sourceUnit.Path;
                codeLine = (line > 0) ? sourceUnit.GetCodeLine(line) : null;
            } else {
                path = null;
                codeLine = null;
            }

            if (severity == Severity.Error || severity == Severity.FatalError) {
                throw new SyntaxError(message, path, line, span.Start.Column, codeLine);
            } else {

                if (_WriteSite == null) {
                    Interlocked.CompareExchange(
                        ref _WriteSite,
                        CallSite<Func<CallSite, object, object, object>>.Create(RubyCallAction.Make(_context, "write", 1)),
                        null
                    );
                }

                message = RubyContext.FormatErrorMessage(message, "warning", path, line, span.Start.Column, null);

                _WriteSite.Target(_WriteSite, _context.StandardErrorOutput, MutableString.CreateMutable(message));
            }
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:35,代码来源:RuntimeErrorSink.cs

示例2: SyntaxErrorException

        public SyntaxErrorException(string message, SourceUnit sourceUnit, SourceSpan span, int errorCode, Severity severity)
            : base(message) {
            ContractUtils.RequiresNotNull(message, "message");

            _span = span;
            _severity = severity;
            _errorCode = errorCode;
            if (sourceUnit != null) {
                _sourcePath = sourceUnit.Path;
                try {
                    _sourceCode = sourceUnit.GetCode();
                    _sourceLine = sourceUnit.GetCodeLine(Line);
                } catch (System.IO.IOException) {
                    // could not get source code.
                }
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:17,代码来源:SyntaxErrorException.cs

示例3: GetSourceLine

 private string GetSourceLine(SourceUnit source, SourceSpan span)
 {
     return source.GetCodeLine(span.Start.Line);
 }
开发者ID:fgretief,项目名称:IronLua,代码行数:4,代码来源:LuaRuntimeException.cs

示例4: Add

		public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
		{
			int line = GetLine(span.Start.Line);
			errors.Add(new PythonCompilerError(source.Path, message, source.GetCodeLine(line), span, errorCode, severity));
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:5,代码来源:PythonCompilerSink.cs


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