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

« back to all changes in this revision

Viewing changes to contrib/NRefactory/Project/Src/Lexer/Special/SpecialTracker.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="none" email=""/>
5
 
//     <version>$Revision: 4482 $</version>
6
 
// </file>
7
 
 
8
 
using System;
9
 
using System.Collections.Generic;
10
 
using System.Text;
11
 
 
12
 
namespace ICSharpCode.OldNRefactory.Parser
13
 
{
14
 
        public class SpecialTracker
15
 
        {
16
 
                List<ISpecial> currentSpecials = new List<ISpecial>();
17
 
                
18
 
                CommentType   currentCommentType;
19
 
                StringBuilder sb = new StringBuilder();
20
 
                Location         startPosition;
21
 
                bool commentStartsLine;
22
 
                
23
 
                public List<ISpecial> CurrentSpecials {
24
 
                        get {
25
 
                                return currentSpecials;
26
 
                        }
27
 
                }
28
 
                
29
 
                public void InformToken(int kind)
30
 
                {
31
 
                        
32
 
                }
33
 
                
34
 
                /// <summary>
35
 
                /// Gets the specials from the SpecialTracker and resets the lists.
36
 
                /// </summary>
37
 
                public List<ISpecial> RetrieveSpecials()
38
 
                {
39
 
                        List<ISpecial> tmp = currentSpecials;
40
 
                        currentSpecials = new List<ISpecial>();
41
 
                        return tmp;
42
 
                }
43
 
                
44
 
                public void AddEndOfLine(Location point)
45
 
                {
46
 
                        currentSpecials.Add(new BlankLine(point));
47
 
                }
48
 
                
49
 
                public void AddPreprocessingDirective(PreprocessingDirective directive)
50
 
                {
51
 
                        if (directive == null)
52
 
                                throw new ArgumentNullException("directive");
53
 
                        currentSpecials.Add(directive);
54
 
                }
55
 
                
56
 
                // used for comment tracking
57
 
                public void StartComment(CommentType commentType, bool commentStartsLine, Location startPosition)
58
 
                {
59
 
                        this.currentCommentType = commentType;
60
 
                        this.startPosition      = startPosition;
61
 
                        this.sb.Length          = 0;
62
 
                        this.commentStartsLine  = commentStartsLine;
63
 
                }
64
 
                
65
 
                public void AddChar(char c)
66
 
                {
67
 
                        sb.Append(c);
68
 
                }
69
 
                
70
 
                public void AddString(string s)
71
 
                {
72
 
                        sb.Append(s);
73
 
                }
74
 
                
75
 
                public void FinishComment(Location endPosition)
76
 
                {
77
 
                        currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), commentStartsLine, startPosition, endPosition));
78
 
                }
79
 
        }
80
 
}