本文整理汇总了C#中Mono.CSharp.CompilerCompilationUnit类的典型用法代码示例。如果您正苦于以下问题:C# CompilerCompilationUnit类的具体用法?C# CompilerCompilationUnit怎么用?C# CompilerCompilationUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilerCompilationUnit类属于Mono.CSharp命名空间,在下文中一共展示了CompilerCompilationUnit类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertComments
static void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
var leaf = GetOuterLeft (conversionVisitor.Unit);
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var special = top.SpecialsBag.Specials [i];
AstNode newLeaf = null;
var comment = special as SpecialsBag.Comment;
if (comment != null) {
// HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
bool isMultilineDocumentationComment = (
comment.CommentType == SpecialsBag.CommentType.Multi
&& comment.Content.StartsWith("*", StringComparison.Ordinal)
&& !comment.Content.StartsWith("**", StringComparison.Ordinal)
);
if (conversionVisitor.convertTypeSystemMode && !(comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment))
continue;
var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
var start = new TextLocation (comment.Line, comment.Col);
var end = new TextLocation (comment.EndLine, comment.EndCol);
newLeaf = new Comment (type, start, end) {
StartsLine = comment.StartsLine,
Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
};
} else {
var directive = special as SpecialsBag.PreProcessorDirective;
if (directive != null) {
newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
Argument = directive.Arg,
Take = directive.Take
};
} else {
/* var newLine = special as SpecialsBag.NewLineToken;
if (newLine != null) {
if (newLine.NewLine == SpecialsBag.NewLine.Unix) {
newLeaf = new UnixNewLine (new TextLocation (newLine.Line, newLine.Col));
} else {
newLeaf = new WindowsNewLine (new TextLocation (newLine.Line, newLine.Col));
}
}*/
}
}
if (newLeaf == null)
continue;
while (true) {
var nextLeaf = NextLeaf (leaf);
// insert comment at begin
if (newLeaf.StartLocation < leaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
while (node.Parent != null && node.FirstChild == leaf) {
leaf = node;
node = node.Parent;
}
if (newLeaf is NewLineNode) {
node.InsertChildBefore (leaf, (NewLineNode)newLeaf, Roles.NewLine);
} else if (newLeaf is Comment) {
node.InsertChildBefore (leaf, (Comment)newLeaf, Roles.Comment);
} else {
node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
// insert comment at the end
if (nextLeaf == null) {
var node = leaf.Parent ?? conversionVisitor.Unit;
if (newLeaf is NewLineNode) {
node.AddChild ((NewLineNode)newLeaf, Roles.NewLine);
} else if (newLeaf is Comment) {
node.AddChild ((Comment)newLeaf, Roles.Comment);
} else {
node.AddChild ((PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
// comment is between 2 nodes
if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
if (newLeaf is NewLineNode) {
node.InsertChildAfter (leaf, (NewLineNode)newLeaf, Roles.NewLine);
} else if (newLeaf is Comment) {
node.InsertChildAfter (leaf, (Comment)newLeaf, Roles.Comment);
} else {
node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
leaf = nextLeaf;
}
}
}
示例2: InsertComments
void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
AstNode insertionPoint = conversionVisitor.Unit.FirstChild;
foreach (var special in top.SpecialsBag.Specials) {
AstNode newLeaf = null;
Role role = null;
bool isDocumentationComment = false;
var comment = special as SpecialsBag.Comment;
if (comment != null) {
// HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
bool isMultilineDocumentationComment = (comment.CommentType == SpecialsBag.CommentType.Multi && comment.Content.StartsWith("*", StringComparison.Ordinal) && !comment.Content.StartsWith("**", StringComparison.Ordinal));
isDocumentationComment = comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment;
if (conversionVisitor.convertTypeSystemMode && !isDocumentationComment)
continue;
var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
var start = new TextLocation(comment.Line, comment.Col);
var end = new TextLocation(comment.EndLine, comment.EndCol);
newLeaf = new Comment(type, start, end) {
StartsLine = comment.StartsLine,
Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
};
role = Roles.Comment;
} else if (!GenerateTypeSystemMode) {
var pragmaDirective = special as SpecialsBag.PragmaPreProcessorDirective;
if (pragmaDirective != null) {
var pragma = new PragmaWarningPreprocessorDirective(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), new TextLocation(pragmaDirective.EndLine, pragmaDirective.EndCol));
pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), PragmaWarningPreprocessorDirective.PragmaKeywordRole), PragmaWarningPreprocessorDirective.PragmaKeywordRole);
pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.WarningColumn), PragmaWarningPreprocessorDirective.WarningKeywordRole), PragmaWarningPreprocessorDirective.WarningKeywordRole);
var pragmaRole = pragmaDirective.Disalbe ? PragmaWarningPreprocessorDirective.DisableKeywordRole : PragmaWarningPreprocessorDirective.RestoreKeywordRole;
pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.DisableRestoreColumn), pragmaRole), pragmaRole);
foreach (var code in pragmaDirective.Codes) {
pragma.AddChild((PrimitiveExpression)conversionVisitor.Visit(code), PragmaWarningPreprocessorDirective.WarningRole);
}
newLeaf = pragma;
role = Roles.PreProcessorDirective;
goto end;
}
var lineDirective = special as SpecialsBag.LineProcessorDirective;
if (lineDirective != null) {
var pragma = new LinePreprocessorDirective(new TextLocation(lineDirective.Line, lineDirective.Col), new TextLocation(lineDirective.EndLine, lineDirective.EndCol));
pragma.LineNumber = lineDirective.LineNumber;
pragma.FileName = lineDirective.FileName;
newLeaf = pragma;
role = Roles.PreProcessorDirective;
goto end;
}
var directive = special as SpecialsBag.PreProcessorDirective;
if (directive != null) {
newLeaf = new PreProcessorDirective((PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation(directive.Line, directive.Col), new TextLocation(directive.EndLine, directive.EndCol)) {
Argument = directive.Arg,
Take = directive.Take
};
role = Roles.PreProcessorDirective;
}
end:
;
}
if (newLeaf != null) {
InsertComment(ref insertionPoint, newLeaf, role, isDocumentationComment, conversionVisitor.Unit);
}
}
if (!GenerateTypeSystemMode) {
// We cannot insert newlines in the same loop as comments/preprocessor directives
// because they are not correctly ordered in the specials bag
insertionPoint = conversionVisitor.Unit.FirstChild;
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var newLine = top.SpecialsBag.Specials [i] as SpecialsBag.NewLineToken;
if (newLine != null) {
var newLeaf = new NewLineNode(new TextLocation(newLine.Line, newLine.Col + 1));
newLeaf.NewLineType = newLine.NewLine == SpecialsBag.NewLine.Unix ? UnicodeNewline.LF : UnicodeNewline.CRLF;
InsertComment(ref insertionPoint, newLeaf, Roles.NewLine, false, conversionVisitor.Unit);
}
}
}
}
示例3: Parse
public CompilationUnit Parse (CompilerCompilationUnit top, string fileName, int lineModifier = 0)
{
if (top == null)
return null;
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (GenerateTypeSystemMode, top.LocationsBag);
top.UsingsBag.Global.Accept (conversionVisitor);
conversionVisitor.AddAttributeSection (conversionVisitor.Unit, top.ModuleCompiled);
InsertComments (top, conversionVisitor);
if (CompilationUnitCallback != null)
CompilationUnitCallback (top);
if (lineModifier != 0)
AdjustLineLocations (conversionVisitor.Unit, lineModifier);
if (top.LastYYValue is Mono.CSharp.Expression)
conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept (conversionVisitor) as AstNode;
conversionVisitor.Unit.FileName = fileName;
return conversionVisitor.Unit;
}
示例4: Parse
/// <summary>
/// Converts a Mono.CSharp syntax tree into an NRefactory syntax tree.
/// </summary>
public SyntaxTree Parse(CompilerCompilationUnit top, string fileName)
{
if (top == null) {
return null;
}
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (GenerateTypeSystemMode, top.LocationsBag);
top.ModuleCompiled.Accept(conversionVisitor);
InsertComments(top, conversionVisitor);
if (CompilationUnitCallback != null) {
CompilationUnitCallback(top);
}
if (top.LastYYValue is Mono.CSharp.Expression) {
conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept(conversionVisitor) as AstNode;
}
conversionVisitor.Unit.FileName = fileName;
conversionVisitor.Unit.ConditionalSymbols = top.Conditionals.Concat (compilerSettings.ConditionalSymbols).ToArray ();
return conversionVisitor.Unit;
}
示例5: InsertComments
static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
var leaf = GetOuterLeft (conversionVisitor.Unit);
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var special = top.SpecialsBag.Specials [i];
AstNode newLeaf = null;
var comment = special as SpecialsBag.Comment;
if (comment != null) {
if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation))
continue;
var type = (CommentType)comment.CommentType;
var start = new TextLocation (comment.Line, comment.Col);
var end = new TextLocation (comment.EndLine, comment.EndCol);
newLeaf = new Comment (type, start, end) {
StartsLine = comment.StartsLine,
Content = comment.Content
};
} else {
var directive = special as SpecialsBag.PreProcessorDirective;
if (directive != null) {
newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
Argument = directive.Arg,
Take = directive.Take
};
}
}
if (newLeaf == null)
continue;
while (true) {
var nextLeaf = NextLeaf (leaf);
// insert comment at begin
if (newLeaf.StartLocation < leaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
while (node.Parent != null && node.FirstChild == leaf) {
leaf = node;
node = node.Parent;
}
if (newLeaf is Comment) {
node.InsertChildBefore (leaf, (Comment)newLeaf, AstNode.Roles.Comment);
} else {
node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
// insert comment at the end
if (nextLeaf == null) {
var node = leaf.Parent ?? conversionVisitor.Unit;
if (newLeaf is Comment) {
node.AddChild ((Comment)newLeaf, AstNode.Roles.Comment);
} else {
node.AddChild ((PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
// comment is between 2 nodes
if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
if (newLeaf is Comment) {
node.InsertChildAfter (leaf, (Comment)newLeaf, AstNode.Roles.Comment);
} else {
node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
}
leaf = newLeaf;
break;
}
leaf = nextLeaf;
}
}
}
示例6: Parse
public CompilationUnit Parse(CompilerCompilationUnit top, string fileName, int lineModifier = 0)
{
if (top == null) {
return null;
}
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (GenerateTypeSystemMode, top.LocationsBag);
top.ModuleCompiled.Accept(conversionVisitor);
InsertComments(top, conversionVisitor);
if (CompilationUnitCallback != null) {
CompilationUnitCallback(top);
}
if (top.LastYYValue is Mono.CSharp.Expression) {
conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept(conversionVisitor) as AstNode;
}
conversionVisitor.Unit.FileName = fileName;
return conversionVisitor.Unit;
}
示例7: Parse
public CompilationUnit Parse (CompilerCompilationUnit top, int line)
{
if (top == null)
return null;
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag);
conversionVisitor.AddAttributeSection (conversionVisitor.Unit, top.ModuleCompiled);
top.UsingsBag.Global.Accept (conversionVisitor);
InsertComments (top, conversionVisitor);
if (line != 0)
AdjustLineLocations (conversionVisitor.Unit, line);
return conversionVisitor.Unit;
}
示例8: InsertComments
static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
var leaf = GetOuterLeft(conversionVisitor.Unit);
foreach (var special in top.SpecialsBag.Specials) {
var comment = special as SpecialsBag.Comment;
if (comment == null)
continue;
if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation))
continue;
var type = (CommentType)comment.CommentType;
var start = new AstLocation (comment.Line, comment.Col);
var end = new AstLocation (comment.EndLine, comment.EndCol);
var domComment = new Comment (type, start, end);
domComment.StartsLine = comment.StartsLine;
domComment.Content = comment.Content;
while (true) {
var nextLeaf = NextLeaf(leaf);
// instert comment at the end
if (nextLeaf == null) {
var node = leaf.Parent ?? conversionVisitor.Unit;
node.AddChild(domComment, AstNode.Roles.Comment);
leaf = domComment;
break;
}
// comment is between 2 nodes
if (leaf.EndLocation <= domComment.StartLocation && domComment.StartLocation <= nextLeaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
node.InsertChildAfter(leaf, domComment, AstNode.Roles.Comment);
leaf = domComment;
break;
}
leaf = nextLeaf;
}
}
}
示例9: InsertComments
static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
var leaf = GetOuterLeft (conversionVisitor.Unit);
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var special = top.SpecialsBag.Specials [i];
Comment newLeaf = null;
var comment = special as SpecialsBag.Comment;
if (comment != null) {
if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation))
continue;
var type = (CommentType)comment.CommentType;
var start = new AstLocation (comment.Line, comment.Col);
var end = new AstLocation (comment.EndLine, comment.EndCol);
newLeaf = new Comment (type, start, end) {
StartsLine = comment.StartsLine,
Content = comment.Content
};
} else {
// TODO: Proper handling of pre processor directives (atm got treated as comments Ast wise)
var directive = special as SpecialsBag.PreProcessorDirective;
if (directive != null) {
newLeaf = new Comment (CommentType.SingleLine, new AstLocation (directive.Line, directive.Col), new AstLocation (directive.EndLine, directive.EndCol + 1));
if (!directive.Take) {
SpecialsBag.PreProcessorDirective endif = null;
int endifLevel = 0;
for (int j = i + 1; j < top.SpecialsBag.Specials.Count; j++) {
var s = top.SpecialsBag.Specials [j] as SpecialsBag.PreProcessorDirective;
if (s == null)
continue;
if (s.Cmd == Tokenizer.PreprocessorDirective.If) {
endifLevel++;
continue;
}
if (s.Cmd == Tokenizer.PreprocessorDirective.Endif || endifLevel == 0 && s.Cmd == Tokenizer.PreprocessorDirective.Else) {
if (endifLevel == 0) {
endif = s;
i = j;
break;
}
endifLevel--;
}
}
if (endif != null)
newLeaf = new Comment (CommentType.SingleLine, new AstLocation (directive.Line, directive.Col), new AstLocation (endif.EndLine, endif.EndCol));
}
}
}
if (newLeaf == null)
continue;
while (true) {
var nextLeaf = NextLeaf (leaf);
// insert comment at begin
if (newLeaf.StartLocation < leaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
while (node.Parent != null && node.FirstChild == leaf) {
leaf = node;
node = node.Parent;
}
node.InsertChildBefore (leaf, newLeaf, AstNode.Roles.Comment);
leaf = newLeaf;
break;
}
// insert comment at the end
if (nextLeaf == null) {
var node = leaf.Parent ?? conversionVisitor.Unit;
node.AddChild (newLeaf, AstNode.Roles.Comment);
leaf = newLeaf;
break;
}
// comment is between 2 nodes
if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) {
var node = leaf.Parent ?? conversionVisitor.Unit;
node.InsertChildAfter (leaf, newLeaf, AstNode.Roles.Comment);
leaf = newLeaf;
break;
}
leaf = nextLeaf;
}
}
}
示例10: Parse
internal static MonoDevelop.CSharp.Ast.CompilationUnit Parse (CompilerCompilationUnit top)
{
if (top == null)
return null;
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag);
top.UsingsBag.Global.Accept (conversionVisitor);
foreach (var special in top.SpecialsBag.Specials) {
var comment = special as SpecialsBag.Comment;
if (comment != null) {
var type = (MonoDevelop.CSharp.Ast.CommentType)comment.CommentType;
var start = new DomLocation (comment.Line, comment.Col);
var end = new DomLocation (comment.EndLine, comment.EndCol);
var domComment = new MonoDevelop.CSharp.Ast.Comment (type, start, end);
domComment.StartsLine = comment.StartsLine;
domComment.Content = comment.Content;
InsertComment (conversionVisitor.Unit, domComment);
}
}
return conversionVisitor.Unit;
}
示例11: InsertComments
void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
foreach (var special in top.SpecialsBag.Specials) {
var comment = special as SpecialsBag.Comment;
if (comment != null) {
var type = (CommentType)comment.CommentType;
var start = new AstLocation (comment.Line, comment.Col);
var end = new AstLocation (comment.EndLine, comment.EndCol);
var domComment = new Comment (type, start, end);
domComment.StartsLine = comment.StartsLine;
domComment.Content = comment.Content;
InsertComment (conversionVisitor.Unit, domComment);
}
}
}
示例12: Parse
internal static CompilationUnit Parse (CompilerCompilationUnit top)
{
if (top == null)
return null;
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag);
top.UsingsBag.Global.Accept (conversionVisitor);
InsertComments (top, conversionVisitor);
return conversionVisitor.Unit;
}
示例13: Parse
/// <summary>
/// Converts a Mono.CSharp syntax tree into an NRefactory syntax tree.
/// </summary>
public SyntaxTree Parse(CompilerCompilationUnit top, string fileName)
{
if (top == null) {
return null;
}
CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor(GenerateTypeSystemMode, top.LocationsBag);
top.ModuleCompiled.Accept(conversionVisitor);
InsertComments(top, conversionVisitor);
if (CompilationUnitCallback != null) {
CompilationUnitCallback(top);
}
var expr = top.LastYYValue as Mono.CSharp.Expression;
if (expr != null)
conversionVisitor.Unit.TopExpression = expr.Accept(conversionVisitor) as AstNode;
conversionVisitor.Unit.FileName = fileName;
var conditionals = new List<string>();
foreach (var settings in compilerSettings.ConditionalSymbols) {
if (top.Conditionals.ContainsKey(settings) && !top.Conditionals [settings])
continue;
conditionals.Add(settings);
}
foreach (var kv in top.Conditionals) {
if (!kv.Value || compilerSettings.ConditionalSymbols.Contains(kv.Key))
continue;
conditionals.Add(kv.Key);
}
conversionVisitor.Unit.ConditionalSymbols = conditionals;
return conversionVisitor.Unit;
}
示例14: InsertComments
void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
{
AstNode insertionPoint = conversionVisitor.Unit.FirstChild;
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var special = top.SpecialsBag.Specials [i];
AstNode newLeaf = null;
Role role = null;
bool isDocumentationComment = false;
var comment = special as SpecialsBag.Comment;
if (comment != null) {
// HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
bool isMultilineDocumentationComment = (
comment.CommentType == SpecialsBag.CommentType.Multi
&& comment.Content.StartsWith("*", StringComparison.Ordinal)
&& !comment.Content.StartsWith("**", StringComparison.Ordinal)
);
isDocumentationComment = comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment;
if (conversionVisitor.convertTypeSystemMode && !isDocumentationComment)
continue;
var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
var start = new TextLocation (comment.Line, comment.Col);
var end = new TextLocation (comment.EndLine, comment.EndCol);
newLeaf = new Comment (type, start, end) {
StartsLine = comment.StartsLine,
Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
};
role = Roles.Comment;
} else if (!GenerateTypeSystemMode) {
var pragmaDirective = special as SpecialsBag.PragmaPreProcessorDirective;
if (pragmaDirective != null) {
var pragma = new PragmaWarningPreprocssorDirective(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), new TextLocation(pragmaDirective.EndLine, pragmaDirective.EndCol));
pragma.Disable = pragmaDirective.Disalbe;
pragma.AddWarnings(pragmaDirective.Codes);
newLeaf = pragma;
role = Roles.PreProcessorDirective;
} else {
var directive = special as SpecialsBag.PreProcessorDirective;
if (directive != null) {
newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
Argument = directive.Arg,
Take = directive.Take
};
role = Roles.PreProcessorDirective;
}
}
}
if (newLeaf != null) {
InsertComment(ref insertionPoint, newLeaf, role, isDocumentationComment, conversionVisitor.Unit);
}
}
if (!GenerateTypeSystemMode) {
// We cannot insert newlines in the same loop as comments/preprocessor directives
// because they are not correctly ordered in the specials bag
insertionPoint = conversionVisitor.Unit.FirstChild;
for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
var newLine = top.SpecialsBag.Specials[i] as SpecialsBag.NewLineToken;
if (newLine != null) {
AstNode newLeaf;
if (newLine.NewLine == SpecialsBag.NewLine.Unix) {
newLeaf = new UnixNewLine (new TextLocation (newLine.Line, newLine.Col + 1));
} else {
newLeaf = new WindowsNewLine (new TextLocation (newLine.Line, newLine.Col + 1));
}
InsertComment(ref insertionPoint, newLeaf, Roles.NewLine, false, conversionVisitor.Unit);
}
}
}
}