Пример #1
0
        public void When_file_is_changed_it_will_use_the_dirty_buffer()
        {
            var signature =
                new EnclosingSignatureFromPosition(new OutputWriter(new NullResponseWriter()), (filePath) => getFileContent(filePath), (filepath) => { }, (f) => "file1|DirtyFile")
                .GetSignature("file1", 6, 1);

            Assert.That(signature, Is.EqualTo("MyNamespace.ITestClass"));
        }
Пример #2
0
        public void When_outside_of_the_method_it_will_pick_containing_class()
        {
            var signature =
                new EnclosingSignatureFromPosition(new OutputWriter(new NullResponseWriter()), (filePath) => getFileContent(filePath), (filepath) => { }, (f) => null)
                .GetSignature("file1", 12, 1);

            Assert.That(signature, Is.EqualTo("MyNamespace.TestClass"));
        }
Пример #3
0
        public void When_the_closest_code_item_is_a_method_it_will_return_signature()
        {
            var signature =
                new EnclosingSignatureFromPosition(new OutputWriter(new NullResponseWriter()), (filePath) => getFileContent(filePath), (filepath) => { }, (f) => null)
                .GetSignature("file1", 10, 1);

            Assert.That(signature, Is.EqualTo("MyNamespace.MyStruct MyNamespace.TestClass.MyMethod(System.Int32)"));
        }
Пример #4
0
        public void When_the_closest_code_is_a_field_it_will_return_the_class()
        {
            var signature =
                new EnclosingSignatureFromPosition(new OutputWriter(new NullResponseWriter()), (filePath) => getFileContent(filePath), (filepath) => { }, (f) => null)
                .GetSignature("file1", 7, 1);

            Assert.That(signature, Is.EqualTo("MyNamespace.TestClass"));
        }
Пример #5
0
        public void When_outside_a_namespace_it_returns_null()
        {
            var signature =
                new EnclosingSignatureFromPosition(new OutputWriter(new NullResponseWriter()), (filePath) => getFileContent(filePath), (filepath) => {}, (f) => null)
                .GetSignature("file1", 2, 1);

            Assert.That(signature, Is.Null);
        }
Пример #6
0
        public void Execute(IResponseWriter writer, string[] args)
        {
            if (args.Length != 1)
            {
                return;
            }
            var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            if (chunks.Length != 3)
            {
                return;
            }
            try {
                var file   = chunks[0];
                var line   = int.Parse(chunks[1]);
                var column = int.Parse(chunks[2]);

                var signatureFetcher =
                    new EnclosingSignatureFromPosition(
                        _globalCache,
                        (fileName) => File.ReadAllText(fileName),
                        (fileName) => File.Delete(fileName),
                        (fileName) => {
                    var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory);
                    if (instance != null)
                    {
                        return(instance.GetDirtyFiles(fileName));
                    }
                    return("");
                });
                var signature = signatureFetcher.GetSignature(file, line, column);
                writer.Write(signature);
            } catch (Exception ex) {
                writer.Write(ex.ToString());
            }
        }