public TextNode([NotNull] ISnapshot snapshot, [NotNull] string key, [NotNull] string value, TextSpan textSpan) { Snapshot = snapshot; Key = key; Value = value; TextSpan = textSpan; }
public Diagnostic(int msg, [NotNull] string fileName, TextSpan span, Severity severity, [NotNull] string text) { Msg = msg; FileName = fileName; Span = span; Severity = severity; Text = text; }
public Token([NotNull] string key, TextSpan keyTextSpan, [NotNull] string value, TextSpan valueTextSpan, int indent, bool isNested) { Key = key; KeyTextSpan = keyTextSpan; Value = value; ValueTextSpan = valueTextSpan; Indent = indent; IsNested = isNested; }
public void TraceError(int msg, string text, string fileName, TextSpan span, string details = "") { Write(msg, text, Severity.Error, fileName, span, details); if (Configuration.GetBool(Constants.Configuration.Debug)) { Debugger.Launch(); } }
public Token([NotNull] string key, TextSpan keyTextSpan, int indent, bool isNested) { Key = key; KeyTextSpan = keyTextSpan; Indent = indent; IsNested = isNested; Value = string.Empty; ValueTextSpan = TextSpan.Empty; }
protected Token NextToken() { while (_lineNumber < _lines.Length && string.IsNullOrWhiteSpace(_lines[_lineNumber])) { _lineNumber++; } if (_lineNumber >= _lines.Length) { return null; } Token token; var line = _lines[_lineNumber]; var indent = line.IndexOfNotWhitespace(); var isNested = line[indent] == '-'; var keyStartIndex = isNested ? line.IndexOfNotWhitespace(indent + 1) : indent; var n = line.IndexOf(':'); if (n < 0) { var key = line.Mid(keyStartIndex).Trim(); var keyTextSpan = new TextSpan(_lineNumber, keyStartIndex, key.Length); token = new Token(key, keyTextSpan, indent, isNested); } else { var key = line.Mid(keyStartIndex, n - keyStartIndex).Trim(); var keyTextSpan = new TextSpan(_lineNumber, keyStartIndex, key.Length); var value = line.Mid(n + 1).Trim(); TextSpan valueTextSpan; if (value == ">") { ParseValue(out value, out valueTextSpan, " "); } else if (value == "|") { ParseValue(out value, out valueTextSpan, "\r\n"); } else { valueTextSpan = new TextSpan(_lineNumber, n + 1, line.Length - n); } token = new Token(key, keyTextSpan, value, valueTextSpan, indent, isNested); } _lineNumber++; return token; }
protected override void Write(int msg, string text, Severity severity, string fileName, TextSpan span, string details) { if (IgnoredMessages.Contains(msg)) { return; } if (!string.IsNullOrEmpty(details)) { text += ": " + details; } var diagnostic = Factory.Diagnostic(msg, fileName, span, severity, text); Project.Diagnostics.Add(diagnostic); }
public void ConstructorTest() { var position = new TextSpan(1, 2, 3); Assert.AreEqual(1, position.LineNumber); Assert.AreEqual(2, position.LinePosition); Assert.AreEqual(3, position.Length); Assert.AreEqual(472428, position.GetHashCode()); Assert.IsFalse(position.Equals(null)); var position2 = new TextSpan(1, 2, 3); Assert.AreEqual(position, position2); Assert.IsTrue(position == position2); Assert.IsTrue(position == position2); var position3 = new TextSpan(1, 2, 1); Assert.IsTrue(position != position3); }
private Rendering FindRendering([NotNull] BuildContext context, [NotNull] string renderingName, [NotNull] string renderingId, TextSpan textSpan) { var renderings = context.Project.ProjectItems.OfType<Rendering>().Where(r => r.ItemName == renderingName).ToList(); if (renderings.Count != 1) { if (!string.IsNullOrEmpty(renderingId)) { Guid guid; if (Guid.TryParse(renderingId, out guid)) { renderings = context.Project.ProjectItems.OfType<Rendering>().Where(r => r.Uri.Guid == guid).ToList(); } else { renderings = context.Project.ProjectItems.OfType<Rendering>().Where(r => string.Equals(r.QualifiedName, renderingId, StringComparison.OrdinalIgnoreCase)).ToList(); } } } if (!renderings.Any()) { context.CompileContext.Trace.TraceError(0, "Rendering not found", context.SourceFile.AbsoluteFileName, textSpan, renderingName); return null; } if (renderings.Count > 1) { context.CompileContext.Trace.TraceError(0, "Ambigeous rendering", context.SourceFile.AbsoluteFileName, textSpan, renderingName); return null; } return renderings.First(); }
public TextNode([NotNull] ISnapshot snapshot, [NotNull] string key, [NotNull] string value, TextSpan textSpan, [ItemNotNull, NotNull] IEnumerable <ITextNode> attributes, [ItemNotNull, NotNull] IEnumerable <ITextNode> childNodes) { Snapshot = snapshot; Key = key; Value = value; TextSpan = textSpan; Attributes = attributes; ChildNodes = childNodes; }
public void TraceInformation(string text, string fileName, TextSpan span, string details = "") { TraceInformation(0, text, fileName, span, details); }
public void TraceError(string text, string fileName, TextSpan span, string details = "") { TraceError(0, text, fileName, span, details); }
public void TraceWarning(int msg, string text, string fileName, TextSpan span, string details = "") { Write(msg, text, Severity.Warning, fileName, span, details); }
public virtual TextNode TextNode(ISnapshot snapshot, TextSpan span, string name, string value) { return new TextNode(snapshot, name, value, span); }
private void ParseValue([NotNull] out string value, out TextSpan valueTextSpan, [NotNull] string delimiter) { _lineNumber++; if (_lineNumber >= _lines.Length) { value = string.Empty; valueTextSpan = new TextSpan(0, 0, 0); return; } var startLineNumber = _lineNumber; var startIndent = _lines[_lineNumber].IndexOfNotWhitespace(); var length = 0; var sb = new StringBuilder(); do { var line = _lines[_lineNumber]; length += line.Length + 2; if (string.IsNullOrWhiteSpace(line)) { _lineNumber++; continue; } var indent = line.IndexOfNotWhitespace(); if (indent < startIndent) { _lineNumber--; break; } sb.Append(line.Trim()); sb.Append(delimiter); _lineNumber++; } while (_lineNumber < _lines.Length); value = sb.ToString().Trim(); valueTextSpan = new TextSpan(startLineNumber, startLineNumber, length); }
public void TraceInformation(int msg, string text, string fileName, TextSpan span, string details = "") { Write(msg, text, Severity.Information, fileName, span, details); }
public virtual Diagnostic Diagnostic(int msg, string fileName, TextSpan span, Severity severity, string text) { return new Diagnostic(msg, fileName, span, severity, text); }
protected virtual void Write(int msg, [NotNull] string text, Severity severity, [NotNull] string fileName, TextSpan textSpan, [NotNull] string details) { if (IgnoredMessages.Contains(msg)) { return; } if (!string.IsNullOrEmpty(details)) { text += ": " + details; } var fileInfo = !string.IsNullOrEmpty(fileName) ? fileName : "scc.cmd"; var projectDirectory = Configuration.Get(Constants.Configuration.ProjectDirectory); if (!string.IsNullOrEmpty(projectDirectory)) { if (fileInfo.StartsWith(projectDirectory, StringComparison.OrdinalIgnoreCase)) { fileInfo = fileInfo.Mid(projectDirectory.Length + 1); } } var lineInfo = textSpan.Length == 0 ? $"({textSpan.LineNumber},{textSpan.LinePosition})" : $"({textSpan.LineNumber},{textSpan.LinePosition},{textSpan.LineNumber},{textSpan.LinePosition + textSpan.Length})"; Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write($"{fileInfo}{lineInfo}: "); switch (severity) { case Severity.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case Severity.Error: Console.ForegroundColor = ConsoleColor.Red; break; default: Console.ForegroundColor = ConsoleColor.DarkGray; break; } Console.Write(severity.ToString().ToLowerInvariant()); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write(" SCC{0}: ", msg.ToString("0000")); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(text); }
public YamlTextNode([NotNull] ISnapshot snapshot, TextSpan textSpan, [NotNull] string key, [NotNull] string value) : base(snapshot, key, value, textSpan) { }
public void TraceError(int msg, string text, string fileName, TextSpan span, string details = "") { Write(msg, text, Severity.Error, fileName, span, details); }
public bool Equals(TextSpan other) { return Length == other.Length && LineNumber == other.LineNumber && LinePosition == other.LinePosition; }
public virtual XmlTextSnapshot With([NotNull] SnapshotParseContext parseContext, [NotNull] ISourceFile sourceFile, [NotNull] string contents, [NotNull] string schemaNamespace, [NotNull] string schemaFileName) { base.With(sourceFile); SchemaNamespace = schemaNamespace; SchemaFileName = schemaFileName; ParseContext = parseContext; try { var doc = XDocument.Parse(contents, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); RootElement = doc.Root; } catch (XmlException ex) { ParseError = ex.Message; ParseErrorTextSpan = new TextSpan(ex.LineNumber, ex.LinePosition, 0); RootElement = null; } catch (Exception ex) { ParseError = ex.Message; RootElement = null; } return this; }
public TextNode([NotNull] ISnapshot snapshot, [NotNull] string key, [NotNull] string value, TextSpan textSpan) { Snapshot = snapshot; Key = key; Value = value; TextSpan = textSpan; Attributes = Enumerable.Empty <ITextNode>(); ChildNodes = Enumerable.Empty <ITextNode>(); }