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

C# DocumentContext类代码示例

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

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



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

示例1: GetSymbolInfoAsync

		public static async Task<RefactoringSymbolInfo> GetSymbolInfoAsync (DocumentContext document, int offset, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (document == null)
				throw new ArgumentNullException (nameof (document));
			if (document.ParsedDocument == null)
				return RefactoringSymbolInfo.Empty;
			var unit = await document.AnalysisDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
			if (unit != null) {
				var root = await unit.SyntaxTree.GetRootAsync (cancellationToken).ConfigureAwait (false);
				try {
					var token = root.FindToken (offset);
					if (!token.Span.IntersectsWith (offset))
						return RefactoringSymbolInfo.Empty;
					var symbol = unit.GetSymbolInfo (token.Parent);
					return new RefactoringSymbolInfo (symbol) {
						DeclaredSymbol = token.IsKind (SyntaxKind.IdentifierToken) ? unit.GetDeclaredSymbol (token.Parent) : null,
						Node = token.Parent,
						Model = unit
					};
				} catch (Exception) {
					return RefactoringSymbolInfo.Empty;
				}
			}
			return RefactoringSymbolInfo.Empty;
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:25,代码来源:RefactoringSymbolInfo.cs


示例2: FormatStatmentAt

		public static void FormatStatmentAt (TextEditor editor, DocumentContext context, MonoDevelop.Ide.Editor.DocumentLocation location, OptionSet optionSet = null)
		{
			var offset = editor.LocationToOffset (location);
			var policyParent = context.Project != null ? context.Project.Policies : PolicyService.DefaultPolicies;
			var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
			Format (policyParent, mimeTypeChain, editor, context, offset, offset, false, true, optionSet: optionSet);
		}
开发者ID:hbons,项目名称:monodevelop,代码行数:7,代码来源:OnTheFlyFormatter.cs


示例3: CheckOpeningPoint

		public override bool CheckOpeningPoint(TextEditor editor, DocumentContext ctx, CancellationToken cancellationToken)
		{
			var snapshot = CurrentSnapshot;
			var position = StartOffset;
			var token = FindToken(snapshot, position, cancellationToken);

			// check token at the opening point first
			if (!IsValidToken(token) ||
			    token.RawKind != OpeningTokenKind ||
			    token.SpanStart != position || token.Parent == null)
			{
				return false;
			}

			// now check whether parser think whether there is already counterpart closing parenthesis
			var pair = token.Parent.GetParentheses();

			// if pair is on the same line, then the closing parenthesis must belong to other tracker.
			// let it through
			if (Editor.GetLineByOffset (pair.Item1.SpanStart).LineNumber == Editor.GetLineByOffset(pair.Item2.Span.End).LineNumber)
			{
				return true;
			}

			return (int)pair.Item2.Kind() != ClosingTokenKind || pair.Item2.Span.Length == 0;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:26,代码来源:ParenthesisCompletionSession.cs


示例4: GetItem

		public override async Task<TooltipItem> GetItem (TextEditor editor, DocumentContext ctx, int offset, CancellationToken token = default(CancellationToken))
		{
			if (ctx == null)
				return null;
			var analysisDocument = ctx.ParsedDocument;
			if (analysisDocument == null)
				return null;
			var unit = analysisDocument.GetAst<SemanticModel> ();
			if (unit == null)
				return null;
			
			var root = unit.SyntaxTree.GetRoot (token);
			SyntaxToken syntaxToken;
			try {
				syntaxToken = root.FindToken (offset);
			} catch (ArgumentOutOfRangeException) {
				return null;
			}
			if (!syntaxToken.Span.IntersectsWith (offset))
				return null;
			var symbolInfo = unit.GetSymbolInfo (syntaxToken.Parent, token);
			var symbol = symbolInfo.Symbol ?? unit.GetDeclaredSymbol (syntaxToken.Parent, token);
			var tooltipInformation = await CreateTooltip (symbol, syntaxToken, editor, ctx, offset);
			if (tooltipInformation == null || string.IsNullOrEmpty (tooltipInformation.SignatureMarkup))
				return null;
			return new TooltipItem (tooltipInformation, syntaxToken.Span.Start, syntaxToken.Span.Length);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:27,代码来源:LanguageItemTooltipProvider.cs


示例5: ProjectedCompletionExtension

		public ProjectedCompletionExtension (DocumentContext ctx, IReadOnlyList<Projection> projections)
		{
			if (projections == null)
				throw new ArgumentNullException ("projections");
			this.ctx = ctx;
			this.projections = projections;
		}
开发者ID:vvarshne,项目名称:monodevelop,代码行数:7,代码来源:ProjectedCompletionExtension.cs


示例6: ProjectedDocumentContext

		public ProjectedDocumentContext (TextEditor projectedEditor, DocumentContext originalContext)
		{
			if (projectedEditor == null)
				throw new ArgumentNullException ("projectedEditor");
			if (originalContext == null)
				throw new ArgumentNullException ("originalContext");
			this.projectedEditor = projectedEditor;
			this.originalContext = originalContext;

			if (originalContext.Project != null) {
				var originalProjectId = TypeSystemService.GetProjectId (originalContext.Project);
				if (originalProjectId != null) {
					var originalProject = TypeSystemService.Workspace.CurrentSolution.GetProject (originalProjectId);
					if (originalProject != null) {
						projectedDocument = originalProject.AddDocument (
							projectedEditor.FileName,
							projectedEditor
						);
					}
				}
			}

			projectedEditor.TextChanged += delegate(object sender, TextChangeEventArgs e) {
				if (projectedDocument != null)
					projectedDocument = projectedDocument.WithText (projectedEditor);
				ReparseDocument ();
			};

			ReparseDocument ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:30,代码来源:ProjectedDocumentContext.cs


示例7: IsValidInContext

		public override bool IsValidInContext (DocumentContext context)
		{
			var pctx = context as ProjectedDocumentContext;
			if (pctx == null)
				return false;
			return pctx.ProjectedEditor.GetContent<CompletionTextEditorExtension> () != null;
		}
开发者ID:vvarshne,项目名称:monodevelop,代码行数:7,代码来源:ProjectedCompletionExtension.cs


示例8: NavigationVisitor

			public NavigationVisitor (DocumentContext documentContext, SemanticModel model, TextSpan region, CancellationToken token)
			{
				this.documentContext = documentContext;
				this.model = model;
				this.region = region;
				this.token = token;
			}
开发者ID:michaelc37,项目名称:monodevelop,代码行数:7,代码来源:CSharpNavigationTextEditorExtension.cs


示例9: CreateTooltipWindow

		public override Control CreateTooltipWindow (TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState)
		{
			var result = new LanguageItemWindow (GetExtensibleTextEditor (editor), modifierState, null, (string)item.Item, null);
			if (result.IsEmpty)
				return null;
			return result;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:CompileErrorTooltipProvider.cs


示例10: IsContext

		public static bool IsContext(TextEditor editor, DocumentContext ctx, int position, CancellationToken cancellationToken)
		{
			// Check to see if we're to the right of an $ or an @$
			var start = position - 1;
			if (start < 0)
			{
				return false;
			}

			if (editor[start] == '@')
			{
				start--;

				if (start < 0)
				{
					return false;
				}
			}

			if (editor[start] != '$')
			{
				return false;
			}

			var tree = ctx.AnalysisDocument.GetSyntaxTreeAsync (cancellationToken).WaitAndGetResult(cancellationToken);
			var token = tree.GetRoot(cancellationToken).FindTokenOnLeftOfPosition(start);

			return tree.IsExpressionContext(start, token, attributes: false, cancellationToken: cancellationToken)
				       || tree.IsStatementContext(start, token, cancellationToken);
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:30,代码来源:InterpolatedStringCompletionSession.cs


示例11: CreateCompletionAndUpdate

		CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var completion = CreateCompletion (editor, context, docInfo, out codeCompletionContext);
			completion.UpdateParsedDocument ();
			return completion;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:7,代码来源:RazorCSharpCompletionBuilder.cs


示例12: HandleDocumentContextChanged

		void HandleDocumentContextChanged (object sender, EventArgs e)
		{
			if (currentContext != null)
				currentContext.DocumentParsed -= HandleDocumentParsed;
			currentContext = textEditor.DocumentContext;
			currentContext.DocumentParsed += HandleDocumentParsed;
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:7,代码来源:TextEditorViewContent.cs


示例13: HandleCompletion

		public Task<ICompletionDataList> HandleCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
			return completion.HandleCodeCompletionAsync (completionContext, currentChar, token);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:7,代码来源:RazorCSharpCompletionBuilder.cs


示例14: Format

		static void Format (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain, TextEditor editor, DocumentContext context, int startOffset, int endOffset, bool exact, bool formatLastStatementOnly = false, OptionSet optionSet = null)
		{
			TextSpan span;
			if (exact) {
				span = new TextSpan (startOffset, endOffset - startOffset);
			} else {
				span = new TextSpan (0, endOffset);
			}

			var analysisDocument = context.AnalysisDocument;
			if (analysisDocument == null)
				return;

			using (var undo = editor.OpenUndoGroup (/*OperationType.Format*/)) {
				try {
					var syntaxTree = analysisDocument.GetSyntaxTreeAsync ().Result;

					if (formatLastStatementOnly) {
						var root = syntaxTree.GetRoot ();
						var token = root.FindToken (endOffset);
						var tokens = ICSharpCode.NRefactory6.CSharp.FormattingRangeHelper.FindAppropriateRange (token);
						if (tokens.HasValue) {
							span = new TextSpan (tokens.Value.Item1.SpanStart, tokens.Value.Item2.Span.End - tokens.Value.Item1.SpanStart);
						} else {
							var parent = token.Parent;
							if (parent != null)
								span = parent.FullSpan;
						}
					}

					if (optionSet == null) {
						var policy = policyParent.Get<CSharpFormattingPolicy> (mimeTypeChain);
						var textPolicy = policyParent.Get<TextStylePolicy> (mimeTypeChain);
						optionSet = policy.CreateOptions (textPolicy);
					}

					var doc = Formatter.FormatAsync (analysisDocument, span, optionSet).Result;
					var newTree = doc.GetSyntaxTreeAsync ().Result;
					var caretOffset = editor.CaretOffset;

					int delta = 0;
					foreach (var change in newTree.GetChanges (syntaxTree)) {
						if (!exact && change.Span.Start + delta >= caretOffset)
							continue;
						var newText = change.NewText;
						editor.ReplaceText (delta + change.Span.Start, change.Span.Length, newText);
						delta = delta - change.Span.Length + newText.Length;
					}

					var caretEndOffset = caretOffset + delta;
					if (0 <= caretEndOffset && caretEndOffset < editor.Length)
						editor.CaretOffset = caretEndOffset;
					if (editor.CaretColumn == 1)
						editor.CaretColumn = editor.GetVirtualIndentationColumn (editor.CaretLine);
				} catch (Exception e) {
					LoggingService.LogError ("Error in on the fly formatter", e);
				}
			}
		}
开发者ID:xinfushe,项目名称:monodevelop,代码行数:59,代码来源:OnTheFlyFormatter.cs


示例15: Run

		internal void Run (TextEditor editor, DocumentContext ctx)
		{
			var info = RefactoringSymbolInfo.GetSymbolInfoAsync (ctx, editor.CaretOffset).Result;
			var sym = info.DeclaredSymbol ?? info.Symbol;
			if (!CanRename (sym))
				return;
			new RenameRefactoring ().Rename (sym);
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:8,代码来源:RenameHandler.cs


示例16: AbstractTokenBraceCompletionSession

		protected AbstractTokenBraceCompletionSession (DocumentContext ctx,
		                                               int openingTokenKind, int closingTokenKind, char ch)
		{
			this.closingChar = ch;
			this.ctx = ctx;
			this.OpeningTokenKind = openingTokenKind;
			this.ClosingTokenKind = closingTokenKind;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:8,代码来源:AbstractTokenBraceCompletionSession.cs


示例17: CodeGenerator

 public CodeGenerator(TemplateLoader templateLoader, DocumentContext context,
     GeneratorConfig config, DirectoryInfo outputFolder)
 {
     this.outputFolder = outputFolder;
     this.templateLoader = templateLoader;
     this.contextGenerator = context.TemplateContextGenerator;
     this.config = config;
 }
开发者ID:ppdai,项目名称:TripSerializer.Net,代码行数:8,代码来源:CodeGenerator.cs


示例18: GetCodeRefactoringsAsync

		public async static Task<IEnumerable<CodeRefactoringDescriptor>> GetCodeRefactoringsAsync (DocumentContext documentContext, string language, CancellationToken cancellationToken = default (CancellationToken))
		{
			var result = new List<CodeRefactoringDescriptor> ();
			foreach (var provider in providers) {
				result.AddRange (await provider.GetCodeRefactoringDescriptorsAsync (documentContext, language, cancellationToken).ConfigureAwait (false));
			}
			return result;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:8,代码来源:CodeRefactoringService.cs


示例19: ProjectedSemanticHighlighting

		public ProjectedSemanticHighlighting (TextEditor editor, DocumentContext documentContext, IEnumerable<Projection> projections) : base (editor, documentContext)
		{
			this.projections = new List<Projection> (projections);
			foreach (var p in this.projections) {
				if (p.ProjectedEditor.SemanticHighlighting == null)
					continue;
				p.ProjectedEditor.SemanticHighlighting.SemanticHighlightingUpdated += HandleSemanticHighlightingUpdated;
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:ProjectedSemanticHighlighting.cs


示例20: CreateTooltipWindow

		public override Control CreateTooltipWindow (TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState)
		{
			var result = item.Item as Result;

			var window = new LanguageItemWindow (CompileErrorTooltipProvider.GetExtensibleTextEditor (editor), modifierState, null, result.Message, null);
			if (window.IsEmpty)
				return null;
			return window;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:9,代码来源:ResultTooltipProvider.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# DocumentDatabase类代码示例发布时间:2022-05-24
下一篇:
C# DocumentConfig类代码示例发布时间: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