Skip to content

Commit

Permalink
add key attribute for enum
Browse files Browse the repository at this point in the history
  • Loading branch information
CppCXY committed Aug 6, 2024
1 parent 5387b32 commit 592efcc
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
pre-release: true
- name: Build-General
if: matrix.target != 'linux-musl-x64'
run: dotnet publish EmmyLua.LanguageServer -r ${{ matrix.target }} -c Release -o ${{ github.workspace }}/artifact/ --sc /p:DebugType=None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,28 @@ private void AddEnumParamCompletion(TypeInfo typeInfo, CompleteContext context)
{
return;
}

foreach (var field in typeInfo.Declarations.Values)

if (typeInfo.KeyEnum)
{
foreach (var field in typeInfo.Declarations.Values)
{
context.Add(new CompletionItem
{
Label = field.Name,
Kind = CompletionItemKind.EnumMember,
});
}
}
else
{
context.Add(new CompletionItem
foreach (var field in typeInfo.Declarations.Values)
{
Label = field.Name,
Kind = CompletionItemKind.EnumMember,
});
context.Add(new CompletionItem
{
Label = $"{typeInfo.Name}.{field.Name}",
Kind = CompletionItemKind.EnumMember,
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public override void Analyze(AnalyzeContext analyzeContext)
var attachDeclarationAnalyzer = new AttachDeclarationAnalyzer(declarationContext, searchContext);
attachDeclarationAnalyzer.Analyze();
}
compilation.TypeManager.BuildSubTypes();
Compilation.TypeManager.BuildSubTypes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ private LuaTypeAttribute GetAttribute(LuaDocTagNamedTypeSyntax tagNamedTypeSynta
attribute |= LuaTypeAttribute.Exact;
break;
}
case "global":
{
attribute |= LuaTypeAttribute.Global;
break;
}
case "key":
{
attribute |= LuaTypeAttribute.Key;
break;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions EmmyLua/CodeAnalysis/Type/LuaTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public enum LuaTypeAttribute
Partial = 0x01,
Exact = 0x02,
Global = 0x04,
Key = 0x08,
}
2 changes: 2 additions & 0 deletions EmmyLua/CodeAnalysis/Type/Manager/TypeInfo/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public record struct OverloadStub(LuaDocumentId DocumentId, LuaMethodType Method

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

public bool KeyEnum => Attribute.HasFlag(LuaTypeAttribute.Key);

public bool RemovePartial(LuaDocumentId documentId, LuaTypeManager typeManager)
{
var removeAll = true;
Expand Down

0 comments on commit 592efcc

Please sign in to comment.