~ubuntu-branches/ubuntu/saucy/monodevelop/saucy

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Output/OutputSettings.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-05-27 18:08:20 UTC
  • mfrom: (1.8.5) (1.5.8 sid)
  • Revision ID: package-import@ubuntu.com-20120527180820-f1ub6lhg0s50wci1
Tags: 3.0.2+dfsg-3
* [fcecfe7] Fix monodevelop-core-addins.pc.in to point to actual 
  installed location of assemblies.
* [26e1a07] DebSrc 3.0 does not support Quilt's -p parameter, so 
  manually adjust the path in the patch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// OutputSettings.cs
2
 
//
3
 
// Author:
4
 
//   Mike Krüger <mkrueger@novell.com>
5
 
//
6
 
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
7
 
//
8
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
 
// of this software and associated documentation files (the "Software"), to deal
10
 
// in the Software without restriction, including without limitation the rights
11
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 
// copies of the Software, and to permit persons to whom the Software is
13
 
// furnished to do so, subject to the following conditions:
14
 
//
15
 
// The above copyright notice and this permission notice shall be included in
16
 
// all copies or substantial portions of the Software.
17
 
//
18
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 
// THE SOFTWARE.
25
 
//
26
 
 
27
 
using System;
28
 
using System.Text;
29
 
using MonoDevelop.Projects.Policies;
30
 
using System.Collections.Generic;
31
 
 
32
 
namespace MonoDevelop.Projects.Dom.Output
33
 
