public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (!_globalSettingsProvider.GlobalSettings.CodingStyleOpenBraceAfterNewLine) { yield break; } if (!_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) { yield break; } foreach (var point in line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default).GetPoints()) { if (WhitespaceCharacters.IndexOf(point.GetChar()) >= 0) { // continue as long as we find whitespaces } else if (point.GetChar() == '{') { yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, point + 1), Message = "Open curly brace ('{') should always be at the end of a line, never on a new line preceeded by spaces.", }); } else { // Stop at the first non-whitespace character. yield break; } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (!_globalSettingsProvider.GlobalSettings.CodingStyleTabCharacter) { yield break; } if (!_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) { yield break; } if (line.Length == 0) { yield break; } foreach (var point in line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default).GetPoints()) { if (point.GetChar() == '\t') { yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, point + 1), Message = "TAB characters are not allowed." }); } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (_chromiumSourceFiles.ApplyCodingStyle(line)) { var fragment = line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default); foreach (var point in fragment.GetPoints()) { if (_whitespaceCharacters.IndexOf(point.GetChar()) >= 0) { // continue as long as we find whitespaces } else if (GetMarker(line, fragment, point) != null) { var marker = GetMarker(line, fragment, point); yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, marker.Length), Message = string.Format("Missing space before ( in \"{0}\".", marker) }); } else { // Stop at the first non-whitespace character. yield break; } } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (!_globalSettingsProvider.GlobalSettings.CodingStyleElseIfOnNewLine) { yield break; } if (!_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) { yield break; } var fragment = line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default); foreach (var point in fragment.GetPoints()) { if (WhitespaceCharacters.IndexOf(point.GetChar()) >= 0) { // continue as long as we find whitespaces } else if (GetMarker(line, fragment, point) != null) { var marker = GetMarker(line, fragment, point); yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, marker.Length), Message = string.Format("\"{0}\" should always be on the same line as the \"}}\" character.", marker) }); } else { // Stop at the first non-whitespace character. yield break; } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (_chromiumSourceFiles.ApplyCodingStyle(line)) { int indent = 0; var fragment = line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default); foreach (var point in fragment.GetPoints()) { if (_whitespaceCharacters.IndexOf(point.GetChar()) >= 0) { // continue as long as we find whitespaces indent++; } else if (GetMarker(line, fragment, point) != null) { if (indent % 2 == 0) // even indentation is not ok { var marker = GetMarker(line, fragment, point); yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, marker.Length), Message = string.Format("Accessor \"{0}\" should always be indented 1 character less than rest of class body.", marker) }); } } else { // Stop at the first non-whitespace character. yield break; } } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (!_globalSettingsProvider.GlobalSettings.CodingStyleTrailingSpace) { yield break; } if (!_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) { yield break; } foreach (var point in line.GetFragment(line.Start, line.End, TextLineFragment.Options.Reverse).GetPoints()) { if (WhitespaceCharacters.IndexOf(point.GetChar()) >= 0) { yield return(new TextLineCheckerError { Span = new SnapshotSpan(point, point + 1), Message = "Trailing whitespaces are not allowed.", }); } else { yield break; } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (_chromiumSourceFiles.ApplyCodingStyle(line)) { if (line.Length > 80) { if (!IsAllowedOverflow(line)) { yield return(new TextLineCheckerError { Span = new SnapshotSpan(line.Start + 80, line.End), Message = "Maximum length of line is 80 characters.", }); } } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (_chromiumSourceFiles.ApplyCodingStyle(line)) { var lineBreak = line.GetLineBreakText(); if (lineBreak.Length > 0 && lineBreak != "\n") { var fragment = line.GetFragment(line.End.Position - 1, line.EndIncludingLineBreak.Position, TextLineFragment.Options.IncludeLineBreak); yield return(new TextLineCheckerError { Span = fragment.SnapshotSpan, Message = "Line breaks should be \"unix\" (i.e. LF) style only.", }); } } }
public IEnumerable <TextLineCheckerError> CheckLine(ITextSnapshotLine line) { if (!_globalSettingsProvider.GlobalSettings.CodingStyleLongLine) { yield break; } if (!_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) { yield break; } if (line.Length > 80) { if (!IsAllowedOverflow(line)) { yield return(new TextLineCheckerError { Span = new SnapshotSpan(line.Start + 80, line.End), Message = "Maximum length of line is 80 characters.", }); } } }
public static bool ApplyCodingStyle(this IChromiumSourceFiles chromiumSourceFiles, IFileSystem fileSystem, ITextSnapshotLine line) { // Check document is part of a Chromium source repository ITextDocument document; if (!line.Snapshot.TextBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out document)) { return(false); } var path = document.FilePath; if (!PathHelpers.IsAbsolutePath(path)) { return(false); } if (!fileSystem.FileExists(new FullPath(path))) { return(false); } return(chromiumSourceFiles.ApplyCodingStyle(document.FilePath)); }