本文整理汇总了C#中Mono.TextEditor.Document类的典型用法代码示例。如果您正苦于以下问题:C# Document类的具体用法?C# Document怎么用?C# Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Document类属于Mono.TextEditor命名空间,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
static CSharpTextEditorIndentation Setup (string input, out TestViewContent content)
{
TestWorkbenchWindow tww = new TestWorkbenchWindow ();
content = new TestViewContent ();
content.Data.Options.IndentStyle = IndentStyle.Auto;
tww.ViewContent = content;
content.ContentName = "a.cs";
content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
Document doc = new Document (tww);
var text = input;
int endPos = text.IndexOf ('$');
if (endPos >= 0)
text = text.Substring (0, endPos) + text.Substring (endPos + 1);
content.Text = text;
content.CursorPosition = System.Math.Max (0, endPos);
var compExt = new CSharpCompletionTextEditorExtension ();
compExt.Initialize (doc);
content.Contents.Add (compExt);
var ext = new CSharpTextEditorIndentation ();
CSharpTextEditorIndentation.OnTheFlyFormatting = true;
ext.Initialize (doc);
content.Contents.Add (ext);
doc.UpdateParseDocument ();
return ext;
}
示例2: CreateCompletionAndUpdate
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo,
out CodeCompletionContext codeCompletionContext)
{
var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext);
completion.UpdateParsedDocument ();
return completion;
}
示例3: FoldSegment
public FoldSegment (Document doc, string description, int offset, int length, FoldingType foldingType) : base (offset, length)
{
this.doc = doc;
this.IsFolded = false;
this.Description = description;
this.FoldingType = foldingType;
}
示例4: TestCreateMethod
void TestCreateMethod (string input, string outputString, bool returnWholeFile)
{
var generator = new CSharpCodeGeneratorNode ();
MonoDevelop.Projects.CodeGeneration.CodeGenerator.AddGenerator (generator);
var refactoring = new CreateMethodCodeGenerator ();
RefactoringOptions options = ExtractMethodTests.CreateRefactoringOptions (input);
Assert.IsTrue (refactoring.IsValid (options));
if (returnWholeFile) {
refactoring.SetInsertionPoint (CodeGenerationService.GetInsertionPoints (options.Document, refactoring.DeclaringType).First ());
} else {
DocumentLocation loc = new DocumentLocation (1, 1);
refactoring.SetInsertionPoint (new InsertionPoint (loc, NewLineInsertion.Eol, NewLineInsertion.Eol));
}
List<Change> changes = refactoring.PerformChanges (options, null);
// changes.ForEach (c => Console.WriteLine (c));
// get just the generated method.
string output = ExtractMethodTests.GetOutput (options, changes);
if (returnWholeFile) {
Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
return;
}
output = output.Substring (0, output.IndexOf ('}') + 1).Trim ();
// crop 1 level of indent
Document doc = new Document (output);
foreach (LineSegment line in doc.Lines) {
if (doc.GetCharAt (line.Offset) == '\t')
((IBuffer)doc).Remove (line.Offset, 1);
}
output = doc.Text;
Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
MonoDevelop.Projects.CodeGeneration.CodeGenerator.RemoveGenerator (generator);
}
示例5: HandleCompletion
public ICompletionDataList HandleCompletion (Document realDocument, CodeCompletionContext completionContext,
UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength)
{
CodeCompletionContext ccc;
var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
}
示例6: Initialize
public void Initialize (Document document)
{
if (this.document != null)
throw new InvalidOperationException ("Extension is already initialized.");
this.document = document;
Initialize ();
}
示例7: Setup
static Document Setup (string input)
{
TestWorkbenchWindow tww = new TestWorkbenchWindow ();
var content = new TestViewContent ();
tww.ViewContent = content;
content.ContentName = "a.cs";
content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
Document doc = new Document (tww);
var text = input;
int endPos = text.IndexOf ('$');
if (endPos >= 0)
text = text.Substring (0, endPos) + text.Substring (endPos + 1);
content.Text = text;
content.CursorPosition = System.Math.Max (0, endPos);
var compExt = new CSharpCompletionTextEditorExtension ();
compExt.Initialize (doc);
content.Contents.Add (compExt);
doc.UpdateParseDocument ();
return doc;
}
示例8: Setup
static Document Setup (string input)
{
var tww = new TestWorkbenchWindow ();
var content = new TestViewContent ();
var project = new DotNetAssemblyProject ("C#");
project.Name = "test";
project.References.Add (new ProjectReference (ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
project.References.Add (new ProjectReference (ReferenceType.Package, "System.Core"));
project.FileName = "test.csproj";
TypeSystemService.LoadProject (project);
TypeSystemService.GetProjectContentWrapper (project).ReconnectAssemblyReferences ();
content.Project = project;
tww.ViewContent = content;
content.ContentName = "a.cs";
content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
var doc = new Document (tww);
var text = input;
int endPos = text.IndexOf ('$');
if (endPos >= 0)
text = text.Substring (0, endPos) + text.Substring (endPos + 1);
content.Text = text;
content.CursorPosition = Math.Max (0, endPos);
var compExt = new CSharpCompletionTextEditorExtension ();
compExt.Initialize (doc);
content.Contents.Add (compExt);
doc.UpdateParseDocument ();
return doc;
}
示例9: SourceEditorPrintOperation
public SourceEditorPrintOperation (Document doc, FilePath filename)
{
this.doc = doc;
this.filename = filename;
this.settings = SourceEditorPrintSettings.Load ();
this.Unit = Unit.Mm;
}
示例10: MDRefactoringScript
public MDRefactoringScript (MDRefactoringContext context, Document document, CSharpFormattingOptions formattingOptions) : base(document.Editor.Document, formattingOptions, document.Editor.CreateNRefactoryTextEditorOptions ())
{
this.context = context;
this.document = document;
undoGroup = this.document.Editor.OpenUndoGroup ();
this.startVersion = this.document.Editor.Version;
}
示例11: GetNextOffset
static int GetNextOffset (Document document, int lineNumber)
{
int startLineNumber = lineNumber + 1;
if (startLineNumber > document.Length)
startLineNumber = 0;
var line = document.GetLinesStartingAt (startLineNumber).FirstOrDefault (l => l.IsBookmarked);
return line != null ? line.Offset : -1;
}
示例12: GetPrevOffset
static int GetPrevOffset (Document document, int lineNumber)
{
int startLineNumber = lineNumber - 1;
if (startLineNumber < 0)
startLineNumber = document.Length - 1;
var line = document.GetLinesReverseStartingAt (startLineNumber - 1).FirstOrDefault (l => l.IsBookmarked);
return line != null ? line.Offset : -1;
}
示例13: GetFormatter
internal static CodeFormatter GetFormatter (out Document doc)
{
doc = IdeApp.Workbench.ActiveDocument;
if (doc == null)
return null;
var editor = doc.Editor;
if (editor == null)
return null;
return editor == null ? null : CodeFormatterService.GetFormatter (editor.MimeType);
}
示例14: StartsWithListMember
static int StartsWithListMember (Document document, List<string> list, int offset)
{
for (int i = 0; i < list.Count; i++) {
string item = list[i];
if (offset + item.Length < document.Length) {
if (document.GetTextAt (offset, item.Length) == item)
return i;
}
}
return -1;
}
示例15: Check
public static IEnumerable<Result> Check (Document input, CancellationToken cancellationToken)
{
if (!QuickTaskStrip.EnableFancyFeatures)
return Enumerable.Empty<Result> ();
// var now = DateTime.Now;
var editor = input.Editor;
if (editor == null)
return Enumerable.Empty<Result> ();
var loc = editor.Caret.Location;
var result = new BlockingCollection<Result> ();
var codeIssueProvider = RefactoringService.GetInspectors (editor.Document.MimeType).ToArray ();
var context = input.ParsedDocument.CreateRefactoringContext != null ?
input.ParsedDocument.CreateRefactoringContext (input, cancellationToken) : null;
// Console.WriteLine ("start check:"+ (DateTime.Now - now).TotalMilliseconds);
Parallel.ForEach (codeIssueProvider, (parentProvider) => {
try {
foreach (var provider in EnumerateProvider (parentProvider)){
var severity = provider.GetSeverity ();
if (severity == Severity.None)
return;
// var now2 = DateTime.Now;
foreach (var r in provider.GetIssues (context, cancellationToken)) {
var fixes = new List<GenericFix> (r.Actions.Where (a => a != null).Select (a =>
new GenericFix (
a.Title,
new System.Action (() => a.Run (input, loc))) {
DocumentRegion = new DocumentRegion (r.Region.Begin, r.Region.End)
}));
result.Add (new InspectorResults (
provider,
r.Region,
r.Description,
severity,
provider.IssueMarker,
fixes.ToArray ()
));
}
}
/* var ms = (DateTime.Now - now2).TotalMilliseconds;
if (ms > 1000)
Console.WriteLine (ms +"\t\t"+ provider.Title);*/
} catch (OperationCanceledException) {
//ignore
} catch (Exception e) {
LoggingService.LogError ("CodeAnalysis: Got exception in inspector '" + parentProvider + "'", e);
}
});
// Console.WriteLine ("END check:"+ (DateTime.Now - now).TotalMilliseconds);
return result;
}