Changeset 2604


Ignore:
Timestamp:
Mar 25, 2013, 7:20:01 PM (7 years ago)
Author:
sam
Message:

vslol: highlight Lol Engine types if the solution name is Lol.sln.

File:
1 edited

Legend:

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

    r2213 r2604  
    1717using System.Diagnostics; /* For debugging purposes */
    1818
     19using Microsoft.VisualStudio.Shell;
    1920using Microsoft.VisualStudio.Text;
    2021using Microsoft.VisualStudio.Text.Classification;
     
    3839    [Import]
    3940    internal IClassificationFormatMapService m_format_map = null;
     41#if FALSE
     42    [Import]
     43    internal ITextDocumentFactoryService m_textdoc_factory = null;
     44#endif
     45    [Import]
     46    internal SVsServiceProvider m_sp = null;
    4047
    4148    internal static bool m_inprogress = false;
     
    4754            return null;
    4855
     56        /* Try to guess whether this is a Lol Engine project */
     57#if FALSE
     58        if (m_textdoc_factory != null)
     59        {
     60            ITextDocument doc;
     61            m_textdoc_factory.TryGetTextDocument(buffer, out doc);
     62            /* print doc.FilePath */
     63        }
     64#endif
     65        EnvDTE.DTE dte = m_sp.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
     66        bool islolengine = false;
     67        if (dte.Solution.FullName.Contains("Lol.sln"))
     68            islolengine = true;
     69
    4970        LolGenericFormat.SetRegistry(m_type_registry, m_format_map);
    5071
     
    5273        {
    5374            m_inprogress = true;
    54             return buffer.Properties.GetOrCreateSingletonProperty<CppKeywordClassifier>(delegate { return new CppKeywordClassifier(m_type_registry, m_aggregator.GetClassifier(buffer), buffer.ContentType); });
     75            return buffer.Properties.GetOrCreateSingletonProperty<CppKeywordClassifier>(delegate { return new CppKeywordClassifier(m_type_registry, m_aggregator.GetClassifier(buffer), buffer.ContentType, islolengine); });
    5576        }
    5677        finally { m_inprogress = false; }
     
    6182{
    6283    private IClassifier m_classifier;
    63     private bool m_inprogress;
     84    private bool m_inprogress, m_islolengine;
    6485
    6586    private IClassificationType m_types_type, m_constant_type, m_normal_type;
     
    84105    };
    85106
    86     /* ldouble real half
    87        "(f(16|128)||d|[ui](8|16||64)|r)(vec[234]|mat[234]|quat|cmplx)";
    88      */
     107    private static string[] m_lol_types =
     108    {
     109        "ldouble|real|half",
     110        "(f(16|128)||d|[ui](8|16||64)|r)(vec[234]|mat[234]|quat|cmplx)",
     111    };
    89112
    90113    private static string[] m_csharp_types =
     
    110133        "NULL|nullptr",
    111134        "EXIT_SUCCESS|EXIT_FAILURE",
    112         "M_(E|LOG(2|10)E|LN2|LN10|PI|PI_2|PI_4|1_PI|2_PI|2_SQRTPI|SQRT(2|1_2))",
     135        "M_(E|LOG(2|10)E|LN2|LN10|PI|PI_[24]|[12]_PI|2_SQRTPI|SQRT(2|1_2))",
    113136        "SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|FPE|KILL|USR1|SEGV|USR2|PIPE|ALRM)",
    114137        "SIG(TERM|CHLD|CONT|STOP|TSTP|TTIN|TTOU)"
    115138    };
    116139
     140    private static string[] m_lol_constants =
     141    {
     142        "(F|D|LD)_(PI|PI_[234]|[12]_PI|SQRT(2|3|1_2))",
     143    };
     144
    117145    private static string[] m_csharp_constants =
    118146    {
     
    137165    internal CppKeywordClassifier(IClassificationTypeRegistryService registry,
    138166                                  IClassifier classifier,
    139                                   IContentType type)
     167                                  IContentType type,
     168                                  bool islolengine)
    140169    {
    141170        m_classifier = classifier;
    142171        m_inprogress = false;
     172        m_islolengine = islolengine;
    143173
    144174        m_types_type = registry.GetClassificationType("LolAnyType");
     
    167197            types_list = types_list.Concat(m_lolfx_types).ToList();
    168198            constants_list = constants_list.Concat(m_lolfx_constants).ToList();
     199        }
     200
     201        if (m_islolengine)
     202        {
     203            types_list = types_list.Concat(m_lol_types).ToList();
     204            constants_list = constants_list.Concat(m_lol_constants).ToList();
    169205        }
    170206
Note: See TracChangeset for help on using the changeset viewer.