本文整理汇总了C#中Mono.OffsetToLocation方法的典型用法代码示例。如果您正苦于以下问题:C# Mono.OffsetToLocation方法的具体用法?C# Mono.OffsetToLocation怎么用?C# Mono.OffsetToLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono
的用法示例。
在下文中一共展示了Mono.OffsetToLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToLine
public void AddToLine(Mono.TextEditor.Document doc)
{
if (Line != null) {
DocumentLocation dl = doc.OffsetToLocation(marker.StartCol);
marker.StartCol = dl.Column;
dl = doc.OffsetToLocation(marker.EndCol);
marker.EndCol = dl.Column;
doc.AddMarker (Line, marker);
}
}
示例2: GetItem
public TooltipItem GetItem (Mono.TextEditor.TextEditor editor, int offset)
{
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null || doc.ParsedDocument == null)
return null;
var unit = doc.ParsedDocument.GetAst<CompilationUnit> ();
if (unit == null)
return null;
var file = doc.ParsedDocument.ParsedFile as CSharpParsedFile;
if (file == null)
return null;
ResolveResult result;
AstNode node;
var loc = editor.OffsetToLocation (offset);
if (!doc.TryResolveAt (loc, out result, out node))
return null;
var resolver = new CSharpAstResolver (doc.Compilation, unit, file);
resolver.ApplyNavigator (new NodeListResolveVisitorNavigator (node), CancellationToken.None);
int startOffset = offset;
int endOffset = offset;
return new TooltipItem (new ToolTipData (unit, result, node, resolver), startOffset, endOffset - startOffset);
}
示例3: GetExpression
public string GetExpression (Mono.TextEditor.TextEditorData data, int offset)
{
if (offset < 0)
return "";
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null)
return "";
var loc = RefactoringService.GetCorrectResolveLocation (doc, data.OffsetToLocation (offset));
var unit = doc.ParsedDocument.GetAst<CompilationUnit> ();
var parsedFile = doc.ParsedDocument.ParsedFile as CSharpParsedFile;
var node = unit.GetNodeAt<Expression> (loc.Line, loc.Column);
if (unit == null || parsedFile == null || node == null)
return "";
return data.GetTextBetween (node.StartLocation, node.EndLocation);
}
示例4: SearchMember
IEnumerable<MemberReference> SearchMember (INode member, ProjectDom dom, FilePath fileName, Mono.TextEditor.TextEditorData editor, Mono.TextEditor.Document buildDocument, List<LocalDocumentInfo.OffsetInfo> offsetInfos, ParsedDocument parsedDocument)
{
var resolver = new NRefactoryResolver (dom, parsedDocument.CompilationUnit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);
FindMemberAstVisitor visitor = new FindMemberAstVisitor (buildDocument, member);
visitor.IncludeXmlDocumentation = IncludeDocumentation;
visitor.RunVisitor (resolver);
foreach (var result in visitor.FoundReferences) {
var offsetInfo = offsetInfos.FirstOrDefault (info => info.ToOffset <= result.Position && result.Position < info.ToOffset + info.Length);
if (offsetInfo == null)
continue;
var offset = offsetInfo.FromOffset + result.Position - offsetInfo.ToOffset;
var loc = editor.OffsetToLocation (offset);
yield return new MemberReference (null, fileName, offset, loc.Line, loc.Column, result.Name, null);
}
}
示例5: GetItem
public override TooltipItem GetItem (Mono.TextEditor.TextEditor editor, int offset)
{
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null || doc.ParsedDocument == null)
return null;
var unit = doc.ParsedDocument.GetAst<SyntaxTree> ();
if (unit == null)
return null;
var file = doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile;
if (file == null)
return null;
ResolveResult result;
AstNode node;
var loc = editor.OffsetToLocation (offset);
if (!doc.TryResolveAt (loc, out result, out node)) {
if (node is CSharpTokenNode) {
int startOffset2 = editor.LocationToOffset (node.StartLocation);
int endOffset2 = editor.LocationToOffset (node.EndLocation);
return new TooltipItem (new ToolTipData (unit, result, node, null), startOffset2, endOffset2 - startOffset2);
}
return null;
}
if (node == lastNode)
return lastResult;
var resolver = new CSharpAstResolver (doc.Compilation, unit, file);
resolver.ApplyNavigator (new NodeListResolveVisitorNavigator (node), CancellationToken.None);
var hoverNode = node.GetNodeAt (loc) ?? node;
int startOffset = editor.LocationToOffset (hoverNode.StartLocation);
int endOffset = editor.LocationToOffset (hoverNode.EndLocation);
return lastResult = new TooltipItem (new ToolTipData (unit, result, node, resolver), startOffset, endOffset - startOffset);
}