@@ -80,7 +80,7 @@ pub fn from_dump_file<T: DeserializeOwned, P: AsRef<Path>>(path: P) -> Result<T>
80
80
#[ cfg( all( feature = "parsing" , feature = "assets" , any( feature = "dump-load" , feature = "dump-load-rs" ) ) ) ]
81
81
impl SyntaxSet {
82
82
/// Instantiates a new syntax set from a binary dump of
83
- /// Sublime Text's default open source syntax definitions and then links it .
83
+ /// Sublime Text's default open source syntax definitions.
84
84
/// These dumps are included in this library's binary for convenience.
85
85
///
86
86
/// This method loads the version for parsing line strings with no `\n` characters at the end.
@@ -90,24 +90,21 @@ impl SyntaxSet {
90
90
/// This is the recommended way of creating a syntax set for
91
91
/// non-advanced use cases. It is also significantly faster than loading the YAML files.
92
92
///
93
- /// Note that you can load additional syntaxes after doing this,
94
- /// you'll just have to link again. If you want you can even
95
- /// use the fact that SyntaxDefinitions are serializable with
93
+ /// Note that you can load additional syntaxes after doing this. If you want
94
+ /// you can even use the fact that SyntaxDefinitions are serializable with
96
95
/// the bincode crate to cache dumps of additional syntaxes yourself.
97
96
pub fn load_defaults_nonewlines ( ) -> SyntaxSet {
98
- let mut ps : SyntaxSet = from_binary ( include_bytes ! ( "../assets/default_nonewlines.\
97
+ let ss : SyntaxSet = from_binary ( include_bytes ! ( "../assets/default_nonewlines.\
99
98
packdump") ) ;
100
- ps. link_syntaxes ( ) ;
101
- ps
99
+ ss
102
100
}
103
101
104
102
/// Same as `load_defaults_nonewlines` but for parsing line strings with newlines at the end.
105
103
/// These are separate methods because thanks to linker garbage collection, only the serialized
106
104
/// dumps for the method(s) you call will be included in the binary (each is ~200kb for now).
107
105
pub fn load_defaults_newlines ( ) -> SyntaxSet {
108
- let mut ps: SyntaxSet = from_binary ( include_bytes ! ( "../assets/default_newlines.packdump" ) ) ;
109
- ps. link_syntaxes ( ) ;
110
- ps
106
+ let ss: SyntaxSet = from_binary ( include_bytes ! ( "../assets/default_newlines.packdump" ) ) ;
107
+ ss
111
108
}
112
109
}
113
110
@@ -130,29 +127,32 @@ mod tests {
130
127
#[ test]
131
128
fn can_dump_and_load ( ) {
132
129
use super :: * ;
133
- use parsing:: SyntaxSet ;
134
- let mut ps = SyntaxSet :: new ( ) ;
135
- ps. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
130
+ use parsing:: SyntaxSetBuilder ;
131
+ let mut builder = SyntaxSetBuilder :: new ( ) ;
132
+ builder. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
133
+ let ss = builder. build ( ) ;
136
134
137
- let bin = dump_binary ( & ps ) ;
135
+ let bin = dump_binary ( & ss ) ;
138
136
println ! ( "{:?}" , bin. len( ) ) ;
139
- let ps2 : SyntaxSet = from_binary ( & bin[ ..] ) ;
140
- assert_eq ! ( ps . syntaxes( ) . len( ) , ps2 . syntaxes( ) . len( ) ) ;
137
+ let ss2 : SyntaxSet = from_binary ( & bin[ ..] ) ;
138
+ assert_eq ! ( ss . syntaxes( ) . len( ) , ss2 . syntaxes( ) . len( ) ) ;
141
139
}
142
140
143
141
#[ cfg( all( feature = "yaml-load" , any( feature = "dump-create" , feature = "dump-create-rs" ) , any( feature = "dump-load" , feature = "dump-load-rs" ) ) ) ]
144
142
#[ test]
145
143
fn dump_is_deterministic ( ) {
146
144
use super :: * ;
147
- use parsing:: SyntaxSet ;
145
+ use parsing:: SyntaxSetBuilder ;
148
146
149
- let mut ps1 = SyntaxSet :: new ( ) ;
150
- ps1. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
151
- let bin1 = dump_binary ( & ps1) ;
147
+ let mut builder1 = SyntaxSetBuilder :: new ( ) ;
148
+ builder1. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
149
+ let ss1 = builder1. build ( ) ;
150
+ let bin1 = dump_binary ( & ss1) ;
152
151
153
- let mut ps2 = SyntaxSet :: new ( ) ;
154
- ps2. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
155
- let bin2 = dump_binary ( & ps2) ;
152
+ let mut builder2 = SyntaxSetBuilder :: new ( ) ;
153
+ builder2. load_syntaxes ( "testdata/Packages" , false ) . unwrap ( ) ;
154
+ let ss2 = builder2. build ( ) ;
155
+ let bin2 = dump_binary ( & ss2) ;
156
156
assert_eq ! ( bin1, bin2) ;
157
157
}
158
158
0 commit comments