~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Projects/MonoDevelop.Projects.Dom.Parser/CommentTag.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-07-05 13:00:05 UTC
  • mfrom: (1.2.8 upstream) (1.3.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100705130005-d6hp4k5gcn1xkj8c
Tags: 2.4+dfsg-1ubuntu1
* debian/patches/remove_support_for_moonlight.patch,
  debian/patches/dont_add_moonlight_to_core_addins.patch,
  debian/control:
  + Enable support for Moonlight
* debian/rules:
  + Ensure Moonlight addin isn't shipped in main MonoDevelop package by
    mistake

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// CommentTag.cs
3
 
//  
4
 
// Author:
5
 
//       Lluis Sanchez Gual <lluis@novell.com>
6
 
// 
7
 
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
8
 
// 
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:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
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
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using System.Collections;
29
 
using System.Collections.Generic;
30
 
 
31
 
namespace MonoDevelop.Projects.Dom.Parser
32
 
{
33
 
        public class CommentTagSet: IEnumerable<CommentTag>
34
 
        {
35
 
                List<CommentTag> list;
36
 
                
37
 
                public CommentTagSet (IEnumerable<CommentTag> tags)
38
 
                {
39
 
                        list = new List<CommentTag> (tags);
40
 
                }
41
 
                
42
 
                public CommentTagSet (string tagListString)
43
 
                {
44
 
                        list = new List<CommentTag> ();
45
 
                        if (string.IsNullOrEmpty (tagListString))
46
 
                                return;
47
 
                        
48
 
                        string[] tags = tagListString.Split (';');
49
 
                        for (int n=0; n<tags.Length; n++) {
50
 
                                string[] split = tags [n].Split (':');
51
 
                                int priority;
52
 
                                if (split.Length == 2 && int.TryParse (split[1], out priority))
53
 
                                        list.Add (new CommentTag (split[0], priority));
54
 
                                else
55
 
                                        MonoDevelop.Core.LoggingService.LogWarning ("Invalid tag list in CommentTagSet: '{0}'", tagListString);
56
 
                        }
57
 
                }
58
 
                
59
 
                public IEnumerator<CommentTag> GetEnumerator ()
60
 
                {
61
 
                        return list.GetEnumerator ();
62
 
                }
63
 
 
64
 
                IEnumerator IEnumerable.GetEnumerator ()
65
 
                {
66
 
                        return ((IEnumerable)list).GetEnumerator ();
67
 
                }
68
 
                
69
 
                public string[] GetNames ()
70
 
                {
71
 
                        string[] names = new string[list.Count];
72
 
                        for (int n=0; n<list.Count; n++)
73
 
                                names [n] = list [n].Tag;
74
 
                        return names;
75
 
                }
76
 
                
77
 
                public bool ContainsTag (string name)
78
 
                {
79
 
                        foreach (CommentTag tag in list)
80
 
                                if (tag.Tag == name)
81
 
                                        return true;
82
 
                        return false;
83
 
                }
84
 
                
85
 
                public override string ToString ()
86
 
                {
87
 
                        string res = "";
88
 
                        for (int n=0; n<list.Count; n++) {
89
 
                                if (n > 0)
90
 
                                        res += ";";
91
 
                                res += list [n].Tag + ":" + list [n].Priority;
92
 
                        }
93
 
                        return res;
94
 
                }
95
 
                
96
 
                public bool Equals (CommentTagSet other)
97
 
                {
98
 
                        if (other.list.Count != list.Count)
99
 
                                return false;
100
 
                        List<CommentTag> otags = new List<CommentTag> (other.list);
101
 
                        foreach (CommentTag tag in list) {
102
 
                                bool found = false;
103
 
                                for (int n=0; n<otags.Count; n++) {
104
 
                                        CommentTag otag = otags [n];
105
 
                                        if (otag != null && tag.Tag == otag.Tag && tag.Priority == otag.Priority) {
106
 
                                                otags [n] = null;
107
 
                                                found = true;
108
 
                                                break;
109
 
                                        }
110
 
                                }
111
 
                                if (!found)
112
 
                                        return false;
113
 
                        }
114
 
                        return true;
115
 
                }
116
 
        }
117
 
        
118
 
        public class CommentTag
119
 
        {
120
 
                public CommentTag (string tag, int priority)
121
 
                {
122
 
                        Tag = tag;
123
 
                        Priority = priority;
124
 
                }
125
 
                
126
 
                public string Tag { get; internal set; }
127
 
                public int Priority { get; internal set; }
128
 
        }
129
 
}