mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using System.Text; |
|
|
|
namespace ICSharpCode.NRefactory.VB.Parser |
|
{ |
|
public class SpecialTracker |
|
{ |
|
List<ISpecial> currentSpecials = new List<ISpecial>(); |
|
|
|
CommentType currentCommentType; |
|
StringBuilder sb = new StringBuilder(); |
|
Location startPosition; |
|
bool commentStartsLine; |
|
|
|
public List<ISpecial> CurrentSpecials { |
|
get { |
|
return currentSpecials; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// Gets the specials from the SpecialTracker and resets the lists. |
|
/// </summary> |
|
public List<ISpecial> RetrieveSpecials() |
|
{ |
|
List<ISpecial> tmp = currentSpecials; |
|
currentSpecials = new List<ISpecial>(); |
|
return tmp; |
|
} |
|
|
|
public void AddEndOfLine(Location point) |
|
{ |
|
currentSpecials.Add(new BlankLine(point)); |
|
} |
|
|
|
public void AddPreprocessingDirective(PreprocessingDirective directive) |
|
{ |
|
if (directive == null) |
|
throw new ArgumentNullException("directive"); |
|
currentSpecials.Add(directive); |
|
} |
|
|
|
// used for comment tracking |
|
public void StartComment(CommentType commentType, bool commentStartsLine, Location startPosition) |
|
{ |
|
this.currentCommentType = commentType; |
|
this.startPosition = startPosition; |
|
this.sb.Length = 0; |
|
this.commentStartsLine = commentStartsLine; |
|
} |
|
|
|
public void AddChar(char c) |
|
{ |
|
sb.Append(c); |
|
} |
|
|
|
public void AddString(string s) |
|
{ |
|
sb.Append(s); |
|
} |
|
|
|
public void FinishComment(Location endPosition) |
|
{ |
|
currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), commentStartsLine, startPosition, endPosition)); |
|
} |
|
} |
|
}
|
|
|