当前位置: 首页>>代码示例>>C#>>正文


C# Ast.UsingDeclaration类代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.Ast.UsingDeclaration的典型用法代码示例。如果您正苦于以下问题:C# UsingDeclaration类的具体用法?C# UsingDeclaration怎么用?C# UsingDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UsingDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了UsingDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitUsingDeclaration

		public object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
		{
			foreach (Using u in usingDeclaration.Usings) {
				VisitUsing(u, data);
			}
			return null;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:ConvertVisitorGlobal.cs

示例2: UsingDirective

	void UsingDirective() {

#line  189 "cs.ATG" 
		string qualident = null; TypeReference aliasedType = null;
		
		Expect(121);

#line  192 "cs.ATG" 
		Location startPos = t.Location; 
		Qualident(
#line  193 "cs.ATG" 
out qualident);
		if (la.kind == 3) {
			lexer.NextToken();
			NonArrayType(
#line  194 "cs.ATG" 
out aliasedType);
		}
		Expect(11);

#line  196 "cs.ATG" 
		if (qualident != null && qualident.Length > 0) {
		 INode node;
		 if (aliasedType != null) {
		     node = new UsingDeclaration(qualident, aliasedType);
		 } else {
		     node = new UsingDeclaration(qualident);
		 }
		 node.StartLocation = startPos;
		 node.EndLocation   = t.EndLocation;
		 compilationUnit.AddChild(node);
		}
		
	}
开发者ID:almazik,项目名称:ILSpy,代码行数:34,代码来源:Parser.cs

示例3: RemoveCurrentNamespaceUsings

        public void RemoveCurrentNamespaceUsings()
        {
            string program = @"package Janett.Translator;
                                public class Translation
                                {
                                }";

            string expected = @"namespace Janett.Translator
                                {
                                    public class Translation
                                    {
                                    }
                                }";

            CompilationUnit cu = TestUtil.ParseProgram(program);
            NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];

            UsingDeclaration us1 = new UsingDeclaration("Refactoring", AstUtil.GetTypeReference("Janett.Translator.Refactoring", ns));
            UsingDeclaration us2 = new UsingDeclaration("Transformation", AstUtil.GetTypeReference("Janett.Translator.Transformation", ns));

            ns.Children.Insert(0, us2);
            ns.Children.Insert(0, us1);
            us1.Parent = ns;
            us2.Parent = ns;

            VisitCompilationUnit(cu, null);
            TestUtil.CodeEqual(expected, TestUtil.GenerateCode(cu));
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:28,代码来源:UsedTypesTest.cs

示例4: VisitUsingDeclaration

		public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
		{
			base.VisitUsingDeclaration(usingDeclaration, data);
			if (usingDeclaration.Usings.Count == 0) {
				RemoveCurrentNode();
			}
			return null;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:8,代码来源:CSharpToVBNetConvertVisitor.cs

示例5: TrackedVisitUsingDeclaration

 public override object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
 {
     Using usi = (Using) usingDeclaration.Usings[0];
     string type = GetShortReferenceTypeName(usi);
     if (similarTypes.Contains(type))
         RemoveCurrentNode();
     return null;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:SameProjectAndExternalTypeNameTransformer.cs

示例6: VisitUsingDeclaration

		public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
		{
			base.VisitUsingDeclaration(usingDeclaration, data);
			if (usingDeclaration.Parent is NamespaceDeclaration) {
				nodesToMoveToCompilationUnit.Add(usingDeclaration);
				RemoveCurrentNode();
			}
			return null;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:9,代码来源:ToVBNetConvertVisitor.cs

示例7: VisitUsingDeclaration

		public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
		{
			foreach (var usingLine in usingDeclaration.Usings)
				if (usingLine.IsAlias)
					TypeResolver.AliasNamespace(usingLine.Name, usingLine.Alias.Type);
				else
					TypeResolver.UseNamespace(usingLine.Name);
			
			return base.VisitUsingDeclaration(usingDeclaration, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:10,代码来源:TypeResolvingVisitor.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: VisitUsingDeclaration

 public override object VisitUsingDeclaration (UsingDeclaration node, object data)
 {
     //Usings = new HashSet<string> ();
     foreach (Using item in node.Usings) {
         if (item.IsAlias)
             throw CreateException (node, "Aliases not are supported");
         
         if (!Usings.Contains (item.Name))
             Usings.Add (item.Name);
     }
     return null;
 }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:12,代码来源:JsSourceInspector.cs

示例10: AddUsing

        private void AddUsing(INode currentNode, object data, string name)
        {
            string ns = name.Substring(name.LastIndexOf('.') + 1);

            NamespaceDeclaration namespaceDeclaration = (NamespaceDeclaration) AstUtil.GetParentOfType(currentNode, typeof(NamespaceDeclaration));
            UsingDeclaration usingDeclaration = new UsingDeclaration(ns);
            usingDeclaration.Parent = namespaceDeclaration;
            ((Using) usingDeclaration.Usings[0]).Alias = AstUtil.GetTypeReference(name, usingDeclaration);
            IList usings = AstUtil.GetChildrenWithType(namespaceDeclaration, typeof(UsingDeclaration));
            if (! ContainsUsing(usings, usingDeclaration) && !ContainsUsing((IList) data, usingDeclaration))
                ((IList) data).Add(usingDeclaration);
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:12,代码来源:ShortenReferencesTransformer.cs

示例11: add_Using

        public static UsingDeclaration add_Using(this CompilationUnit compilationUnit, string @namespace)
        {
            @namespace = @namespace.remove(";").trim();
            var currentUsingDeclaration = [email protected](@namespace);
            if (currentUsingDeclaration != null)
                // these UsingDeclaration & Using classes are a bit of a mess (need to normalize this later)
                return new UsingDeclaration(currentUsingDeclaration.wrapOnList());

            var newUsing = new UsingDeclaration(@namespace);
            compilationUnit.insert(newUsing);
            return newUsing;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:UsingDeclaration_ExtensionMethods.cs

示例12: FieldTwoLayerInvocation

        public void FieldTwoLayerInvocation()
        {
            string program = TestUtil.StatementParse("Field f; f.getName().indexOf('$')");
            string expected = TestUtil.StatementParse("Field f; java.lang.String.instancehelper_indexOf(f.getName(), '$')");

            CompilationUnit cu = TestUtil.ParseProgram(program);
            CompilationUnit cv = TestUtil.ParseProgram(expected);
            UsingDeclaration usiDec = new UsingDeclaration("Field", new TypeReference("java.lang.reflect.Field"));
            ((NamespaceDeclaration) cu.Children[0]).Children.Insert(0, usiDec);
            ((NamespaceDeclaration) cv.Children[0]).Children.Insert(0, usiDec);
            VisitCompilationUnit(cu, null);
            TestUtil.CodeEqual(TestUtil.GenerateCode(cv), TestUtil.GenerateCode(cu));
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:13,代码来源:MemberMapperTest_IKVM.cs

示例13: AddAssembly

        public void AddAssembly(AssemblyDefinition assemblyDefinition)
        {
            Ast.UsingDeclaration astUsing = new Ast.UsingDeclaration("System");
            astCompileUnit.Children.Add(astUsing);

            foreach(TypeDefinition typeDef in assemblyDefinition.MainModule.Types) {
                // Skip nested types - they will be added by the parent type
                if (typeDef.DeclaringType != null) continue;
                // Skip the <Module> class
                if (typeDef.Name == "<Module>") continue;

                AddType(typeDef);
            }
        }
开发者ID:almazik,项目名称:ILSpy,代码行数:14,代码来源:AstBuilder.cs

示例14: Used

        public void Used()
        {
            string program = TestUtil.PackageMemberParse("public class A {object obj = new ToStringBuilder();}");
            string expected = TestUtil.NamespaceMemberParse("using ToStringBuilder = NClassifier.Util.ToStringBuilder; public class A {object obj = new ToStringBuilder();}");

            CompilationUnit cu = TestUtil.ParseProgram(program);
            NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];

            UsingDeclaration us = new UsingDeclaration("ToStringBuilder", AstUtil.GetTypeReference("NClassifier.Util.ToStringBuilder", ns));
            ns.Children.Insert(0, us);
            us.Parent = ns;

            Mode = "DotNet";
            VisitCompilationUnit(cu, null);
            TestUtil.CodeEqual(expected, TestUtil.GenerateCode(cu));
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:16,代码来源:UsedTypesTest.cs

示例15: ContainsUsing

        private bool ContainsUsing(IList usingList, UsingDeclaration usingDec)
        {
            foreach (UsingDeclaration usi in usingList)
            {
                Using usingDeclared = (Using) usingDec.Usings[0];
                Using usiUsing = (Using) usi.Usings[0];

                if (usiUsing.IsAlias && usingDeclared.IsAlias)
                {
                    if (usiUsing.Name == usingDeclared.Name &&
                        usiUsing.Alias.Type == usingDeclared.Alias.Type)
                        return true;
                }
                else if (!(usiUsing.IsAlias && usingDeclared.IsAlias))
                {
                    if (usingDeclared.Name == usiUsing.Name)
                        return true;
                }
            }
            return false;
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:21,代码来源:ShortenReferencesTransformer.cs


注:本文中的ICSharpCode.NRefactory.Ast.UsingDeclaration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。