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


C# EditorContext.GetContainingElement方法代码示例

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


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

示例1: GetElement

		protected AbstractNode GetElement(EditorContext context)
		{
			// a = Foo()      : AssignmentExpression.Left == IdentifierExpression(*identifier*)
			// var a = Foo()  : VariableDeclaration(*name*).Initializer != empty
			var assignment = context.GetContainingElement<AssignmentExpression>();
			if (assignment != null)
				return assignment;
			var declaration = context.GetContainingElement<LocalVariableDeclaration>();
			if (declaration != null)
				return declaration;
			
			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:13,代码来源:CheckAssignmentCache.cs

示例2: GetVariableName

		protected string GetVariableName(EditorContext context)
		{
			// a = Foo()      : AssignmentExpression.Left == IdentifierExpression(*identifier*)
			// var a = Foo()  : VariableDeclaration(*name*).Initializer != empty
			var variableName = GetVariableNameFromAssignment(context.GetContainingElement<AssignmentExpression>());
			if (variableName != null)
				return variableName;
			variableName = GetVariableNameFromVariableDeclaration(context.GetContainingElement<LocalVariableDeclaration>());
			if (variableName != null)
				return variableName;
			
			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:13,代码来源:CheckAssignmentCache.cs

示例3: GetStatementRegion

		protected DomRegion GetStatementRegion(EditorContext context)
		{
			// a = Foo()      : AssignmentExpression.Left == IdentifierExpression(*identifier*)
			// var a = Foo()  : VariableDeclaration(*name*).Initializer != empty
			
			var assignment = context.GetContainingElement<AssignmentExpression>();
			if (assignment != null)
				return DomRegion.FromLocation(assignment.StartLocation, assignment.EndLocation);
			var declaration = context.GetContainingElement<LocalVariableDeclaration>();
			if (declaration != null)
				return DomRegion.FromLocation(declaration.StartLocation, declaration.EndLocation);
			
			return DomRegion.Empty;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:14,代码来源:CheckAssignmentCache.cs

示例4: IsAvailable

		public override bool IsAvailable(EditorContext context)
		{
			this.currentExpr = context.GetContainingElement<Expression>();
			if (currentExpr is InvocationExpression) {
				// InvocationExpression (e.g. "e.Foo()") has MemberReferenceExpression as TargetObject (e.g. "e.Foo")
				// "e.Foo() -> e"
				this.targetExpr = GetTarget(((InvocationExpression)currentExpr).TargetObject);
			} else {
				// "a.b" -> "a"
				this.targetExpr = GetTarget(currentExpr);
			}
			return 
				this.targetExpr is MemberReferenceExpression ||
				this.targetExpr is CastExpression ||
				this.targetExpr is ParenthesizedExpression;
				//this.targetExpr is IdentifierExpression;		// "don't offer the action for just a.b, only for a.b.c"
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:17,代码来源:CheckMemberNotNull.cs

示例5: GetContextAction

		/// <summary>
		/// If given symbol is Unknown ResolveResult, returns action that can generate code for this missing symbol.
		/// </summary>
		public static GenerateCodeContextAction GetContextAction(EditorContext context)
		{
			if (context.CurrentSymbol is UnknownMethodResolveResult) {
				UnknownMethodResolveResult unknownMethodCall = (UnknownMethodResolveResult)context.CurrentSymbol;
				Ast.Expression expression = context.GetContainingElement<Ast.InvocationExpression>();
				if (expression == null)
					return null;
				
				string title = "${res:AddIns.SharpRefactoring.IntroduceMethod}";
				try {
					title = string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.IntroduceMethod}"), unknownMethodCall.CallName, unknownMethodCall.Target.FullyQualifiedName);
				} catch (FormatException) {
				}
				
				if (unknownMethodCall.Target != null && unknownMethodCall.Target.IsUserCode()) {
					// Don't introduce method on non-modyfiable types
					return new IntroduceMethodContextAction(unknownMethodCall, expression, context.Editor) {
						Title = title
					};
				}
			}
			return null;
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:26,代码来源:GenerateCode.cs


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