Repository: openlawlibrary/pygls

Issue:
CreateFile, RenameFile, and DeleteFile missing required kind field
According to spec, `CreateFile`, `RenameFile`, and `DeleteFile` requires the `kind` field: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#resourceChanges


CreateFile: https://github.com/openlawlibrary/pygls/blob/97ebd90adc1aa1aae09bd351f48b098d0c82c681/pygls/lsp/types/basic_structures.py#L252-L254

RenameFile:
https://github.com/openlawlibrary/pygls/blob/97ebd90adc1aa1aae09bd351f48b098d0c82c681/pygls/lsp/types/basic_structures.py#L262-L265

DeleteFile:
https://github.com/openlawlibrary/pygls/blob/97ebd90adc1aa1aae09bd351f48b098d0c82c681/pygls/lsp/types/basic_structures.py#L273-L275

This causes https://github.com/pappasam/jedi-language-server/issues/134

Discussion:

Patch:
diff --git a/pygls/lsp/types/basic_structures.py b/pygls/lsp/types/basic_structures.py
index 5ed2092..e628a4a 100644
--- a/pygls/lsp/types/basic_structures.py
+++ b/pygls/lsp/types/basic_structures.py
@@ -244,12 +244,19 @@ class TextEdit(Model):
     new_text: str
 
 
+class ResourceOperationKind(str, enum.Enum):
+    Create = 'create'
+    Rename = 'rename'
+    Delete = 'delete'
+
+
 class CreateFileOptions(Model):
     overwrite: Optional[bool] = False
     ignore_if_exists: Optional[bool] = False
 
 
 class CreateFile(Model):
+    kind: ResourceOperationKind = ResourceOperationKind.Create
     uri: str
     options: Optional[CreateFileOptions] = None
 
@@ -260,6 +267,7 @@ class RenameFileOptions(Model):
 
 
 class RenameFile(Model):
+    kind: ResourceOperationKind = ResourceOperationKind.Rename
     old_uri: str
     new_uri: str
     options: Optional[RenameFileOptions] = None
@@ -271,16 +279,11 @@ class DeleteFileOptions(Model):
 
 
 class DeleteFile(Model):
+    kind: ResourceOperationKind = ResourceOperationKind.Delete
     uri: str
     options: Optional[DeleteFileOptions] = None
 
 
-class ResourceOperationKind(str, enum.Enum):
-    Create = 'create'
-    Rename = 'rename'
-    Delete = 'delete'
-
-
 class FailureHandlingKind(str, enum.Enum):
     Abort = 'abort'
     Transactional = 'transactional'


Test patch:
diff --git a/tests/lsp/test_rename.py b/tests/lsp/test_rename.py
index 609988f..6f85569 100644
--- a/tests/lsp/test_rename.py
+++ b/tests/lsp/test_rename.py
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and      #
 # limitations under the License.                                           #
 ############################################################################
+from pygls.lsp.types.basic_structures import ResourceOperationKind
 import unittest
 from typing import Optional
 
@@ -75,6 +76,7 @@ class TestRename(unittest.TestCase):
                             ]
                         ),
                         CreateFile(
+                            kind=ResourceOperationKind.Create,
                             uri='create file',
                             options=CreateFileOptions(
                                 overwrite=True,
@@ -82,6 +84,7 @@ class TestRename(unittest.TestCase):
                             ),
                         ),
                         RenameFile(
+                            kind=ResourceOperationKind.Rename,
                             old_uri='rename old uri',
                             new_uri='rename new uri',
                             options=RenameFileOptions(
@@ -90,6 +93,7 @@ class TestRename(unittest.TestCase):
                             )
                         ),
                         DeleteFile(
+                            kind=ResourceOperationKind.Delete,
                             uri='delete file',
                             options=DeleteFileOptions(
                                 recursive=True,
@@ -146,15 +150,18 @@ class TestRename(unittest.TestCase):
         assert response['documentChanges'][0]['edits'][0]['range']['end']['line'] == 3
         assert response['documentChanges'][0]['edits'][0]['range']['end']['character'] == 3
 
+        assert response['documentChanges'][1]['kind'] == ResourceOperationKind.Create
         assert response['documentChanges'][1]['uri'] == 'create file'
         assert response['documentChanges'][1]['options']['ignoreIfExists'] == True
         assert response['documentChanges'][1]['options']['overwrite'] == True
 
+        assert response['documentChanges'][2]['kind'] == ResourceOperationKind.Rename
         assert response['documentChanges'][2]['newUri'] == 'rename new uri'
         assert response['documentChanges'][2]['oldUri'] == 'rename old uri'
         assert response['documentChanges'][2]['options']['ignoreIfExists'] == True
         assert response['documentChanges'][2]['options']['overwrite'] == True
 
+        assert response['documentChanges'][3]['kind'] == ResourceOperationKind.Delete
         assert response['documentChanges'][3]['uri'] == 'delete file'
         assert response['documentChanges'][3]['options']['ignoreIfExists'] == True
         assert response['documentChanges'][3]['options']['recursive'] == True