Skip to content

Commit

Permalink
Version 2.9
Browse files Browse the repository at this point in the history
! Compatible with VS 15.7
! Reorganized option pages
+ Showed delegate signature in Super Quick Info
+ Showed number of cases in switch statement
+ Showed delegate argument documentation
! Possible to highlight namespace declaration braces
- Fixed an issue which could crash VS in Scrollbar Marker
  • Loading branch information
wmjordan committed May 15, 2018
1 parent 381a919 commit 5828ea3
Show file tree
Hide file tree
Showing 40 changed files with 2,158 additions and 832 deletions.
55 changes: 50 additions & 5 deletions Codist/Codist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,41 @@
<Compile Include="Options\ConfigPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Options\CSharpPage.cs">
<Compile Include="Options\CSharpSpecialHighlightPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\CSharpPage.Designer.cs">
<DependentUpon>CSharpPage.cs</DependentUpon>
<Compile Include="Options\CSharpSpecialHighlightPage.Designer.cs">
<DependentUpon>CSharpSpecialHighlightPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\CSharpScrollbarMarkerPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\CSharpScrollbarMarkerPage.Designer.cs">
<DependentUpon>CSharpScrollbarMarkerPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\CSharpSuperQuickInfoPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\CSharpSuperQuickInfoPage.Designer.cs">
<DependentUpon>CSharpSuperQuickInfoPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\SyntaxHighlightPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\SyntaxHighlightPage.Designer.cs">
<DependentUpon>SyntaxHighlightPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\ScrollbarMarkerPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\ScrollbarMarkerPage.Designer.cs">
<DependentUpon>ScrollbarMarkerPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\SuperQuickInfoPage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Options\SuperQuickInfoPage.Designer.cs">
<DependentUpon>SuperQuickInfoPage.cs</DependentUpon>
</Compile>
<Compile Include="Options\GeneralPage.cs">
<SubType>UserControl</SubType>
Expand Down Expand Up @@ -402,8 +432,23 @@
<EmbeddedResource Include="Options\CommentTaggerOptionPage.resx">
<DependentUpon>CommentTaggerOptionPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\CSharpPage.resx">
<DependentUpon>CSharpPage.cs</DependentUpon>
<EmbeddedResource Include="Options\CSharpSpecialHighlightPage.resx">
<DependentUpon>CSharpSpecialHighlightPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\CSharpScrollbarMarkerPage.resx">
<DependentUpon>CSharpScrollbarMarkerPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\CSharpSuperQuickInfoPage.resx">
<DependentUpon>CSharpSuperQuickInfoPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\SyntaxHighlightPage.resx">
<DependentUpon>SyntaxHighlightPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\ScrollbarMarkerPage.resx">
<DependentUpon>ScrollbarMarkerPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\SuperQuickInfoPage.resx">
<DependentUpon>SuperQuickInfoPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options\GeneralPage.resx">
<DependentUpon>GeneralPage.cs</DependentUpon>
Expand Down
21 changes: 15 additions & 6 deletions Codist/CodistPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@ namespace Codist
/// </para>
/// </remarks>
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "2.8", IconResourceID = 400)] // Information on this package for Help/About
[InstalledProductRegistration("#110", "#112", "2.9", IconResourceID = 400)] // Information on this package for Help/About
[Guid(PackageGuidString)]
[ProvideOptionPage(typeof(Options.Misc), Constants.NameOfMe, "General", 0, 0, true)]
[ProvideOptionPage(typeof(Options.CSharp), Constants.NameOfMe, "C#", 0, 0, true, Sort = 10)]
[ProvideOptionPage(typeof(Options.CodeStyle), Constants.NameOfMe , "Syntax highlight (C# & C++)", 0, 0, true, Sort = 110)]
[ProvideOptionPage(typeof(Options.XmlCodeStyle), Constants.NameOfMe, "Syntax highlight (XML)", 0, 0, true, Sort = 120)]
[ProvideOptionPage(typeof(Options.CommentStyle), Constants.NameOfMe, "Syntax highlight (Comment)", 0, 0, true, Sort = 130)]
[ProvideOptionPage(typeof(Options.CommentTagger), Constants.NameOfMe + "\\Syntax highlight (Comment)", "Tagger (Comment)", 0, 0, true, Sort = 131)]
[ProvideOptionPage(typeof(Options.SuperQuickInfo), CategorySuperQuickInfo, "General", 0, 0, true, Sort = 10)]
[ProvideOptionPage(typeof(Options.CSharpSuperQuickInfo), CategorySuperQuickInfo, "C#", 0, 0, true, Sort = 20)]
[ProvideOptionPage(typeof(Options.ScrollbarMarker), CategoryScrollbarMarker, "General", 0, 0, true, Sort = 50)]
[ProvideOptionPage(typeof(Options.CSharpScrollbarMarker), CategoryScrollbarMarker, "C#", 0, 0, true, Sort = 50)]
[ProvideOptionPage(typeof(Options.SyntaxHighlight), CategorySyntaxHighlight, "General", 0, 0, true, Sort = 100)]
[ProvideOptionPage(typeof(Options.CodeStyle), CategorySyntaxHighlight, "Common styles", 0, 0, true, Sort = 10)]
[ProvideOptionPage(typeof(Options.CSharpStyle), CategorySyntaxHighlight, "C# & C++ styles", 0, 0, true, Sort = 20)]
[ProvideOptionPage(typeof(Options.CSharpSpecialHighlight), CategorySyntaxHighlight, "C# Special highlight", 0, 0, true, Sort = 30)]
[ProvideOptionPage(typeof(Options.XmlCodeStyle), CategorySyntaxHighlight, "XML styles", 0, 0, true, Sort = 40)]
[ProvideOptionPage(typeof(Options.CommentStyle), CategorySyntaxHighlight, "Comment styles", 0, 0, true, Sort = 50)]
[ProvideOptionPage(typeof(Options.CommentTagger), CategorySyntaxHighlight, "Comment Tagger", 0, 0, true, Sort = 60)]
sealed class CodistPackage : Package
{
const string CategorySuperQuickInfo = Constants.NameOfMe + "\\Super Quick Info";
const string CategoryScrollbarMarker = Constants.NameOfMe + "\\Scrollbar Marker";
const string CategorySyntaxHighlight = Constants.NameOfMe + "\\Syntax Highlight";
/// <summary>
/// CodistPackage GUID string.
/// </summary>
Expand Down
144 changes: 103 additions & 41 deletions Codist/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public double BottomSpace {
public List<CommentLabel> Labels { get; } = new List<CommentLabel>();
public List<CommentStyle> CommentStyles { get; } = new List<CommentStyle>();
public List<XmlCodeStyle> XmlCodeStyles { get; } = new List<XmlCodeStyle>();
public List<CodeStyle> CodeStyles { get; } = new List<CodeStyle>();
public List<CSharpStyle> CodeStyles { get; } = new List<CSharpStyle>();
public List<CodeStyle> GeneralStyles { get; } = new List<CodeStyle>();

public static event EventHandler Loaded;
public static event EventHandler Updated;
Expand Down Expand Up @@ -110,22 +111,30 @@ static Config InternalLoadConfig(string configPath) {
if (l.Count == 0) {
InitDefaultLabels(l);
}
var cs = config.GeneralStyles;
CleanUpStyleEntry(cs, loadFromTheme);
for (int i = cs.Count - 1; i >= 0; i--) {
if (cs[i] == null || Enum.IsDefined(typeof(CodeStyleTypes), cs[i].StyleID) == false) {
cs.RemoveAt(i);
}
}
MergeDefaultCodeStyles(cs);
var s = config.CommentStyles;
CleanUpStyleEntry(s, loadFromTheme);
for (int i = s.Count - 1; i >= 0; i--) {
if (s[i] == null || Enum.IsDefined(typeof(CommentStyleTypes), s[i].StyleID) == false) {
s.RemoveAt(i);
}
}
MergeDefaultStyles(s);
var cs = config.CodeStyles;
CleanUpStyleEntry(cs, loadFromTheme);
for (int i = cs.Count - 1; i >= 0; i--) {
if (cs[i] == null || Enum.IsDefined(typeof(CodeStyleTypes), cs[i].StyleID) == false) {
cs.RemoveAt(i);
MergeDefaultCommentStyles(s);
var css = config.CodeStyles;
CleanUpStyleEntry(css, loadFromTheme);
for (int i = css.Count - 1; i >= 0; i--) {
if (css[i] == null || Enum.IsDefined(typeof(CSharpStyleTypes), css[i].StyleID) == false) {
css.RemoveAt(i);
}
}
MergeDefaultCodeStyles(cs);
MergeDefaultCSharpStyles(css);
var xcs = config.XmlCodeStyles;
CleanUpStyleEntry(xcs, loadFromTheme);
for (int i = xcs.Count - 1; i >= 0; i--) {
Expand All @@ -149,7 +158,7 @@ static Config InternalLoadConfig(string configPath) {

public static void ResetStyles() {
ResetCodeStyle(Instance.CommentStyles, GetDefaultCommentStyles());
ResetCodeStyle(Instance.CodeStyles, GetDefaultCodeStyles());
ResetCodeStyle(Instance.CodeStyles, GetDefaultCSharpStyles());
ResetCodeStyle(Instance.XmlCodeStyles, GetDefaultXmlCodeStyles());
Updated?.Invoke(Instance, EventArgs.Empty);
}
Expand Down Expand Up @@ -201,8 +210,9 @@ static Config GetDefaultConfig() {
_LastLoaded = DateTime.Now;
var c = new Config();
InitDefaultLabels(c.Labels);
c.GeneralStyles.AddRange(GetDefaultCodeStyles());
c.CommentStyles.AddRange(GetDefaultCommentStyles());
c.CodeStyles.AddRange(GetDefaultCodeStyles());
c.CodeStyles.AddRange(GetDefaultCSharpStyles());
c.XmlCodeStyles.AddRange(GetDefaultXmlCodeStyles());
return c;
}
Expand All @@ -228,15 +238,22 @@ static void InitDefaultLabels(List<CommentLabel> labels) {
new CommentLabel("HACK", CommentStyleTypes.Hack, true) { AllowPunctuationDelimiter = true },
});
}
static void MergeDefaultStyles(List<CommentStyle> styles) {
static void MergeDefaultCodeStyles(List<CodeStyle> styles) {
foreach (var s in GetDefaultCodeStyles()) {
if (s.Id > 0 && styles.FindIndex(i => i.StyleID == s.StyleID) == -1) {
styles.Add(s);
}
}
}
static void MergeDefaultCommentStyles(List<CommentStyle> styles) {
foreach (var s in GetDefaultCommentStyles()) {
if (s.Id > 0 && styles.FindIndex(i=> i.StyleID == s.StyleID) == -1) {
styles.Add(s);
}
}
}
static void MergeDefaultCodeStyles(List<CodeStyle> styles) {
foreach (var s in GetDefaultCodeStyles()) {
static void MergeDefaultCSharpStyles(List<CSharpStyle> styles) {
foreach (var s in GetDefaultCSharpStyles()) {
if (s.Id > 0 && styles.FindIndex(i => i.StyleID == s.StyleID) == -1) {
styles.Add(s);
}
Expand Down Expand Up @@ -287,6 +304,13 @@ internal static CodeStyle[] GetDefaultCodeStyles() {
}
return r;
}
internal static CSharpStyle[] GetDefaultCSharpStyles() {
var r = new CSharpStyle[Enum.GetValues(typeof(CSharpStyleTypes)).Length];
for (int i = 0; i < r.Length; i++) {
r[i] = new CSharpStyle { StyleID = (CSharpStyleTypes)i };
}
return r;
}
internal static XmlCodeStyle[] GetDefaultXmlCodeStyles() {
var r = new XmlCodeStyle[Enum.GetValues(typeof(XmlStyleTypes)).Length];
for (int i = 0; i < r.Length; i++) {
Expand Down Expand Up @@ -370,76 +394,85 @@ internal void Reset() {
}

[DebuggerDisplay("{StyleID} {ForegroundColor} {FontSize}")]
sealed class CommentStyle : StyleBase
sealed class CodeStyle : StyleBase
{
public CommentStyle() {
}
public CommentStyle(CommentStyleTypes styleID) {
StyleID = styleID;
}
public CommentStyle(CommentStyleTypes styleID, Color foregroundColor) {
StyleID = styleID;
ForegroundColor = foregroundColor.ToHexString();
}
string _Category;

public override int Id => (int)StyleID;

/// <summary>Gets or sets the comment style.</summary>
public CommentStyleTypes StyleID { get; set; }

public override string Category => Constants.SyntaxCategory.Comment;
/// <summary>Gets or sets the code style.</summary>
public CodeStyleTypes StyleID { get; set; }

internal new CommentStyle Clone() {
return (CommentStyle)MemberwiseClone();
public override string Category {
get {
if (_Category != null) {
return _Category;
}
var f = typeof(CodeStyleTypes).GetField(StyleID.ToString());
if (f == null) {
return _Category = String.Empty;
}
var c = f.GetCustomAttribute<CategoryAttribute>(false);
if (c == null) {
return _Category = String.Empty;
}
return _Category = c.Category;
}
}
internal new CodeStyle Clone() {
return (CodeStyle)MemberwiseClone();
}

public override string ToString() {
return StyleID.ToString();
return FriendlyNamePattern.Replace(StyleID.ToString(), "$1 $2");
}
}

[DebuggerDisplay("{StyleID} {ForegroundColor} {FontSize}")]
sealed class XmlCodeStyle : StyleBase
sealed class CommentStyle : StyleBase
{
public XmlCodeStyle() {
public CommentStyle() {
}
public XmlCodeStyle(XmlStyleTypes styleID, Color foregroundColor) {
public CommentStyle(CommentStyleTypes styleID) {
StyleID = styleID;
}
public CommentStyle(CommentStyleTypes styleID, Color foregroundColor) {
StyleID = styleID;
ForegroundColor = foregroundColor.ToHexString();
}

public override int Id => (int)StyleID;

/// <summary>Gets or sets the comment style.</summary>
public XmlStyleTypes StyleID { get; set; }
public CommentStyleTypes StyleID { get; set; }

public override string Category => StyleID != XmlStyleTypes.None ? Constants.SyntaxCategory.Xml : String.Empty;
public override string Category => Constants.SyntaxCategory.Comment;

internal new CommentStyle Clone() {
return (CommentStyle)MemberwiseClone();
}

public override string ToString() {
return FriendlyNamePattern.Replace(StyleID.ToString(), "$1 $2");
return StyleID.ToString();
}
}

[DebuggerDisplay("{StyleID} {ForegroundColor} {FontSize}")]
sealed class CodeStyle : StyleBase
sealed class CSharpStyle : StyleBase
{
string _Category;

public override int Id => (int)StyleID;

/// <summary>Gets or sets the code style.</summary>
public CodeStyleTypes StyleID { get; set; }
public CSharpStyleTypes StyleID { get; set; }

public override string Category {
get {
if (_Category != null) {
return _Category;
}
var f = typeof(CodeStyleTypes).GetField(StyleID.ToString());
var f = typeof(CSharpStyleTypes).GetField(StyleID.ToString());
if (f == null) {
return _Category = String.Empty;
}
Expand All @@ -450,8 +483,34 @@ public override string Category {
return _Category = c.Category;
}
}
internal new CodeStyle Clone() {
return (CodeStyle)MemberwiseClone();
internal new CSharpStyle Clone() {
return (CSharpStyle)MemberwiseClone();
}

public override string ToString() {
return FriendlyNamePattern.Replace(StyleID.ToString(), "$1 $2");
}
}

[DebuggerDisplay("{StyleID} {ForegroundColor} {FontSize}")]
sealed class XmlCodeStyle : StyleBase
{
public XmlCodeStyle() {
}
public XmlCodeStyle(XmlStyleTypes styleID, Color foregroundColor) {
StyleID = styleID;
ForegroundColor = foregroundColor.ToHexString();
}

public override int Id => (int)StyleID;

/// <summary>Gets or sets the comment style.</summary>
public XmlStyleTypes StyleID { get; set; }

public override string Category => StyleID != XmlStyleTypes.None ? Constants.SyntaxCategory.Xml : String.Empty;

internal new CommentStyle Clone() {
return (CommentStyle)MemberwiseClone();
}

public override string ToString() {
Expand Down Expand Up @@ -551,10 +610,13 @@ public enum QuickInfoOptions
TypeParameters = 1 << 11,
OverrideDefaultDocumentation = 1 << 20,
DocumentationFromBaseType = 1 << 21,
TextOnlyDoc = 1 << 22,
ReturnsDoc = 1 << 23,
Selection = 1 << 27,
ClickAndGo = 1 << 28,
CtrlQuickInfo = 1 << 29,
HideOriginalQuickInfo = 1 << 30,
QuickInfoOverride = OverrideDefaultDocumentation | DocumentationFromBaseType,
Default = Attributes | BaseType | Interfaces | NumericValues | InterfaceImplementations | ClickAndGo,
}

Expand Down
Loading

0 comments on commit 5828ea3

Please sign in to comment.