File tree Expand file tree Collapse file tree 5 files changed +19
-17
lines changed
SwiftCompilerSources/Sources Expand file tree Collapse file tree 5 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ public struct DiagnosticFixIt {
50
50
self . text = text
51
51
}
52
52
53
- func withBridgedDiagnosticFixIt( _ fn: ( BridgedDiagnosticFixIt ) -> Void ) {
53
+ func withBridgedDiagnosticFixIt( _ fn: ( swift . DiagnosticInfo . FixIt ) -> Void ) {
54
54
text. withBridgedStringRef { bridgedTextRef in
55
- let bridgedDiagnosticFixIt = BridgedDiagnosticFixIt (
56
- start: start . bridged,
57
- byteLength : byteLength ,
58
- text : bridgedTextRef )
55
+ let bridgedDiagnosticFixIt = swift . DiagnosticInfo . FixIt (
56
+ swift . CharSourceRange ( start. bridged, UInt32 ( byteLength ) ) ,
57
+ llvm . StringRef ( bridgedTextRef ) ,
58
+ llvm . ArrayRef < swift . DiagnosticArgument > ( ) )
59
59
fn ( bridgedDiagnosticFixIt)
60
60
}
61
61
}
@@ -83,7 +83,7 @@ public struct DiagnosticEngine {
83
83
let bridgedSourceLoc : swift . SourceLoc = position. bridged
84
84
let bridgedHighlightRange : swift . CharSourceRange = highlight. bridged
85
85
var bridgedArgs : [ BridgedDiagnosticArgument ] = [ ]
86
- var bridgedFixIts : [ BridgedDiagnosticFixIt ] = [ ]
86
+ var bridgedFixIts : [ swift . DiagnosticInfo . FixIt ] = [ ]
87
87
88
88
// Build a higher-order function to wrap every 'withBridgedXXX { ... }'
89
89
// calls, so we don't escape anything from the closure. 'bridgedArgs' and
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ extension BridgedStringRef {
48
48
}
49
49
}
50
50
51
+ extension llvm . StringRef {
52
+ public init ( _ bridged: BridgedStringRef ) {
53
+ self . init ( bridged. data, bridged. length)
54
+ }
55
+ }
56
+
51
57
extension String {
52
58
public func withBridgedStringRef< T> ( _ c: ( BridgedStringRef ) -> T ) -> T {
53
59
var str = self
Original file line number Diff line number Diff line change @@ -51,12 +51,6 @@ typedef struct {
51
51
} value ;
52
52
} BridgedDiagnosticArgument ;
53
53
54
- typedef struct {
55
- swift ::SourceLoc start ;
56
- SwiftInt byteLength ;
57
- BridgedStringRef text ;
58
- } BridgedDiagnosticFixIt ;
59
-
60
54
typedef struct {
61
55
void * _Nonnull object ;
62
56
} BridgedDiagnosticEngine ;
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ module BasicBridging {
6
6
7
7
module ASTBridging {
8
8
header "AST/ASTBridging.h"
9
+ header "AST/DiagnosticEngine.h"
10
+ header "AST/DiagnosticConsumer.h"
11
+ requires cplusplus
9
12
export *
10
13
}
11
14
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ void DiagnosticEngine_diagnose(
42
42
BridgedDiagID bridgedDiagID,
43
43
BridgedArrayRef /* BridgedDiagnosticArgument*/ bridgedArguments,
44
44
CharSourceRange highlight,
45
- BridgedArrayRef /* BridgedDiagnosticFixIt */ bridgedFixIts) {
45
+ BridgedArrayRef /* DiagnosticInfo::FixIt */ bridgedFixIts) {
46
46
auto *D = getDiagnosticEngine (bridgedEngine);
47
47
48
48
auto diagID = static_cast <DiagID>(bridgedDiagID);
@@ -59,10 +59,9 @@ void DiagnosticEngine_diagnose(
59
59
}
60
60
61
61
// Add fix-its.
62
- for (auto bridgedFixIt : getArrayRef<BridgedDiagnosticFixIt>(bridgedFixIts)) {
63
- auto range = CharSourceRange (bridgedFixIt.start ,
64
- bridgedFixIt.byteLength );
65
- auto text = getStringRef (bridgedFixIt.text );
62
+ for (auto bridgedFixIt : getArrayRef<DiagnosticInfo::FixIt>(bridgedFixIts)) {
63
+ auto range = bridgedFixIt.getRange ();
64
+ auto text = bridgedFixIt.getText ();
66
65
inflight.fixItReplaceChars (range.getStart (), range.getEnd (), text);
67
66
}
68
67
}
You can’t perform that action at this time.
0 commit comments