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


C# EditorContext.GetClassDeclarationsOnCurrentLine方法代码示例

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


在下文中一共展示了EditorContext.GetClassDeclarationsOnCurrentLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: GetAvailableActions

		public override IEnumerable<IContextAction> GetAvailableActions(EditorContext editorContext)
		{
			// Using CurrentLineAST is basically OK, but when the "class" keyword is on different line than class name,
			// parsing only one line never tells us that we are looking at TypeDeclaration
			// Alternative solution could be to try to resolve also IdentifierExpression to see if it is class declaration.
			foreach (var targetClass in editorContext.GetClassDeclarationsOnCurrentLine()
			         .Where(c => c.ClassType == ClassType.Class || c.ClassType == ClassType.Interface)
			         .Select(c2 => c2.GetCurrentClassPart(editorContext.Editor.FileName))) {
				foreach (var implementAction in RefactoringService.GetImplementInterfaceActions(targetClass)) {
					yield return implementAction;
				}
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:13,代码来源:ImplementInterface.cs


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