From f5e37276c2cfe71cfd9176cf4bc6c785a397e05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Tue, 17 Mar 2009 09:23:11 +0000 Subject: [PATCH] * Src/Lexer/ILexer.cs: * Src/Lexer/CSharp/Lexer.cs: * Src/Lexer/AbstractLexer.cs: Added SetConditionalCompilationSymbols method. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3866 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../NRefactory/Project/Src/Lexer/AbstractLexer.cs | 15 +++++++++++++++ .../NRefactory/Project/Src/Lexer/CSharp/Lexer.cs | 8 ++++++++ .../NRefactory/Project/Src/Lexer/ILexer.cs | 8 ++++++++ 3 files changed, 31 insertions(+) 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. ///