本文整理汇总了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;
}
示例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;
}
示例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);
}
});
}
示例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;
}
示例5: GetHighlightUsageExtension
internal static HighlightUsagesExtension GetHighlightUsageExtension (MonoDevelop.Ide.Gui.Document doc)
{
return doc.GetContent <HighlightUsagesExtension> ();
}
示例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);
}
}
示例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);
}
}
示例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);
}
});
}
示例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;
}
示例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);
}
});
}