diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs index c2e76dfffc..805d81dd9b 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs @@ -46,6 +46,21 @@ namespace ICSharpCode.NRefactory.Parser get { throw new NotSupportedException(); } } + protected static IEnumerable GetSymbols (string symbols) + { + foreach (string symbol in symbols.Split (';')) { + string s = symbol.Trim (); + if (s.Length == 0) + continue; + yield return s; + } + } + + public virtual void SetConditionalCompilationSymbols (string symbols) + { + throw new NotSupportedException (); + } + protected int Line { get { return line; diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs index 63a85342d3..02c2d8af17 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs @@ -990,6 +990,14 @@ namespace ICSharpCode.NRefactory.Parser.CSharp get { return conditionalCompilation.Symbols; } } + public override void SetConditionalCompilationSymbols (string symbols) + { + foreach (string symbol in GetSymbols (symbols)) { + conditionalCompilation.Define (symbol); + } + } + + ConditionalCompilation conditionalCompilation = new ConditionalCompilation(); void ReadPreProcessingDirective() diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs index ab647b75f6..26d4f9605d 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs @@ -61,6 +61,14 @@ namespace ICSharpCode.NRefactory.Parser /// IDictionary ConditionalCompilationSymbols { get; } + /// + /// Sets the conditional compilation symbols. + /// + /// + /// A containing the symbols. The symbols are separated by ';'. + /// + void SetConditionalCompilationSymbols (string symbols); + /// /// Returns the comments that had been read and containing tag key words. ///