-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup in VS generator UI code. #74448
Changes from 5 commits
bedf640
1eda82f
1b59759
cf4c87e
4d66ca3
0632dc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,83 +9,42 @@ | |
using Microsoft.VisualStudio.Imaging; | ||
using Microsoft.VisualStudio.Imaging.Interop; | ||
|
||
namespace Microsoft.VisualStudio.LanguageServices.Implementation.SolutionExplorer | ||
namespace Microsoft.VisualStudio.LanguageServices.Implementation.SolutionExplorer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FSNs and primary constructors. |
||
|
||
internal partial class AnalyzerItem( | ||
AnalyzersFolderItem analyzersFolder, | ||
AnalyzerReference analyzerReference, | ||
IContextMenuController contextMenuController) : BaseItem(GetNameText(analyzerReference)) | ||
{ | ||
internal partial class AnalyzerItem : BaseItem | ||
{ | ||
private readonly AnalyzersFolderItem _analyzersFolder; | ||
private readonly AnalyzerReference _analyzerReference; | ||
private readonly IContextMenuController _contextMenuController; | ||
public AnalyzersFolderItem AnalyzersFolder { get; } = analyzersFolder; | ||
public AnalyzerReference AnalyzerReference { get; } = analyzerReference; | ||
public override IContextMenuController ContextMenuController { get; } = contextMenuController; | ||
|
||
public AnalyzerItem(AnalyzersFolderItem analyzersFolder, AnalyzerReference analyzerReference, IContextMenuController contextMenuController) | ||
: base(GetNameText(analyzerReference)) | ||
{ | ||
_analyzersFolder = analyzersFolder; | ||
_analyzerReference = analyzerReference; | ||
_contextMenuController = contextMenuController; | ||
} | ||
public override ImageMoniker IconMoniker => KnownMonikers.CodeInformation; | ||
|
||
public override ImageMoniker IconMoniker | ||
{ | ||
get | ||
{ | ||
return KnownMonikers.CodeInformation; | ||
} | ||
} | ||
public override ImageMoniker OverlayIconMoniker | ||
=> this.AnalyzerReference is UnresolvedAnalyzerReference | ||
? KnownMonikers.OverlayWarning | ||
: default; | ||
|
||
public override ImageMoniker OverlayIconMoniker | ||
{ | ||
get | ||
{ | ||
if (_analyzerReference is UnresolvedAnalyzerReference) | ||
{ | ||
return KnownMonikers.OverlayWarning; | ||
} | ||
else | ||
{ | ||
return default; | ||
} | ||
} | ||
} | ||
public override object GetBrowseObject() | ||
=> new BrowseObject(this); | ||
|
||
public override object GetBrowseObject() | ||
{ | ||
return new BrowseObject(this); | ||
} | ||
/// <summary> | ||
/// Remove this AnalyzerItem from it's folder. | ||
/// </summary> | ||
public void Remove() | ||
=> this.AnalyzersFolder.RemoveAnalyzer(this.AnalyzerReference.FullPath); | ||
|
||
public AnalyzerReference AnalyzerReference | ||
CyrusNajmabadi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
get { return _analyzerReference; } | ||
} | ||
|
||
public override IContextMenuController ContextMenuController | ||
{ | ||
get { return _contextMenuController; } | ||
} | ||
|
||
public AnalyzersFolderItem AnalyzersFolder | ||
{ | ||
get { return _analyzersFolder; } | ||
} | ||
|
||
/// <summary> | ||
/// Remove this AnalyzerItem from it's folder. | ||
/// </summary> | ||
public void Remove() | ||
private static string GetNameText(AnalyzerReference analyzerReference) | ||
{ | ||
if (analyzerReference is UnresolvedAnalyzerReference) | ||
{ | ||
_analyzersFolder.RemoveAnalyzer(_analyzerReference.FullPath); | ||
return analyzerReference.FullPath; | ||
} | ||
|
||
private static string GetNameText(AnalyzerReference analyzerReference) | ||
else | ||
{ | ||
if (analyzerReference is UnresolvedAnalyzerReference) | ||
{ | ||
return analyzerReference.FullPath; | ||
} | ||
else | ||
{ | ||
return analyzerReference.Display; | ||
} | ||
return analyzerReference.Display; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,11 @@ internal abstract class BaseItem : | |
{ | ||
public virtual event PropertyChangedEventHandler PropertyChanged { add { } remove { } } | ||
|
||
private readonly string _name; | ||
protected readonly string Name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. part of the equality contract the derived tuypes check. |
||
|
||
public BaseItem(string name) | ||
{ | ||
_name = name; | ||
Name = name; | ||
} | ||
|
||
public IEnumerable<string> Children => []; | ||
|
@@ -61,9 +61,9 @@ public BaseItem(string name) | |
public virtual ImageMoniker StateIconMoniker => default; | ||
public string? StateToolTipText => null; | ||
public override string ToString() => Text; | ||
public string Text => _name; | ||
public string Text => Name; | ||
public object? ToolTipContent => null; | ||
public string ToolTipText => _name; | ||
public string ToolTipText => Name; | ||
|
||
private static readonly HashSet<Type> s_supportedPatterns = | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ private BulkObservableCollection<BaseItem> CreateDiagnosticAndGeneratorItems(Pro | |
|
||
collection.AddRange( | ||
AnalyzerReference.GetGenerators(language) | ||
.Select(g => new SourceGeneratorItem(projectId, g, AnalyzerReference))); | ||
.Select(g => new SourceGeneratorItem(projectId, SourceGeneratorIdentity.Create(g, AnalyzerReference), AnalyzerReference.FullPath))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved SGItem to be pure data. |
||
|
||
return collection; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
view with whitespace off.