本文整理汇总了C#中ITextEditor.ToEditorOptions方法的典型用法代码示例。如果您正苦于以下问题:C# ITextEditor.ToEditorOptions方法的具体用法?C# ITextEditor.ToEditorOptions怎么用?C# ITextEditor.ToEditorOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextEditor
的用法示例。
在下文中一共展示了ITextEditor.ToEditorOptions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
/// <summary>
/// Formats the specified part of the document.
/// </summary>
public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptions options)
{
var formatter = new CSharpFormatter(options, editor.ToEditorOptions());
formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length)));
var changes = formatter.AnalyzeFormatting(editor.Document, SyntaxTree.Parse(editor.Document));
changes.ApplyChanges(offset, length);
}
示例2: Format
/// <summary>
/// Formats the specified part of the document.
/// </summary>
public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptionsContainer optionsContainer)
{
TextEditorOptions editorOptions = editor.ToEditorOptions();
optionsContainer.CustomizeEditorOptions(editorOptions);
var formatter = new CSharpFormatter(optionsContainer.GetEffectiveOptions(), editorOptions);
formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length)));
var changes = formatter.AnalyzeFormatting(editor.Document, SyntaxTree.Parse(editor.Document));
changes.ApplyChanges(offset, length);
}
示例3: IndentLines
public override void IndentLines(ITextEditor editor, int beginLine, int endLine)
{
var document = editor.Document;
var engine = CreateIndentEngine(document, editor.ToEditorOptions());
int currentLine = beginLine;
do {
var line = document.GetLineByNumber(currentLine);
IndentSingleLine(engine, document, line);
} while (++currentLine <= endLine);
}
示例4: Format
/// <summary>
/// Formats the specified part of the document.
/// </summary>
public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptionsContainer optionsContainer)
{
SyntaxTree syntaxTree = SyntaxTree.Parse(editor.Document);
if (syntaxTree.Errors.Count > 0) {
// Don't format files containing syntax errors!
return;
}
TextEditorOptions editorOptions = editor.ToEditorOptions();
optionsContainer.CustomizeEditorOptions(editorOptions);
var formatter = new CSharpFormatter(optionsContainer.GetEffectiveOptions(), editorOptions);
formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length)));
var changes = formatter.AnalyzeFormatting(editor.Document, syntaxTree);
changes.ApplyChanges(offset, length);
}
示例5: IndentLine
public override void IndentLine(ITextEditor editor, IDocumentLine line)
{
var document = editor.Document;
var engine = CreateIndentEngine(document, editor.ToEditorOptions());
IndentSingleLine(engine, document, line);
}
示例6: SDRefactoringContext
public SDRefactoringContext(ITextEditor editor, CSharpAstResolver resolver, TextLocation location, CancellationToken cancellationToken = default(CancellationToken))
: base(resolver, cancellationToken)
{
this.resolver = resolver;
this.editor = editor;
this.textSource = editor.Document;
this.document = editor.Document;
this.selectionStart = editor.SelectionStart;
this.selectionLength = editor.SelectionLength;
this.location = location;
this.editorOptions = editor.ToEditorOptions();
InitializeServices();
}