本文整理汇总了C#中ICSharpCode.NRefactory.Ast.NamespaceDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# NamespaceDeclaration类的具体用法?C# NamespaceDeclaration怎么用?C# NamespaceDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了NamespaceDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitNamespaceDeclaration
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
currentNamepace = namespaceDeclaration.Name;
base.VisitNamespaceDeclaration(namespaceDeclaration, data);
currentNamepace = string.Empty;
return null;
}
示例2: CreateNamespace
NamespaceDeclaration CreateNamespace(DependencyRelation relation, NamespaceDeclaration originalNamespace)
{
var ns = new NamespaceDeclaration(originalNamespace.Name);
ns.Children.AddRange(originalNamespace.Children.OfType<UsingDeclaration>());
ns.Children.Add(CreatePartialClass(relation));
return ns;
}
示例3: CreateNamespace
NamespaceDeclaration CreateNamespace(ValueObjectDescriptor valueObject, NamespaceDeclaration originalNamespace)
{
var ns = new NamespaceDeclaration(originalNamespace.Name);
ns.Children.AddRange(originalNamespace.Children.OfType<UsingDeclaration>());
ns.Children.Add(CreatePartialClass(valueObject));
return ns;
}
示例4: VisitCompilationUnit
public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
{
base.VisitCompilationUnit(compilationUnit, data);
if (!string.IsNullOrEmpty(NamespacePrefixToAdd)) {
for (int i = 0; i < compilationUnit.Children.Count; i++) {
NamespaceDeclaration ns = compilationUnit.Children[i] as NamespaceDeclaration;
if (ns != null) {
ns.Name = NamespacePrefixToAdd + "." + ns.Name;
}
if (compilationUnit.Children[i] is TypeDeclaration || compilationUnit.Children[i] is DelegateDeclaration) {
ns = new NamespaceDeclaration(NamespacePrefixToAdd);
ns.AddChild(compilationUnit.Children[i]);
compilationUnit.Children[i] = ns;
}
}
}
ToCSharpConvertVisitor v = new ToCSharpConvertVisitor();
compilationUnit.AcceptVisitor(v, data);
if (projectContent != null && projectContent.DefaultImports != null) {
int index = 0;
foreach (string u in projectContent.DefaultImports.Usings) {
compilationUnit.Children.Insert(index++, new UsingDeclaration(u));
}
}
return null;
}
示例5: VisitNamespaceDeclaration
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
CSharpLanguage.VisitorData data2 = (CSharpLanguage.VisitorData) data;
data2.CurrentNamespaces.Push(namespaceDeclaration.Name);
namespaceDeclaration.AcceptChildren(this, data2);
data2.CurrentNamespaces.Pop();
return null;
}
示例6: VisitNamespaceDeclaration
public virtual object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
CSharpLanguage.VisitorData visitorData = (CSharpLanguage.VisitorData) data;
visitorData.CurrentNamespaces.Push(namespaceDeclaration.get_Name());
((AbstractNode) namespaceDeclaration).AcceptChildren((IAstVisitor) this, (object) visitorData);
visitorData.CurrentNamespaces.Pop();
return (object) null;
}
示例7: add_Namespace
public static NamespaceDeclaration add_Namespace(this CompilationUnit compilationUnit, string @namespace)
{
var newNamespace = compilationUnit.namespaces(@namespace); // check if already exists and if it does return it
if (newNamespace != null)
return newNamespace;
newNamespace = new NamespaceDeclaration(@namespace);
compilationUnit.Children.Add(newNamespace);
return newNamespace;
}
示例8: TrackedVisitNamespaceDeclaration
public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
NamespaceDeclaration replacedNamespace = namespaceDeclaration;
UsingDeclaration usingDeclaration = new UsingDeclaration("java.lang.*");
replacedNamespace.Children.Insert(0, usingDeclaration);
ReplaceCurrentNode(replacedNamespace);
return base.TrackedVisitNamespaceDeclaration(namespaceDeclaration, data);
}
示例9: Setup
public void Setup()
{
mocks = new MockRepository();
typeResolver = mocks.DynamicMock<ITypeResolver>();
visitor = new TypeInspectionVisitor(typeResolver);
type = new TypeDeclaration(Modifiers.Public, new List<AttributeSection>()) {Name = "SomeType"};
@namespace = new NamespaceDeclaration("SomeNamespace");
@namespace.AddChild(type);
type.Parent = @namespace;
}
示例10: VisitingNamespace_MustAddParentNamespacesToTypeResolver
public void VisitingNamespace_MustAddParentNamespacesToTypeResolver()
{
var typeTables = new List<TypeTableEntry>();
var usings = new List<String>();
var aliases = new Dictionary<string, string>();
var resolver = new TypeResolver(typeTables, usings, aliases);
var nsDecl = new NamespaceDeclaration("System.Collections.Specialized");
var visitor = new TypeResolvingVisitor(resolver);
visitor.VisitNamespaceDeclaration(nsDecl, null);
Assert.AreEqual(3, usings.Count);
}
示例11: TrackedVisitNamespaceDeclaration
public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
Removeables.Clear();
UsedTypes.Clear();
NamespaceDeclaration replaced = namespaceDeclaration;
IList types = AstUtil.GetChildrenWithType(replaced, typeof(TypeDeclaration));
foreach (TypeDeclaration typeDeclaration in types)
{
VisitTypeDeclaration(typeDeclaration, data);
}
ReplaceCurrentNode(replaced);
return base.TrackedVisitNamespaceDeclaration(namespaceDeclaration, data);
}
示例12: CreateTypeDeclarations
private void CreateTypeDeclarations(string jarFile)
{
LoadClasses(Path.GetFullPath(jarFile));
foreach (string package in classes.Keys)
{
if (!IsIncluded(package))
continue;
Console.WriteLine(package);
IDictionary types = new Hashtable();
IList packageClasses = (IList) classes[package];
foreach (ClassFile cf in packageClasses)
{
if (cf.IsPublic)
{
TypeDeclaration type = GetTypeDeclaration(cf);
types.Add(type.Name, type);
}
}
foreach (TypeDeclaration type in types.Values)
{
if (type.Name.IndexOf("$") == -1)
{
NamespaceDeclaration nameSpace = new NamespaceDeclaration(package);
type.Parent = nameSpace;
nameSpace.AddChild(type);
CompilationUnit cu = new CompilationUnit();
cu.Children.Add(nameSpace);
compilationUnits.Add(cu);
}
else
{
string parentName = type.Name.Substring(0, type.Name.IndexOf("$"));
TypeDeclaration parent = (TypeDeclaration) types[GetTypeName(parentName)];
if (parent != null)
{
type.Name = GetTypeName(type.Name);
parent.AddChild(type);
}
}
}
}
}
示例13: TrackedVisitNamespaceDeclaration
public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
similarTypes = new Hashtable();
IList usings = AstUtil.GetChildrenWithType(namespaceDeclaration, typeof(UsingDeclaration));
foreach (UsingDeclaration usingDeclaration in usings)
{
Using usi = (Using) usingDeclaration.Usings[0];
string fullName = GetFullyQualifiedName(usi);
string type = GetShortReferenceTypeName(usi);
string projectType = namespaceDeclaration.Name + "." + type;
if (CodeBase.Types.Contains(projectType))
similarTypes.Add(type, fullName);
}
if (similarTypes.Count < 1)
return null;
else
return base.TrackedVisitNamespaceDeclaration(namespaceDeclaration, data);
}
示例14: VisitNamespaceDeclaration
public override object VisitNamespaceDeclaration (NamespaceDeclaration node, object data)
{
if (!String.IsNullOrEmpty (Namespace))
throw CreateException (node, "Nested namespaces are not supported");
string prevNamespace = Namespace;
//var prevUsings = Usings;
Namespace = node.Name;
//Usings = new HashSet<string> ();
node.AcceptChildren (this, null);
Namespace = prevNamespace;
//Usings = prevUsings;
return null;
}
示例15: VisitNamespaceDeclaration
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
if (RootNamespaceToRemove != null) {
if (namespaceDeclaration.Name == RootNamespaceToRemove) {
// remove namespace declaration
INode insertAfter = namespaceDeclaration;
foreach (INode child in namespaceDeclaration.Children) {
InsertAfterSibling(insertAfter, child);
insertAfter = child;
}
namespaceDeclaration.Children.Clear();
RemoveCurrentNode();
} else if (namespaceDeclaration.Name.StartsWith(RootNamespaceToRemove + ".")) {
namespaceDeclaration.Name = namespaceDeclaration.Name.Substring(RootNamespaceToRemove.Length + 1);
}
}
base.VisitNamespaceDeclaration(namespaceDeclaration, data);
return null;
}