Changeset 2118
- Timestamp:
- Nov 26, 2012, 7:10:35 PM (10 years ago)
- Location:
- trunk/tools/vslol
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/vslol/MenuGenerateCompilers.cs
r2115 r2118 92 92 return; 93 93 94 cmd.ClearOutputPane();95 cmd.WriteToOutputPane("------ Build started: Generating Compilers ------\n");94 Logger.Clear(); 95 Logger.Info("------ Build started: Generating Compilers ------\n"); 96 96 97 97 int scanner_count = 0, parser_count = 0, error_count = 0; … … 99 99 foreach (Project project in cmd.projects) 100 100 { 101 cmd.WriteToOutputPane("Project " + project.Name + "\n");101 Logger.Info("Project " + project.Name + "\n"); 102 102 103 103 string project_path = Path.GetDirectoryName(project.FullName); … … 138 138 if (item.Name.EndsWith("-scanner.l")) 139 139 { 140 cmd.WriteToOutputPane("flex.exe " + filename + "\n");140 Logger.Info("flex.exe " + filename + "\n"); 141 141 142 142 string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-scanner.l"))); … … 154 154 if (item.Name.EndsWith("-parser.y")) 155 155 { 156 cmd.WriteToOutputPane("bison.exe " + filename + "\n");156 Logger.Info("bison.exe " + filename + "\n"); 157 157 158 158 string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-parser.y"))); … … 174 174 } 175 175 176 cmd.WriteToOutputPane(string.Format("========== Done: {0} scanner(s), {1} parser(s), {2} error(s) ==========\n",176 Logger.Info(string.Format("========== Done: {0} scanner(s), {1} parser(s), {2} error(s) ==========\n", 177 177 scanner_count, parser_count, error_count)); 178 178 } … … 203 203 + p.StandardOutput.ReadToEnd(); 204 204 p.WaitForExit(); 205 WriteToOutputPane(output);205 Logger.Info(output); 206 206 if (p.ExitCode != 0) 207 207 { 208 WriteToOutputPane("Error: " + executable + " exited with code " + p.ExitCode + "\n");208 Logger.Info("Error: " + executable + " exited with code " + p.ExitCode + "\n"); 209 209 if (arguments != "") 210 WriteToOutputPane("Error: args: " + arguments + "\n");210 Logger.Info("Error: args: " + arguments + "\n"); 211 211 if (env != "") 212 WriteToOutputPane("Error: env: " + env + "\n");212 Logger.Info("Error: env: " + env + "\n"); 213 213 return false; 214 214 } … … 216 216 catch (Exception e) 217 217 { 218 WriteToOutputPane("Error: failed to launch " + executable + "\n");218 Logger.Info("Error: failed to launch " + executable + "\n"); 219 219 return false; 220 220 } 221 221 222 222 return true; 223 }224 225 private void ClearOutputPane()226 {227 IVsOutputWindow win = sp.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;228 if (null == win)229 {230 Trace.WriteLine("Failed to get a reference to IVsOutputWindow");231 pane = null;232 }233 234 Guid guid = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid;235 if (Microsoft.VisualStudio.ErrorHandler.Failed(win.GetPane(ref guid, out pane)))236 {237 Trace.WriteLine("Failed to get a reference to the Output window Build pane");238 pane = null;239 }240 241 pane.Activate();242 pane.Clear();243 }244 245 private void WriteToOutputPane(string s)246 {247 if (pane != null)248 pane.OutputString(s);249 223 } 250 224 … … 268 242 269 243 private ServiceProvider sp; 270 private IVsOutputWindowPane pane;271 244 272 245 private List<Project> projects; -
trunk/tools/vslol/VsLol.cs
r1932 r2118 14 14 [PackageRegistration(UseManagedResourcesOnly = true)] 15 15 16 /* LolFx syntax highlighting */ 17 [ProvideServiceAttribute(typeof(LolFxLanguageService), 18 ServiceName = "LolFx Service")] 19 [ProvideLanguageServiceAttribute(typeof(LolFxLanguageService), 20 "LolFx", 106 /* resource ID */, 21 CodeSense = true, 22 RequestStockColors = true, 23 EnableCommenting = true, 24 EnableAsyncCompletion = true)] 25 [ProvideLanguageExtensionAttribute(typeof(LolFxLanguageService), 26 ".lolfx")] 27 16 28 [ProvideMenuResource(1000, 1)] 17 29 [Guid("f96f7ac5-16ac-4061-8b92-0a02bb455ae9")] 18 30 [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] 19 31 [ComVisible(true)] 20 [ProvideAutoLoad("f1536ef8-92ec-443c-9ed7-fdadf150da82")] // This is needed for the package to be autoloaded 32 33 /* Autoload package */ 34 [ProvideAutoLoad("f1536ef8-92ec-443c-9ed7-fdadf150da82")] 35 21 36 public sealed class PluginPackage : Package 22 37 { … … 33 48 base.Initialize(); 34 49 35 // Ensure the "Build" output pane exists 36 IVsOutputWindow outputWindow = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; 37 if (null != outputWindow) 38 { 39 Guid guidBuild = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid; 40 outputWindow.CreatePane(guidBuild, "Build", 1, 0); 41 } 50 Logger.Initialize(GetService(typeof(SVsOutputWindow)) as IVsOutputWindow); 42 51 43 / / Register the "Generate Compilers" context menu52 /* Register the "Generate Compilers" context menu */ 44 53 OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; 45 54 if (null != mcs) 46 55 { 47 CommandID id = new CommandID(GuidsList.guidVsLolCmdSet, VsLolIDList.cmdidGenerateCompilers); 56 CommandID id = new CommandID(GuidsList.guidVsLolCmdSet, 57 VsLolIDList.cmdidGenerateCompilers); 48 58 OleMenuCommand command = new MenuGenerateCompilers(new ServiceProvider((IOleServiceProvider)this.GetService(typeof(IOleServiceProvider))), id); 49 59 mcs.AddCommand(command); 50 60 } 61 62 /* Register the LolFx language service */ 63 IServiceContainer serviceContainer = this as IServiceContainer; 64 LolFxLanguageService lolfxserv = new LolFxLanguageService(); 65 lolfxserv.SetSite(this); 66 serviceContainer.AddService(typeof(LolFxLanguageService), 67 lolfxserv, true); 51 68 } 69 70 } 71 72 internal static class Logger 73 { 74 public static void Initialize(IVsOutputWindow window) 75 { 76 m_window = window; 77 78 OpenBuildPane(); 79 80 if (m_pane == null) 81 Trace.WriteLine("Failed to get a reference to the Output window Build pane"); 82 } 83 84 private static void OpenBuildPane() 85 { 86 /* Ensure the "Build" output pane exists */ 87 if (m_window != null) 88 { 89 Guid guidBuild = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid; 90 m_window.CreatePane(guidBuild, "Build", 1, 0); 91 92 if (Microsoft.VisualStudio.ErrorHandler.Failed(m_window.GetPane(ref guidBuild, out m_pane))) 93 m_pane = null; 94 } 95 } 96 97 public static void Clear() 98 { 99 OpenBuildPane(); 100 101 if (m_pane != null) 102 { 103 m_pane.Activate(); 104 m_pane.Clear(); 105 } 106 } 107 108 public static void Info(string s) 109 { 110 OpenBuildPane(); 111 112 if (m_pane != null) 113 m_pane.OutputString(s); 114 } 115 116 private static IVsOutputWindow m_window = null; 117 private static IVsOutputWindowPane m_pane = null; 52 118 } 53 119 … … 71 137 } 72 138 } 73 -
trunk/tools/vslol/VsLol.csproj
r2117 r2118 56 56 <Reference Include="Microsoft.CSharp" /> 57 57 <Reference Include="Microsoft.VisualStudio.OLE.Interop" /> 58 <Reference Include="Microsoft.VisualStudio.Package.LanguageService.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> 58 59 <Reference Include="Microsoft.VisualStudio.Shell.Interop" /> 59 60 <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" /> … … 65 66 </Reference> 66 67 <Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" /> 68 <Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 67 69 <Reference Include="System" /> 68 70 <Reference Include="System.Core" /> … … 74 76 </ItemGroup> 75 77 <ItemGroup> 78 <Compile Include="LolFxLanguageService.cs" /> 76 79 <Compile Include="MenuGenerateCompilers.cs" /> 77 80 <Compile Include="GlobalSuppressions.cs" />
Note: See TracChangeset
for help on using the changeset viewer.