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


C# EditorContext类代码示例

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


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

示例1: Initialize

		public void Initialize(EditorContext context)
		{
			// class at caret (either declaration of usage)
			this.Class = GetClass(context.CurrentSymbol);
			if (this.Class == null)
				return;
			var c = this.Class;
			
			// TODO cache
			var classDecls = context.GetClassDeclarationsOnCurrentLine().ToList();
			this.IsCaretAtClassDeclaration = classDecls.Count == 1 && (classDecls[0].FullyQualifiedName == c.FullyQualifiedName);
			
			this.IsClassFileNameCorrect = (c.IsInnerClass() || (!c.IsUserCode()) ||
			                               c.Name.Equals(Path.GetFileNameWithoutExtension(c.CompilationUnit.FileName), StringComparison.OrdinalIgnoreCase));
			
			if (string.IsNullOrEmpty(c.Name) || c.CompilationUnit == null || string.IsNullOrEmpty(c.CompilationUnit.FileName)) {
				// Cannot get path
				this.CorrectClassFileName = null;
				this.IsCorrectClassFileNameAvailable = false;
				return;
			}
			this.CorrectClassFileName = Path.Combine(Path.GetDirectoryName(c.CompilationUnit.FileName),
			                                    c.Name + Path.GetExtension(c.CompilationUnit.FileName));
			
			this.IsCorrectClassFileNameAvailable = (FileUtility.IsValidPath(CorrectClassFileName)
			                                        && Path.IsPathRooted(CorrectClassFileName)
			                                        && !File.Exists(CorrectClassFileName));
			
			this.IsClassReadOnly = FindReferencesAndRenameHelper.IsReadOnly(this.Class);
			
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:31,代码来源:CacheClassAtCaret.cs

示例2: CalculateEditorSize

 protected override Size CalculateEditorSize(EditorContext context)
 {
     if (Parent.UseColumns)
     return context.Bounds.Size;
        else
     return new Size(EditorWidth, context.Bounds.Height);
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:7,代码来源:NodeComboBox.cs

示例3: GetAddUsingAttributeActions

		IEnumerable<IContextAction> GetAddUsingAttributeActions(EditorContext context)
		{
			ResolveResult symbol = context.CurrentSymbol;
			if (!(symbol is UnknownIdentifierResolveResult || symbol is UnknownMethodResolveResult))
				yield break;

			List<IClass> results = new List<IClass>();
			
			ParseInformation info = context.CurrentParseInformation;
			if (info == null || info.CompilationUnit == null || info.CompilationUnit.ProjectContent == null)
				yield break;
			ICompilationUnit unit = info.CompilationUnit;
			IProjectContent pc = info.CompilationUnit.ProjectContent;
			
			string name = null;
			if (symbol is UnknownMethodResolveResult) {
				name = Search((UnknownMethodResolveResult)symbol, pc, results);
			}
			if (symbol is UnknownIdentifierResolveResult) {
				name = Search((UnknownIdentifierResolveResult)symbol, pc, results);
			} else {
				yield break;
			}
			
			foreach (IClass c in results) {
				yield return new RefactoringService.AddUsingAction(unit, context.Editor, c.Namespace);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:28,代码来源:AddUsing.cs

示例4: Execute

		public override void Execute(EditorContext context)
		{
			var cache = context.GetCached<CheckAssignmentCache>();
			
			var ifStatement = GenerateAstToInsert(cache.VariableName);
			context.Editor.InsertCodeAfter(cache.Element, ifStatement, true);
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:7,代码来源:CheckAssignmentNull.cs

示例5: CalculateEditorSize

 protected override Size CalculateEditorSize(EditorContext context)
 {
     if (Parent.HeaderStyle != ColumnHeaderStyle.None)
         return context.Bounds.Size;
     else
         return new Size(EditorWidth, context.Bounds.Height);
 }
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:7,代码来源:NodeComboBox.cs

示例6: GetAvailableActions

		public IEnumerable<IContextAction> GetAvailableActions(EditorContext context)
		{
			// re-initialize the context
			this.Context = context;
			if (this.IsAvailable(context))
				yield return this;
		}
开发者ID:kleinux,项目名称:SharpDevelop,代码行数:7,代码来源:ContextAction.cs

示例7: SetEditorBounds

		public void SetEditorBounds(EditorContext context)
		{
			Size size = CalculateEditorSize(context);
			context.Editor.Bounds = new Rectangle(context.Bounds.X, context.Bounds.Y,
				Math.Min(size.Width, context.Bounds.Width),
				Math.Min(size.Height, Parent.ClientSize.Height - context.Bounds.Y)
			);
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:8,代码来源:EditableControl.cs

示例8: IsAvailable

		public override bool IsAvailable(EditorContext context)
		{
			var paramAtCaret = GetParameterAtCaret(context.CurrentSymbol);
			if (paramAtCaret == null)
				return false;
			
			return IsAvailable(paramAtCaret.ResolvedType);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:ParamCheck.cs

示例9: Execute

		public override void Execute(EditorContext context)
		{
			var paramAtCaret = GetParameterAtCaret(context);
			if (paramAtCaret != null)
			{
				Extensions.AddCodeToMethodStart(paramAtCaret.CallingMember, context.Editor, GetCodeToInsert(paramAtCaret.VariableName));
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:8,代码来源:ParamCheck.cs

示例10: GetAvailableActions

		public override IEnumerable<IContextAction> GetAvailableActions(EditorContext editorContext)
		{
			foreach (var targetClass in editorContext.GetClassDeclarationsOnCurrentLine().Where(c => c.ClassType == ClassType.Class).Select(c2 => c2.GetCurrentClassPart(editorContext.Editor.FileName))) {
				foreach (var implementAction in RefactoringService.GetImplementAbstractClassActions(targetClass)) {
					yield return implementAction;
				}
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:ImplementAbstractClass.cs

示例11: Execute

		public override void Execute(EditorContext context)
		{
			IProject project = (IProject)ClassAtCaret.Class.ProjectContent.Project;
			RefactoringHelpers.RenameFile(project, ClassAtCaret.Class.CompilationUnit.FileName, ClassAtCaret.CorrectClassFileName);
			if (project != null) {
				project.Save();
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:8,代码来源:RenameFileToMatchClassName.cs

示例12: Initialize

		public void Initialize(EditorContext context)
		{
			this.context = context;
			this.VariableName = GetVariableName(context);
			this.CodeGenerator = GetCodeGenerator(context);
			this.Element = GetElement(context);
			this.ElementRegion = (Element == null) ? DomRegion.Empty : DomRegion.FromLocation(Element.StartLocation, Element.EndLocation);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:8,代码来源:CheckAssignmentCache.cs

示例13: Execute

		public override void Execute(EditorContext context)
		{
			var conditionExpr = BuildCondition(this.targetExpr);
			if (conditionExpr == null)
				return;
			var ifExpr = new IfElseStatement(conditionExpr, new BlockStatement());
			
			context.Editor.InsertCodeBefore(this.currentExpr, ifExpr);
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:9,代码来源:CheckMemberNotNull.cs

示例14: CalculateEditorSize

		protected override Size CalculateEditorSize(EditorContext context)
		{
			if (Parent.UseColumns)
				return context.Bounds.Size;
			else
			{
				Size size = GetLabelSize(context.CurrentNode, context.DrawContext, _label);
				int width = Math.Max(size.Width + Font.Height, MinTextBoxWidth); // reserve a place for new typed character
				return new Size(width, size.Height);
			}
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:11,代码来源:NodeTextBox.cs

示例15: Execute

		public override void Execute(EditorContext context)
		{
			var cache = context.GetCached<CheckAssignmentCache>();
			
			var ifStatement = GenerateAstToInsert(cache.VariableName);

			var editor = context.Editor;
			string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.GetLineStartOffset(cache.ElementRegion.GetStart()));
			string code = cache.CodeGenerator.GenerateCode(ifStatement, indent);
			int insertOffset = editor.Document.GetLineEndOffset(cache.ElementRegion.GetEnd());
			editor.Document.Insert(insertOffset, code);
			editor.Caret.Offset = insertOffset + code.Length - 1;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:13,代码来源:CheckAssignmentNull.cs


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