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


C# MonoDevelop.GetContent方法代码示例

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


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

示例1: GetResolveResult

		public static ResolveResult GetResolveResult (MonoDevelop.Ide.Gui.Document doc)
		{
			ITextEditorResolver textEditorResolver = doc.GetContent<ITextEditorResolver> ();
			if (textEditorResolver != null)
				return textEditorResolver.GetLanguageItem (doc.Editor.Caret.Offset);
			return null;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:RefactoryCommands.cs

示例2: GetEditorData

        public static EditorData GetEditorData(MonoDevelop.Ide.Gui.Document doc = null)
        {
            var ed = new EditorData();

            if (doc == null)
                doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null ||
                doc.FileName == FilePath.Null)
                return null;

            var editor = doc.GetContent<ITextBuffer>();
            if (editor == null)
                return null;

            int line, column;
            editor.GetLineColumnFromPosition(editor.CursorPosition, out line, out column);
            ed.CaretLocation = new CodeLocation(column, line);
            ed.CaretOffset = editor.CursorPosition;

            var ast = doc.ParsedDocument as ParsedDModule;
            if(ast==null)
                return null;

            ed.SyntaxTree = ast.DDom as DModule;
            ed.ModuleCode = editor.Text;

            if (ed.SyntaxTree == null)
                return null;

            var Project = doc.Project as DProject;
            // Encapsule editor data for resolving
            ed.ParseCache = Project != null ?
                Project.ParseCache :
                ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache);

            return ed;
        }
开发者ID:rikkimax,项目名称:Mono-D,代码行数:38,代码来源:DResolverWrapper.cs

示例3: QueueQuickFixAnalysis

		public static void QueueQuickFixAnalysis (MonoDevelop.Ide.Gui.Document doc, DomLocation loc, Action<List<ContextAction>> callback)
		{
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				try {
					string disabledNodes = PropertyService.Get ("ContextActions." + doc.Editor.Document.MimeType, "") ?? "";
					
					var availableFixes = new List<ContextAction> (contextActions.Where (fix => disabledNodes.IndexOf (fix.Type.FullName) < 0 && fix.Action.IsValid (doc, loc)).Select (fix => fix.Action));
					var ext = doc.GetContent<MonoDevelop.AnalysisCore.Gui.ResultsEditorExtension> ();
					if (ext != null) {
						foreach (var result in ext.GetResultsAtOffset (doc.Editor.LocationToOffset (loc.Line, loc.Column))) {
							var fresult = result as FixableResult;
							if (fresult == null)
								continue;
							foreach (var action in FixOperationsHandler.GetActions (doc, fresult)) {
								availableFixes.Add (new AnalysisContextAction (result, action));
							}
						}
					}
					
					callback (availableFixes);
				} catch (Exception ex) {
					LoggingService.LogError ("Error in analysis service", ex);
				}
			});
		}	
开发者ID:yayanyang,项目名称:monodevelop,代码行数:25,代码来源:RefactoringService.cs

示例4: GetTextWithDirective

		string GetTextWithDirective (MonoDevelop.Ide.Gui.Document document, bool insertDirective)
		{
			string tag = Text;
			
			if (!tag.Contains ("{0}"))
				return tag;
			
			if (Type.AssemblyName.StartsWith ("System.Web.UI.WebControls", StringComparison.Ordinal))
				return string.Format (tag, "asp");
			
			//register the assembly and look up the class
			//FIXME: only do this on the insert, not the preview - or remove it afterwards
			RegisterReference (document.Project);
			
			var database = document.Compilation;
			
			var cls = database.FindType (Type.Load ());
			if (cls == null)
				return tag;

			var ed = document.GetContent<WebFormsEditorExtension> ();
			if (ed == null)
				return tag;

			var assemName = SystemAssemblyService.ParseAssemblyName (Type.AssemblyName);

			WebFormsPageInfo.RegisterDirective directive;
			string prefix = ed.ReferenceManager.GetTagPrefixWithNewDirective (cls, assemName.Name, null, out directive);
			
			if (prefix == null)
				return tag;
			
			tag = string.Format (tag, prefix);
			
			if (directive != null && insertDirective)
				ed.ReferenceManager.AddRegisterDirective (directive, document.Editor, true);
			
			return tag;
		}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:39,代码来源:WebFormsToolboxNode.cs

