~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputFormatter.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// <file>
2
 
//     <copyright see="prj:///doc/copyright.txt"/>
3
 
//     <license see="prj:///doc/license.txt"/>
4
 
//     <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
5
 
//     <version>$Revision: 4482 $</version>
6
 
// </file>
7
 
 
8
 
using System;
9
 
using ICSharpCode.OldNRefactory.Parser.VB;
10
 
 
11
 
namespace ICSharpCode.OldNRefactory.PrettyPrinter
12
 
{
13
 
        /// <summary>
14
 
        /// Description of VBNetOutputFormatter.
15
 
        /// </summary>
16
 
        public sealed class VBNetOutputFormatter : AbstractOutputFormatter
17
 
        {
18
 
                public VBNetOutputFormatter(VBNetPrettyPrintOptions prettyPrintOptions) : base(prettyPrintOptions)
19
 
                {
20
 
                }
21
 
                
22
 
                public override void PrintToken(int token)
23
 
                {
24
 
                        PrintText(Tokens.GetTokenString(token));
25
 
                }
26
 
                
27
 
                public override void PrintIdentifier(string identifier)
28
 
                {
29
 
                        if (Keywords.IsNonIdentifierKeyword(identifier)) {
30
 
                                PrintText("[");
31
 
                                PrintText(identifier);
32
 
                                PrintText("]");
33
 
                        } else {
34
 
                                PrintText(identifier);
35
 
                        }
36
 
                }
37
 
                
38
 
                public override void PrintComment(Comment comment, bool forceWriteInPreviousBlock)
39
 
                {
40
 
                        switch (comment.CommentType) {
41
 
                                case CommentType.Block:
42
 
                                        WriteLineInPreviousLine("'" + comment.CommentText.Replace("\n", "\n'"), forceWriteInPreviousBlock);
43
 
                                        break;
44
 
                                case CommentType.Documentation:
45
 
                                        WriteLineInPreviousLine("'''" + comment.CommentText, forceWriteInPreviousBlock);
46
 
                                        break;
47
 
                                default:
48
 
                                        WriteLineInPreviousLine("'" + comment.CommentText, forceWriteInPreviousBlock);
49
 
                                        break;
50
 
                        }
51
 
                }
52
 
                
53
 
                public override void PrintPreprocessingDirective(PreprocessingDirective directive, bool forceWriteInPreviousBlock)
54
 
                {
55
 
                        if (IsInMemberBody
56
 
                            && (string.Equals(directive.Cmd, "#Region", StringComparison.InvariantCultureIgnoreCase)
57
 
                                || string.Equals(directive.Cmd, "#End", StringComparison.InvariantCultureIgnoreCase)
58
 
                                && directive.Arg.StartsWith("Region", StringComparison.InvariantCultureIgnoreCase)))
59
 
                        {
60
 
                                WriteLineInPreviousLine("'" + directive.Cmd + " " + directive.Arg, forceWriteInPreviousBlock);
61
 
                        } else if (!directive.Expression.IsNull) {
62
 
                                VBNetOutputVisitor visitor = new VBNetOutputVisitor();
63
 
                                directive.Expression.AcceptVisitor(visitor, null);
64
 
                                WriteLineInPreviousLine(directive.Cmd + " " + visitor.Text + " Then", forceWriteInPreviousBlock);
65
 
                        } else {
66
 
                                base.PrintPreprocessingDirective(directive, forceWriteInPreviousBlock);
67
 
                        }
68
 
                }
69
 
                
70
 
                public void PrintLineContinuation()
71
 
                {
72
 
                        if (!LastCharacterIsWhiteSpace)
73
 
                                Space();
74
 
                        PrintText("_" + Environment.NewLine);
75
 
                }
76
 
        }
77
 
}