static void AddGlobalNamespaceImport (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, string nsName) { var parsedDocument = context.ParsedDocument; var unit = parsedDocument.GetAst<SemanticModel> (); if (unit == null) return; int offset = SearchUsingInsertionPoint (unit.SyntaxTree.GetRoot ()); var text = new StringBuilder (); text.Append ("using "); text.Append (nsName); text.Append (";"); text.Append (editor.EolMarker); editor.InsertText (offset, text.ToString ()); }