Beispiel #1
0
        public void TestFindDef3()
        {
            var      cwd      = Directory.GetCurrentDirectory();
            Document document = CheckDoc("../../../../UnitTestProject1/ANTLRv3.g3");
            // Position at the "grammarSpec" rule, beginning of RHS symbol "grammarDecl".
            // All lines and columns are zero based in LSP.
            int line      = 88;
            int character = 40;
            int index     = new LanguageServer.Module().GetIndex(line, character, document);

            (int, int)back = new LanguageServer.Module().GetLineColumn(index, document);
            if (back.Item1 != line || back.Item2 != character)
            {
                throw new Exception();
            }
            IList <Location> found = new LanguageServer.Module().FindDefs(index, document);

            if (found.Count != 1)
            {
                throw new Exception();
            }
            (int, int)back_start = new LanguageServer.Module().GetLineColumn(found.First().Range.Start.Value, document);
            if (back_start.Item1 != 96 || back_start.Item2 != 0)
            {
                throw new Exception();
            }
            (int, int)back_end = new LanguageServer.Module().GetLineColumn(found.First().Range.End.Value, document);
            if (back_end.Item1 != 96 || back_end.Item2 != 9)
            {
                throw new Exception();
            }
        }
Beispiel #2
0
        public void TestFindDefBison()
        {
            var      cwd       = Directory.GetCurrentDirectory();
            Document document  = CheckDoc("../../../../UnitTestProject1/calc.y");
            int      line      = 8;
            int      character = 7;
            int      index     = new LanguageServer.Module().GetIndex(line, character, document);

            (int, int)back = new LanguageServer.Module().GetLineColumn(index, document);
            if (back.Item1 != line || back.Item2 != character)
            {
                throw new Exception();
            }
            IList <Location> found = new LanguageServer.Module().FindDefs(index, document);

            if (found.Count != 1)
            {
                throw new Exception();
            }
            (int, int)back_start = new LanguageServer.Module().GetLineColumn(found.First().Range.Start.Value, document);
            if (back_start.Item1 != 8 || back_start.Item2 != 7)
            {
                throw new Exception();
            }
            (int, int)back_end = new LanguageServer.Module().GetLineColumn(found.First().Range.End.Value, document);
            if (back_end.Item1 != 8 || back_end.Item2 != 9)
            {
                throw new Exception();
            }
        }
Beispiel #3
0
        public void TestFindDef4()
        {
            var      cwd       = Directory.GetCurrentDirectory();
            Document lexer_doc = CheckDoc("../../../../LanguageServer/ANTLRv4Lexer.g4");
            Document document  = CheckDoc("../../../../LanguageServer/ANTLRv4Parser.g4");
            int      line      = 50;
            int      character = 18;
            int      index     = new LanguageServer.Module().GetIndex(line, character, document);

            (int, int)back = new LanguageServer.Module().GetLineColumn(index, document);
            if (back.Item1 != line || back.Item2 != character)
            {
                throw new Exception();
            }
            IList <Location> found = new LanguageServer.Module().FindDefs(index, document);

            if (found.Count != 1)
            {
                throw new Exception();
            }
            (int, int)back_start = new LanguageServer.Module().GetLineColumn(found.First().Range.Start.Value, document);
            if (back_start.Item1 != 53 || back_start.Item2 != 0)
            {
                throw new Exception();
            }
            (int, int)back_end = new LanguageServer.Module().GetLineColumn(found.First().Range.End.Value, document);
            if (back_end.Item1 != 53 || back_end.Item2 != 10)
            {
                throw new Exception();
            }
        }