List:Commits« Previous MessageNext Message »
From:rburnett Date:September 13 2008 12:10am
Subject:Connector/NET commit: r1422 - in trunk/MySql.VisualStudio: . LanguageService
View as plain text  
Modified:
   trunk/MySql.VisualStudio/LanguageService/Configuration.cs
   trunk/MySql.VisualStudio/LanguageService/MySqlColorizer.cs
   trunk/MySql.VisualStudio/LanguageService/MySqlLanguageService.cs
   trunk/MySql.VisualStudio/VsPkg.cs
Log:
some fixes for our language service.  split view now working correctly

Modified: trunk/MySql.VisualStudio/LanguageService/Configuration.cs
===================================================================
--- trunk/MySql.VisualStudio/LanguageService/Configuration.cs	2008-09-12 22:02:08 UTC (rev 1421)
+++ trunk/MySql.VisualStudio/LanguageService/Configuration.cs	2008-09-12 22:10:29 UTC (rev 1422)
@@ -1,6 +1,6 @@
 using Microsoft.VisualStudio.Package;
-using MySql.Data.Common;
 using System.Collections.Generic;
+using MySql.Data.MySqlClient;
 
 namespace MySql.Data.VisualStudio
 {
@@ -86,7 +86,7 @@
             keywords.Add("REPLACE");
         }
 
-        public static TokenInfo GetTokenInfo(string token, SqlTokenizer tokenizer)
+        public static TokenInfo GetTokenInfo(string token, MySqlTokenizer tokenizer)
         {
             TokenInfo ti = new TokenInfo();
             if (tokenizer.Quoted)

Modified: trunk/MySql.VisualStudio/LanguageService/MySqlColorizer.cs
===================================================================
--- trunk/MySql.VisualStudio/LanguageService/MySqlColorizer.cs	2008-09-12 22:02:08 UTC (rev 1421)
+++ trunk/MySql.VisualStudio/LanguageService/MySqlColorizer.cs	2008-09-12 22:10:29 UTC (rev 1422)
@@ -4,8 +4,7 @@
 using System.Collections.Generic;
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.TextManager.Interop;
-using MySql.Data.Common;
-using MySql.Data.VisualStudio.LanguageService;
+using MySql.Data.MySqlClient;
 
 namespace MySql.Data.VisualStudio 
 {
@@ -15,14 +14,12 @@
         private IVsTextLines buffer;
         private List<TokenInfo>[] tokenList;
         private string savedSqlText;
-        private SqlTokenizer tokenizer;
 
         public MySqlColorizer(LanguageService service, IVsTextLines buffer, IScanner scanner)
             : base(service, buffer, scanner)
         {
             this.scanner = scanner;
             this.buffer = buffer;
-            tokenizer = new SqlTokenizer();
         }
 
         public override TokenInfo[] GetLineInfo(IVsTextLines buffer, int line, IVsTextColorState colorState)
@@ -93,7 +90,7 @@
                 buffer.GetLengthOfLine(line, out length);
 
                 buffer.GetLineText(line, 0, line, length, out lines[line]);
-                lines[line] = lines[line].Replace(@"\r\n", " ").Replace(@"\n", " ");
+                //lines[line] = lines[line].Replace(@"\r\n", " ").Replace(@"\n", " ");
             }
 
             // now reformat the buffer to have new lines where VS wants them to be
@@ -110,26 +107,41 @@
             for (int i = 0; i < lineCount; i++)
                 tokenList[i] = new List<TokenInfo>();
 
-            tokenizer.Text = sqlText;
+            MySqlTokenizer tokenizer = new MySqlTokenizer(sqlText);
             tokenizer.ReturnComments = true;
 
             string token = tokenizer.NextToken();
 
             while (token != null)
             {
-                int startLine = tokenizer.StartLine;
-                int endLine = tokenizer.StopLine;
+                int startIndex = tokenizer.StartIndex;
+                int stopIndex = tokenizer.StopIndex;
+                int startLine = GetLineAndIndex(lines, ref startIndex);
+                int endLine = GetLineAndIndex(lines, ref stopIndex);
 
                 for (int line = startLine; line <= endLine; line++)
                 {
                     TokenInfo ti = Configuration.GetTokenInfo(token, tokenizer);
-                    ti.StartIndex = line == startLine ? tokenizer.StartIndex : 0;
-                    ti.EndIndex = line == endLine ? tokenizer.StopIndex : lines[line].Length;
+                    ti.StartIndex = line == startLine ? startIndex : 0;
+                    ti.EndIndex = line == endLine ? stopIndex : lines[line].Length;
                     tokenList[line].Add(ti);
                 }
 
                 token = tokenizer.NextToken();
             }
         }
