本文整理汇总了C#中SnapshotSpan.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# SnapshotSpan.GetText方法的具体用法?C# SnapshotSpan.GetText怎么用?C# SnapshotSpan.GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SnapshotSpan
的用法示例。
在下文中一共展示了SnapshotSpan.GetText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateClassificationSpans
private IList<ClassificationSpan> CreateClassificationSpans(SnapshotSpan trackingSpan)
{
var gherkinClassificationSpans = new GherkinClassificationSpans(
this.classificationTypeRegistryService, trackingSpan.Snapshot, trackingSpan.Start);
gherkinClassificationSpans.Parse(trackingSpan.GetText());
return gherkinClassificationSpans.ClassificationSpans.ToList();
}
示例2: CreateVisuals
private void CreateVisuals(ITextViewLine line)
{
IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(line.Start, line.End));
if (span.GetText().IsMethodDefinition())
AddAdornmentToMethod(line, textViewLines, span);
}
示例3: GetClassificationSpans
/// <summary>
/// Classify the given spans
/// </summary>
/// <param name="span">The span of interest in this projection buffer.</param>
/// <returns>The list of <see cref="ClassificationSpan"/> as contributed by the source buffers.</returns>
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
ITextSnapshot snapshot = span.Snapshot;
List<ClassificationSpan> spans = new List<ClassificationSpan>();
if (snapshot.Length == 0)
return spans;
var text = span.GetText();
if (text.StartsWith("System.Windows.Data Error", StringComparison.OrdinalIgnoreCase))
{
IClassificationType type = _classificationTypeRegistry.GetClassificationType("output.wpfbindingalert");
spans.Add(new ClassificationSpan(span, type));
}
else if (text.IndexOf("error ", StringComparison.OrdinalIgnoreCase) >= 0 ||
text.IndexOf("error:", StringComparison.OrdinalIgnoreCase) >= 0)
{
//error followed by a space is the typical error of the build.
IClassificationType type = _classificationTypeRegistry.GetClassificationType("output.alert");
spans.Add(new ClassificationSpan(span, type));
}
else if (text.IndexOf("INFO:", StringComparison.OrdinalIgnoreCase) >= 0)
{
//error followed by a space is the typical error of the build.
IClassificationType type = _classificationTypeRegistry.GetClassificationType("output.info");
spans.Add(new ClassificationSpan(span, type));
}
return spans;
}
示例4: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
IList<ClassificationSpan> list = new List<ClassificationSpan>();
if (!_isDockerfile)
return list;
string text = span.GetText();
int index = text.IndexOf("#", StringComparison.Ordinal);
if (index > -1)
{
var result = new SnapshotSpan(span.Snapshot, span.Start + index, text.Length - index);
list.Add(new ClassificationSpan(result, _comment));
}
if (_textType != TextType.Dockerfile)
return list;
if (index == -1 || index > 0)
{
string[] args = text.Split(' ');
if (args.Length >= 2 && Valid.Contains(args[0].Trim().ToUpperInvariant()))
{
var result = new SnapshotSpan(span.Snapshot, span.Start, args[0].Length);
list.Add(new ClassificationSpan(result, _keyword));
}
}
return list;
}
示例5: CalculateDeletionStartFromStartPosition
private static int CalculateDeletionStartFromStartPosition(ITextSnapshot snapshot, int startPosition)
{
var position = startPosition - 1;
if (position < 0)
{
return 0;
}
while (true)
{
if (position > 0)
{
var ss = new SnapshotSpan(snapshot, position, 1);
var text = ss.GetText();
if (text != null && !"\r\n".Contains(text) && string.IsNullOrWhiteSpace(text))
{
--position;
continue;
}
++position;
}
return position;
}
}
示例6: CalculateDeletionEndFromRuleEndPosition
private static int CalculateDeletionEndFromRuleEndPosition(ITextSnapshot snapshot, int endPosition)
{
var position = endPosition;
var committedPosition = position;
while (true)
{
if (position < snapshot.Length)
{
var ss = new SnapshotSpan(snapshot, position, 1);
var text = ss.GetText();
if (text != null)
{
if ("\r\n".Contains(text))
{
committedPosition = ++position;
continue;
}
if (string.IsNullOrWhiteSpace(text))
{
++position;
continue;
}
}
}
return committedPosition;
}
}
示例7: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
IList<ClassificationSpan> list = new List<ClassificationSpan>();
string text = span.GetText();
if (text.StartsWith("/// <binding"))
{
foreach (Match match in _binding.Matches(text))
{
var value = match.Groups["value"];
var result = new SnapshotSpan(span.Snapshot, span.Start + value.Index, value.Length);
list.Add(new ClassificationSpan(result, _formatDefinition));
}
}
else
{
int index = text.IndexOf(_searchText, StringComparison.Ordinal);
if (index == -1)
return list;
foreach (Match match in _task.Matches(text))
{
var name = match.Groups["name"];
var result = new SnapshotSpan(span.Snapshot, span.Start + name.Index, name.Length);
list.Add(new ClassificationSpan(result, _formatDefinition));
}
}
return list;
}
示例8: TryParse
public static Boolean TryParse(SnapshotSpan span, out BuildResult result)
{
var text = span.GetText();
result = null;
if (!text.StartsWith("========== ", StringComparison.Ordinal)) {
return false;
}
if (!text.EndsWith(" ==========\r\n", StringComparison.Ordinal)) {
return false;
}
var regex = "^========== (?:Build|Rebuild All): (?<Succeeded>\\d+) succeeded, (?<Failed>\\d+) failed, (?:(?<UpToDate>\\d+) up-to-date, )?(?<Skipped>\\d+) skipped ==========\r\n$";
var match = Regex.Match(text, regex);
if (!match.Success) {
return false;
}
var localResult = new BuildResult();
localResult.Succeeded = Convert.ToInt32(match.Groups["Succeeded"].Value);
localResult.Failed = Convert.ToInt32(match.Groups["Failed"].Value);
if (match.Groups["UpToDate"].Success) {
localResult.UpToDate = Convert.ToInt32(match.Groups["UpToDate"].Value);
}
localResult.Skipped = Convert.ToInt32(match.Groups["Skipped"].Value);
result = localResult;
return true;
}
示例9: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
var classifications = new List<ClassificationSpan>();
var snapshot = span.Snapshot;
if (snapshot == null || snapshot.Length == 0 || !CanSearch(span) || !SettingsProvider.IsHighlightFindResultsEnabled())
{
return classifications;
}
var text = span.GetText();
var filenameSpans = GetMatches(text, FilenameRegex, span.Start, FilenameClassificationType).ToList();
//var searchTermSpans = GetMatches(text, searchTextRegex, span.Start, SearchTermClassificationType).ToList();
List<ClassificationSpan> searchTermSpans = null;
//if (StudioUtility.IsMultitextFind())
if (multitext)
{
searchTermSpans = GetMatches(text, listsearchTextRegex, span.Start, SearchTermClassificationType).ToList();
}
else
{
searchTermSpans = GetMatches(text, searchTextRegex, span.Start, SearchTermClassificationType).ToList();
}
var toRemove = (from searchSpan in searchTermSpans
from filenameSpan in filenameSpans
where filenameSpan.Span.Contains(searchSpan.Span)
select searchSpan).ToList();
classifications.AddRange(filenameSpans);
classifications.AddRange(searchTermSpans.Except(toRemove));
return classifications;
}
示例10: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
IList<ClassificationSpan> list = new List<ClassificationSpan>();
if (!_isRobotsTxt)
return list;
string text = span.GetText();
int index = text.IndexOf("#");
if (index > -1)
{
var result = new SnapshotSpan(span.Snapshot, span.Start + index, text.Length - index);
list.Add(new ClassificationSpan(result, _comment));
}
if (index == -1 || index > 0)
{
string[] args = text.Split(':');
if (args.Length >= 2 && _valid.Contains(args[0].Trim().ToLowerInvariant()))
{
var result = new SnapshotSpan(span.Snapshot, span.Start, args[0].Length);
list.Add(new ClassificationSpan(result, _keyword));
}
}
return list;
}
示例11: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
LoadSettings();
var classifications = new List<ClassificationSpan>();
var snapshot = span.Snapshot;
if (snapshot == null || snapshot.Length == 0 || !CanSearch(span) || !HighlightFindResults)
{
return classifications;
}
var text = span.GetText();
var filenameSpans = GetMatches(text, FilenameRegex, span.Start, FilenameClassificationType).ToList();
var searchTermSpans = GetMatches(text, _searchTextRegex, span.Start, SearchTermClassificationType).ToList();
var toRemove = (from searchSpan in searchTermSpans
from filenameSpan in filenameSpans
where filenameSpan.Span.Contains(searchSpan.Span)
select searchSpan).ToList();
classifications.AddRange(filenameSpans);
classifications.AddRange(searchTermSpans.Except(toRemove));
return classifications;
}
示例12: TrackingSession
public TrackingSession(StateMachine stateMachine, SnapshotSpan snapshotSpan, IAsynchronousOperationListener asyncListener)
{
AssertIsForeground();
_asyncListener = asyncListener;
_trackingSpan = snapshotSpan.Snapshot.CreateTrackingSpan(snapshotSpan.Span, SpanTrackingMode.EdgeInclusive);
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
if (snapshotSpan.Length > 0)
{
// If the snapshotSpan is nonempty, then the session began with a change that
// was touching a word. Asynchronously determine whether that word was a
// renamable identifier. If it is, alert the state machine so it can trigger
// tagging.
_originalName = snapshotSpan.GetText();
_isRenamableIdentifierTask = Task.Factory.SafeStartNewFromAsync(
() => DetermineIfRenamableIdentifierAsync(snapshotSpan, initialCheck: true),
_cancellationToken,
TaskScheduler.Default);
QueueUpdateToStateMachine(stateMachine, _isRenamableIdentifierTask);
}
else
{
// If the snapshotSpan is empty, that means text was added in a location that is
// not touching an existing word, which happens a fair amount when writing new
// code. In this case we already know that the user is not renaming an
// identifier.
_isRenamableIdentifierTask = s_notRenamableTask;
}
}
示例13: GetClassificationSpans
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
IList<ClassificationSpan> spans = new List<ClassificationSpan>();
string text = span.GetText();
int index = text.IndexOf("#", StringComparison.Ordinal);
if (index > -1)
{
var result = new SnapshotSpan(span.Snapshot, span.Start + index, text.Length - index);
spans.Add(new ClassificationSpan(result, comment));
}
if (index == -1 || index > 0)
{
var trimmed = text.TrimStart();
var offset = text.Length - trimmed.Length;
string[] args = trimmed.Split(' ');
if (args.Length >= 2 && ValidKeywords.Contains(args[0].Trim().ToLowerInvariant()))
{
var result = new SnapshotSpan(span.Snapshot, span.Start + offset, args[0].Trim().Length);
spans.Add(new ClassificationSpan(result, keyword));
}
}
return spans;
}
示例14: GetClassificationSpans
// This does not work properly for multiline fenced code-blocks,
// since we get each line separately. If I can assume that this
// always runs sequentially without skipping, I can add state to
// track whether we're in a fenced block.
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
string text = span.GetText();
var codeBlocks = FindMatches(span, text, _reCode, _code).ToList();
if (codeBlocks.Any())
{
// Flatten all code blocks to avoid matching text within them
var nonCodeBuilder = text.ToCharArray();
foreach (var code in codeBlocks)
{
for (int i = code.Span.Start; i < code.Span.End; i++)
{
nonCodeBuilder[i - span.Start] = 'Q';
}
}
text = new String(nonCodeBuilder);
}
var quotes = FindMatches(span, text, _reQuote, _quote);
var bolds = FindMatches(span, text, _reBold, _bold);
var italics = FindMatches(span, text, _reItalic, _italic);
var headers = FindMatches(span, text, _reHeader, _header);
return bolds.Concat(italics).Concat(headers).Concat(codeBlocks).Concat(quotes).ToList();
}
示例15: using
IList<ClassificationSpan> IClassifier.GetClassificationSpans(SnapshotSpan span)
{
var classifications = new List<ClassificationSpan>();
using (var systemState = new SystemState())
{
int startIndex, endIndex;
if (span != null)
{
string spanText = span.GetText();
System.Diagnostics.Debug.WriteLine((spanText != null) ? spanText : string.Empty);
}
// Execute the IPy tokenizer
var tokenizer = new Tokenizer(span.GetText().ToCharArray(), true, systemState, new CompilerContext(string.Empty, new QuietCompilerSink()));
var token = tokenizer.Next();
// Iterate the tokens
while (token.Kind != TokenKind.EndOfFile)
{
// Determine the bounds of the classfication span
startIndex = span.Snapshot.GetLineFromLineNumber(tokenizer.StartLocation.Line - 1 + span.Start.GetContainingLine().LineNumber).Start.Position + tokenizer.StartLocation.Column;
endIndex = span.Snapshot.GetLineFromLineNumber(tokenizer.EndLocation.Line - 1 + span.Start.GetContainingLine().LineNumber).Start.Position + tokenizer.EndLocation.Column;
if (endIndex > span.Snapshot.GetText().Length)
endIndex = span.Snapshot.GetText().Length;
if (endIndex > startIndex && !span.Snapshot.TextBuffer.IsReadOnly(new Span(startIndex, endIndex - startIndex)))
{
// Add the classfication span
classifications.Add(new ClassificationSpan(new SnapshotSpan(span.Snapshot, startIndex, endIndex - startIndex), GetClassificationType(token)));
}
// Get next token
token = tokenizer.Next();
}
}
foreach (var region in span.Snapshot.TextBuffer.GetReadOnlyExtents(span))
{
// Add classfication for read only regions
classifications.Add(new ClassificationSpan(new SnapshotSpan(span.Snapshot, region), classificationRegistryService.GetClassificationType("PythonReadOnlyRegion")));
}
return classifications;
}