本文整理汇总了C#中DocumentStateTracker类的典型用法代码示例。如果您正苦于以下问题:C# DocumentStateTracker类的具体用法?C# DocumentStateTracker怎么用?C# DocumentStateTracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentStateTracker类属于命名空间,在下文中一共展示了DocumentStateTracker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CorrectIndenting
public override void CorrectIndenting (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain,
TextEditorData data, int line)
{
LineSegment lineSegment = data.Document.GetLine (line);
if (lineSegment == null)
return;
var policy = policyParent.Get<CFormattingPolicy> (mimeTypeChain);
var tracker = new DocumentStateTracker<CIndentEngine> (new CIndentEngine (policy), data);
tracker.UpdateEngine (lineSegment.Offset);
for (int i = lineSegment.Offset; i < lineSegment.Offset + lineSegment.EditableLength; i++) {
tracker.Engine.Push (data.Document.GetCharAt (i));
}
string curIndent = lineSegment.GetIndentation (data.Document);
int nlwsp = curIndent.Length;
if (!tracker.Engine.LineBeganInsideMultiLineComment || (nlwsp < lineSegment.Length && data.Document.GetCharAt (lineSegment.Offset + nlwsp) == '*')) {
// Possibly replace the indent
string newIndent = tracker.Engine.ThisLineIndent;
if (newIndent != curIndent)
data.Replace (lineSegment.Offset, nlwsp, newIndent);
}
tracker.Dispose ();
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:25,代码来源:CFormatter.cs
示例2: CorrectIndenting
public override void CorrectIndenting (object textEditorData, int line)
{
TextEditorData data = (TextEditorData)textEditorData;
LineSegment lineSegment = data.Document.GetLine (line);
if (lineSegment == null)
return;
IEnumerable<string> types = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
var policy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<CSharpFormattingPolicy> (types);
DocumentStateTracker<CSharpIndentEngine> tracker = new DocumentStateTracker<CSharpIndentEngine> (new CSharpIndentEngine (policy), data);
tracker.UpdateEngine (lineSegment.Offset);
for (int i = lineSegment.Offset; i < lineSegment.Offset + lineSegment.EditableLength; i++) {
tracker.Engine.Push (data.Document.GetCharAt (i));
}
string curIndent = lineSegment.GetIndentation (data.Document);
int nlwsp = curIndent.Length;
if (!tracker.Engine.LineBeganInsideMultiLineComment || (nlwsp < lineSegment.Length && data.Document.GetCharAt (lineSegment.Offset + nlwsp) == '*')) {
// Possibly replace the indent
string newIndent = tracker.Engine.ThisLineIndent;
if (newIndent != curIndent)
data.Replace (lineSegment.Offset, nlwsp, newIndent);
}
tracker.Dispose ();
}
开发者ID:Ein,项目名称:monodevelop,代码行数:25,代码来源:CSharpFormatter.cs
示例3: CreateTracker
DocumentStateTracker<CSharpIndentEngine> CreateTracker (TextEditorData data)
{
var policy = PolicyService.InvariantPolicies.Get <CSharpFormattingPolicy> ("text/x-csharp");
var textStylePolicy = PolicyService.InvariantPolicies.Get <TextStylePolicy> ("text/x-csharp");
var result = new DocumentStateTracker<CSharpIndentEngine> (new CSharpIndentEngine (policy, textStylePolicy), data);
result.UpdateEngine ();
return result;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:8,代码来源:CSharpTextEditorIndentationTests.cs
示例4: Initialize
public override void Initialize ()
{
base.Initialize ();
Parser parser = new Parser (CreateRootState (), false);
tracker = new DocumentStateTracker<Parser> (parser, Editor);
MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParsedDocumentUpdated += OnParseInformationChanged;
if (Document.ParsedDocument != null) {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
}
}
开发者ID:nickname100,项目名称:monodevelop,代码行数:12,代码来源:BaseXmlEditorExtension.cs
示例5: StateShouldBeRazorRootStateAfterCodeBlock
public void StateShouldBeRazorRootStateAfterCodeBlock ()
{
editor.Text =
@"@{
}
";
var parser = new XmlParser (new RazorRootState (), false);
var tracker = new DocumentStateTracker<XmlParser> (parser, editor);
editor.CaretLine = 3;
tracker.UpdateEngine ();
Assert.IsInstanceOf<RazorRootState> (tracker.Engine.CurrentState);
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:14,代码来源:RazorDocumentTrackerTests.cs
示例6: Initialize
public override void Initialize ()
{
base.Initialize ();
Parser parser = new Parser (CreateRootState (), false);
tracker = new DocumentStateTracker<Parser> (parser, Editor);
Document.DocumentParsed += delegate {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
};
if (Document.ParsedDocument != null) {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
}
}
开发者ID:fedorw,项目名称:monodevelop,代码行数:15,代码来源:BaseXmlEditorExtension.cs
示例7: Initialize
public override void Initialize ()
{
base.Initialize ();
UpdateOwnerProjects ();
Parser parser = new Parser (CreateRootState (), false);
tracker = new DocumentStateTracker<Parser> (parser, Editor);
Document.DocumentParsed += delegate {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
};
if (Document.ParsedDocument != null) {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
}
if (IdeApp.Workspace != null) {
IdeApp.Workspace.FileAddedToProject += HandleProjectChanged;
IdeApp.Workspace.FileRemovedFromProject += HandleProjectChanged;
}
}
开发者ID:alexrp,项目名称:monodevelop,代码行数:20,代码来源:BaseXmlEditorExtension.cs
示例8: InitTracker
void InitTracker ()
{
//if there's a CSharpTextEditorIndentation in the extension chain, we can reuse its stateTracker
CSharpTextEditorIndentation c = this.Document.GetContent<CSharpTextEditorIndentation> ();
if (c != null && c.StateTracker != null) {
stateTracker = c.StateTracker;
} else {
stateTracker = new DocumentStateTracker<CSharpIndentEngine> (new CSharpIndentEngine (policy), textEditorData);
}
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:10,代码来源:CSharpTextEditorCompletion.cs
示例9: InitTracker
void InitTracker()
{
//if there's a FSharpTextEditorCompletion in the extension chain, we can reuse its stateTracker
FSharpTextEditorCompletion c = this.Document.GetContent<FSharpTextEditorCompletion> ();
if (c != null && c.StateTracker != null) {
stateTracker = c.StateTracker;
} else {
stateTracker = new DocumentStateTracker<FSharpIndentEngine> (new FSharpIndentEngine (), Editor);
}
}
开发者ID:vasili,项目名称:FSharpBinding,代码行数:10,代码来源:FSharpTextEditorIndentation.cs
示例10: IndentVirtualSpaceManager
public IndentVirtualSpaceManager (Mono.TextEditor.TextEditorData data, DocumentStateTracker<CSharpIndentEngine> stateTracker)
{
this.data = data;
this.stateTracker = stateTracker;
}
开发者ID:txdv,项目名称:monodevelop,代码行数:5,代码来源:CSharpIndentVirtualSpaceManager.cs
示例11: InitTracker
void InitTracker()
{
stateTracker = new DocumentStateTracker<TypeScriptIndentEngine> (new TypeScriptIndentEngine (policy, textStylePolicy), Editor);
}
开发者ID:atsushieno,项目名称:md-typescript,代码行数:4,代码来源:TypeScriptTextEditorIndentation.cs
示例12: Initialize
public override void Initialize ()
{
base.Initialize ();
textEditorData = Document.Editor;
if (textEditorData != null) {
textEditorData.Options.Changed += delegate {
textEditorData.IndentationTracker = new DIndentationTracker (
textEditorData,
new DocumentStateTracker<DIndentEngine> (new DIndentEngine (Policy, TextStyle), textEditorData)
);
};
textEditorData.IndentationTracker = new DIndentationTracker (
textEditorData,
new DocumentStateTracker<DIndentEngine> (new DIndentEngine (Policy, TextStyle), textEditorData)
);
}
// Init tracker
stateTracker = new DocumentStateTracker<DIndentEngine> (new DIndentEngine (Policy, TextStyle), textEditorData);
Document.Editor.Paste += HandleTextPaste;
}
开发者ID:DinrusGroup,项目名称:Mono-D,代码行数:23,代码来源:DTextEditorIndentation.cs
示例13: RunFormatterAt
/* void TextCut (object sender, ReplaceEventArgs e)
{
if (!string.IsNullOrEmpty (e.Value) || e.Count == 0)
return;
RunFormatterAt (e.Offset);
}*/
#region Sharing the tracker
void InitTracker ()
{
stateTracker = new DocumentStateTracker<CSharpIndentEngine> (new CSharpIndentEngine (Policy, TextStylePolicy), textEditorData);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:14,代码来源:CSharpTextEditorIndentation.cs
示例14: Initialize
public override void Initialize ()
{
base.Initialize ();
S.Parser parser = new S.Parser (new S.XmlFreeState (), true);
tracker = new DocumentStateTracker<S.Parser> (parser, Editor);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:6,代码来源:BaseXmlEditorExtension.cs
示例15: InitTracker
void InitTracker ()
{
stateTracker = new DocumentStateTracker<CIndentEngine> (new CIndentEngine (policy), textEditorData);
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:4,代码来源:CTextEditorIndentation.cs
示例16: FixLineStart
public static bool FixLineStart (TextEditorData textEditorData, DocumentStateTracker<CSharpIndentEngine> stateTracker, int lineNumber)
{
if (lineNumber > DocumentLocation.MinLine) {
DocumentLine line = textEditorData.Document.GetLine (lineNumber);
if (line == null)
return false;
DocumentLine prevLine = textEditorData.Document.GetLine (lineNumber - 1);
if (prevLine == null)
return false;
string trimmedPreviousLine = textEditorData.Document.GetTextAt (prevLine).TrimStart ();
//xml doc comments
//check previous line was a doc comment
//check there's a following line?
if (trimmedPreviousLine.StartsWith ("///", StringComparison.Ordinal)) {
if (textEditorData.GetTextAt (line.Offset, line.Length).TrimStart ().StartsWith ("///", StringComparison.Ordinal))
return false;
//check that the newline command actually inserted a newline
textEditorData.EnsureCaretIsNotVirtual ();
string nextLine = textEditorData.Document.GetTextAt (textEditorData.Document.GetLine (lineNumber + 1)).TrimStart ();
if (trimmedPreviousLine.Length > "///".Length || nextLine.StartsWith ("///", StringComparison.Ordinal)) {
var insertionPoint = line.Offset + line.GetIndentation (textEditorData.Document).Length;
textEditorData.Insert (insertionPoint, "/// ");
return true;
}
//multi-line comments
} else if (stateTracker.Engine.IsInsideMultiLineComment) {
if (textEditorData.GetTextAt (line.Offset, line.Length).TrimStart ().StartsWith ("*", StringComparison.Ordinal))
return false;
textEditorData.EnsureCaretIsNotVirtual ();
string commentPrefix = string.Empty;
if (trimmedPreviousLine.StartsWith ("* ", StringComparison.Ordinal)) {
commentPrefix = "* ";
} else if (trimmedPreviousLine.StartsWith ("/**", StringComparison.Ordinal) || trimmedPreviousLine.StartsWith ("/*", StringComparison.Ordinal)) {
commentPrefix = " * ";
} else if (trimmedPreviousLine.StartsWith ("*", StringComparison.Ordinal)) {
commentPrefix = "*";
}
int indentSize = line.GetIndentation (textEditorData.Document).Length;
var insertedText = prevLine.GetIndentation (textEditorData.Document) + commentPrefix;
textEditorData.Replace (line.Offset, indentSize, insertedText);
textEditorData.Caret.Offset = line.Offset + insertedText.Length;
return true;
} else if (stateTracker.Engine.IsInsideStringLiteral) {
var lexer = new CSharpCompletionEngineBase.MiniLexer (textEditorData.Document.GetTextAt (0, prevLine.EndOffset));
lexer.Parse ();
if (!lexer.IsInString)
return false;
textEditorData.EnsureCaretIsNotVirtual ();
textEditorData.Insert (prevLine.Offset + prevLine.Length, "\" +");
int indentSize = line.GetIndentation (textEditorData.Document).Length;
var insertedText = prevLine.GetIndentation (textEditorData.Document) + (trimmedPreviousLine.StartsWith ("\"", StringComparison.Ordinal) ? "" : "\t") + "\"";
textEditorData.Replace (line.Offset, indentSize, insertedText);
return true;
}
}
return false;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:62,代码来源:CSharpTextEditorIndentation.cs
示例17: DIndentationTracker
public DIndentationTracker(Mono.TextEditor.TextEditorData data, DocumentStateTracker<DIndentEngine> stateTracker)
{
this.data = data;
this.stateTracker = stateTracker;
}
开发者ID:simendsjo,项目名称:Mono-D,代码行数:5,代码来源:DIndentationTracker.cs
示例18: Initialize
protected override void Initialize ()
{
base.Initialize ();
// Delay the execution of UpdateOwnerProjects since it may end calling Document.AttachToProject,
// which shouldn't be called while the extension chain is being initialized.
// TODO: Move handling of owner projects to Document
Application.Invoke (delegate {
UpdateOwnerProjects ();
});
var parser = new XmlParser (CreateRootState (), false);
tracker = new DocumentStateTracker<XmlParser> (parser, Editor);
DocumentContext.DocumentParsed += UpdateParsedDocument;
Editor.CaretPositionChanged += HandleCaretPositionChanged;
if (DocumentContext.ParsedDocument != null) {
lastCU = DocumentContext.ParsedDocument;
OnParsedDocumentUpdated ();
}
if (IdeApp.Workspace != null) {
IdeApp.Workspace.FileAddedToProject += HandleProjectChanged;
IdeApp.Workspace.FileRemovedFromProject += HandleProjectChanged;
}
}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:26,代码来源:BaseXmlEditorExtension.cs
示例19: Dispose
public override void Dispose ()
{
if (tracker != null) {
tracker = null;
MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParsedDocumentUpdated
-= OnParseInformationChanged;
base.Dispose ();
}
}
开发者ID:nickname100,项目名称:monodevelop,代码行数:9,代码来源:BaseXmlEditorExtension.cs
示例20: Dispose
public override void Dispose ()
{
if (tracker != null) {
tracker = null;
base.Dispose ();
}
}
开发者ID:fedorw,项目名称:monodevelop,代码行数:7,代码来源:BaseXmlEditorExtension.cs
注:本文中的DocumentStateTracker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论