+
+        private int GetLineAndIndex(string[] lines, ref int index)
+        {
+            if (lines == null || lines.Length == 0) return -1;
+
+            int line = 0;
+            int len = lines[line].Length;
+            while (index > len)
+                len += lines[++line].Length;
+
+            index -= len;
+            return line;
+        }
     }
 }

Modified: trunk/MySql.VisualStudio/LanguageService/MySqlLanguageService.cs
===================================================================
--- trunk/MySql.VisualStudio/LanguageService/MySqlLanguageService.cs	2008-09-12 22:02:08 UTC (rev 1421)
+++ trunk/MySql.VisualStudio/LanguageService/MySqlLanguageService.cs	2008-09-12 22:10:29 UTC (rev 1422)
@@ -1,6 +1,7 @@
 using System.Runtime.InteropServices;
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.TextManager.Interop;
+using System;
 
 namespace MySql.Data.VisualStudio
 {
@@ -12,13 +13,13 @@
     class MySqlLanguageService : LanguageService
     {
         private LanguagePreferences preferences;
-        private MySqlScanner scanner;
+        private IScanner scanner;
 
         public const string LanguageName = "MySQL";
 
         public override AuthoringScope ParseSource(ParseRequest req)
         {
-            throw new System.NotImplementedException();
+            throw new NotImplementedException();
         }
 
         public override string Name
@@ -26,6 +27,11 @@
             get { return LanguageName; }
         }
 
+        public override string GetFormatFilterList()
+        {
+            return String.Empty;
+        }
+
         public override IScanner GetScanner(IVsTextLines buffer)
         {
             if (scanner == null)

Modified: trunk/MySql.VisualStudio/VsPkg.cs
===================================================================
--- trunk/MySql.VisualStudio/VsPkg.cs	2008-09-12 22:02:08 UTC (rev 1421)
+++ trunk/MySql.VisualStudio/VsPkg.cs	2008-09-12 22:10:29 UTC (rev 1422)
@@ -13,7 +13,7 @@
 using Microsoft.VisualStudio;
 using System.Reflection;
 using MySql.Data.VisualStudio.Properties;
-using EnvDTE;
+using MySql.Data.VisualStudio.Editors;
 
 namespace MySql.Data.VisualStudio
 {
@@ -31,11 +31,15 @@
     // This attribute tells the registration utility (regpkg.exe) that this class needs
     // to be registered as package.
     [PackageRegistration(UseManagedResourcesOnly = true)]
-    // A Visual Studio component can be registered under different regitry roots; for instance
+    // A Visual Studio component can be registered under different registry roots; for instance
     // when you debug your package you want to register it in the experimental hive. This
     // attribute specifies the registry root to use if no one is provided to regpkg.exe with
     // the /root switch.
+#if DEBUG
+    [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0Exp")]
+#else
     [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0")]
+#endif
     // This attribute is used to register the informations needed to show the this package
     // in the Help/About dialog of Visual Studio.
     [InstalledProductRegistration(true, null, null, null)]
@@ -45,8 +49,8 @@
     // package has a load key embedded in its resources.
 	[ProvideService(typeof(MySqlProviderObjectFactory), ServiceName = "MySQL Provider Object Factory")]
     [ProvideService(typeof(MySqlLanguageService))]
-    [ProvideLanguageService(typeof(MySqlLanguageService), MySqlLanguageService.LanguageName, 0,
-        EnableCommenting=true)]
+    [ProvideLanguageService(typeof(MySqlLanguageService), MySqlLanguageService.LanguageName, 101,
+        RequestStockColors=true)]
 	[ProvideMenuResource(1000, 1)]
 	[ProvideLoadKey("Standard", "1.0", "MySQL Tools for Visual Studio", "MySQL AB c/o MySQL, Inc.", 100)]
     [Guid(GuidList.PackageGUIDString)]
@@ -127,7 +131,11 @@
 
         int IVsInstalledProduct.ProductID(out string pbstrPID)
         {
-            pbstrPID = "5.2";
+			string fullname = Assembly.GetExecutingAssembly().FullName;
+			string[] parts = fullname.Split(new char[] { '=' });
+			string[] versionParts = parts[1].Split(new char[] { '.' });
+
+            pbstrPID = String.Format("{0}.{1}.{2}", versionParts[0], versionParts[1], versionParts[2]);
             return VSConstants.S_OK;
         }
 

Thread
Connector/NET commit: r1422 - in trunk/MySql.VisualStudio: . LanguageServicerburnett13 Sep