Changeset 2128 for trunk/tools


Ignore:
Timestamp:
Dec 1, 2012, 7:47:53 PM (7 years ago)
Author:
sam
Message:

vslol: new feature: disable syntax highlighting for Microsoft "extensions"
that aren't exactly extensions and perfectly valid C++ identifiers.

Location:
trunk/tools/vslol
Files:
3 edited

Legend:

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

    r2127 r2128  
    6161    private IClassifier m_classifier;
    6262
    63     private IClassificationType m_types_type, m_constant_type;
    64     private Regex m_types_regex, m_constant_regex;
     63    private IClassificationType m_types_type, m_constant_type, m_normal_type;
     64    private Regex m_types_regex, m_constant_regex, m_normal_regex;
    6565
    6666    private static string[] m_all_types =
     
    122122    };
    123123
     124    private static string[] m_all_normal =
     125    {
     126    };
     127
     128    private static string[] m_cpp_normal =
     129    {
     130        "interface|delegate|event|finally",
     131        "gcnew|generic|initonly|property|sealed",
     132    };
     133
    124134    internal CppKeywordClassifier(IClassificationTypeRegistryService registry,
    125135                                  IClassifier classifier,
     
    128138        m_classifier = classifier;
    129139
    130         /* Regex for types and specifiers */
    131140        m_types_type = registry.GetClassificationType("LolAnyType");
     141        m_normal_type = registry.GetClassificationType("LolAnyIdentifier");
     142        m_constant_type = registry.GetClassificationType("LolAnyConstant");
    132143
    133144        List<string> types_list = m_all_types.ToList();
     145        List<string> constants_list = m_all_constants.ToList();
     146        List<string> normals_list = m_all_normal.ToList();
     147
    134148        if (type.IsOfType("c/c++"))
     149        {
    135150            types_list = types_list.Concat(m_cpp_types).ToList();
     151            constants_list = constants_list.Concat(m_cpp_constants).ToList();
     152            normals_list = normals_list.Concat(m_cpp_normal).ToList();
     153        }
     154
    136155        if (type.IsOfType("csharp"))
     156        {
    137157            types_list = types_list.Concat(m_csharp_types).ToList();
     158            constants_list = constants_list.Concat(m_csharp_constants).ToList();
     159        }
     160
    138161        if (type.IsOfType("lolfx"))
     162        {
    139163            types_list = types_list.Concat(m_lolfx_types).ToList();
     164            constants_list = constants_list.Concat(m_lolfx_constants).ToList();
     165        }
     166
    140167        m_types_regex =
    141             new Regex(@"\b(" + String.Join("|", types_list.ToArray()) + @")\b");
    142 
    143         /* Regex for constant words */
    144         m_constant_type = registry.GetClassificationType("LolAnyConstant");
    145 
    146         List<string> constants_list = m_all_constants.ToList();
    147         if (type.IsOfType("c/c++"))
    148             constants_list = constants_list.Concat(m_cpp_constants).ToList();
    149         if (type.IsOfType("csharp"))
    150             constants_list = constants_list.Concat(m_csharp_constants).ToList();
    151         if (type.IsOfType("lolfx"))
    152             constants_list = constants_list.Concat(m_lolfx_constants).ToList();
     168            new Regex("^(" + String.Join("|", types_list.ToArray()) + ")$");
    153169        m_constant_regex =
    154             new Regex(@"\b(" + String.Join("|", constants_list.ToArray()) + @")\b");
     170            new Regex("^(" + String.Join("|", constants_list.ToArray()) + ")$");
     171        m_normal_regex =
     172            new Regex("^(" + String.Join("|", normals_list.ToArray()) + ")$");
    155173    }
    156174
     
    177195                    continue;
    178196                }
     197
     198                if (m_normal_regex.IsMatch(cs.Span.GetText()))
     199                {
     200                    ret.Add(new ClassificationSpan(cs.Span, m_normal_type));
     201                    continue;
     202                }
    179203            }
    180204
     
    243267    [Name(LolCppConstantFormat.m_name)]
    244268    internal static ClassificationTypeDefinition LolCustomConstantType = null;
     269
     270    [Export(typeof(ClassificationTypeDefinition))]
     271    [Name(LolCppIdentifierFormat.m_name)]
     272    internal static ClassificationTypeDefinition LolCustomIdentifierType = null;
    245273}
    246274
     
    255283    public LolCppTypeFormat()
    256284    {
    257         this.DisplayName = "C/C++ Types and Qualifiers";
     285        this.DisplayName = "C/C++ Types and Qualifiers (VsLol)";
    258286        this.ForegroundColor = Colors.Lime;
    259287        this.ForegroundOpacity = 1.0;
     
    273301    public LolCppConstantFormat()
    274302    {
    275         this.DisplayName = "C/C++ Constants";
     303        this.DisplayName = "C/C++ Constants (VsLol)";
    276304        this.ForegroundColor = Colors.Magenta;
    277305        this.ForegroundOpacity = 1.0;
     
    281309}
    282310
     311[Export(typeof(EditorFormatDefinition))]
     312[ClassificationType(ClassificationTypeNames = LolCppIdentifierFormat.m_name)]
     313[Name(LolCppIdentifierFormat.m_name)]
     314[UserVisible(true)]
     315[Order(After = Priority.Default)] /* Override the Visual Studio classifiers */
     316internal sealed class LolCppIdentifierFormat : LolGenericFormat
     317{
     318    public const string m_name = "LolAnyIdentifier";
     319    public LolCppIdentifierFormat()
     320    {
     321        this.DisplayName = "C/C++ Identifiers (VsLol)";
     322        this.ForegroundColor = Colors.Silver;
     323        this.ForegroundOpacity = 1.0;
     324        this.IsBold = false;
     325        CopyStyleColor(PredefinedClassificationTypeNames.Identifier);
     326    }
     327}
     328
    283329} /* namespace lol */
  • trunk/tools/vslol/Properties/AssemblyInfo.cs

    r2123 r2128  
    3030[assembly: Guid("58968f91-edb8-4a4c-9f4f-ba39fdb4a21a")]
    3131
    32 [assembly: AssemblyVersion("1.0.0.5")]
    33 [assembly: AssemblyFileVersion("1.0.0.5")]
     32[assembly: AssemblyVersion("1.0.0.6")]
     33[assembly: AssemblyFileVersion("1.0.0.6")]
  • trunk/tools/vslol/source.extension.vsixmanifest

    r2122 r2128  
    44    <Name>VsLol</Name>
    55    <Author>Lol</Author>
    6     <Version>1.0.0.5</Version>
     6    <Version>1.0.0.6</Version>
    77    <Description xml:space="preserve">Lol Engine Productivity Tools.</Description>
    88    <Locale>1033</Locale>
Note: See TracChangeset for help on using the changeset viewer.