示例#1
0
        private static SourceAnnotationFile ParseAnnotationFile(Target target, string origin, IMessageLogger messageLogger)
        {
            var documentInfo = SymbolHelper.TryGetSourceInfo(target, messageLogger);

            if (documentInfo == null)
            {
                return(new SourceAnnotationFile(origin, Array <string> .Empty));
            }

            Code.BugIf(documentInfo.Path != origin, "documentInfo.Path != origin");

            if (!TryValidate(documentInfo, messageLogger))
            {
                return(new SourceAnnotationFile(origin, Array <string> .Empty));
            }

            var methodRanges = documentInfo.MethodLinesMap;
            var noCodeRanges = methodRanges.GetComplementation()
                               .MakeInclusive(i => i, i => i)
                               .TrimFrom(1);
            var candidateLines = methodRanges.SubRanges
                                 .Zip(
                noCodeRanges.SubRanges,
                (methodRange, noCodeRange) => noCodeRange.WithKey(methodRange.Key))
                                 .ToCompositeRange();

            Code.BugIf(
                candidateLines.SubRanges.Count != methodRanges.SubRanges.Count,
                "candidateLines.SubRanges.Count != map.SubRanges.Count");

            var sourceLines = TryReadFileContent(origin, messageLogger);

            if (sourceLines.Length == 0)
            {
                return(new SourceAnnotationFile(origin, sourceLines));
            }

            var benchmarkMethods = FillAttributeLines(candidateLines, sourceLines, origin, messageLogger);

            return(new SourceAnnotationFile(origin, sourceLines, benchmarkMethods));
        }
示例#2
0
 private static string TryGetAnnotationLocation(
     [NotNull] CompetitionTarget targetToAnnotate,
     [NotNull] IMessageLogger messageLogger) =>
 SymbolHelper.TryGetSourcePath(targetToAnnotate.Target, messageLogger);