diff --git a/tools/vslol/CppKeywordClassifier.cs b/tools/vslol/CppKeywordClassifier.cs index 8a83e95d..4db66f96 100644 --- a/tools/vslol/CppKeywordClassifier.cs +++ b/tools/vslol/CppKeywordClassifier.cs @@ -60,8 +60,8 @@ class CppKeywordClassifier : IClassifier { private IClassifier m_classifier; - private IClassificationType m_types_type, m_constant_type; - private Regex m_types_regex, m_constant_regex; + private IClassificationType m_types_type, m_constant_type, m_normal_type; + private Regex m_types_regex, m_constant_regex, m_normal_regex; private static string[] m_all_types = { @@ -121,37 +121,55 @@ class CppKeywordClassifier : IClassifier "gl_Position|gl_FragColor", }; + private static string[] m_all_normal = + { + }; + + private static string[] m_cpp_normal = + { + "interface|delegate|event|finally", + "gcnew|generic|initonly|property|sealed", + }; + internal CppKeywordClassifier(IClassificationTypeRegistryService registry, IClassifier classifier, IContentType type) { m_classifier = classifier; - /* Regex for types and specifiers */ m_types_type = registry.GetClassificationType("LolAnyType"); - - List types_list = m_all_types.ToList(); - if (type.IsOfType("c/c++")) - types_list = types_list.Concat(m_cpp_types).ToList(); - if (type.IsOfType("csharp")) - types_list = types_list.Concat(m_csharp_types).ToList(); - if (type.IsOfType("lolfx")) - types_list = types_list.Concat(m_lolfx_types).ToList(); - m_types_regex = - new Regex(@"\b(" + String.Join("|", types_list.ToArray()) + @")\b"); - - /* Regex for constant words */ + m_normal_type = registry.GetClassificationType("LolAnyIdentifier"); m_constant_type = registry.GetClassificationType("LolAnyConstant"); + List types_list = m_all_types.ToList(); List constants_list = m_all_constants.ToList(); + List normals_list = m_all_normal.ToList(); + if (type.IsOfType("c/c++")) + { + types_list = types_list.Concat(m_cpp_types).ToList(); constants_list = constants_list.Concat(m_cpp_constants).ToList(); + normals_list = normals_list.Concat(m_cpp_normal).ToList(); + } + if (type.IsOfType("csharp")) + { + types_list = types_list.Concat(m_csharp_types).ToList(); constants_list = constants_list.Concat(m_csharp_constants).ToList(); + } + if (type.IsOfType("lolfx")) + { + types_list = types_list.Concat(m_lolfx_types).ToList(); constants_list = constants_list.Concat(m_lolfx_constants).ToList(); + } + + m_types_regex = + new Regex("^(" + String.Join("|", types_list.ToArray()) + ")$"); m_constant_regex = - new Regex(@"\b(" + String.Join("|", constants_list.ToArray()) + @")\b"); + new Regex("^(" + String.Join("|", constants_list.ToArray()) + ")$"); + m_normal_regex = + new Regex("^(" + String.Join("|", normals_list.ToArray()) + ")$"); } public IList GetClassificationSpans(SnapshotSpan span) @@ -176,6 +194,12 @@ class CppKeywordClassifier : IClassifier ret.Add(new ClassificationSpan(cs.Span, m_constant_type)); continue; } + + if (m_normal_regex.IsMatch(cs.Span.GetText())) + { + ret.Add(new ClassificationSpan(cs.Span, m_normal_type)); + continue; + } } ret.Add(cs); @@ -242,6 +266,10 @@ internal static class LolClassifierClassificationDefinition [Export(typeof(ClassificationTypeDefinition))] [Name(LolCppConstantFormat.m_name)] internal static ClassificationTypeDefinition LolCustomConstantType = null; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(LolCppIdentifierFormat.m_name)] + internal static ClassificationTypeDefinition LolCustomIdentifierType = null; } [Export(typeof(EditorFormatDefinition))] @@ -254,7 +282,7 @@ internal sealed class LolCppTypeFormat : LolGenericFormat public const string m_name = "LolAnyType"; public LolCppTypeFormat() { - this.DisplayName = "C/C++ Types and Qualifiers"; + this.DisplayName = "C/C++ Types and Qualifiers (VsLol)"; this.ForegroundColor = Colors.Lime; this.ForegroundOpacity = 1.0; this.IsBold = true; @@ -272,7 +300,7 @@ internal sealed class LolCppConstantFormat : LolGenericFormat public const string m_name = "LolAnyConstant"; public LolCppConstantFormat() { - this.DisplayName = "C/C++ Constants"; + this.DisplayName = "C/C++ Constants (VsLol)"; this.ForegroundColor = Colors.Magenta; this.ForegroundOpacity = 1.0; this.IsBold = true; @@ -280,4 +308,22 @@ internal sealed class LolCppConstantFormat : LolGenericFormat } } +[Export(typeof(EditorFormatDefinition))] +[ClassificationType(ClassificationTypeNames = LolCppIdentifierFormat.m_name)] +[Name(LolCppIdentifierFormat.m_name)] +[UserVisible(true)] +[Order(After = Priority.Default)] /* Override the Visual Studio classifiers */ +internal sealed class LolCppIdentifierFormat : LolGenericFormat +{ + public const string m_name = "LolAnyIdentifier"; + public LolCppIdentifierFormat() + { + this.DisplayName = "C/C++ Identifiers (VsLol)"; + this.ForegroundColor = Colors.Silver; + this.ForegroundOpacity = 1.0; + this.IsBold = false; + CopyStyleColor(PredefinedClassificationTypeNames.Identifier); + } +} + } /* namespace lol */ diff --git a/tools/vslol/Properties/AssemblyInfo.cs b/tools/vslol/Properties/AssemblyInfo.cs index 5585c13c..0e9f14dc 100644 --- a/tools/vslol/Properties/AssemblyInfo.cs +++ b/tools/vslol/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("58968f91-edb8-4a4c-9f4f-ba39fdb4a21a")] -[assembly: AssemblyVersion("1.0.0.5")] -[assembly: AssemblyFileVersion("1.0.0.5")] +[assembly: AssemblyVersion("1.0.0.6")] +[assembly: AssemblyFileVersion("1.0.0.6")] diff --git a/tools/vslol/source.extension.vsixmanifest b/tools/vslol/source.extension.vsixmanifest index 9f78f037..8fe742b2 100644 --- a/tools/vslol/source.extension.vsixmanifest +++ b/tools/vslol/source.extension.vsixmanifest @@ -3,7 +3,7 @@ VsLol Lol - 1.0.0.5 + 1.0.0.6 Lol Engine Productivity Tools. 1033 http://lol.zoy.org/