[Monodevelop-patches-list] r645 - in trunk/MonoDevelop/src: AddIns/BackendBindings/CSharpBinding/Parser AddIns/DisplayBindings/TextEditor/Gui/Editor AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow Libraries/ICSharpCode.TextEditor/src/Document Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy Main/Base/Gui/BrowserDisplayBinding Main/Base/Internal/Codons/DisplayBinding Main/Base/Services/File Main/Base/Services/ParserService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sun Jan 25 01:12:50 EST 2004


Author: benm
Date: 2004-01-25 01:12:49 -0500 (Sun, 25 Jan 2004)
New Revision: 645

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingManager.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/IDocument.cs
   trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs
   trunk/MonoDevelop/src/Main/Base/Internal/Codons/DisplayBinding/IDisplayBinding.cs
   trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs
Log:
Get codecomplete to work in non-named files, sorta

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -94,7 +94,8 @@
 			this.caretColumn   = caretColumn;
 			
 			this.parserService = parserService;
-			IParseInformation parseInfo = parserService.GetParseInformation(fileName);
+			IParseInformation parseInfo = parserService.GetParseInformation (fileName, fileContent);
+			
 			ICSharpCode.SharpRefactory.Parser.AST.CompilationUnit fileCompilationUnit = parseInfo.MostRecentCompilationUnit.Tag as ICSharpCode.SharpRefactory.Parser.AST.CompilationUnit;
 			if (fileCompilationUnit == null) {
 //				ICSharpCode.SharpRefactory.Parser.Parser fileParser = new ICSharpCode.SharpRefactory.Parser.Parser();

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -52,6 +52,8 @@
 		public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
 		{
 			IDocument document =  textArea.Document;
+			Console.WriteLine ("resolve " + document.Language);
+			Console.WriteLine ("nm " + fileName);
 			completionData = new ArrayList();
 			this.fileName = fileName;
 			
@@ -90,11 +92,14 @@
 			} else {
 				//FIXME: I added the null check, #D doesnt need it, why do we?
 				if (fileName != null) {
+					Console.WriteLine ("resolve " + document.Language);
+					Console.WriteLine ("resolve " + document.TextContent);
 					results = parserService.Resolve(expression, 
 				                                caretLineNumber,
 				                                caretColumn,
 				                                fileName,
-				                                document.TextContent);
+				                                document.TextContent,
+								document.Language);
 				
 					AddResolveResults(results);
 				}

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -61,6 +61,7 @@
 #endif
 			b2.Load(fileName);
 			b2.textAreaControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName);
+			b2.textAreaControl.Document.Language = HighlightingStrategyFactory.LanguageFromFile (fileName);
 			b2.textAreaControl.InitializeFormatter();
 			return b2;
 		}
@@ -71,9 +72,24 @@
 			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
 			b2.textAreaControl.Document.TextContent = stringParserService.Parse(content);
 			b2.textAreaControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(language);
+			Console.WriteLine (language);
+			b2.textAreaControl.Document.Language = language;
 			b2.textAreaControl.InitializeFormatter();
 			return b2;
-		}		
+		}
+		
+		public virtual IViewContent CreateContentForLanguage(string language, string content, string new_file_name)
+		{
+			TextEditorDisplayBindingWrapper b2 = new TextEditorDisplayBindingWrapper();
+			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
+			b2.textAreaControl.Document.TextContent = stringParserService.Parse(content);
+			b2.textAreaControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(language);
+			Console.WriteLine (language);
+			b2.textAreaControl.Document.Language = language;
+			b2.textAreaControl.FileName = new_file_name;
+			b2.textAreaControl.InitializeFormatter();
+			return b2;
+		}	
 	}
 	
 	public class TextEditorDisplayBindingWrapper : AbstractViewContent, IMementoCapable, IPrintable, IEditable, IPositionable, ITextEditorControlProvider, IParseInformationListener, IClipboardHandler

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -195,6 +195,12 @@
 			}
 		}
 		
