Ignore:
Timestamp:
Nov 30, 2012, 6:40:43 PM (8 years ago)
Author:
sam
Message:

vslol: add licensing information to important files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/vslol/VsLol.cs

    r2119 r2123  
     1//
     2// Lol Engine - VsLol add-in for Visual Studio
     3//
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
     5//   This program is free software; you can redistribute it and/or
     6//   modify it under the terms of the Do What The Fuck You Want To
     7//   Public License, Version 2, as published by Sam Hocevar. See
     8//   http://www.wtfpl.net/ for more details.
     9//
     10
    111using System;
    212using System.ComponentModel.Design;
     
    1020using Microsoft.VisualStudio.Shell.Interop;
    1121
    12 namespace Lol.VisualStudio.Plugin
     22namespace lol
    1323{
    14     [PackageRegistration(UseManagedResourcesOnly = true)]
    1524
    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")]
     25[PackageRegistration(UseManagedResourcesOnly = true)]
    2726
    28     [ProvideMenuResource(1000, 1)]
    29     [Guid("f96f7ac5-16ac-4061-8b92-0a02bb455ae9")]
    30     [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
    31     [ComVisible(true)]
     27/* LolFx syntax highlighting */
     28[ProvideServiceAttribute(typeof(LolFxLanguageService),
     29                         ServiceName = "LolFx Service")]
     30[ProvideLanguageServiceAttribute(typeof(LolFxLanguageService),
     31                                 "LolFx", 106 /* resource ID */,
     32                                 CodeSense = true,
     33                                 RequestStockColors = true,
     34                                 EnableCommenting = true,
     35                                 EnableAsyncCompletion = true)]
     36[ProvideLanguageExtensionAttribute(typeof(LolFxLanguageService),
     37                                   ".lolfx")]
    3238
    33     /* Autoload package */
    34     [ProvideAutoLoad("f1536ef8-92ec-443c-9ed7-fdadf150da82")]
     39[ProvideMenuResource(1000, 1)]
     40[Guid("f96f7ac5-16ac-4061-8b92-0a02bb455ae9")]
     41[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
     42[ComVisible(true)]
    3543
    36     public sealed class PluginPackage : Package
     44/* Autoload package */
     45[ProvideAutoLoad("f1536ef8-92ec-443c-9ed7-fdadf150da82")]
     46
     47public sealed class PluginPackage : Package
     48{
     49    public PluginPackage()
    3750    {
    38         public PluginPackage()
     51        Trace.WriteLine(String.Format("Entering constructor for: {0}", this.ToString()));
     52    }
     53
     54    [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
     55    protected override void Initialize()
     56    {
     57        // Trace the beginning of this method and call the base implementation.
     58        Trace.WriteLine(String.Format("Entering Initialize() of: {0}", this.ToString()));
     59        base.Initialize();
     60
     61        Logger.Initialize(GetService(typeof(SVsOutputWindow)) as IVsOutputWindow);
     62
     63        /* Register the "Generate Compilers" context menu */
     64        OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
     65        if (null != mcs)
    3966        {
    40             Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering constructor for: {0}", this.ToString()));
     67            CommandID id = new CommandID(GuidsList.guidVsLolCmdSet,
     68                                         VsLolIDList.cmdidGenerateCompilers);
     69            OleMenuCommand command = new MenuGenerateCompilers(new ServiceProvider((IOleServiceProvider)this.GetService(typeof(IOleServiceProvider))), id);
     70            mcs.AddCommand(command);
    4171        }
    4272
    43         [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
    44         protected override void Initialize()
     73        /* Register the LolFx language service */
     74        IServiceContainer serviceContainer = this as IServiceContainer;
     75        LolFxLanguageService lolfxserv = new LolFxLanguageService();
     76        lolfxserv.SetSite(this);
     77        serviceContainer.AddService(typeof(LolFxLanguageService),
     78                                    lolfxserv, true);
     79    }
     80}
     81
     82internal static class Logger
     83{
     84    public static void Initialize(IVsOutputWindow window)
     85    {
     86        m_window = window;
     87
     88        OpenBuildPane();
     89
     90        if (m_pane == null)
     91            Trace.WriteLine("Failed to get a reference to the Output window Build pane");
     92    }
     93
     94    private static void OpenBuildPane()
     95    {
     96        /* Ensure the "Build" output pane exists */
     97        if (m_window != null)
    4598        {
    46             // Trace the beginning of this method and call the base implementation.
    47             Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Initialize() of: {0}", this.ToString()));
    48             base.Initialize();
     99            Guid guidBuild = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid;
     100            m_window.CreatePane(guidBuild, "Build", 1, 0);
    49101
    50             Logger.Initialize(GetService(typeof(SVsOutputWindow)) as IVsOutputWindow);
    51 
    52             /* Register the "Generate Compilers" context menu */
    53             OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
    54             if (null != mcs)
    55             {
    56                 CommandID id = new CommandID(GuidsList.guidVsLolCmdSet,
    57                                              VsLolIDList.cmdidGenerateCompilers);
    58                 OleMenuCommand command = new MenuGenerateCompilers(new ServiceProvider((IOleServiceProvider)this.GetService(typeof(IOleServiceProvider))), id);
    59                 mcs.AddCommand(command);
    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);
     102            if (Microsoft.VisualStudio.ErrorHandler.Failed(m_window.GetPane(ref guidBuild, out m_pane)))
     103                m_pane = null;
    68104        }
    69105
     106        if (m_pane != null)
     107            m_pane.Activate();
    70108    }
    71109
    72     internal static class Logger
     110    public static void Clear()
    73111    {
    74         public static void Initialize(IVsOutputWindow window)
     112        OpenBuildPane();
     113
     114        if (m_pane == null)
    75115        {
    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");
     116            m_backlog = "";
     117            return;
    82118        }
    83119
    84         private static void OpenBuildPane()
     120        m_pane.Clear();
     121    }
     122
     123    public static void Info(string s)
     124    {
     125        OpenBuildPane();
     126
     127        if (m_pane == null)
    85128        {
    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             if (m_pane != null)
    97                 m_pane.Activate();
     129            m_backlog += s;
     130            return;
    98131        }
    99132
    100         public static void Clear()
    101         {
    102             OpenBuildPane();
    103 
    104             if (m_pane == null)
    105             {
    106                 m_backlog = "";
    107                 return;
    108             }
    109 
    110             m_pane.Clear();
    111         }
    112 
    113         public static void Info(string s)
    114         {
    115             OpenBuildPane();
    116 
    117             if (m_pane == null)
    118             {
    119                 m_backlog += s;
    120                 return;
    121             }
    122 
    123             m_pane.OutputString(m_backlog);
    124             m_backlog = "";
    125             m_pane.OutputString(s);
    126         }
    127 
    128         private static IVsOutputWindow m_window = null;
    129         private static IVsOutputWindowPane m_pane = null;
    130         private static string m_backlog = "";
     133        m_pane.OutputString(m_backlog);
     134        m_backlog = "";
     135        m_pane.OutputString(s);
    131136    }
    132137
    133     internal static class GuidsList
    134     {
    135         // Now define the list of guids as public static members.
    136         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
    137         public static readonly Guid guidVsLolPkg = new Guid("{f96f7ac5-16ac-4061-8b92-0a02bb455ae9}");
     138    private static IVsOutputWindow m_window = null;
     139    private static IVsOutputWindowPane m_pane = null;
     140    private static string m_backlog = "";
     141}
    138142
    139         public static readonly Guid guidVsLolCmdSet = new Guid("{ce508d12-530e-45d0-8b52-1e9ee3f8eaaf}");
     143internal static class GuidsList
     144{
     145    // Now define the list of guids as public static members.
     146    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
     147    public static readonly Guid guidVsLolPkg = new Guid("{f96f7ac5-16ac-4061-8b92-0a02bb455ae9}");
    140148
    141         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
    142         public static readonly Guid guidGearBmp = new Guid("{560dba06-c26b-4731-8229-b816818e5992}");
    143     }
     149    public static readonly Guid guidVsLolCmdSet = new Guid("{ce508d12-530e-45d0-8b52-1e9ee3f8eaaf}");
    144150
    145     internal static class VsLolIDList
    146     {
    147         public const int cmdidGenerateCompilers = 0x2001;
    148         public const int cmdidUnused1 = 0x2002;
    149         public const int cmdidUnused2 = 0x2003;
    150     }
     151    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
     152    public static readonly Guid guidGearBmp = new Guid("{560dba06-c26b-4731-8229-b816818e5992}");
    151153}
     154
     155internal static class VsLolIDList
     156{
     157    public const int cmdidGenerateCompilers = 0x2001;
     158    public const int cmdidUnused1 = 0x2002;
     159    public const int cmdidUnused2 = 0x2003;
     160}
     161
     162} /* namespace lol */
Note: See TracChangeset for help on using the changeset viewer.