Ejemplo n.º 1
1
        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));
            }
        }
Ejemplo n.º 2
0
        SourceLocation CorrectParametersEndLocation(SourceLocation parametersEndLocation)
        {
            int endLine = parametersEndLocation.Line - 1;

            string lastLineOfCodeForMethodDef = sourceUnit.GetCodeLine(endLine);
            int    LengthOfNewLineCharacters  = 2;
            int    endColumn = lastLineOfCodeForMethodDef.Length + LengthOfNewLineCharacters + 1;

            return(new SourceLocation(0, endLine, endColumn));
        }
Ejemplo n.º 3
0
        public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
        {
            int line = GetLine(span.Start.Line);

            //ensure errors are unique by line/message
            if (ContainsError(line, message) == false)
            {
                Errors.Add(new ScriptError(source.Path, message, source.GetCodeLine(line), span, errorCode, severity));
            }
        }
Ejemplo n.º 4
0
        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.
                }
            }
        }
Ejemplo n.º 5
0
        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, RubyContext, object, object, object> > .Create(RubyCallAction.Make("write", 1)),
                        null
                        );
                }

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

                _WriteSite.Target(_WriteSite, _context, _context.StandardErrorOutput, MutableString.CreateMutable(message));
            }
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
 private string GetSourceLine(SourceUnit source, SourceSpan span)
 {
     return source.GetCodeLine(span.Start.Line);
 }
Ejemplo n.º 8
0
 public override void Add(SourceUnit source, String message, SourceSpan span, Int32 errorCode, Severity severity)
 {
     Add(message, source.Path, source.GetCode(), source.GetCodeLine(span.Start.Line), span, errorCode, severity);
 }
Ejemplo n.º 9
0
		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));
		}