+		string language;
+		public string Language {
+			get { return language; }
+			set { language = value; }
+		}
+		
 		public string TextContent {
 			get {
 				return GetText(0, textBufferStrategy.Length);

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingManager.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingManager.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingManager.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -19,7 +19,7 @@
 		static HighlightingManager highlightingManager;
 		
 		Hashtable highlightingDefs = new Hashtable();
-		Hashtable extensionsToName = new Hashtable();
+		internal Hashtable extensionsToName = new Hashtable();
 		
 		public Hashtable HighlightingDefinitions {
 			get {

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -42,5 +42,11 @@
 			}
 			return highlightingStrategy;
 		}
+		
+		// HACK: this shouldnt be here ;-)
+		public static string LanguageFromFile (string file)
+		{
+			return (string) HighlightingManager.Manager.extensionsToName [Path.GetExtension(file).ToUpper()];
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/IDocument.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/IDocument.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/IDocument.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -71,6 +71,10 @@
 			get;
 		}
 		
+		string Language {
+			get; set;
+		}
+		
 //		/// <summary>
 //		/// The <see cref="SelectionManager"/> attached to the <see cref="IDocument"/> instance
 //		/// </summary>

Modified: trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -41,5 +41,10 @@
 		{
 			return null;
 		}
+		
+		public IViewContent CreateContentForLanguage(string languageName, string content, string new_file_name)
+		{
+			return null;
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Internal/Codons/DisplayBinding/IDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Codons/DisplayBinding/IDisplayBinding.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Codons/DisplayBinding/IDisplayBinding.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -58,5 +58,7 @@
 		/// A newly created IViewContent object.
 		/// </returns>
 		IViewContent CreateContentForLanguage(string languageName, string content);
+		
+		IViewContent CreateContentForLanguage(string languageName, string content, string new_file_name);
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -114,7 +114,7 @@
 			IDisplayBinding binding = displayBindingService.GetBindingPerLanguageName(language);
 			
 			if (binding != null) {
-				IViewContent newContent = binding.CreateContentForLanguage(language, content);
+				IViewContent newContent = binding.CreateContentForLanguage(language, content, defaultName);
 				if (newContent == null) {
 					throw new ApplicationException(String.Format("Created view content was null{3}DefaultName:{0}{3}Language:{1}{3}Content:{2}", defaultName, language, content, Environment.NewLine));
 				}

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -540,10 +540,23 @@
 			return ParseFile(fileName, null);
 		}
 
-		public IParseInformation ParseFile(string fileName, string fileContent)
+		public IParseInformation ParseFile (string fileName, string fileContent)
 		{
-			IParser parser = GetParser(fileName);
+			return ParseFile (GetParser (fileName), fileName, fileContent);
+		}
+		
+		public IParseInformation ParseFile (string language, string fileName, string fileContent)
+		{
+			if (language == "C#" || language == "c#")
+				return ParseFile (parser[0], fileName, fileContent);
 			
+			return null;
+		}
+		
+				
+			
+		public IParseInformation ParseFile (IParser parser, string fileName, string fileContent)
+		{
 			if (parser == null) {
 				return null;
 			}
@@ -642,7 +655,19 @@
 			}
 			return (IParseInformation)cu;
 		}
+		public IParseInformation GetParseInformation(string fileName, string content)
+		{
+			if (fileName == null || fileName.Length == 0) {
+				return null;
+			}
+			object cu = parsings[fileName];
+			if (cu == null) {
+				return ParseFile(fileName, content);
+			}
+			return (IParseInformation)cu;
+		}
 		
+		
 		public virtual IParser GetParser(string fileName)
 		{
 			if (fileName == null)
@@ -722,7 +747,27 @@
 //				return null;
 			//}
 		}
-
+		
+		public ResolveResult Resolve(string expression,
+		                             int caretLineNumber,
+		                             int caretColumn,
+		                             string fileName,
+		                             string fileContent,
+					     string language)
+		{
+			// added exception handling here to prevent silly parser exceptions from
+			// being thrown and corrupting the textarea control
+			//try {
+				IParser p = language == "c#" || language == "C#" ? parser[0] : null;
+				if (p != null) {
+					return p.Resolve(this, expression, caretLineNumber, caretColumn, fileName, fileContent);
+				}
+				return null;
+			//} catch {
+//				return null;
+			//}
+		}
+		
 		protected void OnParseInformationAdded(ParseInformationEventArgs e)
 		{
 			if (ParseInformationAdded != null) {

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs	2004-01-25 04:39:05 UTC (rev 644)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs	2004-01-25 06:12:49 UTC (rev 645)
@@ -43,6 +43,7 @@
 		IParseInformation ParseFile(string fileName, string fileContent);
 
 		IParseInformation GetParseInformation(string fileName);
+		IParseInformation GetParseInformation(string fileName, string fileContent);
 
 		IParser GetParser(string fileName);
 
@@ -62,6 +63,13 @@
 		                      int caretColumn,
 		                      string fileName,
 		                      string fileContent);
+				      
+		ResolveResult Resolve(string expression,
+		                      int caretLineNumber,
+		                      int caretColumn,
+		                      string fileName,
+		                      string fileContent,
+				      string language);
 
 		void AddReferenceToCompletionLookup(IProject project, ProjectReference reference);
 




More information about the Monodevelop-patches-list mailing list