本文整理汇总了C#中ITextSnapshot.IsReplBufferWithCommand方法的典型用法代码示例。如果您正苦于以下问题:C# ITextSnapshot.IsReplBufferWithCommand方法的具体用法?C# ITextSnapshot.IsReplBufferWithCommand怎么用?C# ITextSnapshot.IsReplBufferWithCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextSnapshot
的用法示例。
在下文中一共展示了ITextSnapshot.IsReplBufferWithCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrySpecialCompletions
private static CompletionAnalysis TrySpecialCompletions(IServiceProvider serviceProvider, ITextSnapshot snapshot, ITrackingSpan span, ITrackingPoint point, CompletionOptions options) {
var snapSpan = span.GetSpan(snapshot);
var buffer = snapshot.TextBuffer;
var classifier = buffer.GetPythonClassifier();
if (classifier == null) {
return null;
}
var parser = new ReverseExpressionParser(snapshot, buffer, span);
var statementRange = parser.GetStatementRange();
if (!statementRange.HasValue) {
statementRange = snapSpan.Start.GetContainingLine().Extent;
}
if (snapSpan.Start < statementRange.Value.Start) {
return null;
}
var tokens = classifier.GetClassificationSpans(new SnapshotSpan(statementRange.Value.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
if (lastClass.Span.Start.GetContainingLine().LineNumber == lastClass.Span.End.GetContainingLine().LineNumber) {
return new StringLiteralCompletionList(span, buffer, options);
} else {
// multi-line string, no string completions.
return CompletionAnalysis.EmptyCompletionContext;
}
} else if (lastClass.ClassificationType == classifier.Provider.Operator &&
lastClass.Span.GetText() == "@") {
if (tokens.Count == 1) {
return new DecoratorCompletionAnalysis(span, buffer, options);
}
// TODO: Handle completions automatically popping up
// after '@' when it is used as a binary operator.
} else if (CompletionAnalysis.IsKeyword(lastClass, "def")) {
return new OverrideCompletionAnalysis(span, buffer, options);
}
// Import completions
var first = tokens[0];
if (CompletionAnalysis.IsKeyword(first, "import")) {
return ImportCompletionAnalysis.Make(tokens, span, buffer, options);
} else if (CompletionAnalysis.IsKeyword(first, "from")) {
return FromImportCompletionAnalysis.Make(tokens, span, buffer, options);
} else if (CompletionAnalysis.IsKeyword(first, "raise") || CompletionAnalysis.IsKeyword(first, "except")) {
if (tokens.Count == 1 ||
lastClass.ClassificationType.IsOfType(PythonPredefinedClassificationTypeNames.Comma) ||
(lastClass.IsOpenGrouping() && tokens.Count < 3)) {
return new ExceptionCompletionAnalysis(span, buffer, options);
}
}
return null;
} else if ((tokens = classifier.GetClassificationSpans(snapSpan.Start.GetContainingLine().ExtentIncludingLineBreak)).Count > 0 &&
tokens[0].ClassificationType == classifier.Provider.StringLiteral) {
// multi-line string, no string completions.
return CompletionAnalysis.EmptyCompletionContext;
} else if (snapshot.IsReplBufferWithCommand()) {
return CompletionAnalysis.EmptyCompletionContext;
}
return null;
}