{
34
 
        public class OutputSettings
35
 
        {
36
 
                public OutputFlags OutputFlags {
37
 
                        get;
38
 
                        set;
39
 
                }
40
 
                
41
 
                public PolicyContainer PolicyParent {
42
 
                        get;
43
 
                        set;
44
 
                }
45
 
                
46
 
                public OutputSettings (OutputFlags outputFlags)
47
 
                {
48
 
                        this.OutputFlags = outputFlags;
49
 
                }
50
 
                
51
 
                public string Markup (string text)
52
 
                {
53
 
                        if (MarkupCallback != null)
54
 
                                return MarkupCallback (text);
55
 
                        return IncludeMarkup ? PangoFormat (text) : text;
56
 
                }
57
 
 
58
 
                public string EmitName (INode domVisitable, string text)
59
 
                {
60
 
                        if (EmitNameCallback != null) {
61
 
                                EmitNameCallback (domVisitable, ref text);
62
 
                                return text;
63
 
                        }
64
 
                        return text;
65
 
                }
66
 
                
67
 
                public string EmitModifiers (string text)
68
 
                {
69
 
                        if (!IncludeModifiers)
70
 
                                return string.Empty;
71
 
                        if (EmitModifiersCallback != null)
72
 
                                return EmitModifiersCallback (text) + " ";
73
 
                        if (IncludeMarkup)
74
 
                                return "<b>" + PangoFormat (text) + "</b> ";
75
 
                        return text + " ";
76
 
                }
77
 
                
78
 
                public string EmitKeyword (string text)
79
 
                {
80
 
                        if (EmitKeywordCallback != null)
81
 
                                return EmitKeywordCallback (text) + " ";
82
 
                        if (!IncludeKeywords)
83
 
                                return "";
84
 
                        if (IncludeMarkup)
85
 
                                return "<b>" + PangoFormat (text) + "</b> ";
86
 
                        return text + " ";
87
 
                }
88
 
                
89
 
                public string Highlight (string text)
90
 
                {
91
 
                        if (HighlightCallback != null)
92
 
                                return HighlightCallback (text);
93
 
                        if (IncludeMarkup)
94
 
                                return "<b>" + PangoFormat (text) + "</b>";
95
 
                        return text;
96
 
                }
97
 
                
98
 
                public void PostProcess (INode domVisitable, ref string outString)
99
 
                {
100
 
                        if (PostProcessCallback != null)
101
 
                                PostProcessCallback (domVisitable, ref outString);
102
 
                }
103
 
                
104
 
                static string PangoFormat (string input)
105
 
                {
106
 
                        StringBuilder result = new StringBuilder ();
107
 
                        foreach (char ch in input) {
108
 
                                switch (ch) {
109
 
                                        case '<':
110
 
                                                result.Append ("&lt;");
111
 
                                                break;
112
 
                                        case '>':
113
 
                                                result.Append ("&gt;");
114
 
                                                break;
115
 
                                        case '&':
116
 
                                                result.Append ("&amp;");
117
 
                                                break;
118
 
                                        default:
119
 
                                                result.Append (ch);
120
 
                                                break;
121
 
                                }
122
 
                        }
123
 
                        return result.ToString ();
124
 
                }
125
 
                        
126
 
                public bool IncludeMarkup {
127
 
                        get {
128
 
                                return (OutputFlags & OutputFlags.IncludeMarkup) == OutputFlags.IncludeMarkup;
129
 
                        }
130
 
                }
131
 
                
132
 
                public bool IncludeKeywords  {
133
 
                        get {
134
 
                                return (OutputFlags & OutputFlags.IncludeKeywords) == OutputFlags.IncludeKeywords;
135
 
                        }
136
 
                }
137
 
                
138
 
                public bool IncludeModifiers {
139
 
                        get {
140
 
                                return (OutputFlags & OutputFlags.IncludeModifiers) == OutputFlags.IncludeModifiers;
141
 
                        }
142
 
                }
143
 
 
144
 
                public bool UseFullName {
145
 
                        get {
146
 
                                return (OutputFlags & OutputFlags.UseFullName) == OutputFlags.UseFullName;
147
 
                        }
148
 
                }
149
 
                
150
 
                public bool UseFullInnerTypeName {
151
 
                        get {
152
 
                                return (OutputFlags & OutputFlags.UseFullInnerTypeName) == OutputFlags.UseFullInnerTypeName;
153
 
                        }
154
 
                }
155
 
                
156
 
                
157
 
                
158
 
                public bool IncludeParameters {
159
 
                        get {
160
 
                                return (OutputFlags & OutputFlags.IncludeParameters) == OutputFlags.IncludeParameters;
161
 
                        }
162
 
                }
163
 
 
164
 
                public bool IncludeReturnType {
165
 
                        get {
166
 
                                return (OutputFlags & OutputFlags.IncludeReturnType) == OutputFlags.IncludeReturnType;
167
 
                        }
168
 
                }
169
 
                
170
 
                public bool IncludeParameterName {
171
 
                        get {
172
 
                                return (OutputFlags & OutputFlags.IncludeParameterName) == OutputFlags.IncludeParameterName;
173
 
                        }
174
 
                }
175
 
                
176
 
                public bool IncludeBaseTypes {
177
 
                        get {
178
 
                                return (OutputFlags & OutputFlags.IncludeBaseTypes) == OutputFlags.IncludeBaseTypes;
179
 
                        }
180
 
                }
181
 
                
182
 
                public bool IncludeGenerics {
183
 
                        get {
184
 
                                return (OutputFlags & OutputFlags.IncludeGenerics) == OutputFlags.IncludeGenerics;
185
 
                        }
186
 
                }
187
 
                
188
 
                public bool HideArrayBrackets {
189
 
                        get {
190
 
                                return (OutputFlags & OutputFlags.HideArrayBrackets) == OutputFlags.HideArrayBrackets;
191
 
                        }
192
 
                }
193
 
                
194
 
                public bool HighlightName {
195
 
                        get {
196
 
                                return (OutputFlags & OutputFlags.HighlightName) == OutputFlags.HighlightName;
197
 
                        }
198
 
                }
199
 
                
200
 
                public bool HideExtensionsParameter {
201
 
                        get {
202
 
                                return (OutputFlags & OutputFlags.HideExtensionsParameter) == OutputFlags.HideExtensionsParameter;
203
 
                        }
204
 
                }
205
 
                
206
 
                public bool HideGenericParameterNames {
207
 
                        get {
208
 
                                return (OutputFlags & OutputFlags.HideGenericParameterNames) != 0;
209
 
                        }
210
 
                }
211
 
                
212
 
                public bool GeneralizeGenerics {
213
 
                        get {
214
 
                                return (OutputFlags & OutputFlags.GeneralizeGenerics) != 0;
215
 
                        }
216
 
                }
217
 
                
218
 
                public bool UseNETTypeNames {
219
 
                        get {
220
 
                                return (OutputFlags & OutputFlags.UseNETTypeNames) != 0;
221
 
                        }
222
 
                }
223
 
                
224
 
                public bool ReformatDelegates {
225
 
                        get {
226
 
                                return (OutputFlags & OutputFlags.ReformatDelegates) != 0;
227
 
                        }
228
 
                }
229
 
                
230
 
                public bool StaticUsage {
231
 
                        get {
232
 
                                return (OutputFlags & OutputFlags.StaticUsage) != 0;
233
 
                        }
234
 
                }
235
 
                
236
 
                public bool IncludeConstraints {
237
 
                        get {
238
 
                                return (OutputFlags & OutputFlags.IncludeConstraints) != 0;
239
 
                        }
240
 
                }
241
 
                
242
 
                public bool ReturnTypesLast {
243
 
                        get {
244
 
                                return (OutputFlags & OutputFlags.ReturnTypesLast) != 0;
245
 
                        }
246
 
                }
247
 
                
248
 
                public MarkupText EmitModifiersCallback;
249
 
                public MarkupText EmitKeywordCallback;
250
 
                public MarkupText MarkupCallback;
251
 
                public MarkupText HighlightCallback;
252
 
                public ProcessString EmitNameCallback;
253
 
                
254
 
                public delegate string MarkupText (string text);
255
 
                
256
 
                public ProcessString PostProcessCallback;
257
 
                public delegate void ProcessString (INode domVisitable, ref string outString);
258
 
        }
259
 
}