本文整理汇总了C#中IDocument类的典型用法代码示例。如果您正苦于以下问题:C# IDocument类的具体用法?C# IDocument怎么用?C# IDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDocument类属于命名空间,在下文中一共展示了IDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchBracket
public BracketSearchResult SearchBracket(IDocument document, int offset)
{
if (offset > 0)
{
char c = document.GetCharAt(offset - 1);
int index = OpeningBrackets.IndexOf(c);
int otherOffset = -1;
if (index > -1)
otherOffset = SearchBracketForward(document, offset, OpeningBrackets[index], ClosingBrackets[index]);
index = ClosingBrackets.IndexOf(c);
if (index > -1)
otherOffset = SearchBracketBackward(document, offset - 2, OpeningBrackets[index], ClosingBrackets[index]);
if (otherOffset > -1)
{
var result = new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1,
Math.Max(offset - 1, otherOffset), 1);
SearchDefinition(document, result);
return result;
}
}
return null;
}
示例2: PrepareCompletionDocument
private static IDocument PrepareCompletionDocument(IDocument document, ref int offset, string usings = null, string variables = null)
{
if (String.IsNullOrEmpty(document.FileName))
return document;
//if the code is just a script it it will contain no namestpace, class and method structure and so the code completion will not work properly
// for it to work we have to suround the code with the appropriate code structure
//we only process the file if its a .csx file
var fileExtension = Path.GetExtension(document.FileName);
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(document.FileName);
if (String.IsNullOrEmpty(fileExtension) || String.IsNullOrEmpty(fileNameWithoutExtension))
return document;
if (fileExtension.ToLower() == ".csx")
{
string classname = replaceRegex.Replace(fileNameWithoutExtension, "");
classname = classname.TrimStart('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
string header = String.Empty;
header += (usings ?? "") + Environment.NewLine;
header += "public static class " + classname + " {" + Environment.NewLine;
header += "public static void Main() {" + Environment.NewLine;
header += (variables ?? "") + Environment.NewLine;
string footer = "}" + Environment.NewLine + "}" + Environment.NewLine;
string code = header + document.Text + Environment.NewLine + footer;
offset += header.Length;
return new ReadOnlyDocument(new StringTextSource(code), document.FileName);
}
return document;
}
示例3: ManageUsings
public static void ManageUsings(Gui.IProgressMonitor progressMonitor, string fileName, IDocument document, bool sort, bool removedUnused)
{
ParseInformation info = ParserService.ParseFile(fileName, document.TextContent);
if (info == null) return;
ICompilationUnit cu = info.MostRecentCompilationUnit;
List<IUsing> newUsings = new List<IUsing>(cu.UsingScope.Usings);
if (sort) {
newUsings.Sort(CompareUsings);
}
if (removedUnused) {
IList<IUsing> decl = cu.ProjectContent.Language.RefactoringProvider.FindUnusedUsingDeclarations(Gui.DomProgressMonitor.Wrap(progressMonitor), fileName, document.TextContent, cu);
if (decl != null && decl.Count > 0) {
foreach (IUsing u in decl) {
string ns = null;
for (int i = 0; i < u.Usings.Count; i++) {
ns = u.Usings[i];
if (ns == "System") break;
}
if (ns != "System") { // never remove "using System;"
newUsings.Remove(u);
}
}
}
}
// put empty line after last System namespace
if (sort) {
PutEmptyLineAfterLastSystemNamespace(newUsings);
}
cu.ProjectContent.Language.CodeGenerator.ReplaceUsings(new TextEditorDocument(document), cu.UsingScope.Usings, newUsings);
}
示例4: TryExtendSelectionToComments
static Selection TryExtendSelectionToComments(IDocument document, Selection selection, IList<ISpecial> commentsBlankLines)
{
var extendedToComments = ExtendSelectionToComments(document, selection, commentsBlankLines);
if (extendedToComments != null)
return extendedToComments;
return selection;
}
示例5: Initialize
public void Initialize(IDocument document)
{
if (changeList != null && changeList.Any())
return;
this.document = document;
this.textDocument = (TextDocument)document.GetService(typeof(TextDocument));
this.changeList = new CompressingTreeList<LineChangeInfo>((x, y) => x.Equals(y));
Stream baseFileStream = GetBaseVersion();
// TODO : update baseDocument on VCS actions
if (baseFileStream != null) {
// ReadAll() is taking care of closing the stream
baseDocument = DocumentUtilitites.LoadReadOnlyDocumentFromBuffer(new StringTextBuffer(ReadAll(baseFileStream)));
} else {
if (baseDocument == null) {
// if the file is not under subversion, the document is the opened document
var doc = new TextDocument(textDocument.Text);
baseDocument = new AvalonEditDocumentAdapter(doc, null);
}
}
SetupInitialFileState(false);
this.textDocument.LineTrackers.Add(this);
this.textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged;
}
示例6: SearchBracketBackward
static int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
char ch;
int brackets = -1;
for (int i = offset; i > 0; --i) {
ch = document.GetCharAt(i);
if (ch == openBracket && !inString) {
++brackets;
if (brackets == 0) return i;
} else if (ch == closingBracket && !inString) {
--brackets;
} else if (ch == '"') {
inString = !inString;
} else if (ch == '\n') {
int lineStart = ScanLineStart(document, i);
if (lineStart >= 0) { // line could have a comment
inString = false;
for (int j = lineStart; j < i; ++j) {
ch = document.GetCharAt(j);
if (ch == '"') inString = !inString;
if (ch == '\'' && !inString) {
// comment found!
// Skip searching in the comment:
i = j;
break;
}
}
}
inString = false;
}
}
return -1;
}
示例7: Row
/// <summary>
/// Initializes a new instance of the <see cref="Row"/> class.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="node">The node.</param>
public Row(IDocument document, XmlNode node)
{
this.Document = document;
this.Node = node;
this.InitStandards();
}
示例8: TableEditor
/// <summary>
/// Constructs and initializes editor.
/// </summary>
/// <param name="document">Reference to document object.</param>
public TableEditor(IDocument document)
: base(document)
{
if (!(document is TableDocument))
throw new ArgumentException(
Resources.Error_UnsupportedDocument,
"document");
InitializeComponent();
// Set columns grid databindings
InitializeColumnsGridDatabindings();
// Change advanced columns grid properties
AdjustColumnsGridStyle();
// Initialize column details tab
InitColumnDetails();
// Initialize foreign keys tab
foreignKeysEdit.Document = Document;
// Initialize indexes tab
indexesEdit.Document = Document;
}
示例9: FixSpellingCodeAction
public FixSpellingCodeAction(IDocument document, CommonSyntaxNode syntaxNode, string oldIdentifier, string newIdentifier)
{
this.Document = document;
this.Node = syntaxNode;
this.OldIdentifier = oldIdentifier;
this.NewIdentifier = newIdentifier;
}
示例10: ClassifyNode
public IEnumerable<SyntaxClassification> ClassifyNode(IDocument document, CommonSyntaxNode syntax, CancellationToken cancellationToken)
{
// If this node is a field declaration, return syntax classifications for the
// identifier token of each field name.
//
// For example, "x" and "y" would be classified in the following code:
//
// class C
// {
// int x, y;
// }
if (syntax is FieldDeclarationSyntax)
{
var field = (FieldDeclarationSyntax)syntax;
return from v in field.Declaration.Variables
select new SyntaxClassification(v.Identifier.Span, fieldClassification);
}
// If this node is an identifier, use the binding API to retrieve its symbol and return a
// syntax classification for the node if that symbol is a field.
if (syntax is IdentifierNameSyntax)
{
var semanticModel = document.GetSemanticModel(cancellationToken);
var symbol = semanticModel.GetSemanticInfo(syntax).Symbol;
if (symbol != null && symbol.Kind == CommonSymbolKind.Field)
{
return new[] { new SyntaxClassification(syntax.Span, fieldClassification) };
}
}
return null;
}
示例11: Paste
/// <exception cref="ArgumentNullException">
/// <paramref name="document"/> is null.
/// </exception>
public static void Paste(IDocument document)
{
if (document == null)
throw new ArgumentNullException("document");
item.Paste(document);
}
示例12: CreateHtmlFragment
/// <summary>
/// Creates a HTML fragment from a part of a document.
/// </summary>
/// <param name="document">The document to create HTML from.</param>
/// <param name="highlighter">The highlighter used to highlight the document. <c>null</c> is valid and will create HTML without any highlighting.</param>
/// <param name="segment">The part of the document to create HTML for. You can pass <c>null</c> to create HTML for the whole document.</param>
/// <param name="options">The options for the HTML creation.</param>
/// <returns>HTML code for the document part.</returns>
public static string CreateHtmlFragment(IDocument document, IHighlighter highlighter, ISegment segment, HtmlOptions options)
{
if (document == null)
throw new ArgumentNullException("document");
if (options == null)
throw new ArgumentNullException("options");
if (highlighter != null && highlighter.Document != document)
throw new ArgumentException("Highlighter does not belong to the specified document.");
if (segment == null)
segment = new SimpleSegment(0, document.TextLength);
StringBuilder html = new StringBuilder();
int segmentEndOffset = segment.EndOffset;
IDocumentLine line = document.GetLineByOffset(segment.Offset);
while (line != null && line.Offset < segmentEndOffset) {
HighlightedLine highlightedLine;
if (highlighter != null)
highlightedLine = highlighter.HighlightLine(line.LineNumber);
else
highlightedLine = new HighlightedLine(document, line);
SimpleSegment s = SimpleSegment.GetOverlap(segment, line);
if (html.Length > 0)
html.AppendLine("<br>");
html.Append(highlightedLine.ToHtml(s.Offset, s.EndOffset, options));
line = line.NextLine;
}
return html.ToString();
}
示例13: CheckCondition
protected override ICodeIssueComputer CheckCondition(IDocument before, IDocument after,
IManualExtractMethodRefactoring input)
{
// Calculate the outflow data
IEnumerable<ISymbol> flowOuts;
if (input.ExtractedStatements != null)
flowOuts = GetFlowOutData(input.ExtractedStatements, before);
else
flowOuts = GetFlowOutData(input.ExtractedExpression, before);
// Get the returning data of the return statements.
var delaration = input.ExtractedMethodDeclaration;
var methodAnalyzer = AnalyzerFactory.GetMethodDeclarationAnalyzer();
methodAnalyzer.SetMethodDeclaration(delaration);
// Get the returning data in the return statements of the extracted method, also log them.
var returningData = GetMethodReturningData(methodAnalyzer, after);
// Missing symbols that are in the flow out before but not in the returning data.
// Remove this symbol.
var missing = ConditionCheckersUtils.RemoveThisSymbol(
ConditionCheckersUtils.GetSymbolListExceptByName(flowOuts, returningData));
if (missing.Any())
{
return new ReturnTypeCheckingResult(input.ExtractedMethodDeclaration,
ConditionCheckersUtils.GetTypeNameTuples(missing));
}
return new NullCodeIssueComputer();
}
示例14: ProcessResponseAsync
protected override async Task ProcessResponseAsync(IResponse response)
{
var context = new BrowsingContext(_parentDocument.Context, Sandboxes.None);
var options = new CreateDocumentOptions(response, _configuration, _parentDocument);
var factory = _configuration.GetFactory<IDocumentFactory>();
ChildDocument = await factory.CreateAsync(context, options, CancellationToken.None).ConfigureAwait(false);
}
示例15: Render
public RenderInfo Render(IDocument document)
{
return new RenderInfo {
PartialViewName = "Body",
Model = document.Body
};
}