Beispiel #1
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 cache =
                    new DirtyFileParser(
                        _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 "";
                        }).Parse(file);

                var name = new TypeUnderPositionResolver()
                    .GetTypeName(file, File.ReadAllText(file), line, column);
                writer.Write("Found name {0}", name);
                var signature = new FileContextAnalyzer(_globalCache, cache)
                    .GetSignatureFromNameAndPosition(file, name, line, column);
                writer.Write("Found signature {0}", signature);
                var pos = cache.PositionFromSignature(signature);
                if (pos != null) {
                    writer.Write("command|editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column);
                    return;
                }
                writer.Write("Looking in global cache");
                pos = _globalCache.PositionFromSignature(signature);
                if (pos != null)
                    writer.Write("command|editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column);
            } catch (Exception ex) {
                writer.Write(ex.ToString());
            }
        }
 private string signatureFromPosition(int line, int column)
 {
     var name =
         new TypeUnderPositionResolver()
             .GetTypeName(_file, _fileContent, line, column);
     return
         _analyzer.GetSignatureFromNameAndPosition(_file, name, line, column);
 }
 public void Setup()
 {
     _resolver =
         new TypeUnderPositionResolver();
 }