Skip to content

Commit

Permalink
Add field names to a few more nodes
Browse files Browse the repository at this point in the history
In advance of reaching 0.1, adding a few more field names should make
stability guarantees easier to satisfy.

Also promotes `protocol_composition_type` to named which breaks semver,
so bumping to 0.0.3.
  • Loading branch information
alex-pinkus committed Jan 14, 2022
1 parent cab8064 commit ce8bedd
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "experimental-tree-sitter-swift"
description = "swift grammar for the tree-sitter parsing library"
version = "0.0.2"
version = "0.0.3"
keywords = ["incremental", "parsing", "swift"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/alex-pinkus/experimental-tree-sitter-swift"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To use this parser to parse Swift code, you'll want to depend on either the Rust
To use the Rust crate, you'll add this to your `Cargo.toml`:
```
tree-sitter = "0.20.0"
experimental-tree-sitter-swift = "=0.0.2"
experimental-tree-sitter-swift = "=0.0.3"
```

Then you can use a `tree-sitter` parser with the language declared here:
Expand All @@ -36,7 +36,7 @@ let tree = parser.parse(&my_source_code, None)
To use this from NPM, you'll add similar dependencies to `package.json`:
```
"dependencies: {
"experimental-tree-sitter-swift": "0.0.2",
"experimental-tree-sitter-swift": "0.0.3",
"tree-sitter": "^0.20.0"
}
```
Expand Down
2 changes: 1 addition & 1 deletion bindings/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod tests {
.ok_or_else(|| anyhow!("Unable to parse!"))?;

assert_eq!(
"(source_file (assignment target: (directly_assignable_expression (simple_identifier)) result: (line_string_literal (line_str_text))))",
"(source_file (assignment target: (directly_assignable_expression (simple_identifier)) result: (line_string_literal text: (line_str_text))))",
tree.root_node().to_sexp(),
);

Expand Down
63 changes: 35 additions & 28 deletions corpus/classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,11 @@ var propertyMap: NodePropertyMap & KeypathSearchable {
(non_binding_pattern
(simple_identifier)))
(type_annotation
(user_type
(type_identifier))
(user_type
(type_identifier)))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier))))
(computed_property
(statements
(control_transfer_statement
Expand Down Expand Up @@ -731,10 +732,11 @@ class SomeClassWithAlias: NSObject {
(class_body
(typealias_declaration
(type_identifier)
(user_type
(type_identifier))
(user_type
(type_identifier))))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier)))))))

================================================================================
Special constructors
Expand Down Expand Up @@ -1216,18 +1218,20 @@ let result: HasGeneric<P1 & P2> = HasGeneric<P1 & P2>(t: "Hello")
(user_type
(type_identifier)
(type_arguments
(user_type
(type_identifier))
(user_type
(type_identifier)))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier))))))
(constructor_expression
(user_type
(type_identifier)
(type_arguments
(user_type
(type_identifier))
(user_type
(type_identifier))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier)))))
(constructor_suffix
(value_arguments
(value_argument
Expand Down Expand Up @@ -1266,10 +1270,11 @@ func iterate<S>(h: S) where S : Sequence, S.Element == P1 & P2 { }
(identifier
(simple_identifier)
(simple_identifier))
(user_type
(type_identifier))
(user_type
(type_identifier)))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier))))))
(function_body)))

================================================================================
Expand All @@ -1289,10 +1294,11 @@ enum Foo {
(enum_entry
(simple_identifier)
(enum_type_parameters
(user_type
(type_identifier))
(user_type
(type_identifier)))))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier))))))))

================================================================================
Protocol composition in as expressions
Expand All @@ -1316,10 +1322,11 @@ let result = greet("me") as P1 & P2
(line_string_literal
(line_str_text))))))
(as_operator)
(user_type
(type_identifier))
(user_type
(type_identifier)))))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier))))))

================================================================================
Modify declarations
Expand Down
9 changes: 5 additions & 4 deletions corpus/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,11 @@ func multipleType() -> Foo & Bar { return Foo() }
(line_string_literal)))))
(function_declaration
(simple_identifier)
(user_type
(type_identifier))
(user_type
(type_identifier))
(protocol_composition_type
(user_type
(type_identifier))
(user_type
(type_identifier)))
(function_body
(statements
(control_transfer_statement
Expand Down
Loading

0 comments on commit ce8bedd

Please sign in to comment.