Beispiel #1
0
        public void Get_Children_Of_Definition_Folder()
        {
            //arrange
            var folder = new Mock <IItem>();
            var child  = new Mock <IItem>();

            child.SetupGet(c => c["path"]).Returns("d:\\");
            child.SetupGet(c => c["filter"]).Returns(string.Empty);
            child.SetupGet(c => c["enabled"]).Returns("1");
            folder.SetupGet(f => f.Children).Returns(new []
            {
                child.Object
            });
            var database = new Mock <IDatabase>();

            database.Setup(d => d.GetItem(new Guid("{6AC30241-2EB5-418E-94B1-13915F6B104C}"))).Returns(folder.Object);
            var definitionsProvider = new DefinitionsProvider();

            //act
            var definitions = definitionsProvider.GetSerializationDefinitions(database.Object).ToArray();

            //assert
            Assert.That(definitions.First().Path, Is.EqualTo("d:\\"));
            Assert.That(definitions.First().Filter, Is.EqualTo(string.Empty));
            Assert.That(definitions.First().Enabled, Is.EqualTo(true));
        }
Beispiel #2
0
 protected override void OnNavigateNext()
 {
     if (DefinitionsProvider != null && Selection != null)
     {
         DefinitionsProvider.DefinitionsLoaded += new AsyncOperationFinishedHandler(DefinitionsProvíder_DefinitionsLoaded);
         CurrentOperation = DefinitionsProvider.loadDefinitions();
     }
 }
Beispiel #3
0
        public void TestNoSymbol()
        {
            ISymbolTableManager manager = new FakeSymbolManager(false, true);
            var provider = new DefinitionsProvider(manager);

            var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10);

            Assert.IsFalse(result.Any());

            Assert.AreEqual(DefinitionsOutcome.NotFound, provider.Outcome);
        }
Beispiel #4
0
        public void TestRegularAlreadyDefinition()
        {
            ISymbolTableManager manager = new FakeSymbolManager(true, false);
            var provider = new DefinitionsProvider(manager);

            var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10);

            Assert.AreEqual("file:///N:/u/l.l", result.FirstOrDefault().Location.Uri.ToString());
            Assert.AreEqual(0, result.FirstOrDefault().Location.Range.Start.Line, "Start Line is not matching");
            Assert.AreEqual(10, result.FirstOrDefault().Location.Range.Start.Character, "Start Char is not matching");
            Assert.AreEqual(0, result.FirstOrDefault().Location.Range.End.Line, "End Line is not matching");
            Assert.AreEqual(10, result.FirstOrDefault().Location.Range.End.Character, "End Char is not matching");
            Assert.AreEqual(DefinitionsOutcome.WasAlreadyDefintion, provider.Outcome);
        }
Beispiel #5
0
        public void TestRegularNotDefinition()
        {
            ISymbolTableManager manager = new FakeSymbolManager(false, false);
            var provider = new DefinitionsProvider(manager);

            // note: params do not matter. the fake returns a fixed symbol and does not respect the position. those methods are tested within the symbol table tests.
            var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10);

            Assert.AreEqual("file:///N:/u/l.l", result.FirstOrDefault().Location.Uri.ToString());
            Assert.AreEqual(0, result.FirstOrDefault().Location.Range.Start.Line, "Start Line is not matching");
            Assert.AreEqual(10, result.FirstOrDefault().Location.Range.Start.Character, "Start Char is not matching");
            Assert.AreEqual(0, result.FirstOrDefault().Location.Range.End.Line, "End Line is not matching");
            Assert.AreEqual(10, result.FirstOrDefault().Location.Range.End.Character, "End Char is not matching");
            Assert.AreEqual(DefinitionsOutcome.Success, provider.Outcome);
        }
Beispiel #6
0
        public async Task <LocationOrLocationLinks> Handle(DefinitionParams request, CancellationToken cancellationToken)
        {
            _log.LogInformation(string.Format(Resources.LoggingMessages.request_handle, _method));

            try
            {
                var uri     = request.TextDocument.Uri;
                var line    = (int)request.Position.Line + 1;
                var col     = (int)request.Position.Character + 1;
                var manager = _workspaceManager.GetFileRepository(request.TextDocument.Uri).SymbolTableManager;
                IDefinitionsProvider provider = new DefinitionsProvider(manager);
                return(await Task.Run(() => RunAndEvaluate(provider, uri, line, col), cancellationToken));
            }
            catch (Exception e)
            {
                HandleError(string.Format(Resources.LoggingMessages.request_error, _method), e);
                return(null);
            }
        }