keyword icon v1

This commit is contained in:
Matt Parker
2025-10-27 21:25:47 +10:00
parent 1ee8fb0e41
commit 8946aa1079
4 changed files with 103 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Rename.ConflictEngine;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Tags;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using SharpIDE.Application;
@@ -443,8 +444,9 @@ public partial class SharpIdeCodeEdit : CodeEdit
{
var symbolKindString = CollectionExtensions.GetValueOrDefault(completionItem.Properties, "SymbolKind");
var symbolKind = symbolKindString is null ? null : (SymbolKind?)int.Parse(symbolKindString);
var wellKnownTags = completionItem.Tags;
var typeKindString = completionItem.Tags[0];
var accessibilityModifierString = completionItem.Tags.Skip(1).FirstOrDefault(); // accessibility is not always supplied
var accessibilityModifierString = completionItem.Tags.Skip(1).FirstOrDefault(); // accessibility is not always supplied, and I don't think there's actually any guarantee on the order of tags. See WellKnownTags and WellKnownTagArrays
TypeKind? typeKind = Enum.TryParse<TypeKind>(typeKindString, out var tk) ? tk : null;
Accessibility? accessibilityModifier = Enum.TryParse<Accessibility>(accessibilityModifierString, out var am) ? am : null;
var godotCompletionType = symbolKind switch
@@ -456,7 +458,8 @@ public partial class SharpIdeCodeEdit : CodeEdit
SymbolKind.Field => CodeCompletionKind.Member,
_ => CodeCompletionKind.PlainText
};
var icon = GetIconForCompletion(symbolKind, typeKind, accessibilityModifier);
var isKeyword = wellKnownTags.Contains(WellKnownTags.Keyword);
var icon = GetIconForCompletion(symbolKind, typeKind, accessibilityModifier, isKeyword);
AddCodeCompletionOption(godotCompletionType, completionItem.DisplayText, completionItem.DisplayText, icon: icon, value: new RefCountedContainer<CompletionItem>(completionItem));
}
// partially working - displays menu only when caret is what CodeEdit determines as valid

View File

@@ -11,9 +11,12 @@ public partial class SharpIdeCodeEdit
private readonly Texture2D _localVariableIcon = ResourceLoader.Load<Texture2D>("uid://vwvkxlnvqqk3");
private readonly Texture2D _fieldIcon = ResourceLoader.Load<Texture2D>("uid://c4y7d5m4upfju");
private readonly Texture2D _propertyIcon = ResourceLoader.Load<Texture2D>("uid://y5pwrwwrjqmc");
private readonly Texture2D _keywordIcon = ResourceLoader.Load<Texture2D>("uid://b0ujhoq2xg2v0");
// namespace
private Texture2D? GetIconForCompletion(SymbolKind? symbolKind, TypeKind? typeKind, Accessibility? accessibility)
private Texture2D? GetIconForCompletion(SymbolKind? symbolKind, TypeKind? typeKind, Accessibility? accessibility, bool isKeyword)
{
if (isKeyword) return _keywordIcon;
var texture = (symbolKind, typeKind, accessibility) switch
{
(SymbolKind.Method, _, _) => _csharpMethodIcon,

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg
height="800px"
width="800px"
version="1.1"
id="Capa_1"
viewBox="0 0 525.325 525.325"
xml:space="preserve"
sodipodi:docname="keyword-icon.svg"
inkscape:version="1.4.2 (f4327f4, 2025-05-13)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs1" /><sodipodi:namedview
id="namedview1"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:zoom="0.72937499"
inkscape:cx="281.06256"
inkscape:cy="376.34962"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g1" />
<g
id="g1"
transform="matrix(1.0007541,0,0,0.96334492,-0.19807395,9.6729914)">
<path
style="fill:none;stroke:#ccced5;stroke-width:26.7512;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 504.29298,262.61572 H 251.37496"
id="path3"
sodipodi:nodetypes="cc" /><ellipse
style="fill:#43454a;fill-opacity:1;stroke:#ccced5;stroke-width:26.7512;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="path2"
cx="-135.09888"
cy="262.61572"
rx="116.27608"
ry="120.79138"
transform="scale(-1,1)" /></g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b0ujhoq2xg2v0"
path="res://.godot/imported/keyword-icon.svg-20e9c90a91a77ec5e809420653cd3822.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Features/Completions/Resources/keyword-icon.svg"
dest_files=["res://.godot/imported/keyword-icon.svg-20e9c90a91a77ec5e809420653cd3822.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=0.1
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false