void AddUsing(string requireString) { string assemblyName = GetAssemblyName(requireString); DefaultUsing defaultUsing = new DefaultUsing(compilationUnit.ProjectContent); defaultUsing.Usings.Add(assemblyName); compilationUnit.UsingScope.Usings.Add(defaultUsing); }
public override IUsing CreateDefaultImports(IProjectContent pc) { DefaultUsing u = new DefaultUsing(pc); u.Usings.Add("Microsoft.VisualBasic"); u.Usings.Add("System"); u.Usings.Add("System.Collections"); u.Usings.Add("System.Collections.Generic"); u.Usings.Add("System.Drawing"); u.Usings.Add("System.Diagnostics"); u.Usings.Add("System.Windows.Forms"); return(u); }
public void SetUpFixture() { resolver = new PythonResolver(); mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent(); mockProjectContent.NamespacesToAdd.Add("Test"); myTestClass = new MockClass(mockProjectContent, "MyTestClass"); List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>(); namespaceItems.Add(myTestClass); mockProjectContent.AddExistingNamespaceContents("MyNamespace", namespaceItems); DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent); // Add usings. DefaultUsing newUsing = new DefaultUsing(cu.ProjectContent); newUsing.Usings.Add("MyNamespace"); DefaultUsingScope usingScope = new DefaultUsingScope(); usingScope.Usings.Add(newUsing); cu.UsingScope = usingScope; ParseInformation parseInfo = new ParseInformation(cu); results = resolver.CtrlSpace(0, "".Length, parseInfo, "", ExpressionContext.Default); }
public static void AddUsingDeclaration(ICompilationUnit cu, IDocument document, string newNamespace, bool sortExistingUsings) { if (cu == null) throw new ArgumentNullException("cu"); if (document == null) throw new ArgumentNullException("document"); if (newNamespace == null) throw new ArgumentNullException("newNamespace"); ParseInformation info = ParserService.ParseFile(cu.FileName, document.TextContent); if (info != null) cu = info.MostRecentCompilationUnit; IUsing newUsingDecl = new DefaultUsing(cu.ProjectContent); newUsingDecl.Usings.Add(newNamespace); List<IUsing> newUsings = new List<IUsing>(cu.UsingScope.Usings); if (sortExistingUsings) { newUsings.Sort(CompareUsings); } bool inserted = false; for (int i = 0; i < newUsings.Count; i++) { if (CompareUsings(newUsingDecl, newUsings[i]) <= 0) { newUsings.Insert(i, newUsingDecl); inserted = true; break; } } if (!inserted) { newUsings.Add(newUsingDecl); } if (sortExistingUsings) { PutEmptyLineAfterLastSystemNamespace(newUsings); } cu.ProjectContent.Language.CodeGenerator.ReplaceUsings(new TextEditorDocument(document), cu.UsingScope.Usings, newUsings); }
public override object VisitUsingDeclaration(NRefactoryAST.UsingDeclaration usingDeclaration, object data) { DefaultUsing us = new DefaultUsing(cu.ProjectContent, GetRegion(usingDeclaration.StartLocation, usingDeclaration.EndLocation)); foreach (NRefactoryAST.Using u in usingDeclaration.Usings) { u.AcceptVisitor(this, us); } currentNamespace.Usings.Add(us); return data; }
DefaultUsing CreateUsing(string namespaceName, IProjectContent projectContent) { var defaultUsing = new DefaultUsing(projectContent); defaultUsing.Usings.Add(namespaceName); return defaultUsing; }
void UpdateDefaultImports(ICollection<ProjectItem> items) { if (languageDefaultImportCount < 0) { languageDefaultImportCount = (DefaultImports != null) ? DefaultImports.Usings.Count : 0; } if (languageDefaultImportCount == 0) { DefaultImports = null; } else { while (DefaultImports.Usings.Count > languageDefaultImportCount) { DefaultImports.Usings.RemoveAt(languageDefaultImportCount); } } foreach (ProjectItem item in items) { if (item.ItemType == ItemType.Import) { if (DefaultImports == null) { DefaultImports = new DefaultUsing(this); } DefaultImports.Usings.Add(item.Include); } } }
public override void OnImport(AST.Import p) { DefaultUsing u = new DefaultUsing(_cu.ProjectContent); if (p.Alias == null) u.Usings.Add(p.Namespace); else u.AddAlias(p.Alias.Name, new GetClassReturnType(_cu.ProjectContent, p.Namespace, 0)); _cu.UsingScope.Usings.Add(u); }
public override IUsing CreateDefaultImports(IProjectContent pc) { DefaultUsing u = new DefaultUsing(pc); u.Usings.Add("Microsoft.VisualBasic"); u.Usings.Add("System"); u.Usings.Add("System.Collections"); u.Usings.Add("System.Collections.Generic"); u.Usings.Add("System.Drawing"); u.Usings.Add("System.Diagnostics"); u.Usings.Add("System.Windows.Forms"); return u; }
IUsing CreateUsing(IProjectContent pc, string @namespace) { DefaultUsing @using = new DefaultUsing(pc); @using.Usings.Add(@namespace); return @using; }