Skip to content
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

feat(uuid): support uuid type #39

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# 获取系统架构
UNAME_M := $(shell uname -m)

# 根据系统架构设置 ARCH 变量
ifeq ($(UNAME_M),x86_64)
ARCH := amd64
else ifeq ($(UNAME_M),amd64)
ARCH := amd64
else ifeq ($(UNAME_M),aarch64)
ARCH := arm64
else ifeq ($(UNAME_M),arm64)
ARCH := arm64
else
ARCH := unknown
endif

.PHONY: build install install-for-mason test
build:
go build -o bin/thriftls main.go
install:
cp bin/thriftls /usr/local/bin/thriftls
install-for-mason:
cp bin/thriftls ~/.local/share/nvim/mason/packages/thriftls/thriftls-darwin-amd64
cp bin/thriftls ~/.local/share/nvim/mason/packages/thriftls/thriftls-darwin-$(ARCH)
test:
@go test -gcflags=all=-l -gcflags=all=-d=checkptr=0 -race -coverpkg=./... -coverprofile=coverage.out $(shell go list ./...)
@go tool cover -func coverage.out | tail -n 1 | awk '{ print "Total coverage: " $$3 }'
Expand Down
1 change: 1 addition & 0 deletions lsp/codejump/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ var basicType = map[string]struct{}{
"bool": {},
"byte": {},
"binary": {},
"uuid": {},
}

var containerType = map[string]struct{}{
Expand Down
1 change: 1 addition & 0 deletions lsp/completion/token_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var keywords = map[string]protocol.InsertTextFormat{
"i64": protocol.InsertTextFormatPlainText,
"double": protocol.InsertTextFormatPlainText,
"binary": protocol.InsertTextFormatPlainText,
"uuid": protocol.InsertTextFormatPlainText,
"string": protocol.InsertTextFormatPlainText,
"required": protocol.InsertTextFormatPlainText,
"optional": protocol.InsertTextFormatPlainText,
Expand Down
4 changes: 4 additions & 0 deletions lsp/diagnostic/semantic_analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ struct TestContainer {
101: required i64 user3 = 2
102: required bool isUser = true
}
// line 36
struct TestUUID {
1: required uuid id
}
`
ss := buildSnapshotForTest([]*cache.FileChange{
{
Expand Down
2 changes: 1 addition & 1 deletion parser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3556,7 +3556,7 @@ func (c *FieldType) Equals(node Node) bool {
type TypeName struct {
// TypeName can be:
// container type: map, set, list
// base type: bool, byte, i8, i16, i32, i64, double, string, binary
// base type: bool, byte, i8, i16, i32, i64, double, string, binary, uuid
// struct, enum, union, exception, identifier
Name string
Comments []*Comment
Expand Down
12 changes: 11 additions & 1 deletion parser/thrift.peg
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ IdentifierType = v:Identifier {
return v.(*Identifier).ToFieldType(), nil
}

BaseType = v:(BOOL / BYTE / I8 / I16 / I32 / I64 / DOUBLE / STRING / BINARY) {
BaseType = v:(BOOL / BYTE / I8 / I16 / I32 / I64 / DOUBLE / STRING / BINARY / UUID) {
return NewFieldType(nil, nil, nil, nil, v.(*TypeName), nil, nil, NewLocationFromCurrent(c)), nil
}

Expand Down Expand Up @@ -811,6 +811,16 @@ BINARYToken = "binary" {
return NewTypeName(string(c.text), c.pos), nil
}

UUID = comments:ReservedComments t:UUIDToken !LetterOrDigit Indent* {
tn := t.(*TypeName)
tn.Comments = comments.([]*Comment)

return tn, nil
}
UUIDToken = "uuid" {
return NewTypeName(string(c.text), c.pos), nil
}

MAP = comments:ReservedComments t:MAPToken !LetterOrDigit Indent* {
tn := t.(*TypeName)
tn.Comments = comments.([]*Comment)
Expand Down
Loading
Loading