本文整理汇总了C#中ITrackingSpan.GetSpan方法的典型用法代码示例。如果您正苦于以下问题:C# ITrackingSpan.GetSpan方法的具体用法?C# ITrackingSpan.GetSpan怎么用?C# ITrackingSpan.GetSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITrackingSpan
的用法示例。
在下文中一共展示了ITrackingSpan.GetSpan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersects
bool Intersects(ITrackingSpan span, SnapshotPoint point) {
if (span == null)
return false;
if (point.Snapshot.TextBuffer != span.TextBuffer)
return false;
var span2 = span.GetSpan(span.TextBuffer.CurrentSnapshot);
return span2.IntersectsWith(new SnapshotSpan(point, 0));
}
示例2: Replace
private static void Replace(ITrackingSpan contextSpan, ITextView textView, string atDirective, string fontFamily)
{
using (WebEssentialsPackage.UndoContext(("Embed font")))
{
textView.TextBuffer.Insert(0, atDirective + Environment.NewLine + Environment.NewLine);
textView.TextBuffer.Insert(contextSpan.GetSpan(textView.TextBuffer.CurrentSnapshot).Start, fontFamily);
}
}
示例3: IsSameTrackingSpan
public static bool IsSameTrackingSpan(ITrackingSpan a, ITrackingSpan b) {
if (a == b)
return true;
if (a == null || b == null)
return false;
if (a.TextBuffer != b.TextBuffer)
return false;
var sa = a.GetSpan(a.TextBuffer.CurrentSnapshot);
var sb = b.GetSpan(b.TextBuffer.CurrentSnapshot);
return sa == sb;
}
示例4: ReverseExpressionParser
public ReverseExpressionParser(ITextSnapshot snapshot, ITextBuffer buffer, ITrackingSpan span)
{
_snapshot = snapshot;
_buffer = buffer;
_span = span;
var loc = span.GetSpan(snapshot);
var line = _curLine = snapshot.GetLineFromPosition(loc.Start);
var targetSpan = new Span(line.Start.Position, span.GetEndPoint(snapshot).Position - line.Start.Position);
_tokens = Classifier.GetClassificationSpans(new SnapshotSpan(snapshot, targetSpan));
}
示例5: AddSinglelineEntries
private IList<IRHistoryEntry> AddSinglelineEntries(ITrackingSpan entrySpan) {
var snapshot = entrySpan.TextBuffer.CurrentSnapshot;
var snapshotEntrySpan = entrySpan.GetSpan(snapshot);
var spans = snapshot.Lines
.Where(l => snapshotEntrySpan.Contains(l.Extent))
.Select(l => snapshot.CreateTrackingSpan(l.Start, l.Length, SpanTrackingMode.EdgeExclusive));
var entries = new List<IRHistoryEntry>();
foreach (var span in spans) {
entries.Add(AddEntry(entrySpan, span));
}
return entries;
}
示例6: AddVariableCompletions
private void AddVariableCompletions(ITextSnapshot snapshot, ITrackingSpan tracking, List<Completion> completions)
{
var envVars = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry variable in envVars)
{
string displayText = variable.Key.ToString();
string description = Environment.GetEnvironmentVariable(displayText);
completions.Add(new Completion(displayText, displayText, description, _environmentGlyph, "automationText"));
}
var doc = new SnapshotSpan(snapshot, 0, snapshot.Length);
var idents = _classifier.GetClassificationSpans(doc).Where(g => g.ClassificationType.IsOfType(PredefinedClassificationTypeNames.SymbolDefinition));
foreach (var ident in idents.Where(i => !i.Span.IntersectsWith(tracking.GetSpan(snapshot))))
{
string text = ident.Span.GetText().Trim();
string displayText = text.Trim('%');
if (!completions.Any(c => c.InsertionText == displayText))
completions.Add(new Completion(displayText, displayText, null, _keywordGlyph, "automationText"));
}
}
示例7: IsContentEqualsOrdinal
public static bool IsContentEqualsOrdinal(this ITextBuffer textBuffer, ITrackingSpan span1, ITrackingSpan span2) {
var snapshot = textBuffer.CurrentSnapshot;
var snapshotSpan1 = span1.GetSpan(snapshot);
var snapshotSpan2 = span2.GetSpan(snapshot);
if (snapshotSpan1 == snapshotSpan2) {
return true;
}
if (snapshotSpan1.Length != snapshotSpan2.Length) {
return false;
}
var start1 = snapshotSpan1.Start;
var start2 = snapshotSpan2.Start;
for (int i = 0; i < snapshotSpan1.Length; i++) {
if (snapshot[start1 + i] != snapshot[start2 + i]) {
return false;
}
}
return true;
}
示例8: GetRequireCompletions
public static CompletionAnalysis GetRequireCompletions(ITextSnapshot snapshot, ITrackingSpan applicableSpan, ITrackingPoint point, bool quote) {
var span = applicableSpan.GetSpan(snapshot);
if (IsSpaceCompletion(snapshot, point) && !IntellisenseController.ForceCompletions) {
return CompletionAnalysis.EmptyCompletionContext;
}
return new RequireCompletionAnalysis(
snapshot.TextBuffer.GetAnalyzer(),
snapshot,
applicableSpan,
snapshot.TextBuffer,
quote
);
}
示例9: CleanUpEndLocation
private void CleanUpEndLocation(ITrackingSpan endTrackingSpan)
{
if (endTrackingSpan != null)
{
// Find the empty comment and remove it...
var endSnapshotSpan = endTrackingSpan.GetSpan(SubjectBuffer.CurrentSnapshot);
SubjectBuffer.Delete(endSnapshotSpan.Span);
// Remove the whitespace before the comment if necessary. If whitespace is removed,
// then remember the indentation depth so we can appropriately position the caret
// in virtual space when the session is ended.
var line = SubjectBuffer.CurrentSnapshot.GetLineFromPosition(endSnapshotSpan.Start.Position);
var lineText = line.GetText();
if (lineText.Trim() == string.Empty)
{
indentCaretOnCommit = true;
indentDepth = lineText.Length;
SubjectBuffer.Delete(new Span(line.Start.Position, line.Length));
endSnapshotSpan = SubjectBuffer.CurrentSnapshot.GetSpan(new Span(line.Start.Position, 0));
}
}
}
示例10: SetNewEndPosition
private void SetNewEndPosition(ITrackingSpan endTrackingSpan)
{
if (SetEndPositionIfNoneSpecified(ExpansionSession))
{
return;
}
if (endTrackingSpan != null)
{
SnapshotSpan endSpanInSurfaceBuffer;
if (!TryGetSurfaceBufferSpan(endTrackingSpan.GetSpan(SubjectBuffer.CurrentSnapshot), out endSpanInSurfaceBuffer))
{
return;
}
int endLine, endColumn;
TextView.TextSnapshot.GetLineAndColumn(endSpanInSurfaceBuffer.Start.Position, out endLine, out endColumn);
ExpansionSession.SetEndSpan(new VsTextSpan
{
iStartLine = endLine,
iStartIndex = endColumn,
iEndLine = endLine,
iEndIndex = endColumn
});
}
}
示例11: ShowVisuals
/// <summary>
/// Shoe all adornments within the given extent.
/// </summary>
public void ShowVisuals(ITrackingSpan extent) {
Contract.Requires(extent != null);
var extentSpan = extent.GetSpan(_textView.TextBuffer.CurrentSnapshot.Version);
foreach (var entry in Adornments) {
IAdornment adornment = entry.Value;
var adornmentSpan = adornment.Span.GetSpan(_textView.TextBuffer.CurrentSnapshot);
if (extentSpan.IntersectsWith(adornmentSpan)) {
adornment.CollapsedRegionDepth--;
QueueRefreshLineTransformer();
}
}
}
示例12: Commit
/// <summary>
/// Adds the new text to the text buffer
/// </summary>
/// <param name="replaceSpan">Span to replace with new content</param>
public virtual void Commit(ITrackingSpan replaceSpan) {
var buffer = replaceSpan.TextBuffer;
var span = replaceSpan.GetSpan(buffer.CurrentSnapshot);
buffer.Replace(span.Span, InsertionText);
}
示例13: CleanUpEndLocation
private void CleanUpEndLocation(ITrackingSpan endTrackingSpan)
{
if (endTrackingSpan != null)
{
// Find the empty comment and remove it...
var endSnapshotSpan = endTrackingSpan.GetSpan(SubjectBuffer.CurrentSnapshot);
SubjectBuffer.Delete(endSnapshotSpan.Span);
// Remove the whitespace before the comment if necessary. If whitespace is removed,
// then remember the indentation depth so we can appropriately position the caret
// in virtual space when the session is ended.
var line = SubjectBuffer.CurrentSnapshot.GetLineFromPosition(endSnapshotSpan.Start.Position);
var lineText = line.GetText();
if (lineText.Trim() == string.Empty)
{
indentCaretOnCommit = true;
var document = this.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document != null)
{
var optionService = document.Project.Solution.Workspace.Services.GetService<IOptionService>();
var tabSize = optionService.GetOption(FormattingOptions.TabSize, document.Project.Language);
indentDepth = lineText.GetColumnFromLineOffset(lineText.Length, tabSize);
}
else
{
// If we don't have a document, then just guess the typical default TabSize value.
indentDepth = lineText.GetColumnFromLineOffset(lineText.Length, tabSize: 4);
}
SubjectBuffer.Delete(new Span(line.Start.Position, line.Length));
endSnapshotSpan = SubjectBuffer.CurrentSnapshot.GetSpan(new Span(line.Start.Position, 0));
}
}
}
示例14: TrySpecialCompletions
private static CompletionAnalysis TrySpecialCompletions(ITextSnapshot snapshot, ITrackingSpan span, ITrackingPoint point) {
var snapSpan = span.GetSpan(snapshot);
var buffer = snapshot.TextBuffer;
var classifier = buffer.GetNodejsClassifier();
if (classifier == null) {
return null;
}
var start = snapSpan.Start;
var parser = new ReverseExpressionParser(snapshot, buffer, span);
if (parser.IsInGrouping()) {
var range = parser.GetExpressionRange(nesting: 1);
if (range != null) {
start = range.Value.Start;
}
}
var tokens = classifier.GetClassificationSpans(new SnapshotSpan(start.GetContainingLine().Start, snapSpan.Start));
if (tokens.Count > 0) {
// Check for context-sensitive intellisense
var lastClass = tokens[tokens.Count - 1];
if (lastClass.ClassificationType == classifier.Provider.Comment) {
// No completions in comments
return CompletionAnalysis.EmptyCompletionContext;
} else if (lastClass.ClassificationType == classifier.Provider.StringLiteral) {
// String completion
return CompletionAnalysis.EmptyCompletionContext;
}
return null;
}
return null;
}
示例15: GetNormalCompletionContext
private static CompletionAnalysis GetNormalCompletionContext(IServiceProvider serviceProvider, ITextSnapshot snapshot, ITrackingSpan applicableSpan, ITrackingPoint point, CompletionOptions options) {
var span = applicableSpan.GetSpan(snapshot);
if (IsSpaceCompletion(snapshot, point) && !IntellisenseController.ForceCompletions) {
return CompletionAnalysis.EmptyCompletionContext;
}
var parser = new ReverseExpressionParser(snapshot, snapshot.TextBuffer, applicableSpan);
if (parser.IsInGrouping()) {
options = options.Clone();
options.IncludeStatementKeywords = false;
}
return new NormalCompletionAnalysis(
snapshot.TextBuffer.GetAnalyzer(serviceProvider),
snapshot,
applicableSpan,
snapshot.TextBuffer,
options,
serviceProvider
);
}