Ejemplo n.º 1
0
        private Diagnostic BuildLGDiagnostic(
            string message,
            DiagnosticSeverity severity = DiagnosticSeverity.Error,
            ParserRuleContext context   = null)
        {
            var lineOffset       = _currentTemplate != null ? _currentTemplate.SourceRange.Range.Start.Line : 0;
            var templateNameInfo = string.Empty;

            if (_currentTemplate != null && _currentTemplate.Name.StartsWith(Templates.InlineTemplateIdPrefix, StringComparison.InvariantCulture))
            {
                templateNameInfo = $"[{_currentTemplate.Name}]";
            }

            var range = context == null ? new Range(1 + lineOffset, 0, 1 + lineOffset, 0) : context.ConvertToRange(lineOffset);

            return(new Diagnostic(range, templateNameInfo + message, severity, _templates.Id));
        }
Ejemplo n.º 2
0
 private Diagnostic BuildTemplatesDiagnostic(string errorMessage, ParserRuleContext context, DiagnosticSeverity severity = DiagnosticSeverity.Error)
 {
     return(new Diagnostic(context.ConvertToRange(), errorMessage, severity, _templates.Source));
 }
Ejemplo n.º 3
0
 public SourceRange(ParserRuleContext parseTree, string source = "", int offset = 0)
 {
     this.Source = source ?? string.Empty;
     this.Range  = parseTree.ConvertToRange(offset);
 }
Ejemplo n.º 4
0
        private Diagnostic BuildLGDiagnostic(
            string message,
            DiagnosticSeverity severity = DiagnosticSeverity.Error,
            ParserRuleContext context   = null)
        {
            var lineOffset       = this.currentTemplate != null ? this.currentTemplate.SourceRange.Range.Start.Line : 0;
            var templateNameInfo = string.Empty;

            if (this.currentTemplate != null && this.currentTemplate.Name != Templates.InlineTemplateId)
            {
                templateNameInfo = $"[{this.currentTemplate.Name}]";
            }

            var range = context == null ? new Range(1 + lineOffset, 0, 1 + lineOffset, 0) : context.ConvertToRange(lineOffset);

            return(new Diagnostic(range, templateNameInfo + message, severity, templates.Id));
        }
Ejemplo n.º 5
0
        private Diagnostic BuildLGDiagnostic(
            string message,
            DiagnosticSeverity severity = DiagnosticSeverity.Error,
            ParserRuleContext context   = null)
        {
            var lineOffset = this.currentTemplate != null ? this.currentTemplate.SourceRange.Range.Start.Line : 0;

            message = this.currentTemplate != null ? $"[{this.currentTemplate.Name}]" + message : message;
            var range = context == null ? new Range(1 + lineOffset, 0, 1 + lineOffset, 0) : context.ConvertToRange(lineOffset);

            return(new Diagnostic(range, message, severity, templates.Id));
        }