public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference {assembly/project} {project to add reference to"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference {assembly/project} {project to add reference to"); return; } if (!_project.Read(projectFile, _provider)) return; _project.Reference(file); _project.Write(); writer.Write("Added reference {0} to {1}", file, projectFile); }
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()); } }
private void gotoFile(IResponseWriter writer, string file, int line, int column, string location) { writer.Write( string.Format("editor goto \"{0}|{1}|{2}\"", file, line, column)); writer.Write("editor setfocus"); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) return; _project.Dereference(file); _project.Write(); writer.Write("Rereferenced {0} from {1}", file, projectFile); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("comment|Invalid number of arguments. " + "Usage: create {template name} {item name} {template arguments}"); return; } var project = getFile(arguments[1]); var template = pickTemplate(arguments[0]); if (template == null) { return; } template.Run(project, getArguments(arguments)); writer.Write("comment|Created {0}", project); if (template.File == null) { return; } gotoFile(writer, template.File.Fullpath, template.Line, template.Column, Path.GetDirectoryName(project)); }
public void WriteProject(Project project) { Projects.Add(project); if (_visibility) { _writer.Write("project|" + project.File + "||filesearch"); } }
public void Execute(IResponseWriter writer, string[] args) { var output = ""; _dispatcher.GetHandlers() .Where(x => x.Usage != null).ToList() .ForEach(x => output += x.Usage + " "); writer.Write(output); }
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()); } }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 1) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference REFERENCE [PROJECT"); return; } if (arguments.Length > 1) { var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference REFERENCE [PROJECT"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) return; } else { if (!_project.Read(Environment.CurrentDirectory, _getTypesProviderByLocation)) { writer.Write("error|Could not locate project within " + Environment.CurrentDirectory + ". " + "Usage: dereference REFERENCE [PROJECT]"); return; } } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); _project.Dereference(file); _project.Write(); writer.Write("Rereferenced {0} from {1}", fullpath, _project.Fullpath); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: new {template name} {item name} {template arguments}"); return; } var className = getFileName(arguments[1]); var location = getLocation(arguments[1]); if (!_project.Read(location, _getTypesProviderByLocation)) { return; } var template = _pickTemplate(arguments[0], _project.Type); if (template == null) { writer.Write("error|No template with the name {0} exists.", arguments[0]); return; } var ns = getNamespace(location, _project.Fullpath, _project.DefaultNamespace); template.Run(location, className, ns, _project.Fullpath, _project.Type, getArguments(arguments)); if (template.File == null) { return; } _project.AppendFile(template.File); _project.Write(); writer.Write("comment|Created class {0}.{1}", ns, className); writer.Write("comment|Full path {0}", template.File.Fullpath); gotoFile(writer, template.File.Fullpath, template.Line, template.Column, location); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 1) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference REFERENCE [PROJECT]"); return; } if (arguments.Length > 1) { var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference REFERENCE [PROJECT]"); return; } if (!_project.Read(projectFile, _provider)) return; } else { if (!_project.Read(Environment.CurrentDirectory, _provider)) { writer.Write("error|Could not locate project within " + Environment.CurrentDirectory + ". " + "Usage: reference REFERENCE [PROJECT]"); return; } } var fullpath = new PathParser(arguments[0]).ToAbsolute(Environment.CurrentDirectory); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); _project.Reference(file); _project.Write(); writer.Write("Added reference {0} to {1}", fullpath, _project.Fullpath); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference {assembly/project} {project to add reference to"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) { file = new VSProjectFile().New(fullpath); } else { file = new AssemblyFile().New(fullpath); } var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference {assembly/project} {project to add reference to"); return; } if (!_project.Read(projectFile, _provider)) { return; } _project.Reference(file); _project.Write(); writer.Write("comment|Added reference {0} to {1}", file, projectFile); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) { file = new VSProjectFile().New(fullpath); } else { file = new AssemblyFile().New(fullpath); } var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) { return; } _project.Dereference(file); _project.Write(); writer.Write("comment|Rereferenced {0} from {1}", file, projectFile); }
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()); } }
private CommandArguments parseArguments(IResponseWriter writer, string[] arguments) { var file = arguments.FirstOrDefault(x => !x.StartsWith("-")); if (file == null) { writer.Write("error|No file argument provided"); return(null); } return(new CommandArguments() { File = file, Recursive = arguments.Contains("--recursive") || arguments.Contains("-r") }); }
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("comment|Found name {0}", name); var signature = new FileContextAnalyzer(_globalCache, cache) .GetSignatureFromNameAndPosition(file, name, line, column); writer.Write("comment|Found signature {0}", signature); var pos = cache.PositionFromSignature(signature); if (pos != null) { writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); return; } writer.Write("comment|Looking in global cache"); pos = _globalCache.PositionFromSignature(signature); if (pos != null) { writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); } } catch (Exception ex) { writer.Write(ex.ToString()); } }
private static void handleMessage(CommandMessage msg, IResponseWriter writer, bool serverMode) { if (msg == null) { return; } var handler = _dispatcher.GetHandler(msg.Command); if (handler == null) { writer.Write("comment|" + msg.Command + " is not a valid C# plugin command. For a list of commands type oi."); return; } try { if (handler == null) { return; } handler.Execute(writer, msg.Arguments.ToArray()); } catch (Exception ex) { var builder = new OutputWriter(writer); writeException(builder, ex); } }
public static Task <HttpResponseMessage> Write(this IResponseWriter writer, object response) { return(writer.Write(new ResponseWriterContext(response))); }
public void Send(IResponseWriter response) { VerifyArgument.IsNotNull("response", response); response.Write(this); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: new {template name} {item name} {template arguments}"); return; } var className = getFileName(arguments[1]); var location = getLocation(arguments[1]); if (!_project.Read(location, _getTypesProviderByLocation)) return; var template = _pickTemplate(arguments[0], _project.Type); if (template == null) { writer.Write("error|No template with the name {0} exists.", arguments[0]); return; } var ns = getNamespace(location, _project.Fullpath, _project.DefaultNamespace); template.Run(location, className, ns, _project.Fullpath, _project.Type, getArguments(arguments)); if (template.File == null) return; _project.AppendFile(template.File); _project.Write(); writer.Write("Created class {0}.{1}", ns, className); writer.Write("Full path {0}", template.File.Fullpath); gotoFile(writer, template.File.Fullpath, template.Line, template.Column, location); }
public static Task <HttpResponseMessage> Write(this IResponseWriter writer, Configuration configuration, RequestContext context, object response) { return(writer.Write(new ResponseWriterContext(configuration, context, response))); }
private CommandArguments parseArguments(IResponseWriter writer, string[] arguments) { var file = arguments.FirstOrDefault(x => !x.StartsWith("-")); if (file == null) { writer.Write("error|No file argument provided"); return null; } return new CommandArguments() { File = file, Recursive = arguments.Contains("--recursive") || arguments.Contains("-r") }; }
public void Execute(IResponseWriter writer, string[] args) { writer.Write(".csproj|.cs"); }
private static void handleMessage(CommandMessage msg, IResponseWriter writer, bool serverMode) { if (msg == null) return; Logger.Write("Handling message: " + msg); var handler = _dispatcher.GetHandler(msg.Command); if (handler == null) { writer.Write("error|" + msg.Command + " is not a valid C# plugin command. For a list of commands type oi."); return; } try { if (handler == null) return; handler.Execute(writer, msg.Arguments.ToArray()); } catch (Exception ex) { var builder = new OutputWriter(writer); writeException(builder, ex); } Logger.Write("Done handling message"); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: create {template name} {item name} {template arguments}"); return; } var project = getFile(arguments[1]); var template = pickTemplate(arguments[0]); if (template == null) return; template.Run(project, getArguments(arguments)); writer.Write("Created {0}", project); if (template.File == null) return; gotoFile(writer, template.File.Fullpath, template.Line, template.Column, Path.GetDirectoryName(project)); }
private void gotoFile(IResponseWriter writer, string file, int line, int column, string location) { writer.Write( string.Format("command|editor goto \"{0}|{1}|{2}\"", file, line, column)); writer.Write("command|editor setfocus"); }