本文整理汇总了C#中ICSharpFile.IsPhysical方法的典型用法代码示例。如果您正苦于以下问题:C# ICSharpFile.IsPhysical方法的具体用法?C# ICSharpFile.IsPhysical怎么用?C# ICSharpFile.IsPhysical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpFile
的用法示例。
在下文中一共展示了ICSharpFile.IsPhysical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwapFileHeaderNode
private static void SwapFileHeaderNode(ICSharpFile file, string newHeader)
{
ITreeRange existingHeaderRange = Utils.GetFileHeaderTreeRange(file);
using (WriteLockCookie.Create(file.IsPhysical()))
{
ICommentNode newCommentNode;
if (existingHeaderRange.IsEmpty)
{
// existing header missing so add on a new line for our new header
newHeader += Environment.NewLine;
IWhitespaceNode node = file.FirstChild as IWhitespaceNode;
bool insertNewLine = true;
while (node != null)
{
if (node.IsNewLine)
{
insertNewLine = false;
break;
}
node = node.NextSibling as IWhitespaceNode;
}
if (insertNewLine)
{
newHeader += Environment.NewLine;
}
newCommentNode =
(ICommentNode)
CSharpTokenType.END_OF_LINE_COMMENT.Create(new JB::JetBrains.Text.StringBuffer(newHeader), new TreeOffset(0), new TreeOffset(newHeader.Length));
LowLevelModificationUtil.AddChildBefore(file.FirstChild, new ITreeNode[] { newCommentNode });
}
else
{
ITokenNode lastToken = (ITokenNode)existingHeaderRange.Last;
ITokenNode nextToken = lastToken.GetNextToken();
if (nextToken != null)
{
ITokenNode nextNextToken = nextToken.GetNextToken();
if (nextNextToken != null)
{
ITokenNode nextNextNextToken = nextNextToken.GetNextToken();
if (!nextToken.IsNewLine() || !nextNextToken.IsNewLine())
{
newHeader += Environment.NewLine;
}
if (nextNextNextToken.GetTokenType() == CSharpTokenType.PP_SHARP && nextToken.IsNewLine() && nextNextToken.IsNewLine())
{
newHeader += Environment.NewLine;
}
newCommentNode =
(ICommentNode)
CSharpTokenType.END_OF_LINE_COMMENT.Create(
new JB::JetBrains.Text.StringBuffer(newHeader), new TreeOffset(0), new TreeOffset(newHeader.Length));
LowLevelModificationUtil.ReplaceChildRange(existingHeaderRange.First, existingHeaderRange.Last, new ITreeNode[] { newCommentNode });
}
}
}
}
}