2
// CSharpModifierToken.cs
5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
using System.Collections.Generic;
28
using MonoDevelop.Projects.Dom;
30
namespace MonoDevelop.CSharp.Ast
32
public class CSharpModifierToken : CSharpTokenNode
36
public Modifiers Modifier {
37
get { return modifier; }
40
if (!lengthTable.TryGetValue (modifier, out tokenLength))
41
throw new InvalidOperationException ("Modifier " + modifier + " is invalid.");
45
static Dictionary<Modifiers, int> lengthTable = new Dictionary<Modifiers, int> () {
46
{ Modifiers.Public, "public".Length },
47
{ Modifiers.Protected, "protected".Length },
48
{ Modifiers.Private, "private".Length },
49
{ Modifiers.Internal, "internal".Length },
50
{ Modifiers.New, "new".Length },
51
{ Modifiers.Unsafe, "unsafe".Length },
52
{ Modifiers.Abstract, "abstract".Length },
53
{ Modifiers.Virtual, "virtual".Length },
54
{ Modifiers.Sealed, "sealed".Length },
55
{ Modifiers.Static, "static".Length },
56
{ Modifiers.Override, "override".Length },
57
{ Modifiers.Readonly, "readonly".Length },
58
{ Modifiers.Volatile, "volatile".Length },
59
{ Modifiers.Extern, "extern".Length },
60
{ Modifiers.Partial, "partial".Length },
61
{ Modifiers.Const, "const".Length },
64
public static ICollection<Modifiers> AllModifiers {
65
get { return lengthTable.Keys; }
68
public CSharpModifierToken (AstLocation location, Modifiers modifier) : base (location, 0)
70
this.Modifier = modifier;
73
public static string GetModifierName(Modifiers modifier)
76
case Modifiers.Private:
78
case Modifiers.Internal:
80
case Modifiers.Protected:
82
case Modifiers.Public:
84
case Modifiers.Abstract:
86
case Modifiers.Virtual:
88
case Modifiers.Sealed:
90
case Modifiers.Static:
92
case Modifiers.Override:
94
case Modifiers.Readonly:
100
case Modifiers.Partial:
102
case Modifiers.Extern:
104
case Modifiers.Volatile:
106
case Modifiers.Unsafe:
108
case Modifiers.Fixed:
111
throw new NotSupportedException("Invalid value for Modifiers");
b'\\ No newline at end of file'