• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Ast.Import类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: OnModule

 /// <summary>
 /// Add the namespaces to the module
 /// </summary>
 public override void OnModule(Module node)
 {
     foreach (string ns in namespaces)
     {
         Import import = new Import(node.LexicalInfo, ns);
         node.Imports.Add(import);
     }
 }
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:11,代码来源:AutoImportCompilerStep.cs


示例2: ImportTasks

        IEnumerable<Import> ImportTasks(Import import)
        {
            if (import.AssemblyReference == null)
                throw new InvalidOperationException("Cannot import tasks: 'from' assembly is not specified.");

            return from importer in importers
                   from newImport in importer.BuildImportsFrom(import.AssemblyReference.Name)
                   select newImport;
        }
开发者ID:JeremySkinner,项目名称:Phantom,代码行数:9,代码来源:TaskImportStep.cs


示例3: OnModule

 public override void OnModule(Module node)
 {
     var imports = new[] { "UnityEngine", "System.Collections" };
     foreach (var importName in imports)
     {
         var targetImport = new Import(LexicalInfo.Empty, importName);
         if (node.Imports.Contains(targetImport))
             node.Imports.Add(targetImport);
     }
 }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:10,代码来源:AddImports.cs


示例4: VisitUsing

		public object VisitUsing(Using @using, object data)
		{
			B.Import import;
			if (@using.IsAlias) {
				import = new B.Import(@using.Alias.Type, null, new B.ReferenceExpression(@using.Name));
				import.LexicalInfo = GetLexicalInfo(@using);
			} else {
				import = new B.Import(GetLexicalInfo(@using), @using.Name);
			}
			module.Imports.Add(import);
			return import;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:12,代码来源:ConvertVisitorGlobal.cs


示例5: HandledAsImportError

		private bool HandledAsImportError(Import import, IEntity entity)
		{
			if (entity == null)
			{
				ImportError(import, CompilerErrorFactory.InvalidNamespace(import));
				return true;
			}

			if (!IsValidImportTarget(entity))
			{
				ImportError(import, CompilerErrorFactory.NotANamespace(import, entity));
				return true;
			}

			return false;
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:16,代码来源:ResolveImports.cs


示例6: HandledAsImportError

		private bool HandledAsImportError(Import import, IEntity entity)
		{
			if (null == entity)
			{
				Errors.Add(CompilerErrorFactory.InvalidNamespace(import));
				BindError(import);
				return true;
			}

			if (!IsValidNamespace(entity))
			{
				Errors.Add(CompilerErrorFactory.NotANamespace(import, entity.FullName));
				BindError(import);
				return true;
			}
			return false;
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:17,代码来源:ResolveImports.cs


示例7: OnImport

        public override void OnImport(Import import)
        {
            if (IsAlreadyBound(import))
                return;

            if (import.AssemblyReference != null)
            {
                ImportFromAssemblyReference(import);
                return;
            }

            var entity = ResolveImport(import);
            if (HandledAsImportError(import, entity) || HandledAsDuplicatedNamespace(import))
                return;

            Context.TraceInfo("{1}: import reference '{0}' bound to {2}.", import, import.LexicalInfo, entity);
            import.Entity = ImportedNamespaceFor(import, entity);
        }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:18,代码来源:ResolveImports.cs


示例8: OnModule

        public override void OnModule(Module node){
            logger.get("comdiv.dsl").Debug("SetupDefaultNamespacesAndReferencesStep on {0} started", node.Name);
            Console.WriteLine("SetupDefaultNamespacesAndReferencesStep on {0} started", node.Name);
            if(null==node.Namespace){
                node.Namespace = new NamespaceDeclaration(System.IO.Path.GetFileNameWithoutExtension(Context.Parameters.OutputAssembly));
            }
            if (null != namespaces){
                foreach (var ns in namespaces){
                    var import = new Import();
                    import.Namespace = ns;
                    node.Imports.Add(import);
                    logger.get("comdiv.dsl").Debug("SetupDefaultNamespacesAndReferencesStep on {0} - {1} ns added", node.Name, ns);
                    Console.WriteLine("SetupDefaultNamespacesAndReferencesStep on {0} - {1} ns added", node.Name, ns);
                }
            }

            logger.get("comdiv.dsl").Debug("SetupDefaultNamespacesAndReferencesStep on {0} finished", node.Name);
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:18,代码来源:SetupDefaultNamespacesAndReferencesStep.cs


示例9: import_directive_from_

	protected Import  import_directive_from_() //throws RecognitionException, TokenStreamException
{
		Import returnValue;
		
		IToken  from = null;
		
			Expression ns = null;
			ExpressionCollection names = null;
			returnValue = null;
		
		
		try {      // for error handling
			from = LT(1);
			match(FROM);
			ns=identifier_expression();
			match(IMPORT);
			if (0==inputState.guessing)
			{
				
						var mie = new MethodInvocationExpression(ns);
						names = mie.Arguments;
						returnValue = new Import(ToLexicalInfo(from), mie);
					
			}
			{
				if ((LA(1)==MULTIPLY) && (LA(2)==EOL||LA(2)==EOS))
				{
					match(MULTIPLY);
					if (0==inputState.guessing)
					{
						returnValue.Expression = ns;
					}
				}
				else if ((tokenSet_24_.member(LA(1))) && (tokenSet_25_.member(LA(2)))) {
					expression_list(names);
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "import_directive_from_");
				recover(ex,tokenSet_19_);
			}
			else
			{
				throw ex;
			}
		}
		return returnValue;
	}
开发者ID:hlizard,项目名称:boo,代码行数:57,代码来源:BooParserBase.cs


示例10: InvalidNamespace

 public static CompilerError InvalidNamespace(Import import)
 {
     return new CompilerError("BCE0021", import.LexicalInfo, import.Namespace);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:4,代码来源:CompilerErrorFactory.cs


示例11: EffectiveNameForImportedNamespace

 private static string EffectiveNameForImportedNamespace(Import import)
 {
     return null != import.Alias ? import.Alias.Name : import.Namespace;
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:4,代码来源:ResolveImports.cs


示例12: ResolveImportOnParentNamespace

 private IEntity ResolveImportOnParentNamespace(Import import)
 {
     var current = NameResolutionService.CurrentNamespace;
     try
     {
         INamespace parentNamespace = NameResolutionService.CurrentNamespace.ParentNamespace;
         if (parentNamespace != null)
         {
             NameResolutionService.EnterNamespace(parentNamespace);
             return NameResolutionService.ResolveQualifiedName(import.Namespace);
         }
     }
     finally
     {
         NameResolutionService.EnterNamespace(current);
     }
     return null;
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:18,代码来源:ResolveImports.cs


示例13: ResolveImport

        private IEntity ResolveImport(Import import)
        {
            var entity = ResolveImportOnParentNamespace(import) ?? NameResolutionService.ResolveQualifiedName(import.Namespace);
            if (null != entity)
                return entity;

            //if 'import X', try 'import X from X'
            if (!TryAutoAddAssemblyReference(import))
                return null;

            return NameResolutionService.ResolveQualifiedName(import.Namespace);
        }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:12,代码来源:ResolveImports.cs


示例14: AddFileReference

        private void AddFileReference(Import node)
        {
            RemoveCurrentNode();

            //we may need to preserve this, since it may be used in several compiler cycles.
            //which will set them to different things
            CompilerErrorCollection errors = Errors;
            AssemblyCollection references = Parameters.References;
            string url = GetFilePath(node);

            Assembly assembly;
            if (assemblyCache.TryGetValue(url, out assembly) == false)
            {
                assembly = CompileAssembly(node, url, errors);

                if (assembly == null)
                {
                    throw new CompilationErrorsException(errors);
                }

                assemblyCache.Add(url, assembly);
            }

            references.Add(assembly);
        }
开发者ID:neilb14,项目名称:rhino-dsl,代码行数:25,代码来源:AutoReferenceFilesCompilerStep.cs


示例15: GetFilePath

        private static string GetFilePath(Import node)
        {
            // assume this is located relative to the current file
            if (node.LexicalInfo != null &&
                File.Exists(node.LexicalInfo.FullPath))
            {
                string directory = Path.GetDirectoryName(node.LexicalInfo.FullPath);
                return Path.Combine(directory, node.AssemblyReference.Name);
            }

            return node.AssemblyReference.Name
                .Replace("~", AppDomain.CurrentDomain.BaseDirectory);
        }
开发者ID:neilb14,项目名称:rhino-dsl,代码行数:13,代码来源:AutoReferenceFilesCompilerStep.cs


示例16: ImportError

 private void ImportError(Import import, CompilerError error)
 {
     Errors.Add(error);
     BindError(import);
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:5,代码来源:ResolveImports.cs


示例17: ImportFromAssemblyReference

 private void ImportFromAssemblyReference(Import import)
 {
     var resolvedNamespace = ResolveImportAgainstReferencedAssembly(import);
     if (HandledAsImportError(import, resolvedNamespace))
         return;
     if (HandledAsDuplicatedNamespace(import))
         return;
     import.Entity = ImportedNamespaceFor(import, resolvedNamespace);
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:9,代码来源:ResolveImports.cs


示例18: AddNamespaceImports

        private void AddNamespaceImports(Import node)
        {
            RemoveCurrentNode();

            string url = GetFilePath(node);
            using(TextReader reader = urlResolver(url, baseDirectory))
            {
                BooParsingStep parser = new BooParsingStep();
                CompilerContext context = new CompilerContext();
                StringInput input = new StringInput(node.AssemblyReference.Name, reader.ReadToEnd());
                context.Parameters.Input.Add(input);
                parser.Initialize(context);
                parser.Run();
                Module current = (Module) node.GetAncestor(NodeType.Module);
                foreach (Module module in context.CompileUnit.Modules)
                {
                    foreach (Import import in module.Imports)
                    {
                        current.Imports.Add(import);
                    }
                }
            }
        }
开发者ID:neilb14,项目名称:rhino-dsl,代码行数:23,代码来源:AutoReferenceFilesCompilerStep.cs


示例19: ResolveImportAgainstReferencedAssembly

 private IEntity ResolveImportAgainstReferencedAssembly(Import import)
 {
     return NameResolutionService.ResolveQualifiedName(GetBoundReference(import.AssemblyReference).RootNamespace, import.Namespace);
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:4,代码来源:ResolveImports.cs


示例20: InvalidNamespace

 public static CompilerError InvalidNamespace(Import import)
 {
     if (import.AssemblyReference != null)
         return Instantiate("BCE0167", import, import.Namespace, import.AssemblyReference);
     return Instantiate("BCE0021", import, import.Namespace);
 }
开发者ID:neonux,项目名称:boo,代码行数:6,代码来源:CompilerErrorFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.InterfaceDefinition类代码示例发布时间:2022-05-24
下一篇:
C# Ast.GenericParameterDeclaration类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap