File tree Expand file tree Collapse file tree 10 files changed +26
-26
lines changed
sourcekitd/include/sourcekitd Expand file tree Collapse file tree 10 files changed +26
-26
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ func getInput(_ file: String) -> URL {
17
17
}
18
18
19
19
func getSyntaxTree( _ url: URL ) throws -> SourceFileSyntax {
20
- let content = try SwiftLang . parse ( path : url. path ) . data ( using: . utf8) !
20
+ let content = try SwiftLang . parse ( url) . data ( using: . utf8) !
21
21
return try SyntaxTreeDeserializer ( ) . deserialize ( content)
22
22
}
23
23
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ var DecodeTests = TestSuite("DecodeSyntax")
20
20
21
21
DecodeTests . test ( " Basic " ) {
22
22
expectDoesNotThrow ( {
23
- let content = try SwiftLang . parse ( path : getInput ( " visitor.swift " ) . path )
23
+ let content = try SwiftLang . parse ( getInput ( " visitor.swift " ) )
24
24
let contentData = content. data ( using: . utf8) !
25
25
let source = try String ( contentsOf: getInput ( " visitor.swift " ) )
26
26
let parsed = try SyntaxTreeDeserializer ( ) . deserialize ( contentData)
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ ParseFile.test("ParseSingleFile") {
31
31
let currentFile = URL ( fileURLWithPath: #file)
32
32
expectDoesNotThrow ( {
33
33
let fileContents = try String ( contentsOf: currentFile)
34
- let syntaxTreeData = try SwiftLang . parse ( source : fileContents) . data ( using: . utf8) !
34
+ let syntaxTreeData = try SwiftLang . parse ( fileContents) . data ( using: . utf8) !
35
35
let parsed = try SyntaxTreeDeserializer ( ) . deserialize ( syntaxTreeData)
36
36
expectEqual ( " \( parsed) " , fileContents)
37
37
} )
@@ -40,7 +40,7 @@ ParseFile.test("ParseSingleFile") {
40
40
ParseFile . test ( " ParseBuffer " ) {
41
41
expectDoesNotThrow ( {
42
42
let content = " func foo() {} "
43
- let syntaxTreeData = try SwiftLang . parse ( source : content) . data ( using: . utf8) !
43
+ let syntaxTreeData = try SwiftLang . parse ( content) . data ( using: . utf8) !
44
44
let parsed = try SyntaxTreeDeserializer ( ) . deserialize ( syntaxTreeData)
45
45
expectEqual ( " \( parsed) " , content)
46
46
} )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ func getInput(_ file: String) -> URL {
17
17
}
18
18
19
19
func getSyntaxTree( _ url: URL ) throws -> SourceFileSyntax {
20
- let content = try SwiftLang . parse ( path : url. path ) . data ( using: . utf8) !
20
+ let content = try SwiftLang . parse ( url) . data ( using: . utf8) !
21
21
return try SyntaxTreeDeserializer ( ) . deserialize ( content)
22
22
}
23
23
Original file line number Diff line number Diff line change @@ -10,4 +10,6 @@ if(HAVE_UNICODE_LIBEDIT)
10
10
add_swift_tool_subdirectory (sourcekitd-repl )
11
11
endif ()
12
12
add_swift_tool_subdirectory (complete-test )
13
- add_subdirectory (swift-lang )
13
+ if (BUILD_FOUNDATION )
14
+ add_subdirectory (swift-lang )
15
+ endif ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- if (SWIFT_SOURCEKIT_USE_INPROC_LIBRARY )
2
- set (EXTRA_COMPILE_FLAGS "-I" "${SOURCEKITD_SOURCE_DIR} /include/sourcekitd" )
3
- set (SOURCEKITD_LINK_LIBS sourcekitdInProc )
4
- set (INSTALLED_COMP sourcekit-inproc )
5
- else ()
6
- set (EXTRA_COMPILE_FLAGS "-F" "${SWIFT_LIBRARY_OUTPUT_INTDIR} " )
7
- set (SOURCEKITD_LINK_LIBS sourcekitd )
8
- set (INSTALLED_COMP sourcekit-xpc-service )
9
- endif ()
1
+ set (EXTRA_COMPILE_FLAGS "-F" "${SWIFT_LIBRARY_OUTPUT_INTDIR} " )
2
+ set (EXTRA_LINKER_FLAGS "-Xlinker" "-rpath" "-Xlinker" "${SWIFT_LIBRARY_OUTPUT_INTDIR} "
3
+ "-Xlinker" "-F" "-Xlinker" "${SWIFT_LIBRARY_OUTPUT_INTDIR} " )
10
4
11
5
add_swift_library (swiftSwiftLang SHARED
12
6
SwiftLang.swift
@@ -17,7 +11,10 @@ add_swift_library(swiftSwiftLang SHARED
17
11
UIDs.swift.gyb
18
12
19
13
DEPENDS sourcekitd-test
20
- PRIVATE_LINK_LIBRARIES ${SOURCEKITD_LINK_LIBS}
14
+ PRIVATE_LINK_LIBRARIES sourcekitd
21
15
SWIFT_COMPILE_FLAGS ${EXTRA_COMPILE_FLAGS}
22
- INSTALL_IN_COMPONENT ${INSTALLED_COMP}
16
+ LINK_FLAGS ${EXTRA_LINKER_FLAGS}
17
+ SWIFT_MODULE_DEPENDS Foundation
18
+ INSTALL_IN_COMPONENT sourcekit-xpc-service
19
+ TARGET_SDKS OSX
23
20
IS_STDLIB )
Original file line number Diff line number Diff line change 13
13
//===----------------------------------------------------------------------===//
14
14
15
15
import sourcekitd
16
+ import Foundation
16
17
17
18
public class SourceKitdService {
18
19
Original file line number Diff line number Diff line change 12
12
// This file provides convenient APIs to interpret a SourceKitd response.
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import Foundation
15
16
import sourcekitd
16
17
17
18
public class SourceKitdResponse : CustomStringConvertible {
@@ -252,6 +253,6 @@ extension sourcekitd_variant_t: CustomStringConvertible {
252
253
}
253
254
254
255
private func fromCStringLen( _ ptr: UnsafePointer < Int8 > , length: Int ) -> String ? {
255
- return String ( decoding : Array ( UnsafeBufferPointer ( start : ptr, count : length) ) . map {
256
- UInt8 ( bitPattern : $0 ) } , as : UTF8 . self )
256
+ return NSString ( bytes : ptr, length : length,
257
+ encoding : String . Encoding . utf8 . rawValue ) as String ?
257
258
}
Original file line number Diff line number Diff line change 12
12
// This file provides Swift language support by invoking SourceKit internally.
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import Foundation
16
+
15
17
enum SourceKitdError : Error , CustomStringConvertible {
16
18
case EditorOpenError( message: String )
17
19
case EditorCloseError( message: String )
@@ -63,15 +65,16 @@ public class SwiftLang {
63
65
/// thread safe.
64
66
/// - Parameter url: The URL you wish to parse.
65
67
/// - Returns: The syntax tree in Json format string.
66
- public static func parse( path: String ) throws -> String {
67
- return try parse ( content: path, name: path, isURL: true )
68
+ public static func parse( _ url: URL ) throws -> String {
69
+ let Path = url. path
70
+ return try parse ( content: Path, name: Path, isURL: true )
68
71
}
69
72
70
73
/// Parses a given source buffer into a `Syntax` tree in Json serialization
71
74
/// format by querying SourceKitd service. This function isn't thread safe.
72
75
/// - Parameter source: The source buffer you wish to parse.
73
76
/// - Returns: The syntax tree in Json format string.
74
- public static func parse( source: String ) throws -> String {
77
+ public static func parse( _ source: String ) throws -> String {
75
78
return try parse ( content: source, name: " foo " , isURL: false )
76
79
}
77
80
}
You can’t perform that action at this time.
0 commit comments