File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,14 +76,15 @@ -(BOOL) vv_isSwiftFunction
7676
7777-(BOOL ) vv_isSwiftEnum
7878{
79- return [self vv_matchesPatternRegexPattern: @" ^\\ s*(.*\\ s+)?enum\\ s+" ];
79+ return ![ self vv_isSwiftProperty ] && [self vv_matchesPatternRegexPattern: @" ^\\ s*(.*\\ s+)?enum\\ s+" ];
8080}
8181
8282-(BOOL ) vv_isSwiftProperty
8383{
8484 // `let`/`var` can be in swift func, but `(` appear before `let`/`var` only
8585 // happens when `private(set)` or `internal(set)` is used
86- return [self vv_matchesPatternRegexPattern: @" ^\\ s*([^(]*?)(((\\ s*let|var\\ s*)\\ s+)|(\\ (\\ s*set\\ s*\\ )))" ];
86+ // typealias is considered to share the same comment as property.
87+ return [self vv_matchesPatternRegexPattern: @" ^\\ s*([^(]*?)(((\\ s*let|var|typealias\\ s*)\\ s+)|(\\ (\\ s*set\\ s*\\ )))" ];
8788}
8889
8990@end
Original file line number Diff line number Diff line change 2727-(VVTextResult *) vv_textResultMatchPartWithPairOpenString : (NSString *)open
2828 closeString : (NSString *)close
2929 currentLocation : (NSInteger )location ;
30+
31+ -(VVTextResult *) vv_textResultToEndOfFileCurrentLocation : (NSInteger )location ;
3032@end
Original file line number Diff line number Diff line change @@ -122,6 +122,13 @@ -(VVTextResult *) vv_textResultWithPairOpenString:(NSString *)open
122122 return [self textResultWithPairOpenString: open closeString: close currentLocation: location extractMatch: NO ];
123123}
124124
125+ -(VVTextResult *) vv_textResultToEndOfFileCurrentLocation : (NSInteger )location
126+ {
127+ NSRange range = NSMakeRange (location, self.length - location);
128+ VVTextResult *result = [[VVTextResult alloc ] initWithRange: range string: [self substringWithRange: range]];
129+ return result;
130+ }
131+
125132-(VVTextResult *) textResultWithPairOpenString : (NSString *)open
126133 closeString : (NSString *)close
127134 currentLocation : (NSInteger )location
Original file line number Diff line number Diff line change 2323
2424-(VVTextResult *) vv_textResultWithPairOpenString : (NSString *)open closeString : (NSString *)close ;
2525
26+ -(VVTextResult *) vv_textResultToEndOfFile ;
2627@end
Original file line number Diff line number Diff line change @@ -36,10 +36,14 @@ -(VVTextResult *) vv_textResultUntilNextString:(NSString *)findString
3636 return [self .textStorage.string vv_textResultUntilNextString: findString currentLocation: [self vv_currentCurseLocation ]];
3737}
3838
39-
4039-(VVTextResult *) vv_textResultWithPairOpenString : (NSString *)open closeString : (NSString *)close
4140{
4241 return [self .textStorage.string vv_textResultWithPairOpenString: open closeString: close currentLocation: [self vv_currentCurseLocation ]];
4342}
4443
44+ -(VVTextResult *) vv_textResultToEndOfFile
45+ {
46+ return [self .textStorage.string vv_textResultToEndOfFileCurrentLocation: [self vv_currentCurseLocation ]];
47+ }
48+
4549@end
Original file line number Diff line number Diff line change @@ -114,15 +114,18 @@ - (void) textStorageDidChange:(NSNotification *)noti {
114114 // We just want to document the next valid line.
115115 VVTextResult *resultUntilSemiColon = [textView vv_textResultUntilNextString: @" ;" ];
116116 VVTextResult *resultUntilBrace = [textView vv_textResultUntilNextString: @" {" ];
117+ VVTextResult *resultUntilFileEnd = [textView vv_textResultToEndOfFile ];
117118
118119 VVTextResult *resultToDocument = nil ;
119120
120121 if (resultUntilSemiColon && resultUntilBrace) {
121122 resultToDocument = (resultUntilSemiColon.range .length < resultUntilBrace.range .length ) ? resultUntilSemiColon : resultUntilBrace;
122123 } else if (resultUntilBrace) {
123124 resultToDocument = resultUntilBrace;
124- } else {
125+ } else if (resultUntilSemiColon) {
125126 resultToDocument = resultUntilSemiColon;
127+ } else {
128+ resultToDocument = resultUntilFileEnd;
126129 }
127130
128131 // We always write document until semicolon for enum. (Maybe struct later)
You can’t perform that action at this time.
0 commit comments