[svn] r7690: vs-plugin/trunk/Nemerle.VsIntegration: Project/NemerleFileNodeCodeDomProvider.cs Project/RDTF...

akhropov svnadmin at nemerle.org
Fri May 25 12:24:29 CEST 2007


Log:
fixed code merging bug, added CodeGeneratorOptions initialization from LanguagePreferences

Author: akhropov
Date: Fri May 25 12:24:10 2007
New Revision: 7690

Modified:
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/RDTFileTextMerger.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs	Fri May 25 12:24:10 2007
@@ -18,6 +18,8 @@
 using NCU = Nemerle.Compiler.Utils;
 using Nemerle.Completion2;
 
+using Nemerle.VisualStudio.LanguageService;
+
 namespace Nemerle.VisualStudio.Project
 {
 	internal class NemerleCodeGeneratorProxy : NemerleCodeGenerator, ICodeGenerator
@@ -217,6 +219,9 @@
 
 		public override void GenerateCodeFromCompileUnit(CodeCompileUnit e, TextWriter w, CodeGeneratorOptions o)
 		{
+			if (o == null)
+				o = GetCodeGeneratorOptions();
+
 			if (IsFormSubType)
 			{
 				string mainFilePath = PathOfMainFile();
@@ -236,7 +241,7 @@
 					//ProjectInfo.FindProject(designerFilePath).Project.CompileUnits.
 					ProjectInfo projectInfo = ProjectInfo.FindProject(mainFilePath);
 					if (projectInfo == null)
-						throw new ApplicationException("The component not in project!");
+						throw new ApplicationException("The component is not in the project!");
 
 					_codeDomGenerator.MergeFormCodeFromCompileUnit(
 						projectInfo.Project,
@@ -253,6 +258,30 @@
 				}
 		}
 		
+		private CodeGeneratorOptions GetCodeGeneratorOptions()
+		{
+			NemerleLanguageService langService = (_fileNode.GetService(typeof(NemerleLanguageService)) as NemerleLanguageService);
+
+			if(langService == null)
+				throw new ApplicationException("Language service not found");
+
+			CodeGeneratorOptions codeGenOptions = new CodeGeneratorOptions();
+
+			LanguagePreferences prefs = langService.GetLanguagePreferences();
+
+			if(prefs.InsertTabs)
+				codeGenOptions.IndentString = "\t";
+			else
+				codeGenOptions.IndentString = new string(' ', prefs.IndentSize );
+
+			// Set deliberately (TODO)
+			codeGenOptions.BlankLinesBetweenMembers = true;
+			codeGenOptions.BracingStyle = "Block";
+			codeGenOptions.ElseOnClosing = false;
+
+			return codeGenOptions;
+		}
+		
 		#endregion
 
 		#region Provided (obsolete) interfaces

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/RDTFileTextMerger.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/RDTFileTextMerger.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/RDTFileTextMerger.cs	Fri May 25 12:24:10 2007
@@ -82,8 +82,9 @@
 			{
 				string text = Utils.ConvertToText(this.NewLines);
 
-				Debug.Print("RemoveLinesChange : remove lines (" + this.Start +
-							"," + this.End + ")");
+				Debug.Print("ReplaceLinesChange : replace lines (" + this.Start +
+							"," + this.End + ") with lines (" + this.NewLines.Count + ") :\n"
+							+ text ); 
 
 				//int endLength;
 				//ErrorHandler.ThrowOnFailure(vsTextLines.GetLengthOfLine(this.End-1, out endLength));

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs	Fri May 25 12:24:10 2007
@@ -16,7 +16,7 @@
 		{
 			string[] ary = new string[lines.Count + 1];
 			lines.CopyTo(ary);
-			ary[ary.Length - 1] = System.Environment.NewLine;
+			ary[ary.Length - 1] = string.Empty;
 			return string.Join(System.Environment.NewLine, ary);
 		}
 



More information about the svn mailing list