本文整理汇总了C#中IQuickInfoSession.GetTriggerPoint方法的典型用法代码示例。如果您正苦于以下问题:C# IQuickInfoSession.GetTriggerPoint方法的具体用法?C# IQuickInfoSession.GetTriggerPoint怎么用?C# IQuickInfoSession.GetTriggerPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuickInfoSession
的用法示例。
在下文中一共展示了IQuickInfoSession.GetTriggerPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (!EnsureTreeInitialized() || session == null || qiContent == null)
return;
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);
if (item == null || !item.IsValid)
return;
UrlItem urlItem = item.FindType<UrlItem>();
if (urlItem != null && urlItem.UrlString != null && urlItem.UrlString.IsValid)
{
string url = GetFileName(urlItem.UrlString.Text.Trim('\'', '"'));
if (!string.IsNullOrEmpty(url))
{
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(point.Value.Position, 1, SpanTrackingMode.EdgeNegative);
var image = CreateImage(url);
if (image != null && image.Source != null)
{
qiContent.Add(image);
qiContent.Add(Math.Round(image.Source.Width) + "x" + Math.Round(image.Source.Height));
}
}
}
}
示例2: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan) {
applicableToSpan = null;
var semanticModelResult = SemanticModelService.SemanticModelResult;
if (semanticModelResult == null) {
return;
}
// Map the trigger point down to our buffer.
SnapshotPoint? subjectTriggerPoint = session.GetTriggerPoint(semanticModelResult.Snapshot);
if (!subjectTriggerPoint.HasValue) {
return;
}
var triggerSymbol = semanticModelResult.CompilationUnit.Symbols.FindAtPosition(subjectTriggerPoint.Value.Position);
if (triggerSymbol == null) {
return;
}
foreach(var content in SymbolQuickInfoBuilder.Build(triggerSymbol, SyntaxQuickinfoBuilderService)) {
qiContent.Add(content);
}
var location = triggerSymbol.Location;
applicableToSpan = semanticModelResult.Snapshot.CreateTrackingSpan(
location.Start,
location.Length,
SpanTrackingMode.EdgeExclusive);
}
示例3: 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");
}
}
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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.");
}
}
}
示例7: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
var triggerPoint = session.GetTriggerPoint(buffer.CurrentSnapshot);
if (triggerPoint == null)
return;
ITextDocument doc;
if (!provider.TextDocumentFactoryService.TryGetTextDocument(buffer, out doc))
return;
IOutputWindowPane diagnostics = provider.OutputWindowService.TryGetPane(OutputWindowPanes.DartVSDiagnostics);
if (diagnostics != null)
diagnostics.WriteLine("Quick info requested for: " + doc.FilePath);
// Figure out if this is a recalculate for an existing span (not sure if this is the best way of supporting async...?)
if (inProgressPosition != null && inProgressPosition.Value == triggerPoint.Value.Position)
{
UpdateTooltip(session, quickInfoContent, out applicableToSpan);
}
else
{
applicableToSpan = GetApplicableToSpan(triggerPoint);
var ignoredTask = StartTooltipRequestAsync(session, quickInfoContent, applicableToSpan, triggerPoint, doc.FilePath);
}
}
示例8: 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;
Selector sel = item.FindType<Selector>();
if (sel == null)
return;
// Mixins don't have specificity
if (sel.SimpleSelectors.Count == 1 && sel.SimpleSelectors[0].SubSelectors.Count == 1 && sel.SimpleSelectors[0].SubSelectors[0] is LessMixinDeclaration)
return;
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
string content = GenerateContent(sel);
qiContent.Add(content);
}
示例9: 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);
}
}
}
示例10: 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);
}
}
}
示例11: 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;
RuleSet rule = item.FindType<RuleSet>();
if (rule == null)
return;
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
var fileName = _buffer.GetFileName().ToLowerInvariant();
var unmatchedEntry = UsageRegistry.GetAllUnusedRules().FirstOrDefault(x => x.File == fileName && x.Is(rule));
if(unmatchedEntry == null)
{
return;
}
qiContent.Add("No usages of this rule have been found");
}
示例12: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan)
{
if (session == null)
{
throw new ArgumentNullException("session");
}
if (quickInfoContent == null)
{
throw new ArgumentNullException("quickInfoContent");
}
TemplateAnalysis analysis = this.analyzer.CurrentAnalysis;
SnapshotPoint? triggerPoint = session.GetTriggerPoint(analysis.TextSnapshot);
if (triggerPoint != null && analysis.Template != null)
{
string description;
Span applicableTo;
if (analysis.Template.TryGetDescription(triggerPoint.Value.Position, out description, out applicableTo))
{
quickInfoContent.Add(description);
applicableToSpan = analysis.TextSnapshot.CreateTrackingSpan(applicableTo, SpanTrackingMode.EdgeExclusive);
return;
}
}
applicableToSpan = null;
}
示例13: 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));
}
}
示例14: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan) {
applicableToSpan = null;
var modifier = ModifierKeys.Control | ModifierKeys.Shift;
if((Keyboard.Modifiers & modifier) != modifier) {
return;
}
var parseResult = ParserService.ParseResult;
if (parseResult == null) {
return;
}
// Map the trigger point down to our buffer.
SnapshotPoint? subjectTriggerPoint = session.GetTriggerPoint(parseResult.Snapshot);
if(!subjectTriggerPoint.HasValue) {
return;
}
var triggerToken = parseResult.SyntaxTree.Tokens.FindAtPosition(subjectTriggerPoint.Value.Position);
if(triggerToken.IsMissing || triggerToken.Parent == null) {
return;
}
var location = triggerToken.GetLocation();
qiContent.Add($"{triggerToken.Type} ({triggerToken.Classification}) Ln {location?.StartLine + 1} Ch {location?.StartCharacter + 1}\r\n{triggerToken.Parent?.GetType().Name}");
applicableToSpan = parseResult.Snapshot.CreateTrackingSpan(
triggerToken.Start,
triggerToken.Length,
SpanTrackingMode.EdgeExclusive);
}
示例15: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
SnapshotPoint? point = session.GetTriggerPoint(session.TextView.TextBuffer.CurrentSnapshot);
if (!point.HasValue)
return;
HtmlEditorTree tree = HtmlEditorDocument.FromTextView(session.TextView).HtmlEditorTree;
ElementNode node = null;
AttributeNode attr = null;
tree.GetPositionElement(point.Value.Position, out node, out attr);
if (node == null || !node.Name.Equals("img", StringComparison.OrdinalIgnoreCase))
return;
if (attr == null || !attr.Name.Equals("src", StringComparison.OrdinalIgnoreCase))
return;
string url = ImageQuickInfo.GetFullUrl(attr.Value, session.TextView.TextBuffer);
if (string.IsNullOrEmpty(url))
return;
applicableToSpan = session.TextView.TextBuffer.CurrentSnapshot.CreateTrackingSpan(point.Value.Position, 1, SpanTrackingMode.EdgeNegative);
ImageQuickInfo.AddImageContent(qiContent, url);
}