Skip to content

Commit

Permalink
Use a dedicated icon for the optional "[in,out]" elements in the @param
Browse files Browse the repository at this point in the history
… autocomplete box.

To distinguish the "[in,out]" parts in the autocomplete box from the function parameters in the autocomplete box.
  • Loading branch information
Sedeniono committed Nov 11, 2024
1 parent f4e3917 commit ffdef73
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions VSDoxyHighlighter/CommandCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ private ImmutableArray<CompletionItem>.Builder PopulateAutcompleteBoxWithCommand
private class ParameterAutocompleteSingleEntry
{
public string name; // Name of the C++ element (e.g. of the template parameter)
public string type; // Type of the C++ element, if available (e.g. "const int").
public string context; // Information about the C++ element that contains the entry (e.g. the class, function, etc.)
public string type; // Type of the C++ element, if available (e.g. "const int"). Show on the right side of the autocomplete box.
public string context; // Information about the C++ element that contains the entry (e.g. the class, function, etc.). Shown as tooltip.
public ImageElement icon;
}


Expand All @@ -309,8 +310,6 @@ private class AutocompleteInfosForParameterOfDoxygenCommand
// the function parameters with '@param', the autocomplete box will preselect the most likely next parameter one wants
// to insert, i.e. the one which comes next after the previously documented parameter.
public string elementBeforeElementToPreselect;

public ImageElement icon;
}


Expand All @@ -330,8 +329,7 @@ private async Task<IList<AutocompleteInfosForParameterOfDoxygenCommand>> TryGetA
var infos = await TryGetParametersOfNextCodeElementAsync(startPoint, cCmdsToDocumentParam, preselectAfterPrevious: true, cancellationToken);
if (infos == null) {
infos = new AutocompleteInfosForParameterOfDoxygenCommand {
elementsToShow = new List<ParameterAutocompleteSingleEntry>(),
icon = cParamImage
elementsToShow = new List<ParameterAutocompleteSingleEntry>()
};
}

Expand All @@ -343,9 +341,9 @@ private async Task<IList<AutocompleteInfosForParameterOfDoxygenCommand>> TryGetA
const string cDirContext = "Optional <dir> attribute";
infos.elementsToShow = infos.elementsToShow.Concat(
new[] {
new ParameterAutocompleteSingleEntry() { name = "[in]", type = "", context = cDirContext },
new ParameterAutocompleteSingleEntry() { name = "[out]", type = "", context = cDirContext },
new ParameterAutocompleteSingleEntry() { name = "[in,out]", type = "", context = cDirContext }
new ParameterAutocompleteSingleEntry() { name = "[in]", context = cDirContext, icon = cParamInOutImage },
new ParameterAutocompleteSingleEntry() { name = "[out]", context = cDirContext, icon = cParamInOutImage },
new ParameterAutocompleteSingleEntry() { name = "[in,out]", context = cDirContext, icon = cParamInOutImage }
});
}

Expand Down Expand Up @@ -418,8 +416,7 @@ private async Task<AutocompleteInfosForParameterOfDoxygenCommand> TryGetParamete
string context = $"Parameter of function: {funcInfo.FunctionName}";
var result = new AutocompleteInfosForParameterOfDoxygenCommand {
elementsToShow = funcInfo.Parameters.Select(
p => new ParameterAutocompleteSingleEntry() { name = p.Name, type = p.Type, context = context }),
icon = cParamImage
p => new ParameterAutocompleteSingleEntry() { name = p.Name, type = p.Type, context = context, icon = cParamImage }),
};
if (preselectAfterPrevious) {
result.elementBeforeElementToPreselect
Expand All @@ -433,8 +430,7 @@ private async Task<AutocompleteInfosForParameterOfDoxygenCommand> TryGetParamete
string context = $"Parameter of macro: {macroInfo.MacroName}";
var result = new AutocompleteInfosForParameterOfDoxygenCommand {
elementsToShow = macroInfo.Parameters.Select(
p => new ParameterAutocompleteSingleEntry() { name = p, context = context }),
icon = cParamImage
p => new ParameterAutocompleteSingleEntry() { name = p, context = context, icon = cParamImage }),
};
if (preselectAfterPrevious) {
result.elementBeforeElementToPreselect
Expand All @@ -461,8 +457,7 @@ private async Task<AutocompleteInfosForParameterOfDoxygenCommand> TryGetTemplate
string context = $"Template parameter of function: {funcInfo.FunctionName}";
var result = new AutocompleteInfosForParameterOfDoxygenCommand {
elementsToShow = funcInfo.TemplateParameters.Select(
p => new ParameterAutocompleteSingleEntry() { name = p, context = context }),
icon = cTemplateParamImage
p => new ParameterAutocompleteSingleEntry() { name = p, context = context, icon = cTemplateParamImage }),
};

if (preselectAfterPrevious) {
Expand All @@ -481,8 +476,7 @@ private async Task<AutocompleteInfosForParameterOfDoxygenCommand> TryGetTemplate
string context = $"Template parameter of {clsInfo.Type.ToLower()}: {clsInfo.ClassName}";
var result = new AutocompleteInfosForParameterOfDoxygenCommand {
elementsToShow = clsInfo.TemplateParameters.Select(
p => new ParameterAutocompleteSingleEntry() { name = p, context = context }),
icon = cTemplateParamImage
p => new ParameterAutocompleteSingleEntry() { name = p, context = context, icon = cTemplateParamImage }),
};

if (preselectAfterPrevious) {
Expand Down Expand Up @@ -513,7 +507,7 @@ private ImmutableArray<CompletionItem>.Builder CreateAutocompleteItemsForParamet
var item = new CompletionItem(
displayText: name,
source: this,
icon: info.icon,
icon: singleEntry.icon,
filters: ImmutableArray<CompletionFilter>.Empty,
suffix: singleEntry.type,
insertText: name,
Expand Down Expand Up @@ -633,6 +627,7 @@ private FormattedFragmentGroup TryFindPreviousDoxygenCommandOnLinesBeforePoint(
// http://glyphlist.azurewebsites.net/knownmonikers/
// https://github.com/madskristensen/KnownMonikersExplorer
private static ImageElement cCompletionImage = new ImageElement(KnownMonikers.CommentCode.ToImageId(), "Doxygen command");
private static ImageElement cParamInOutImage = new ImageElement(KnownMonikers.AzureResourceGroup.ToImageId(), "Doxygen in-out argument");
// Image for parameter and template parameter: These should be the images shown by VS's own IntelliSense in C++.
private static ImageElement cParamImage = new ImageElement(KnownMonikers.FieldPublic.ToImageId(), "Doxygen parameter");
private static ImageElement cTemplateParamImage = new ImageElement(KnownMonikers.TypeDefinition.ToImageId(), "Doxygen template parameter");
Expand Down

0 comments on commit ffdef73

Please sign in to comment.