本文整理汇总了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));
}
}
示例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.
}
}
}
示例3: GetSourceLine
private string GetSourceLine(SourceUnit source, SourceSpan span)
{
return source.GetCodeLine(span.Start.Line);
}
示例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));
}