本文整理汇总了C#中ITrackingSpan.GetStartPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ITrackingSpan.GetStartPoint方法的具体用法?C# ITrackingSpan.GetStartPoint怎么用?C# ITrackingSpan.GetStartPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITrackingSpan
的用法示例。
在下文中一共展示了ITrackingSpan.GetStartPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMissingImports
internal static MissingImportAnalysis GetMissingImports(ITextSnapshot snapshot, ITrackingSpan span) {
ReverseExpressionParser parser = new ReverseExpressionParser(snapshot, snapshot.TextBuffer, span);
var loc = span.GetSpan(snapshot.Version);
int dummy;
SnapshotPoint? dummyPoint;
string lastKeywordArg;
bool isParameterName;
var exprRange = parser.GetExpressionRange(0, out dummy, out dummyPoint, out lastKeywordArg, out isParameterName);
if (exprRange == null || isParameterName) {
return MissingImportAnalysis.Empty;
}
var analysis = ((IPythonProjectEntry)snapshot.TextBuffer.GetProjectEntry()).Analysis;
if (analysis == null) {
return MissingImportAnalysis.Empty;
}
var text = exprRange.Value.GetText();
var analyzer = analysis.ProjectState;
var index = span.GetStartPoint(snapshot).Position;
var expr = Statement.GetExpression(
analysis.GetAstFromTextByIndex(
text,
TranslateIndex(
index,
snapshot,
analysis
)
).Body
);
if (expr != null && expr is NameExpression) {
var nameExpr = (NameExpression)expr;
if (!IsImplicitlyDefinedName(nameExpr)) {
var applicableSpan = parser.Snapshot.CreateTrackingSpan(
exprRange.Value.Span,
SpanTrackingMode.EdgeExclusive
);
lock (snapshot.TextBuffer.GetAnalyzer()) {
index = TranslateIndex(
index,
snapshot,
analysis
);
var variables = analysis.GetVariablesByIndex(text, index).Where(IsDefinition).Count();
var values = analysis.GetValuesByIndex(text, index).ToArray();
// if we have type information or an assignment to the variable we won't offer
// an import smart tag.
if (values.Length == 0 && variables == 0) {
string name = nameExpr.Name;
var imports = analysis.ProjectState.FindNameInAllModules(name);
return new MissingImportAnalysis(imports, applicableSpan);
}
}
}
}
// if we have type information don't offer to add imports
return MissingImportAnalysis.Empty;
}