本文整理汇总了C#中ITrackingSpan类的典型用法代码示例。如果您正苦于以下问题:C# ITrackingSpan类的具体用法?C# ITrackingSpan怎么用?C# ITrackingSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITrackingSpan类属于命名空间,在下文中一共展示了ITrackingSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomTrackingSpan
public CustomTrackingSpan(ITrackingSpan referenceSpan)
{
if (referenceSpan == null)
throw new ArgumentNullException("referenceSpan");
_referenceSpan = referenceSpan;
}
示例2: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (!EnsureTreeInitialized() || session == null || qiContent == null)
return;
// Map the trigger point down to our buffer.
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);
if (item == null || !item.IsValid)
return;
Declaration dec = item.FindType<Declaration>();
if (dec == null || !dec.IsValid || !_allowed.Contains(dec.PropertyName.Text.ToUpperInvariant()))
return;
string fontName = item.Text.Trim('\'', '"');
if (fonts.Families.SingleOrDefault(f => f.Name.Equals(fontName, StringComparison.OrdinalIgnoreCase)) != null)
{
FontFamily font = new FontFamily(fontName);
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
qiContent.Add(CreateFontPreview(font, 10));
qiContent.Add(CreateFontPreview(font, 11));
qiContent.Add(CreateFontPreview(font, 12));
qiContent.Add(CreateFontPreview(font, 14));
qiContent.Add(CreateFontPreview(font, 25));
qiContent.Add(CreateFontPreview(font, 40));
}
}
示例3: ValueOrderSignature
public ValueOrderSignature(
string syntax,
string description,
ITrackingSpan trackingSpan,
ISignatureHelpSession session)
{
_propertyName = "Syntax";
_syntax = syntax ?? string.Empty;
_description = description;
_trackingSpan = trackingSpan;
_content = string.Format(CultureInfo.InvariantCulture, "{0}: {1}", _propertyName, _syntax);
_nameParam = new CssPropertyNameParameter(this);
_currentParam = _nameParam;
_session = session;
// In order to dismiss this tip at the appropriate time, I need to listen
// to changes in the text buffer
if (_trackingSpan != null && _session != null)
{
_session.Dismissed += OnSessionDismissed;
_trackingSpan.TextBuffer.Changed += OnTextBufferChanged;
}
}
示例4: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
Declaration dec = (Declaration)item;
if (!item.IsValid || position > dec.Colon.Start)
yield break;
RuleBlock rule = dec.FindType<RuleBlock>();
if (!rule.IsValid)
yield break;
ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaRootForBuffer(itemTrackingSpan.TextBuffer);
if (!dec.IsVendorSpecific())
{
IEnumerable<Declaration> vendors = VendorHelpers.GetMatchingVendorEntriesInRule(dec, rule, schema);
if (vendors.Any(v => v.Start > dec.Start))
{
yield return new VendorOrderSmartTagAction(itemTrackingSpan, vendors.Last(), dec);
}
}
else
{
ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(dec, schema);
if (entry != null && !rule.Declarations.Any(d => d.PropertyName != null && d.PropertyName.Text == entry.DisplayText))
{
yield return new MissingStandardSmartTagAction(itemTrackingSpan, dec, entry.DisplayText);
}
}
}
示例5: SpellDictionarySmartTagAction
/// <summary>
/// Constructor for SpellDictionarySmartTagAction.
/// </summary>
/// <param name="span">Word to add to dictionary.</param>
/// <param name="dictionary">The dictionary (used to ignore the word).</param>
/// <param name="displayText">Text to show in the context menu for this action.</param>
public SpellDictionarySmartTagAction(ITrackingSpan span, IYandexDictionary dictionary, string displayText, Lang lang)
{
_span = span;
_dictionary = dictionary;
_lang = lang;
DisplayText = displayText;
}
示例6: ShowToolTip
public void ShowToolTip(ITrackingSpan span, object toolTipContent) {
if (span == null)
throw new ArgumentNullException(nameof(span));
if (toolTipContent == null)
throw new ArgumentNullException(nameof(toolTipContent));
ShowToolTip(span, toolTipContent, PopupStyles.None);
}
示例7: AugmentQuickInfoSession
/// <summary>
/// Determine which pieces of Quickinfo content should be displayed
/// </summary>
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (_disposed)
throw new ObjectDisposedException("TestQuickInfoSource");
var triggerPoint = (SnapshotPoint) session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (triggerPoint == null)
return;
foreach (IMappingTagSpan<LuaTokenTag> curTag in _aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)))
{
if (curTag.Tag.type == LuaTokenTypes.ReservedWord)
{
var tagSpan = curTag.Span.GetSpans(_buffer).First();
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);
quickInfoContent.Add("A reserved word");
}
else if (curTag.Tag.type == LuaTokenTypes.Operators)
{
var tagSpan = curTag.Span.GetSpans(_buffer).First();
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);
quickInfoContent.Add("A language operator");
}
}
}
示例8: AugmentQuickInfoSession
public void AugmentQuickInfoSession(
IQuickInfoSession session, IList<object> quickInfoContent,
out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
SnapshotPoint? subjectTriggerPoint =
session.GetTriggerPoint(textBuffer.CurrentSnapshot);
if ( !subjectTriggerPoint.HasValue ) {
return;
}
ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
SnapshotSpan querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
var tagAggregator = GetAggregator(session);
TextExtent extent = FindExtentAtPoint(subjectTriggerPoint);
if ( CheckForPrefixTag(tagAggregator, extent.Span) ) {
string text = extent.Span.GetText();
string url = FindNSUri(extent.Span, GetDocText(extent.Span));
applicableToSpan = currentSnapshot.CreateTrackingSpan(
extent.Span, SpanTrackingMode.EdgeInclusive
);
String toolTipText = String.Format("Prefix: {0}\r\nNamespace: {1}", text, url);
quickInfoContent.Add(toolTipText);
}
}
示例9: PresentItem
public void PresentItem(ITrackingSpan triggerSpan, QuickInfoItem item, bool trackMouse)
{
AssertIsForeground();
_triggerSpan = triggerSpan;
_item = item;
// It's a new list of items. Either create the editor session if this is the first time, or ask the
// editor session that we already have to recalculate.
if (_editorSessionOpt == null || _editorSessionOpt.IsDismissed)
{
// We're tracking the caret. Don't have the editor do it.
var triggerPoint = triggerSpan.GetStartTrackingPoint(PointTrackingMode.Negative);
_editorSessionOpt = _quickInfoBroker.CreateQuickInfoSession(_textView, triggerPoint, trackMouse: trackMouse);
_editorSessionOpt.Dismissed += (s, e) => OnEditorSessionDismissed();
}
// So here's the deal. We cannot create the editor session and give it the right
// signatures (even though we know what they are). Instead, the session with
// call back into the ISignatureHelpSourceProvider (which is us) to get those
// values. It will pass itself along with the calls back into
// ISignatureHelpSourceProvider. So, in order to make that connection work, we
// add properties to the session so that we can call back into ourselves, get
// the signatures and add it to the session.
if (!_editorSessionOpt.Properties.ContainsProperty(s_augmentSessionKey))
{
_editorSessionOpt.Properties.AddProperty(s_augmentSessionKey, this);
}
_editorSessionOpt.Recalculate();
}
示例10: AugmentQuickInfoSession
/// <summary>
/// Determine which pieces of Quickinfo content should be displayed
/// </summary>
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (_disposed)
throw new ObjectDisposedException("TestQuickInfoSource");
var triggerPoint = (SnapshotPoint) session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (triggerPoint == null)
return;
foreach (IMappingTagSpan<OokTokenTag> curTag in _aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)))
{
if (curTag.Tag.type == OokTokenTypes.OokExclamation)
{
var tagSpan = curTag.Span.GetSpans(_buffer).First();
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);
quickInfoContent.Add("Exclaimed Ook!");
}
else if (curTag.Tag.type == OokTokenTypes.OokQuestion)
{
var tagSpan = curTag.Span.GetSpans(_buffer).First();
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);
quickInfoContent.Add("Question Ook?");
}
else if (curTag.Tag.type == OokTokenTypes.OokPeriod)
{
var tagSpan = curTag.Span.GetSpans(_buffer).First();
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);
quickInfoContent.Add("Regular Ook.");
}
}
}
示例11: LowerCaseSmartTagAction
public LowerCaseSmartTagAction(ITrackingSpan span)
{
this.span = span;
tsnapshot = span.TextBuffer.CurrentSnapshot;
lower = span.GetText(tsnapshot).ToLower();
display = "Convert to lower case";
}
示例12: GenerateFieldSmartTagAction
public GenerateFieldSmartTagAction(ITrackingSpan span)
{
trackingSpan = span;
snapShot = span.TextBuffer.CurrentSnapshot;
m_upper = span.GetText(snapShot).ToUpper();
displayText = "生成属性";
}
示例13: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (session == null || qiContent == null || qiContent.Count > 0)
return;
// Map the trigger point down to our buffer.
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
var doc = JSONEditorDocument.FromTextBuffer(_buffer);
JSONParseItem item = doc.JSONDocument.ItemBeforePosition(point.Value.Position);
if (item == null || !item.IsValid)
return;
JSONMember member = item.FindType<JSONMember>();
if (member == null || member.Name == null)
return;
IJSONSchema schema = _schemaResolver.DetermineSchemaForTextBuffer(_buffer);
if (schema != null)
{
IJSONSchemaPropertyNameCompletionInfo info = GetInfo(schema, member);
if (info != null && !string.IsNullOrEmpty(info.PropertyDocumentation))
{
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
qiContent.Add(info.DisplayText + Environment.NewLine + info.PropertyDocumentation);
}
}
}
示例14: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (session == null || qiContent == null)
return;
// Map the trigger point down to our buffer.
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
var snapshot = _buffer.CurrentSnapshot;
var classifier = _classifierService.GetClassifier(_buffer);
var doc = new SnapshotSpan(snapshot, 0, snapshot.Length);
var line = point.Value.GetContainingLine();
var idents = classifier.GetClassificationSpans(line.Extent);
bool handled = HandleVariables(qiContent, ref applicableToSpan, idents, point);
if (handled)
return;
HandleKeywords(qiContent, ref applicableToSpan, idents, point);
}
示例15: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
object eventHookupValue;
if (quickInfoContent.Count != 0 ||
session.Properties.TryGetProperty(QuickInfoUtilities.EventHookupKey, out eventHookupValue))
{
// No quickinfo if it's the event hookup popup.
return;
}
var position = session.GetTriggerPoint(_subjectBuffer.CurrentSnapshot);
if (position.HasValue)
{
var textView = session.TextView;
var args = new InvokeQuickInfoCommandArgs(textView, _subjectBuffer);
Controller controller;
if (_commandHandler.TryGetController(args, out controller))
{
controller.InvokeQuickInfo(position.Value, trackMouse: true, augmentSession: session);
}
}
}