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


C# ResolutionContext.Push方法代码示例

本文整理汇总了C#中ResolutionContext.Push方法的典型用法代码示例。如果您正苦于以下问题:C# ResolutionContext.Push方法的具体用法?C# ResolutionContext.Push怎么用?C# ResolutionContext.Push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ResolutionContext的用法示例。


在下文中一共展示了ResolutionContext.Push方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Scan

		public static TypeReferencesResult Scan(DModule ast, ResolutionContext ctxt)
		{
			if (ast == null)
				return new TypeReferencesResult();

			var typeRefFinder = new TypeReferenceFinder(ctxt);

			ContextFrame backupFrame = null;

			if(ctxt.ScopedBlock == ast)
				backupFrame = ctxt.Pop ();

			if (ctxt.CurrentContext == null)
			{
				ctxt.Push(backupFrame);
				backupFrame = null;
			}

			//typeRefFinder.ast = ast;
			// Enum all identifiers
			ast.Accept (typeRefFinder);

			if (backupFrame != null)
				ctxt.Push (backupFrame);

			// Crawl through all remaining expressions by evaluating their types and check if they're actual type references.
			/*typeRefFinder.queueCount = typeRefFinder.q.Count;
			typeRefFinder.ResolveAllIdentifiers();
			*/
			return typeRefFinder.result;
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:31,代码来源:TypeReferenceFinder.cs

示例2: Scan

        /// <summary>
        /// </summary>
        /// <param name="ast">The syntax tree to scan</param>
        /// <param name="symbol">Might not be a child symbol of ast</param>
        /// <param name="ctxt">The context required to search for symbols</param>
        /// <returns></returns>
        public static IEnumerable<ISyntaxRegion> Scan(DModule ast, INode symbol, ResolutionContext ctxt, bool includeDefinition = true)
        {
            if (ast == null || symbol == null || ctxt == null)
                return null;

            var f = new ReferencesFinder(symbol, ast, ctxt);

            using(ctxt.Push(ast))
                ast.Accept (f);

            var nodeRoot = symbol.NodeRoot as DModule;
            if (includeDefinition && nodeRoot != null && nodeRoot.FileName == ast.FileName)
            {
                var dc = symbol.Parent as DClassLike;
                if (dc != null && dc.ClassType == D_Parser.Parser.DTokens.Template &&
                    dc.NameHash == symbol.NameHash)
                {
                    f.l.Insert(0, new IdentifierDeclaration(dc.NameHash)
                        {
                            Location = dc.NameLocation,
                            EndLocation = new CodeLocation(dc.NameLocation.Column + dc.Name.Length, dc.NameLocation.Line)
                        });
                }

                f.l.Insert(0, new IdentifierDeclaration(symbol.NameHash)
                    {
                        Location = symbol.NameLocation,
                        EndLocation = new CodeLocation(symbol.NameLocation.Column + symbol.Name.Length,	symbol.NameLocation.Line)
                    });
            }

            return f.l;
        }
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:39,代码来源:ReferencesFinder.cs

示例3: TryResolveFurtherIdViaOpDispatch

		/// <summary>
		/// http://dlang.org/operatoroverloading.html#Dispatch
		/// Check for the existence of an opDispatch overload.
		/// Important: Because static opDispatches are allowed as well, do check whether we can access non-static overloads from non-instance expressions or such
		/// </summary>
		public static IEnumerable<AbstractType> TryResolveFurtherIdViaOpDispatch (ResolutionContext ctxt, int nextIdentifierHash, UserDefinedType b, ISyntaxRegion typeBase = null)
		{
			// The usual SO prevention
			if (nextIdentifierHash == opDispatchId || b == null)
				yield break;

			AbstractType[] overloads;

			var opt = ctxt.CurrentContext.ContextDependentOptions;
			// Look for opDispatch-Members inside b's Definition
			using (ctxt.Push(b))
			{
				ctxt.CurrentContext.ContextDependentOptions = opt; // Mainly required for not resolving opDispatch's return type, as this will be performed later on in higher levels
				overloads = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(opDispatchId, b, ctxt, typeBase, false);
			}

			if (overloads == null || overloads.Length < 0)
				yield break;

			var av = new ArrayValue (Evaluation.GetStringType(ctxt), Strings.TryGet(nextIdentifierHash));

			foreach (DSymbol o in overloads) {
				var dn = o.Definition;
				if (dn.TemplateParameters != null && dn.TemplateParameters.Length > 0 && 
					dn.TemplateParameters[0] is TemplateValueParameter)
				{
					//TODO: Test parameter types for being a string value
					o.SetDeducedTypes(new[]{ new TemplateParameterSymbol(dn.TemplateParameters[0], av) });
					yield return o;
				}
			}
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:37,代码来源:OpDispatchResolution.cs

示例4: BuildCompletionDataInternal

		protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
		{
			ed = Editor;
			ctxt = ResolutionContext.Create(Editor, false);

			AbstractType t = null;
			CodeCompletion.DoTimeoutableCompletionTask(CompletionDataGenerator,ctxt,() =>
			{
				try
				{
					ctxt.Push(Editor);
					if (AccessExpression is IExpression)
						t = ExpressionTypeEvaluation.EvaluateType(AccessExpression as IExpression, ctxt);
					else if (AccessExpression is ITypeDeclaration)
						t = TypeDeclarationResolver.ResolveSingle(AccessExpression as ITypeDeclaration, ctxt);
				}catch(Exception ex)
				{
					Logger.LogWarn("Error during member completion", ex);
				}
			});

			if (t == null) //TODO: Add after-space list creation when an unbound . (Dot) was entered which means to access the global scope
				return;

			t.Accept(this);
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:26,代码来源:MemberCompletionProvider.cs

示例5: Run

		public static void Run()
		{
			Parse ();

			var pcw = new LegacyParseCacheView (new[]{ srcDir });
			var ctxt = new ResolutionContext (pcw, new ConditionalCompilationFlags(versions,0, true));

			var mod = pcw.LookupModuleName (null, "botan.pubkey.algo.dsa").First();
			var scope = ResolutionTests.N<DMethod> (mod, "DSAVerificationOperation.verify");
			var scopedStmt = ResolutionTests.S (scope, 9);

			ctxt.Push (scope, scopedStmt.Location);

			ITypeDeclaration td = new IdentifierDeclaration ("q"){ Location = scopedStmt.Location };
			AbstractType t;

			var sw = new Stopwatch ();
			Console.WriteLine ("Begin resolving...");
			sw.Restart ();
			t = TypeDeclarationResolver.ResolveSingle(td, ctxt);

			sw.Stop ();

			Console.WriteLine ("Finished resolution. {0} ms.", sw.ElapsedMilliseconds);

			sw.Restart ();
			t = TypeDeclarationResolver.ResolveSingle(td, ctxt);

			sw.Stop ();

			Console.WriteLine ("Finished resolution. {0} ms.", sw.ElapsedMilliseconds);
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:32,代码来源:BotanProfil.cs

示例6: ContextFrame

        public ContextFrame(ResolutionContext ctxt, IBlockNode b, IStatement stmt = null)
        {
            this.ctxt = ctxt;
            declarationCondititons = new ConditionalCompilation.ConditionSet(ctxt.CompilationEnvironment);

            ctxt.Push(this);

            Set(b,stmt);
        }
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:9,代码来源:ContextFrame.cs

示例7: SearchModuleForASTNodeReferences

		/// <summary>
		/// </summary>
		/// <param name="ast">The syntax tree to scan</param>
		/// <param name="symbol">Might not be a child symbol of ast</param>
		/// <param name="ctxt">The context required to search for symbols</param>
		/// <returns></returns>
		public static IEnumerable<ISyntaxRegion> SearchModuleForASTNodeReferences(DModule ast, INode symbol, ResolutionContext ctxt, bool includeDefinition = true)
		{
			if (ast == null || symbol == null || ctxt == null)
				return null;

			var f = new ReferencesFinder(symbol, ast, ctxt);

			using(ctxt.Push(ast))
				ast.Accept (f);

			var nodeRoot = symbol.NodeRoot as DModule;
			if (includeDefinition && nodeRoot != null && nodeRoot.FileName == ast.FileName)
			{
				var dc = symbol.Parent as DClassLike;
				if (dc != null && dc.ClassType == D_Parser.Parser.DTokens.Template &&
					dc.NameHash == symbol.NameHash)
				{
					f.l.Insert(0, new IdentifierDeclaration(dc.NameHash)
						{
							Location = dc.NameLocation,
							EndLocation = new CodeLocation(dc.NameLocation.Column + dc.Name.Length, dc.NameLocation.Line)
						});
				}

				var loc = symbol.NameLocation;
				bool add = !f.l.AsParallel().Any(
					(o) =>	(o is TemplateParameter && (o as TemplateParameter).NameLocation == loc) ||
							(o is INode && (o as INode).NameLocation == loc));

				if(add)
					f.l.Insert(0, new IdentifierDeclaration(symbol.NameHash)
						{
							Location = loc,
							EndLocation = new CodeLocation(loc.Column + symbol.Name.Length,	loc.Line)
						});
			}

			return f.l;
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:45,代码来源:ReferencesFinder.cs

示例8: UpdateTypeResolutionContext

		public bool UpdateTypeResolutionContext ()
		{
			if (!NeedsResolutionContextUpdate && resolutionCtx != null)
				return true;
			NeedsResolutionContextUpdate = false;

			var ff = DebuggingService.CurrentCallStack.GetFrame(Backtrace.CurrentFrameIndex);
			var document = Ide.IdeApp.Workbench.OpenDocument (ff.SourceLocation.FileName);
			if (document == null)
				return false;

			var codeLocation = new CodeLocation (ff.SourceLocation.Column,
			                                     ff.SourceLocation.Line);

			// Only create new if the cursor location is different from the previous
			if (firstFrameEditorData != null &&
				firstFrameEditorData.SyntaxTree.FileName == ff.SourceLocation.FileName &&
				firstFrameEditorData.CaretLocation.Line == codeLocation.Line)
				return true;

			firstFrameEditorData = DResolverWrapper.CreateEditorData (document);

			firstFrameEditorData.CaretLocation = codeLocation;

			resolutionCtx = ResolutionContext.Create (firstFrameEditorData, false);
			CodeCompletion.DoTimeoutableCompletionTask (null, resolutionCtx, () => resolutionCtx.Push (firstFrameEditorData));

			return true;
		}
开发者ID:llucenic,项目名称:MonoDevelop.Debugger.Gdb.D,代码行数:29,代码来源:VariableValueExamination.cs

示例9: GetMixinContent

        static string GetMixinContent(MixinStatement mx, ResolutionContext ctxt, bool takeStmtCache ,out ISyntaxRegion cachedContent)
        {
            cachedContent = null;

            if(!CheckAndPushAnalysisStack(mx))
                return null;
            ISemantic v;
            using (ctxt.Push(mx.ParentNode, mx))
            {
                bool hadCachedItem;
                if (takeStmtCache)
                {
                    BlockStatement stmt;
                    hadCachedItem = mixinStmtCache.TryGet(ctxt, mx, out stmt);
                    cachedContent = stmt;
                }
                else
                {
                    DModule mod;
                    hadCachedItem = mixinDeclCache.TryGet(ctxt, mx, out mod);
                    cachedContent = mod;
                }

                if (hadCachedItem)
                {
                    stmtsBeingAnalysed.Remove(mx);
                    return null;
                }

                try // 'try' because there is always a risk of e.g. not having something implemented or having an evaluation exception...
                {
                    // Evaluate the mixin expression
                    v = Evaluation.EvaluateValue(mx.MixinExpression, ctxt);
                }
                catch {
                    v = null;
                }

                stmtsBeingAnalysed.Remove(mx);
            }

            // Ensure it's a string literal
            var av = v as ArrayValue;
            if(av != null && av.IsString)
                return av.StringValue;

            if(takeStmtCache)
                mixinStmtCache.Add(ctxt, mx, null);
            else
                mixinDeclCache.Add(ctxt, mx, null);
            return null;
        }
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:52,代码来源:MixinAnalysis.cs

示例10: GetInvisibleTypeParameters

		/// <summary>
		/// Add 'superior' template parameters to the current symbol because 
		/// the parameters might be re-used in the nested class.
		/// </summary>
		static List<TemplateParameterSymbol> GetInvisibleTypeParameters(DNode n,ResolutionContext ctxt)
		{
			var invisibleTypeParams = new List<TemplateParameterSymbol> ();

			var tStk = new Stack<ContextFrame> ();
			do {
				var curCtxt = ctxt.Pop ();
				tStk.Push (curCtxt);
				foreach (var kv in curCtxt.DeducedTemplateParameters)
					if (!n.ContainsTemplateParameter (kv.Value.Parameter))
						invisibleTypeParams.Add (kv.Value);
			}
			while (ctxt.PrevContextIsInSameHierarchy);
			while (tStk.Count != 0)
				ctxt.Push (tStk.Pop ());

			return invisibleTypeParams;
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:22,代码来源:TypeDeclarationResolver.cs


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