本文整理汇总了C#中Mono.GetTextBetween方法的典型用法代码示例。如果您正苦于以下问题:C# Mono.GetTextBetween方法的具体用法?C# Mono.GetTextBetween怎么用?C# Mono.GetTextBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono
的用法示例。
在下文中一共展示了Mono.GetTextBetween方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: ExpressionResult
//.........这里部分代码省略.........
if (ch == '\n' || ch == '\r')
break;
if (wasWhitespace && IsNamePart(ch)) {
start++;
if (start < chunk.Offset)
start = Int32.MaxValue;
break;
}
if (ch == '<') {
bracketCount--;
if (bracketCount < 0) {
start++;
break;
}
start--;
wasWhitespace = false;
continue;
}
if (ch == '>') {
if (wasWhitespace && !wasDot)
break;
bracketCount++;
start--;
wasWhitespace = false;
continue;
}
if (!IsNamePart(ch) && !Char.IsWhiteSpace (ch) && ch != '.') {
start++;
break;
}
wasWhitespace = Char.IsWhiteSpace (ch);
wasDot = ch == '.' || wasDot && wasWhitespace;
start--;
}
int end = i;
int genericCount = 0;
wasWhitespace = false;
List<Segment> nameSegments = new List<Segment> ();
while (end < chunk.EndOffset) {
char ch = doc.GetCharAt (end);
if (wasWhitespace && IsNamePart(ch))
break;
if (ch == '<') {
genericCount = 1;
while (end < doc.Length) {
ch = doc.GetCharAt (end);
if (ch == ',')
genericCount++;
if (ch == '>') {
nameSegments.Add (new Segment (end, 1));
break;
}
end++;
}
break;
}
if (!IsNamePart(ch) && !Char.IsWhiteSpace (ch))
break;
wasWhitespace = Char.IsWhiteSpace (ch);
end++;
}
if (start >= end)
continue;
string typeString = doc.GetTextBetween (start, end);
IReturnType returnType = NRefactoryResolver.ParseReturnType (new ExpressionResult (typeString));
int nameEndOffset = start;
for (; nameEndOffset < end; nameEndOffset++) {
char ch = doc.GetCharAt (nameEndOffset);
if (nameEndOffset >= i && ch == '<') {
nameEndOffset++;
break;
}
}
nameSegments.Add (new Segment (i, nameEndOffset - i));
int column = i - line.Offset;
IType callingType = unit.GetTypeAt (lineNumber, column);
List<IReturnType> genericParams = null;
if (genericCount > 0) {
genericParams = new List<IReturnType> ();
for (int n = 0; n < genericCount; n++)
genericParams.Add (new DomReturnType ("A"));
}
IType type = null;
if (ctx != null)
type = ctx.SearchType ((MonoDevelop.Projects.Dom.INode)callingType ?? unit, returnType);
if (type == null && unit != null && returnType != null)
type = unit.GetType (returnType.FullName, returnType.GenericArguments.Count);
if (ctx != null && type == null && returnType != null) {
returnType.Name += "Attribute";
type = ctx.SearchType ((MonoDevelop.Projects.Dom.INode)callingType ?? unit, returnType);
}
if (type != null)
nameSegments.ForEach (segment => HighlightSegment (startChunk, segment, "keyword.semantic.type"));
}
}
}