From 4443262599f7cae74c46c3d5414108637f215e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 25 Oct 2024 11:43:38 -0700 Subject: [PATCH] update access modifiers to Cadence 1.0 --- languageserver/server/document_test.go | 14 +++++++------- languageserver/server/server.go | 7 ++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/languageserver/server/document_test.go b/languageserver/server/document_test.go index 81272724..72324fa3 100644 --- a/languageserver/server/document_test.go +++ b/languageserver/server/document_test.go @@ -41,20 +41,20 @@ func TestDocument_HasAnyPrecedingStringsAtPosition(t *testing.T) { t.Parallel() - doc := Document{Text: " pub \t \n f"} + doc := Document{Text: " access(all) \t \n f"} - assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"pub"}, 2, 1)) - assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"pub"}, 2, 2)) - assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"pub"}, 2, 3)) - assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(self)", "pub"}, 2, 2)) - assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(self)", "pub"}, 1, 6)) + assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(all)"}, 2, 1)) + assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(all)"}, 2, 2)) + assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(all)"}, 2, 3)) + assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(self)", "access(all)"}, 2, 2)) + assert.True(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(self)", "access(all)"}, 1, 13)) }) t.Run("invalid", func(t *testing.T) { t.Parallel() - doc := Document{Text: " pub \t \n f"} + doc := Document{Text: " access(all) \t \n f"} assert.False(t, doc.HasAnyPrecedingStringsAtPosition([]string{"access(self)"}, 2, 2)) }) diff --git a/languageserver/server/server.go b/languageserver/server/server.go index b2c928e2..fa4ab8b1 100644 --- a/languageserver/server/server.go +++ b/languageserver/server/server.go @@ -1129,12 +1129,9 @@ var expressionCompletionItems = []*protocol.CompletionItem{ }, } -var allAccessOptions = []string{"pub", "priv", "pub(set)", "access(contract)", "access(account)", "access(self)"} +var allAccessOptions = []string{"access(all)", "access(contract)", "access(account)", "access(self)"} var allAccessOptionsCommaSeparated = strings.Join(allAccessOptions, ",") -var readAccessOptions = []string{"pub", "priv", "access(contract)", "access(account)", "access(self)"} -var readAccessOptionsCommaSeparated = strings.Join(readAccessOptions, ",") - // NOTE: if the document doesn't specify an access modifier yet, // the completion item's InsertText will get prefixed with a placeholder // for the access modifier. @@ -1287,7 +1284,7 @@ func (s *Server) Completion( if requiresAccessModifierPlaceholder { item = withCompletionItemInsertText( item, - fmt.Sprintf("${1|%s|} %s", readAccessOptionsCommaSeparated, item.InsertText), + fmt.Sprintf("${1|%s|} %s", allAccessOptionsCommaSeparated, item.InsertText), ) } items = append(items, item)