本文整理汇总了C#中ICSharpCode.NRefactory.Ast.NamespaceDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# NamespaceDeclaration类的具体用法?C# NamespaceDeclaration怎么用?C# NamespaceDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了NamespaceDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitNamespaceDeclaration
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
currentNamepace = namespaceDeclaration.Name;
base.VisitNamespaceDeclaration(namespaceDeclaration, data);
currentNamepace = string.Empty;
return null;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:7,代码来源:SimplifyTypeReferences.cs
示例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;
}
开发者ID:modulexcite,项目名称:magic-1,代码行数:7,代码来源:DependencyConstructorGenerator.cs
示例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;
}
开发者ID:modulexcite,项目名称:magic-1,代码行数:7,代码来源:ValueObjectGenerator.cs
示例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;
}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:27,代码来源:VBNetToCSharpConvertVisitor.cs
示例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;
}
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:CSharpLanguage.cs
示例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;
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:CSharpLanguage.cs
示例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;
}
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:NamespaceDeclaration_ExtensionMethods.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:10,代码来源:DefaultImportTransformer.cs
示例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;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:11,代码来源:TypeInspectionVisitorTests.cs
示例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);
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:13,代码来源:TypeResolvingVisitorTests.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:14,代码来源:UsageRemoverTransformer.cs
示例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);
}
}
}
}
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:45,代码来源:JavaArchiveToCodeSkeleton.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:18,代码来源:SameProjectAndExternalTypeNameTransformer.cs
示例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;
}
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:18,代码来源:JsSourceInspector.cs
示例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;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:19,代码来源:CSharpToVBNetConvertVisitor.cs
示例16: TrackedVisitNamespaceDeclaration
public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
IList addingUsings = new ArrayList();
base.TrackedVisitNamespaceDeclaration(namespaceDeclaration, addingUsings);
if (addingUsings.Count > 0)
{
NamespaceDeclaration replaceNamespace = namespaceDeclaration;
List<INode> children = namespaceDeclaration.Children;
INode[] childMembers = new INode[children.Count];
children.CopyTo(childMembers);
replaceNamespace.Children.Clear();
foreach (UsingDeclaration usi in addingUsings)
replaceNamespace.Children.Add(usi);
foreach (INode node in childMembers)
{
replaceNamespace.Children.Add(node);
}
ReplaceCurrentNode(replaceNamespace);
}
return null;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:23,代码来源:ShortenReferencesTransformer.cs
示例17: AddUsing
public void AddUsing(NamespaceDeclaration namespaceDeclaration, IList usings, UsingDeclaration usingDeclaration)
{
Using usin = (Using) usingDeclaration.Usings[0];
string alias = null;
string name = usin.Name;
if (!usin.IsAlias)
name = name.Substring(name.LastIndexOf('.') + 1);
else
alias = usin.Alias.Type;
if (CodeBase.References.Contains(name))
{
string reference = (string) CodeBase.References[name];
alias = alias.Replace("." + name, "." + reference);
TypeReference typeReference = AstUtil.GetTypeReference(alias, namespaceDeclaration);
UsingDeclaration addingUsingDeclaration = new UsingDeclaration(reference, typeReference);
if (!Contains(usings, addingUsingDeclaration))
{
namespaceDeclaration.Children.Insert(0, addingUsingDeclaration);
}
}
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:23,代码来源:ReferenceTransformer.cs
示例18: VisitNamespaceDeclaration
public sealed override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) {
this.BeginVisit(namespaceDeclaration);
object result = this.TrackedVisitNamespaceDeclaration(namespaceDeclaration, data);
this.EndVisit(namespaceDeclaration);
return result;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:6,代码来源:NodeTrackingAstVisitor.cs
示例19: TrackedVisitNamespaceDeclaration
public virtual object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) {
return base.VisitNamespaceDeclaration(namespaceDeclaration, data);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs
示例20: PerformChanges
public override List<Change> PerformChanges (RefactoringOptions options, object prop)
{
IResolver resolver = options.GetResolver ();
List<Change> result = new List<Change> ();
INRefactoryASTProvider provider = options.GetASTProvider ();
if (resolver == null || provider == null)
return result;
TypeDeclaration newType = new TypeDeclaration (ICSharpCode.NRefactory.Ast.Modifiers.None, null);
newType.Name = createExpression.CreateType.Type;
newType.Type = GetNewTypeType ();
ConstructorDeclaration constructor = new ConstructorDeclaration (newType.Name, ICSharpCode.NRefactory.Ast.Modifiers.Public, null, null);
constructor.Body = new BlockStatement ();
int i = 0;
foreach (Expression expression in createExpression.Parameters) {
i++;
string output = provider.OutputNode (options.Dom, expression);
string parameterName;
if (Char.IsLetter (output[0]) || output[0] == '_') {
parameterName = output;
} else {
parameterName = "par" + i;
}
ResolveResult resolveResult2 = resolver.Resolve (new ExpressionResult (output), options.ResolveResult.ResolvedExpression.Region.Start);
TypeReference typeReference = new TypeReference (resolveResult2.ResolvedType.ToInvariantString ());
typeReference.IsKeyword = true;
ParameterDeclarationExpression pde = new ParameterDeclarationExpression (typeReference, parameterName);
constructor.Parameters.Add (pde);
}
ICSharpCode.NRefactory.Ast.INode node = newType;
IType curType = options.Document.CompilationUnit.GetTypeAt (options.Document.TextEditor.CursorLine, options.Document.TextEditor.CursorColumn);
if (curType != null && !string.IsNullOrEmpty (curType.Namespace)) {
NamespaceDeclaration namespaceDeclaration = new NamespaceDeclaration (curType.Namespace);
namespaceDeclaration.Children.Add (newType);
node = namespaceDeclaration;
}
newType.Children.Add (constructor);
string fileName = GetName (Path.Combine (Path.GetDirectoryName (options.Document.FileName), newType.Name + Path.GetExtension (options.Document.FileName)));
string header = options.Dom.Project is DotNetProject ? StandardHeaderService.GetHeader (options.Dom.Project, fileName, true) + Environment.NewLine : "";
CreateFileChange createFile = new CreateFileChange (fileName, header + provider.OutputNode (options.Dom, node));
result.Add (createFile);
result.Add (new OpenFileChange (fileName));
return result;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:46,代码来源:CreateClassCodeGenerator.cs
注:本文中的ICSharpCode.NRefactory.Ast.NamespaceDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论