Exemplo n.º 1
0
        public void SourceCodeHandlesOneSubset()
        {
            string[] selectedLines = code.GetLines(1, 1);

            Assert.True(selectedLines.Length == 1);
            Assert.Equal(code.GetLine(1), selectedLines.First());
        }
        private bool IsProgramNamespace(SourceCode aSourceCode, string aUsingNamespace)
        {
            var found = (from code in aSourceCode.GetLines()
                         where code.StartsWith("namespace") && aSourceCode.ContainKeyword(code, aUsingNamespace)
                         select code).FirstOrDefault();

            return found != null;
        }
 private int CountInterfaces(SourceCode aSourceCode)
 {
     int result = 0;
     int pos = 1;
     foreach(String line in aSourceCode.GetLines())
     {
         if (aSourceCode.ContainKeyword(line, "interface")  && (line.EndsWith("{") || aSourceCode.GetNextLine(pos).StartsWith("{")))
             result++;
         pos++;
     }
     return result;
 }
        private int CountClassName(SourceCode aSourceCode)
        {
            int result = 0;

            ClassDefinitionComp classDef = new ClassDefinitionComp();

            int pos = 1;
            foreach(String line in aSourceCode.GetLines())
            {
                if (classDef.Identify(aSourceCode, line, pos))
                    result++;
                pos++;
            }
            return result;
        }
        public string DoValidation(SourceCode aSourceCode)
        {
            String result = null;

            bool foundIndexers = false;
            int pos = 1;
            foreach (String line in aSourceCode.GetLines())
            {
                if (line.IndexOf("this[") > -1 && (line.EndsWith("{") || aSourceCode.GetNextLine(pos).StartsWith("{")))
                    foundIndexers = true;
                pos++;
            }

            if (foundIndexers)
                result = aSourceCode.GetFileName() + ": Java unfortunatly doesn't support C# indexers. ";

            return result;
        }
Exemplo n.º 6
0
 public void AddError(string message, SourceCode sourceCode, Severity severity, SourceSpan span) =>
 _errors.Add(new ErrorEntry(message, sourceCode.GetLines(span.Start.Line, span.End.Line), severity, span));