本文整理汇总了C#中ICompletionSession.GetTriggerPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ICompletionSession.GetTriggerPoint方法的具体用法?C# ICompletionSession.GetTriggerPoint怎么用?C# ICompletionSession.GetTriggerPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICompletionSession
的用法示例。
在下文中一共展示了ICompletionSession.GetTriggerPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
var buffer = _textBuffer;
var snapshot = buffer.CurrentSnapshot;
var triggerPoint = session.GetTriggerPoint(buffer).GetPoint(snapshot);
// Disable completions if user is editing a special command (e.g. ".cls") in the REPL.
if (snapshot.TextBuffer.Properties.ContainsProperty(typeof(IReplEvaluator)) && snapshot.Length != 0 && snapshot[0] == '.') {
return;
}
if (ShouldTriggerRequireIntellisense(triggerPoint, _classifier, true, true)) {
AugmentCompletionSessionForRequire(triggerPoint, session, completionSets);
return;
}
var textBuffer = _textBuffer;
var span = GetApplicableSpan(session, textBuffer);
var provider = VsProjectAnalyzer.GetCompletions(
_textBuffer.CurrentSnapshot,
span,
session.GetTriggerPoint(buffer));
var completions = provider.GetCompletions(_glyphService);
if (completions != null && completions.Completions.Count > 0) {
completionSets.Add(completions);
}
}
示例2: foreach
void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
var allKnown = new List<string>
{
"var",
"def",
"default",
"global",
"viewdata",
"model",
"set",
"for",
"test",
"if",
"else",
"elseif",
"content",
"use",
"macro",
"render",
"section",
"cache",
};
allKnown.Sort();
_compList = new List<Completion>();
foreach (var known in allKnown)
_compList.Add(new Completion(known, known, known, null, null));
completionSets.Add(new CompletionSet(
"Spark", //the non-localized title of the tab
"Spark", //the display title of the tab
FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer), session), _compList,
null));
}
示例3: TextOfLine
void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
int position = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(textBuffer.CurrentSnapshot);
int line = textBuffer.CurrentSnapshot.GetLineNumberFromPosition(position);
int column = position - textBuffer.CurrentSnapshot.GetLineFromPosition(position).Start.Position;
Microsoft.VisualStudio.IronPythonInference.Modules modules = new Microsoft.VisualStudio.IronPythonInference.Modules();
IList<Declaration> attributes;
if (textBuffer.GetReadOnlyExtents(new Span(0, textBuffer.CurrentSnapshot.Length)).Count > 0)
{
int start;
var readWriteText = TextOfLine(textBuffer, line, column, out start, true);
var module = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), readWriteText);
attributes = module.GetAttributesAt(1, column - 1);
foreach (var attribute in GetEngineAttributes(readWriteText, column - start - 1))
{
attributes.Add(attribute);
}
}
else
{
var module = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), textBuffer.CurrentSnapshot.GetText());
attributes = module.GetAttributesAt(line + 1, column);
}
completionSets.Add(GetCompletions((List<Declaration>)attributes, session));
}
示例4: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if ( !settings.TextCompletionEnabled ) {
return;
}
if ( session.TextView.TextBuffer != this.theBuffer ) {
return;
}
if ( !PlainTextCompletionContext.IsSet(session) ) {
return;
}
var snapshot = theBuffer.CurrentSnapshot;
var triggerPoint = session.GetTriggerPoint(snapshot);
if ( !triggerPoint.HasValue ) {
return;
}
var applicableToSpan = GetApplicableToSpan(triggerPoint.Value);
var then = this.bufferStatsOnCompletion;
var now = new BufferStats(snapshot);
if ( currentCompletions == null || now.SignificantThan(then) ) {
this.currentCompletions = BuildCompletionsList();
this.bufferStatsOnCompletion = now;
}
var set = new CompletionSet(
moniker: "plainText",
displayName: "Text",
applicableTo: applicableToSpan,
completions: currentCompletions,
completionBuilders: null
);
completionSets.Add(set);
}
示例5: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
var line = position.GetContainingLine();
if (line == null)
return;
string text = line.GetText();
var linePosition = position - line.Start;
foreach (var source in completionSources)
{
var span = source.GetInvocationSpan(text, linePosition, position);
if (span == null) continue;
var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(span.Value.Start + line.Start, span.Value.Length, SpanTrackingMode.EdgeInclusive);
completionSets.Add(new StringCompletionSet(
source.GetType().Name,
trackingSpan,
source.GetEntries(quoteChar: text[span.Value.Start], caret: session.TextView.Caret.Position.BufferPosition)
));
}
// TODO: Merge & resort all sets? Will StringCompletionSource handle other entries?
//completionSets.SelectMany(s => s.Completions).OrderBy(c=>c.DisplayText.TrimStart('"','\''))
}
示例6: AugmentCompletionSession
public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
var nullableTriggerPoint = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!nullableTriggerPoint.HasValue) {
return;
}
var triggerPoint = nullableTriggerPoint.Value;
TemplateProjectionBuffer projBuffer;
if (!_buffer.Properties.TryGetProperty<TemplateProjectionBuffer>(typeof(TemplateProjectionBuffer), out projBuffer)) {
return;
}
int templateStart;
TemplateTokenKind kind;
var templateText = projBuffer.GetTemplateText(triggerPoint, out kind, out templateStart);
if (templateText == null) {
return;
}
if (kind == TemplateTokenKind.Block || kind == TemplateTokenKind.Variable) {
ITrackingSpan applicableSpan;
var completionSet = GetCompletionSet(
session.GetOptions(),
_analyzer,
kind,
templateText,
templateStart,
triggerPoint,
out applicableSpan);
completionSets.Add(completionSet);
}
}
示例7: if
void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
var fileModel = VsUtils.TryGetFileModel(_textBuffer);
if (fileModel == null)
return;
var client = fileModel.Server.Client;
var triggerPoint = session.GetTriggerPoint(_textBuffer);
var snapshot = _textBuffer.CurrentSnapshot;
var version = snapshot.Version.Convert();
client.Send(new ClientMessage.CompleteWord(fileModel.Id, version, triggerPoint.GetPoint(snapshot).Position));
var result = client.Receive<ServerMessage.CompleteWord>();
var span = result.replacementSpan;
var applicableTo = snapshot.CreateTrackingSpan(new Span(span.StartPos, span.Length), SpanTrackingMode.EdgeInclusive);
var completions = new List<Completion>();
CompletionElem.Literal literal;
CompletionElem.Symbol symbol;
foreach (var elem in result.completionList)
{
if ((literal = elem as CompletionElem.Literal) != null)
completions.Add(new Completion(literal.text, literal.text, "literal", null, null));
else if ((symbol = elem as CompletionElem.Symbol) != null)
completions.Add(new Completion(symbol.name, symbol.name, symbol.description, null, null));
}
completionSets.Add(new CompletionSet("NitraWordCompletion", "Nitra word completion", applicableTo, completions, null));
}
示例8: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (_disposed)
return;
List<Completion> completions = new List<Completion>();
foreach (string item in RobotsTxtClassifier._valid)
{
completions.Add(new Completion(item, item, null, _glyph, item));
}
ITextSnapshot snapshot = _buffer.CurrentSnapshot;
var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
if (triggerPoint == null)
return;
var line = triggerPoint.GetContainingLine();
string text = line.GetText();
int index = text.IndexOf(':');
int hash = text.IndexOf('#');
SnapshotPoint start = triggerPoint;
if (hash > -1 && hash < triggerPoint.Position || (index > -1 && (start - line.Start.Position) > index))
return;
while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
{
start -= 1;
}
var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty<Completion>()));
}
示例9: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
var line = position.GetContainingLine();
if (line == null) return;
int linePos = position - line.Start.Position;
var info = NodeModuleCompletionUtils.FindCompletionInfo(line.GetText(), linePos);
if (info == null) return;
var callingFilename = _buffer.GetFileName();
var baseFolder = Path.GetDirectoryName(callingFilename);
IEnumerable<Intel.Completion> results;
if (String.IsNullOrWhiteSpace(info.Item1))
results = GetRootCompletions(baseFolder);
else
results = GetRelativeCompletions(NodeModuleService.ResolvePath(baseFolder, info.Item1));
var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(info.Item2.Start + line.Start, info.Item2.Length, SpanTrackingMode.EdgeInclusive);
completionSets.Add(new CompletionSet(
"Node.js Modules",
"Node.js Modules",
trackingSpan,
results,
null
));
}
示例10: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
var snapshot = session.TextView.TextSnapshot;
var triggerPoint = session.GetTriggerPoint(snapshot);
if (triggerPoint == null)
return;
var info = CompletionInfo.Create(snapshot);
if (info == null)
return;
// This helps a little to speed up the code
ProfileOptimizationHelper.StartProfile("roslyn-completion-" + info.Value.CompletionService.Language);
CompletionTrigger completionTrigger;
session.Properties.TryGetProperty(typeof(CompletionTrigger), out completionTrigger);
var completionList = info.Value.CompletionService.GetCompletionsAsync(info.Value.Document, triggerPoint.Value.Position, completionTrigger).GetAwaiter().GetResult();
if (completionList == null)
return;
Debug.Assert(completionList.Span.End <= snapshot.Length);
if (completionList.Span.End > snapshot.Length)
return;
var trackingSpan = snapshot.CreateTrackingSpan(completionList.Span.Start, completionList.Span.Length, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);
var completionSet = RoslynCompletionSet.Create(imageMonikerService, mruCompletionService, completionList, info.Value.CompletionService, session.TextView, DefaultCompletionSetMoniker, dnSpy_Roslyn_Shared_Resources.CompletionSet_All, trackingSpan);
completionSets.Add(completionSet);
}
示例11: AugmentCompletionSession
public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
var doc = HtmlEditorDocument.FromTextBuffer(_buffer);
if (doc == null) {
return;
}
doc.HtmlEditorTree.EnsureTreeReady();
var primarySnapshot = doc.PrimaryView.TextSnapshot;
var nullableTriggerPoint = session.GetTriggerPoint(primarySnapshot);
if (!nullableTriggerPoint.HasValue) {
return;
}
var triggerPoint = nullableTriggerPoint.Value;
var artifacts = doc.HtmlEditorTree.ArtifactCollection;
var index = artifacts.GetItemContaining(triggerPoint.Position);
if (index < 0) {
return;
}
var artifact = artifacts[index] as TemplateArtifact;
if (artifact == null) {
return;
}
var artifactText = doc.HtmlEditorTree.ParseTree.Text.GetText(artifact.InnerRange);
artifact.Parse(artifactText);
ITrackingSpan applicableSpan;
var completionSet = GetCompletionSet(session.GetOptions(_analyzer._serviceProvider), _analyzer, artifact.TokenKind, artifactText, artifact.InnerRange.Start, triggerPoint, out applicableSpan);
completionSets.Add(completionSet);
}
示例12: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
int triggerPointPosition = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(session.TextView.TextSnapshot);
ITrackingSpan trackingSpan = session.TextView.TextSnapshot.CreateTrackingSpan(triggerPointPosition, 0, SpanTrackingMode.EdgeInclusive);
var rewriteDirectives = new[] {
new ApacheCompletion("RewriteBase", "RewriteBase", "The RewriteBase directive explicitly sets the base URL for per-directory rewrites."),
new ApacheCompletion("RewriteCond", "RewriteCond", "The RewriteCond directive defines a rule condition. One or more RewriteCond can precede a RewriteRule directive."),
new ApacheCompletion("RewriteEngine", "RewriteEngine", "The RewriteEngine directive enables or disables the runtime rewriting engine."),
new ApacheCompletion("RewriteLock", "RewriteLock", "This directive sets the filename for a synchronization lockfile which mod_rewrite needs to communicate with RewriteMap programs."),
new ApacheCompletion("RewriteLog", "RewriteLog", "The RewriteLog directive sets the name of the file to which the server logs any rewriting actions it performs."),
new ApacheCompletion("RewriteLogLevel", "RewriteLogLevel", "The RewriteLogLevel directive sets the verbosity level of the rewriting logfile."),
new ApacheCompletion("RewriteMap", "RewriteMap", "The RewriteMap directive defines a Rewriting Map which can be used inside rule substitution strings by the mapping-functions to insert/substitute fields through a key lookup."),
new ApacheCompletion("RewriteOptions", "RewriteOptions", "The RewriteOptions directive sets some special options for the current per-server or per-directory configuration."),
new ApacheCompletion("RewriteRule", "RewriteRule", "The RewriteRule directive is the real rewriting workhorse. The directive can occur more than once, with each instance defining a single rewrite rule. The order in which these rules are defined is important - this is the order in which they will be applied at run-time.")
};
var completionSet = new CompletionSet(
ApacheContentType.Name,
"Apache Rewrite Directives",
trackingSpan,
rewriteDirectives,
null
);
completionSets.Add(completionSet);
}
示例13: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (_disposed)
throw new ObjectDisposedException("XSharpCompletionSource");
List<Completion> completions = new List<Completion>()
{
new Completion("SELF"),
new Completion("FUNCTION"),
new Completion("CLASS")
};
ITextSnapshot snapshot = _buffer.CurrentSnapshot;
var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
if (triggerPoint == null)
return;
var line = triggerPoint.GetContainingLine();
SnapshotPoint start = triggerPoint;
while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
{
start -= 1;
}
var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
// XSHARP : Disable Intellisense
//completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty<Completion>()));
}
示例14: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (_disposed)
return;
ITextSnapshot snapshot = session.TextView.TextBuffer.CurrentSnapshot;
SnapshotPoint? triggerPoint = session.GetTriggerPoint(snapshot);
ClassificationSpan clsSpan;
if (triggerPoint == null || !triggerPoint.HasValue || triggerPoint.Value.Position == 0 || !IsAllowed(triggerPoint.Value, out clsSpan))
return;
ITrackingSpan tracking = FindTokenSpanAtPosition(session);
if (tracking == null)
return;
List<Completion> completions = new List<Completion>();
if (clsSpan != null && clsSpan.ClassificationType.IsOfType(PredefinedClassificationTypeNames.SymbolDefinition))
{
AddVariableCompletions(snapshot, tracking, completions);
}
//else if (!tracking.GetText(snapshot).Any(c => !char.IsLetter(c) && !char.IsWhiteSpace(c)))
//{
// AddKeywordCompletions(completions);
//}
if (completions.Count > 0)
{
var ordered = completions.OrderBy(c => c.DisplayText);
completionSets.Add(new CompletionSet("Cmd", "Cmd", tracking, ordered, Enumerable.Empty<Completion>()));
}
}
示例15: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (disposed)
throw new ObjectDisposedException("GherkinStepCompletionSource");
ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
var triggerPoint = session.GetTriggerPoint(snapshot);
if (triggerPoint == null)
return;
ScenarioBlock? scenarioBlock = GetCurrentScenarioBlock(triggerPoint.Value);
if (scenarioBlock == null)
return;
IEnumerable<Completion> completions = GetCompletionsForBlock(scenarioBlock.Value);
ITrackingSpan applicableTo = GetApplicableToSpan(snapshot, triggerPoint.Value);
string displayName = string.Format("All {0} Steps", scenarioBlock);
completionSets.Add(
new CompletionSet(
displayName,
displayName,
applicableTo,
completions,
null));
}