Skip to content

Commit 592efcc

Browse files
committed
add key attribute for enum
1 parent 5387b32 commit 592efcc

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
uses: actions/setup-dotnet@v4
2727
with:
2828
dotnet-version: 9.0.x
29-
pre-release: true
3029
- name: Build-General
3130
if: matrix.target != 'linux-musl-x64'
3231
run: dotnet publish EmmyLua.LanguageServer -r ${{ matrix.target }} -c Release -o ${{ github.workspace }}/artifact/ --sc /p:DebugType=None

EmmyLua.LanguageServer/Completion/CompleteProvider/AliasAndEnumProvider.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,28 @@ private void AddEnumParamCompletion(TypeInfo typeInfo, CompleteContext context)
111111
{
112112
return;
113113
}
114-
115-
foreach (var field in typeInfo.Declarations.Values)
114+
115+
if (typeInfo.KeyEnum)
116+
{
117+
foreach (var field in typeInfo.Declarations.Values)
118+
{
119+
context.Add(new CompletionItem
120+
{
121+
Label = field.Name,
122+
Kind = CompletionItemKind.EnumMember,
123+
});
124+
}
125+
}
126+
else
116127
{
117-
context.Add(new CompletionItem
128+
foreach (var field in typeInfo.Declarations.Values)
118129
{
119-
Label = field.Name,
120-
Kind = CompletionItemKind.EnumMember,
121-
});
130+
context.Add(new CompletionItem
131+
{
132+
Label = $"{typeInfo.Name}.{field.Name}",
133+
Kind = CompletionItemKind.EnumMember,
134+
});
135+
}
122136
}
123137
}
124138

EmmyLua/CodeAnalysis/Compilation/Analyzer/DeclarationAnalyzer/DeclarationAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public override void Analyze(AnalyzeContext analyzeContext)
2222
var attachDeclarationAnalyzer = new AttachDeclarationAnalyzer(declarationContext, searchContext);
2323
attachDeclarationAnalyzer.Analyze();
2424
}
25-
compilation.TypeManager.BuildSubTypes();
25+
Compilation.TypeManager.BuildSubTypes();
2626
}
2727
}

EmmyLua/CodeAnalysis/Compilation/Analyzer/DeclarationAnalyzer/DeclarationWalker/TagDocWalker.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,16 @@ private LuaTypeAttribute GetAttribute(LuaDocTagNamedTypeSyntax tagNamedTypeSynta
319319
attribute |= LuaTypeAttribute.Exact;
320320
break;
321321
}
322+
case "global":
323+
{
324+
attribute |= LuaTypeAttribute.Global;
325+
break;
326+
}
327+
case "key":
328+
{
329+
attribute |= LuaTypeAttribute.Key;
330+
break;
331+
}
322332
}
323333
}
324334
}

EmmyLua/CodeAnalysis/Type/LuaTypeAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public enum LuaTypeAttribute
77
Partial = 0x01,
88
Exact = 0x02,
99
Global = 0x04,
10+
Key = 0x08,
1011
}

EmmyLua/CodeAnalysis/Type/Manager/TypeInfo/TypeInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public record struct OverloadStub(LuaDocumentId DocumentId, LuaMethodType Method
8383

8484
public bool Global => Attribute.HasFlag(LuaTypeAttribute.Global);
8585

86+
public bool KeyEnum => Attribute.HasFlag(LuaTypeAttribute.Key);
87+
8688
public bool RemovePartial(LuaDocumentId documentId, LuaTypeManager typeManager)
8789
{
8890
var removeAll = true;

0 commit comments

Comments
 (0)