本文整理汇总了C#中ITextDocument类的典型用法代码示例。如果您正苦于以下问题:C# ITextDocument类的具体用法?C# ITextDocument怎么用?C# ITextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextDocument类属于命名空间,在下文中一共展示了ITextDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreviewWindowUpdateListener
public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
{
this.textView = wpfTextView;
this.package = package;
this.document = document;
EventHandler updateHandler =
(sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();
BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
document.FileActionOccurred +=
(sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();
textView.Closed += (sender, args) =>
{
ClearPreviewWindow();
BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
};
//On updating the publish flags re-run the preview
package.PublishFlags.CollectionChanged +=
(sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();
DoxygenHelper.TrackedFilesChanged +=
() => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();
Templates.TemplatesChanged += () => UpdatePreviewWindow(UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.Results);
UDNDocRunningTableMonitor.CurrentOutputIsChanged += UpdatePreviewWindow;
}
示例2: RoslynCodeAnalysisHelper
public RoslynCodeAnalysisHelper(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider, IVsActivityLog log)
{
_view = view;
_document = document;
_text = new Adornment();
_tasks = tasks;
_serviceProvider = serviceProvider;
_log = log;
_dispatcher = Dispatcher.CurrentDispatcher;
_adornmentLayer = view.GetAdornmentLayer(RoslynCodeAnalysisFactory.LayerName);
_view.ViewportHeightChanged += SetAdornmentLocation;
_view.ViewportWidthChanged += SetAdornmentLocation;
_text.MouseUp += (s, e) => dte.ExecuteCommand("View.ErrorList");
_timer = new Timer(750);
_timer.Elapsed += (s, e) =>
{
_timer.Stop();
System.Threading.Tasks.Task.Run(() =>
{
_dispatcher.Invoke(new Action(() => Update(false)), DispatcherPriority.ApplicationIdle, null);
});
};
_timer.Start();
}
示例3: LoadRuleset
/// <summary>
/// Load the ruleset file according to the document file path.
/// </summary>
/// <param name="document">The specified document file.</param>
private void LoadRuleset(ITextDocument document)
{
try
{
for (string path = Path.GetDirectoryName(document.FilePath); path != null; path = Path.GetDirectoryName(path))
{
string[] rulesetFiles = Directory.GetFiles(path, "*.ruleset");
if (rulesetFiles.Length == 1)
{
this.ruleset = DirectiveRuleset.LoadFromRulesetFile(rulesetFiles[0]);
this.RulesetFilePath = Path.GetFullPath(rulesetFiles[0]);
this.NoRulesetFileReason = null;
}
else if (rulesetFiles.Length > 1)
{
this.RulesetFilePath = null;
this.NoRulesetFileReason = string.Format("Folder \"{0}\" contains more than one \"*.ruleset\" files", path);
}
if (rulesetFiles.Length > 0)
break;
}
if (this.ruleset == null)
this.NoRulesetFileReason = "No \"*.ruleset\" file was found in the directory hierarchy";
}
catch (Exception ex)
{
this.RulesetFilePath = null;
this.NoRulesetFileReason = ex.ToString();
}
}
示例4: ParseTemplateCore
protected internal virtual ParserResults ParseTemplateCore(ITextDocument input, CancellationToken? cancelToken)
{
// Construct the parser
RazorParser parser = CreateParser();
Debug.Assert(parser != null);
return parser.Parse(input);
}
示例5: EditorCompilerInvoker
public EditorCompilerInvoker(ITextDocument doc, CompilerRunnerBase compilerRunner)
{
Document = doc;
CompilerRunner = compilerRunner;
Document.FileActionOccurred += Document_FileActionOccurred;
}
示例6: GenerateCodeCore
//copied from base impl in RazorTemplateEngine.ParseTemplateCore, only change is that it actually calls ParseTemplateCore
protected override GeneratorResults GenerateCodeCore (ITextDocument input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken)
{
className = (className ?? Host.DefaultClassName) ?? DefaultClassName;
rootNamespace = (rootNamespace ?? Host.DefaultNamespace) ?? DefaultNamespace;
ParserResults results = ParseTemplateCore (input, cancelToken);
// Generate code
RazorCodeGenerator generator = CreateCodeGenerator(className, rootNamespace, sourceFileName);
generator.DesignTimeMode = Host.DesignTimeMode;
generator.Visit(results);
// Post process code
Host.PostProcessGeneratedCode(generator.Context);
// Extract design-time mappings
IDictionary<int, GeneratedCodeMapping> designTimeLineMappings = null;
if (Host.DesignTimeMode)
{
designTimeLineMappings = generator.Context.CodeMappings;
}
// Collect results and return
return new GeneratorResults(results, generator.Context.CompileUnit, designTimeLineMappings);
}
示例7: MouseClickProcessor
public MouseClickProcessor(IWpfTextView TextView, ITextDocument Document)
{
this.TextView = TextView;
this.Document = Document;
SetupFolderSettings();
}
示例8: ParserContext
/// <summary>
/// Initializes a new instance of the <see cref="ParserContext"/> class.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="parser">The parser.</param>
/// <param name="errorSink">The error sink.</param>
public ParserContext(ITextDocument source, ParserBase parser, ParserErrorSink errorSink, TagProvidersCollection providers)
{
Source = new TextDocumentReader(source);
Parser = parser;
_errorSink = errorSink;
TagProviders = providers;
}
示例9: InformationBarMargin
public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEditorOperations editorOperations, ITextUndoHistory undoHistory, DTE dte)
{
_textView = textView;
_document = document;
_operations = editorOperations;
_undoHistory = undoHistory;
_dte = dte;
_informationBarControl = new InformationBarControl();
_informationBarControl.Hide.Click += Hide;
_informationBarControl.DontShowAgain.Click += DontShowAgain;
var format = new Action(() => this.FormatDocument());
_informationBarControl.Tabify.Click += (s, e) => this.Dispatcher.Invoke(format);
this.Height = 0;
this.Content = _informationBarControl;
this.Name = MarginName;
document.FileActionOccurred += FileActionOccurred;
textView.Closed += TextViewClosed;
// Delay the initial check until the view gets focus
textView.GotAggregateFocus += GotAggregateFocus;
this._tabDirectiveParser = new TabDirectiveParser(textView, document, dte);
this._fileHeuristics = new FileHeuristics(textView, document, dte);
var fix = new Action(() => this.FixFile());
this._tabDirectiveParser.Change += (s, e) => this.Dispatcher.Invoke(fix);
}
示例10: ErrorHighlighter
public ErrorHighlighter(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte)
{
_view = view;
_document = document;
_text = new Adornment();
_tasks = tasks;
_dispatcher = Dispatcher.CurrentDispatcher;
_adornmentLayer = view.GetAdornmentLayer(ErrorHighlighterFactory.LayerName);
_view.ViewportHeightChanged += SetAdornmentLocation;
_view.ViewportWidthChanged += SetAdornmentLocation;
_text.MouseUp += (s, e) => { dte.ExecuteCommand("View.ErrorList"); };
_timer = new Timer(750);
_timer.Elapsed += (s, e) =>
{
_timer.Stop();
Task.Run(() =>
{
_dispatcher.Invoke(new Action(() =>
{
Update(false);
}), DispatcherPriority.ApplicationIdle, null);
});
};
_timer.Start();
}
示例11: PreviewWindowUpdateListener
public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
{
this.textView = wpfTextView;
this.package = package;
this.document = document;
if (textView.HasAggregateFocus)
UpdatePreviewWindow(false);
updateHandler = (sender, args) =>
{
UpdatePreviewWindow(async: true);
};
BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
textView.Closed += (sender, args) =>
{
ClearPreviewWindow();
BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
};
textView.GotAggregateFocus += (sender, args) =>
{
var window = GetPreviewWindow(false);
if (window != null)
{
if (window.CurrentSource == null || window.CurrentSource != this)
UpdatePreviewWindow(false);
}
};
}
示例12: RemoveWhitespaceOnSave
public RemoveWhitespaceOnSave(IVsTextView textViewAdapter, IWpfTextView view, DTE2 dte, ITextDocument document)
{
textViewAdapter.AddCommandFilter(this, out _nextCommandTarget);
_view = view;
_dte = dte;
_document = document;
}
示例13: ParserContext
public ParserContext(ITextDocument source, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (codeParser == null)
{
throw new ArgumentNullException("codeParser");
}
if (markupParser == null)
{
throw new ArgumentNullException("markupParser");
}
if (activeParser == null)
{
throw new ArgumentNullException("activeParser");
}
if (activeParser != codeParser && activeParser != markupParser)
{
throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
}
CaptureOwnerTask();
Source = new TextDocumentReader(source);
CodeParser = codeParser;
MarkupParser = markupParser;
ActiveParser = activeParser;
Errors = new List<RazorError>();
}
示例14: GetGitDiffFor
public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, ITextSnapshot snapshot)
{
string fileName = textDocument.FilePath;
GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(fileName));
if (!tracker.IsGit)
yield break;
GitFileStatus status = tracker.GetFileStatus(fileName);
if (status == GitFileStatus.New || status == GitFileStatus.Added)
yield break;
HistogramDiff diff = new HistogramDiff();
diff.SetFallbackAlgorithm(null);
string currentText = snapshot.GetText();
byte[] preamble = textDocument.Encoding.GetPreamble();
byte[] content = textDocument.Encoding.GetBytes(currentText);
if (preamble.Length > 0)
{
byte[] completeContent = new byte[preamble.Length + content.Length];
Buffer.BlockCopy(preamble, 0, completeContent, 0, preamble.Length);
Buffer.BlockCopy(content, 0, completeContent, preamble.Length, content.Length);
content = completeContent;
}
byte[] previousContent = null; //GetPreviousRevision(tracker, fileName);
RawText b = new RawText(content);
RawText a = new RawText(previousContent ?? new byte[0]);
EditList edits = diff.Diff(RawTextComparator.DEFAULT, a, b);
foreach (Edit edit in edits)
yield return new HunkRangeInfo(snapshot, edit, a, b);
}
示例15: SourceDocument
public SourceDocument(IEditorController controller, ITextDocument document, Project.IProject proj)
{
_controller = controller;
_document = document;
_project = proj;
if(_project != null)
_changeTracker = new DocChangeTracker(this, _project.Index);
}