本文整理汇总了C#中ITextBuffer.GetAnalyzer方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.GetAnalyzer方法的具体用法?C# ITextBuffer.GetAnalyzer怎么用?C# ITextBuffer.GetAnalyzer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextBuffer
的用法示例。
在下文中一共展示了ITextBuffer.GetAnalyzer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PythonClassifier
private static Dictionary<PythonLanguageVersion, Tokenizer> _tokenizers; // tokenizer for each version, shared between all buffers
internal PythonClassifier(PythonClassifierProvider provider, ITextBuffer buffer) {
buffer.Changed += BufferChanged;
buffer.ContentTypeChanged += BufferContentTypeChanged;
_tokenCache = new TokenCache();
_provider = provider;
_buffer = buffer;
var analyzer = _buffer.GetAnalyzer(provider._serviceProvider);
Debug.Assert(analyzer != null);
_version = analyzer.InterpreterFactory.GetLanguageVersion();
}
示例2: DisconnectSubjectBuffer
public void DisconnectSubjectBuffer(ITextBuffer subjectBuffer) {
subjectBuffer.GetAnalyzer().RemoveBuffer(subjectBuffer);
}
示例3: ConnectSubjectBuffer
public void ConnectSubjectBuffer(ITextBuffer subjectBuffer) {
subjectBuffer.GetAnalyzer().AddBuffer(subjectBuffer);
}
示例4: AddImport
public static void AddImport(
IServiceProvider serviceProvider,
ITextBuffer buffer,
ITextView view,
string fromModule,
string name
) {
var analyzer = buffer.GetAnalyzer(serviceProvider);
var curAst = analyzer.ParseSnapshot(buffer.CurrentSnapshot);
var suiteBody = curAst.Body as SuiteStatement;
Statement insertBefore = null;
if (suiteBody != null) {
bool firstStatement = true;
foreach (var statement in suiteBody.Statements) {
if (firstStatement && IsDocString(statement as ExpressionStatement)) {
// doc string, ignore this
firstStatement = false;
continue;
}
firstStatement = false;
// __future__ imports go first
if (fromModule == null || fromModule != "__future__") {
if (statement is ImportStatement) {
// we insert after this
continue;
} else if (statement is FromImportStatement) {
// we might update this, we might insert after
FromImportStatement fromImport = statement as FromImportStatement;
if (fromImport.Root.MakeString() == fromModule) {
// update the existing from ... import statement to include the new name.
UpdateFromImport(curAst, buffer, fromImport, name);
return;
}
continue;
}
}
// this isn't an import, we insert before this statement
insertBefore = statement;
break;
}
}
int start;
if (insertBefore != null) {
var location = insertBefore.GetStart(curAst);
var point = buffer.CurrentSnapshot.GetLineFromLineNumber(location.Line - 1).Start;
// the span starts after any whitespace, so walk backup and see if we should skip some lines
if (point.Position != 0) {
var prevPoint = point.Subtract(1);
// walk past all the previous lines
var classifier = buffer.GetPythonClassifier();
bool moved = false;
while (prevPoint.Position != 0 &&
(char.IsWhiteSpace(prevPoint.GetChar()) || IsCommentChar(prevPoint, classifier))) {
prevPoint = prevPoint.Subtract(1);
moved = true;
}
prevPoint = prevPoint.Add(1);
// then walk forward one line
if (moved) {
int lineNum = prevPoint.GetContainingLine().LineNumber;
do {
prevPoint = prevPoint.Add(1);
} while (lineNum == prevPoint.GetContainingLine().LineNumber);
}
point = prevPoint;
}
start = point.Position;
} else {
start = 0;
}
buffer.Insert(start, MakeImportCode(fromModule, name) + view.Options.GetNewLineCharacter());
}