public Warning GetWarning(string line) { if (!string.IsNullOrWhiteSpace(line)) { if (line.Contains("Assets")) { var match = MatchLogLine.Match(line); if (match.Success) { var filePath = line.Substring(0, match.Index).Replace('\\', '/'); var assetPath = Application.dataPath.Replace('\\', '/'); var fIndex = filePath.LastIndexOf(assetPath); if (fIndex != -1) { filePath = "Assets" + filePath.Substring(fIndex + assetPath.Length, filePath.Length - (fIndex + assetPath.Length)); } if (File.Exists(filePath)) { WarningFile warningFile; if (!_fileMap.TryGetValue(filePath, out warningFile)) { _fileMap[filePath] = warningFile = new WarningFile(filePath); } var matchCode = MatchCode.Match(match.Value).Value; var codeStartWith = "warning CS"; var code = "CS" + matchCode.Substring(codeStartWith.Length, matchCode.Length - 1 - codeStartWith.Length); var matchPosition = MatchPosition.Match(match.Value).Value; var linePos = matchPosition.Trim('(', ')').Split(','); var startLine = int.Parse(linePos[0].Trim()) - 1; var startPos = int.Parse(linePos[1].Trim()) - 1; var endLine = int.Parse(linePos[2].Trim()) - 1; var endPos = int.Parse(linePos[3].Trim()) - 1; var warningLine = warningFile.Line(startLine); var warning = warningLine.Warinig(code, startPos, endPos, line); return(warning); } } } } return(null); }
public WarningLine(WarningFile file, int lineIndex) { Top = new LinkedList <string>(); Bottom = new LinkedList <string>(); Left = new LinkedList <string>(); Right = new LinkedList <string>(); Inserts = new Dictionary <int, Insert>(); DisableWarnings = new HashSet <string>(); Removes = new List <Range>(); File = file; LineIndex = lineIndex; Line = new Line(file.Lines, lineIndex); var text = Line.Text; var initLen = text.Length; var currLen = text.TrimStart().Length; StartPosition = initLen - currLen; StartSpace = text.Substring(0, StartPosition); }