示例5: GetHighlightUsageExtension

		internal static HighlightUsagesExtension GetHighlightUsageExtension (MonoDevelop.Ide.Gui.Document doc)
		{
			return doc.GetContent <HighlightUsagesExtension> ();
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:4,代码来源:MoveToUsagesHandler.cs

示例6: Format

		public static void Format (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain, MonoDevelop.Ide.Gui.Document data, int startOffset, int endOffset)
		{
			if (data.ParsedDocument == null)
				return;
			var ext = data.GetContent<CSharpCompletionTextEditorExtension> ();
			if (ext == null)
				return;
			var seg = ext.typeSystemSegmentTree.GetMemberSegmentAt (startOffset);
			if (seg == null)
				return;
			var member = seg.Entity;
			if (member == null || member.Region.IsEmpty || member.BodyRegion.End.IsEmpty)
				return;
			
			// Build stub
			int formatStartOffset;
			var text = BuildStub (data, seg, endOffset, out formatStartOffset);
			int formatLength = endOffset - seg.Offset;
			// Get changes from formatting visitor
			var changes = GetFormattingChanges (policyParent, mimeTypeChain, data, text);
			if (changes == null)
				return;

			// Do the actual formatting
//			var originalVersion = data.Editor.Document.Version;
			int caretOffset = data.Editor.Caret.Offset;

			int realTextDelta = seg.Offset - formatStartOffset;
			int startDelta = 1;
			using (var undo = data.Editor.OpenUndoGroup ()) {
				try {
					changes.ApplyChanges (formatStartOffset + startDelta, Math.Max (0, formatLength - startDelta - 1), delegate (int replaceOffset, int replaceLength, string insertText) {
						int translatedOffset = realTextDelta + replaceOffset;
						data.Editor.Document.CommitLineUpdate (data.Editor.OffsetToLineNumber (translatedOffset));
						data.Editor.Replace (translatedOffset, replaceLength, insertText);
					}, (replaceOffset, replaceLength, insertText) => {
						int translatedOffset = realTextDelta + replaceOffset;
						if (translatedOffset < 0 || translatedOffset + replaceLength > data.Editor.Length)
							return true;
						return data.Editor.GetTextAt (translatedOffset, replaceLength) == insertText;
					});
				} catch (Exception e) {
					LoggingService.LogError ("Error in on the fly formatter", e);
				}

//				var currentVersion = data.Editor.Document.Version;
//				data.Editor.Caret.Offset = originalVersion.MoveOffsetTo (currentVersion, caretOffset, ICSharpCode.NRefactory.Editor.AnchorMovementType.Default);
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:49,代码来源:OnTheFlyFormatter.cs

示例7: Insert

		public void Insert (MonoDevelop.Ide.Gui.Document document)
		{
			var handler = document.GetContent<ICodeTemplateHandler> ();
			if (handler != null) {
				handler.InsertTemplate (this, document);
			} else {
				InsertTemplateContents (document);
			}	
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:9,代码来源:CodeTemplate.cs

示例8: QueueQuickFixAnalysis

		public static void QueueQuickFixAnalysis (MonoDevelop.Ide.Gui.Document doc, TextLocation loc, Action<List<MonoDevelop.CodeActions.CodeAction>> callback)
		{
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				try {
					var result = new List<MonoDevelop.CodeActions.CodeAction> ();

					var ext = doc.GetContent<MonoDevelop.AnalysisCore.Gui.ResultsEditorExtension> ();
					if (ext != null) {
						foreach (var r in ext.GetResultsAtOffset (doc.Editor.LocationToOffset (loc)).OrderBy (r => r.Level)) {
							var fresult = r as FixableResult;
							if (fresult == null)
								continue;
							foreach (var action in FixOperationsHandler.GetActions (doc, fresult)) {
								result.Add (new AnalysisContextActionProvider.AnalysisCodeAction (action, r));
							}
						}
					}
					result.AddRange (GetValidActions (doc, loc).Result);
					callback (result);
				} catch (Exception ex) {
					LoggingService.LogError ("Error in analysis service", ex);
				}
			});
		}	
开发者ID:head-thrash,项目名称:monodevelop,代码行数:24,代码来源:RefactoringService.cs

示例9: ExtendsEditor

		public override bool ExtendsEditor (MonoDevelop.Ide.Gui.Document doc, IEditableTextBuffer editor)
		{
			//can only attach if there is not already an attached BaseXmlEditorExtension
			return doc.GetContent<BaseXmlEditorExtension> () == null;
		}
开发者ID:rneatherway,项目名称:monodevelop,代码行数:5,代码来源:BaseXmlEditorExtension.cs

示例10: QueueQuickFixAnalysis

		public static void QueueQuickFixAnalysis (MonoDevelop.Ide.Gui.Document doc, TextLocation loc, CancellationToken token, Action<List<MonoDevelop.CodeActions.CodeAction>> callback)
		{
			var ext = doc.GetContent<MonoDevelop.AnalysisCore.Gui.ResultsEditorExtension> ();
			var issues = ext != null ? ext.GetResultsAtOffset (doc.Editor.LocationToOffset (loc), token).OrderBy (r => r.Level).ToList () : new List<Result> ();

			ThreadPool.QueueUserWorkItem (delegate {
				try {
					var result = new List<MonoDevelop.CodeActions.CodeAction> ();
					foreach (var r in issues) {
						if (token.IsCancellationRequested)
							return;
						var fresult = r as FixableResult;
						if (fresult == null)
							continue;
						foreach (var action in FixOperationsHandler.GetActions (doc, fresult)) {
							result.Add (new AnalysisContextActionProvider.AnalysisCodeAction (action, r) {
								DocumentRegion = action.DocumentRegion
							});
						}
					}
					result.AddRange (GetValidActions (doc, loc).Result);
					callback (result);
				} catch (Exception ex) {
					LoggingService.LogError ("Error in analysis service", ex);
				}
			});
		}	
开发者ID:ncoder83,项目名称:monodevelop,代码行数:27,代码来源:RefactoringService.cs


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