profile
viewpoint
Ben Langmuir benlangmuir Waterloo, ON, Canada

llvm/llvm-project 6355

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Note: the repository does not accept github pull requests at this moment. Please submit your patches at http://reviews.llvm.org.

benlangmuir/sourcekit-lsp 3

Language Server Protocol implementation for Swift

benlangmuir/lldb 1

Mirror of official lldb git repository located at http://llvm.org/git/lldb. Updated hourly.

benlangmuir/clang 0

Mirror of official clang git repository located at http://llvm.org/git/clang. Updated hourly.

benlangmuir/gitignore 0

A collection of useful .gitignore templates

benlangmuir/home 0

Dotfiles, scripts, etc.

benlangmuir/indexstore-db 0

Index database library for use with sourcekit-lsp

benlangmuir/language-server-protocol 0

Defines a common protocol for language servers.

benlangmuir/llvm 0

Mirror of official llvm git repository located at http://llvm.org/git/llvm. Updated hourly.

push eventapple/sourcekit-lsp

David Goldman

commit sha 3f551789088fc923af873529098fe959d844578b

Don't log the sourcekit code complete request Seems to be left over from development; SOURCEKIT_LOGGING is an alternative to trace this.

view details

Ben Langmuir

commit sha b9568fc452a628e88a333696f5de0128c2c4f0bd

Merge pull request #339 from DavidGoldman/main Don't log the sourcekit code complete request

view details

push time in 3 days

PR merged apple/sourcekit-lsp

Don't log the sourcekit code complete request

Seems to be left over from development; SOURCEKIT_LOGGING is an alternative to trace this.

+0 -2

1 comment

1 changed file

DavidGoldman

pr closed time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/sourcekit-lsp

Move to standalone TSC in CI configuration

https://github.com/apple/swift-package-manager/pull/2991 @swift-ci please test

neonichu

comment created time in 4 days

push eventapple/indexstore-db

Butta

commit sha e8a704bcbb08136b7935efc7c015e57bac3db2da

[build-script-helper] make it run under Python 3

view details

Ben Langmuir

commit sha faf8235b8e8105908c27fc75f46e5a829d5cd92b

Merge pull request #116 from buttaface/python3 [build-script-helper] make it run under Python 3

view details

push time in 5 days

PR merged apple/indexstore-db

Reviewers
[build-script-helper] make it run under Python 3

I've been running the entire build under Python 3 lately, but I'd get the usual error about mixing strings with bytes if this wasn't set. With this change, no problem building and running the tests.

+1 -1

5 comments

1 changed file

buttaface

pr closed time in 5 days

pull request commentapple/indexstore-db

[build-script-helper] make it run under Python 3

@swift-ci please test macOS

buttaface

comment created time in 5 days

PullRequestReviewEvent

push eventapple/sourcekit-lsp

Butta

commit sha 8deb6e4bead15503c9a01f6e864c35839875b988

[build-script-helper] make it run under Python 3 and always run tests in parallel instead

view details

Ben Langmuir

commit sha bb2ce160197a43c4b4bfddcaeb91ff6e735f47f4

Merge pull request #337 from buttaface/droid [build-script-helper] make it run under Python 3 and run tests in parallel on Android

view details

push time in 5 days

PR merged apple/sourcekit-lsp

[build-script-helper] make it run under Python 3 and run tests in parallel on Android

There's no longer a platform.linux_distribution() by default with Python 3.9, so just check for Android early and run the tests in parallel. I haven't seen it hang on Android when running these tests.

+5 -12

2 comments

1 changed file

buttaface

pr closed time in 5 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/sourcekit-lsp

[build-script-helper] make it run under Python 3 and run tests in parallel on Android

 def delete_rpath(rpath, binary):   def should_test_parallel():-  if platform.system() == 'Linux':+  if platform.system() == 'Linux' and 'ANDROID_DATA' not in os.environ:     distro = platform.linux_distribution()     if distro[0] != 'Ubuntu':       # Workaround hang in Process.run() that hasn't been tracked down yet.

I actually tracked down the bug this is working around after the comment was written and it is a bug in posix_spawn that only affected glibc-2.24. I don't think we're specifically trying to support any distros that use the affected glibc right now, so I'd be okay with just removing this check. If we do want to support this, the correct fix would probably be to patch corelibs-foundation's Process.run to not use posix_spawn on that glibc version (there is already a fallback implementation in foundation not using posix_spawn, but it's currently only enabled when posix_spawn is missing entirely).

buttaface

comment created time in 6 days

delete branch benlangmuir/sourcekit-lsp

delete branch : code-completion-server-side-filtering-5.3-20201012

delete time in 6 days

push eventapple/sourcekit-lsp

Ben Langmuir

commit sha f8f98dd5a9edce64ac92a9c4223ebfbbdf48349a

[completion] Pass through new code-completion options Conflicts: Sources/SourceKit/CodeCompletionOptions.swift Sources/SourceKit/SourceKitServer.swift Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha e0511b9904a499b5adafab3dcce83c20161839ba

[gardening] Split code-completion into its own file Similar to cursor info, there is enough code here it makes sense to separate it out. Conflicts: Sources/SourceKit/sourcekitd/CodeCompletion.swift Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha 198266d775120067d77df73978c3348aa29dc0b9

[completion] Add server-side filtering UIDs

view details

Ben Langmuir

commit sha ffd9690884f8b639cefc154748f7bb0edde06fe3

[completion] Add initial server-side filtering implementation Work in progress: add a basic implementation for keeping track of the current completion session, and use the sourcekitd complete.open/update/close requests. Conflicts: Sources/SourceKit/sourcekitd/CodeCompletion.swift Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha 1f28a7cd03f66ba06fa4f252b9e11d89f3645375

[completion] Set default maxResults = 200

view details

Ben Langmuir

commit sha 9d5f54715cb2d2177a2ecca0924347e10040e997

[completion] Fix tests when using server-side filtering With this change, tests pass whether we default to server-side or client-side filtering. Also duplicate a few interesting tests to run both ways. A future commit will beef up the test coverage for server-side filtering specifically. Conflicts: Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha 34896d2fe18d9b88f139c552545bcde06a9bc020

[log] Improve description of Position By default, print 1-based line/column numbers using the defacto standard line:column format. In debug print, continue to use the 0-based values to match the constructor.

view details

Ben Langmuir

commit sha b97dac9b6f4c0156db8340e79f34db7d93d86bca

[completion] Add an extension to pass completion options per-request Conflicts: Sources/LanguageServerProtocol/SupportTypes/CodeCompletionOptions.swift Sources/SourceKit/CodeCompletionOptions.swift Sources/SourceKitLSP/CodeCompletionOptions.swift

view details

Ben Langmuir

commit sha 443469268dc0f06b7ac068b2788ada27538289fe

[completion] Add tests for server-side filtering

view details

Ben Langmuir

commit sha d8b5a980eede996688dfb44b9d4c182a8c281c8b

[gardening] Fix copyright headers and formating in modified files Conflicts: Sources/SourceKit/SourceKitServer.swift Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha 947e15d25e24f1787622b3790e2b4b69c3eaea4c

[completion] Add usage note for server-side filtering command-line options

view details

Ben Langmuir

commit sha 8c1ef3290c52f0d644fce2a1e3da54e8b40269bf

[gardening] Rename CodeCompletionOptions -> SKCompletionOptions Since it is being used in the LSP protocol layer, give it a name that clarifies that it is SourceKit-specific.

view details

Ben Langmuir

commit sha 439428e65df15332108024142be8d0f28e791742

[completion] Add doc comment for CodeCompletionSession Conflicts: Sources/SourceKit/sourcekitd/CodeCompletion.swift Sources/SourceKit/sourcekitd/CodeCompletionSession.swift

view details

Ben Langmuir

commit sha 44851919f7747f1b1a77d562a73dce26ed2380c6

[completion] Enable server-side filtering by default

view details

Ben Langmuir

commit sha 2eb89985df48639e3258c18edcc2c4d3977059cd

[test] Update linuxmain

view details

Ben Langmuir

commit sha 84848df83f3d5aac058e035d3ce81eed998d190f

[buildsystem] Fix strong reference to delegate Typically this would create a reference cycle.

view details

Ben Langmuir

commit sha 91334e5070c5951c2df4b5595fccbbccdfa6b0dd

[jsonrpc] Workaround file descriptor lifetime issue We should solve this in the JSONRPCConnection itself, but in the meantime workaround by keeping pipes alive until the connection has closed.

view details

Ben Langmuir

commit sha f333b3d489519e47b07243357fc2e0a3c28ea58f

Shutdown toolchain connections on exit When using SourceKit-LSP in tests (or otherwise in a library), we do not want to leak the toolchain connections. Conflicts: Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

view details

Ben Langmuir

commit sha 08f54208eb83a7372ad460d17a723b713004c9bb

Fix merge conflict resolution errors

view details

David Goldman

commit sha 459e3b15f4eb4b6f7ce943a982def04debf989ac

Fix issue where a code-completion session at a specific offset would get stuck failing - Fix for https://bugs.swift.org/browse/SR-13561 by making sure the session close waits for the open to finish - Add a regression test Change-Id: Iff7217d7b03bc797e036c5329afb0765dcc1874b

view details

push time in 6 days

PR merged apple/sourcekit-lsp

[5.3-20201012] [completion] Filter completions on the server side

Cherry-pick the server-side filtering-related changes to release/5.3-20201012

  • #298 [completion] Filter completions on the server side
  • #335 Fix code-completion session repeated failure issue
  • #288 Fix a number of resource leaks when using SourceKit-LSP in tests or as a library
  • Changes to the command-line argument spelling (-- vs -) to match the main branch without pulling in the full swift-argument-parser change.

rdar://69374656

+1122 -300

3 comments

22 changed files

benlangmuir

pr closed time in 6 days

pull request commentapple/indexstore-db

[build-script-helper] make it run under Python 3

@swift-ci please test

buttaface

comment created time in 6 days

push eventapple/indexstore-db

Saleem Abdulrasool

commit sha 16cdd0def77d7b57a09cd6f5ac93183a57d8d438

IndexStoreDB: use `ucrt` instead of `MSVCRT` There is nothing that requires the use of `MSVCRT`. Use the modern C library on Windows, which also helps remove the `visualc` module in the Swift standard library.

view details

Ben Langmuir

commit sha 939d2eb1cabe57a994f4a2c6e3013e34c3feb0bb

Merge pull request #117 from compnerd/ucrt IndexStoreDB: use `ucrt` instead of `MSVCRT`

view details

push time in 6 days

PR merged apple/indexstore-db

Reviewers
IndexStoreDB: use `ucrt` instead of `MSVCRT`

There is nothing that requires the use of MSVCRT. Use the modern C library on Windows, which also helps remove the visualc module in the Swift standard library.

+1 -1

1 comment

1 changed file

compnerd

pr closed time in 6 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/indexstore-db

[build-script-helper] make it run under Python 3

@swift-ci please test

buttaface

comment created time in 6 days

push eventapple/sourcekit-lsp

Sebastian Fichtner

commit sha 7a36a51014263cc153cdebd2209185c17fae96b1

Synchronously send error response on message decoding failure (#334) * Replaces two logs since those don't result in response messages anymore * Adds a func for sending messages synchronously, to get the two messages out before fatalError

view details

push time in 8 days

PR merged apple/sourcekit-lsp

Synchronously send error response on message decoding failure
  • Replaces two logs since those don't result in response messages anymore
  • Adds a func for sending messages synchronously, to get the two messages out before fatalError
+73 -20

10 comments

5 changed files

flowtoolz

pr closed time in 8 days

pull request commentapple/sourcekit-lsp

[5.3-20201012] [completion] Filter completions on the server side

  • Explanation: Code-completion server-side filtering gives a major performance improvement to completion, particularly when completing global values. For developers who import large-ish modules, this is the difference between completion being responsive and being unusably slow (several seconds per global completion).
  • Scope: Affects code-completion in sourcekit-lsp.
  • Risk: We have been using this change successfully on the main branch for a few months now, and the only impactful known issue was recently fixed and is included in this cherry-pick. If there are unanticipated regressions, command-line options can be used to revert to the old behaviour. The biggest risk is that there were many sourcekitd-related changes on main branch that we do not have on 5.3 and it is possible that in edge cases related to server shutdown we will see issues. That would most likely affect unit testing, not real users.
  • Testing: Regression tests included. Also tested manually in an editor.
  • Issue: rdar://69374656
  • Reviewer: Argyrios

@swift-ci please nominate

benlangmuir

comment created time in 8 days

pull request commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

@swift-ci please test

flowtoolz

comment created time in 8 days

pull request commentapple/sourcekit-lsp

[5.3-20201012] [completion] Filter completions on the server side

@swift-ci please test

benlangmuir

comment created time in 8 days

PR opened apple/sourcekit-lsp

[5.3-20201012] [completion] Filter completions on the server side

Cherry-pick the server-side filtering-related changes to release/5.3-20201012

  • #298 [completion] Filter completions on the server side
  • #335 Fix code-completion session repeated failure issue
  • #288 Fix a number of resource leaks when using SourceKit-LSP in tests or as a library
  • Changes to the command-line argument spelling (-- vs -) to match the main branch without pulling in the full swift-argument-parser change.
+1122 -300

0 comment

22 changed files

pr created time in 8 days

pull request commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

Sounds good to me

flowtoolz

comment created time in 8 days

pull request commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

16:01:54 Test Case '-[LanguageServerProtocolJSONRPCTests.CodingTests testMessageDecodingError]' started.
16:01:54 
/Users/buildnode/jenkins/workspace/swift-sourcekit-lsp-PR-macOS/branch-main/sourcekit-lsp/Tests/LanguageServerProtocolJSONRPCTests/CodingTests.swift:161: error: -[LanguageServerProtocolJSONRPCTests.CodingTests testMessageDecodingError] : failed - expected error not seen
16:01:54 Test Case '-[LanguageServerProtocolJSONRPCTests.CodingTests testMessageDecodingError]' failed (1.289 seconds).
flowtoolz

comment created time in 9 days

pull request commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

@swift-ci please test

flowtoolz

comment created time in 9 days

PullRequestReviewEvent

pull request commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

@swift-ci please test

flowtoolz

comment created time in 9 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public final class JSONRPCConnection {               continue MESSAGE_LOOP             }           case .unknown:-            log("error decoding message: \(error.message)", level: .error)+            send(.errorResponse(ResponseError(error), id: nil),

Ah I see we don't have a good way to test this right now. Let's skip this.

flowtoolz

comment created time in 9 days

PullRequestReviewEvent

pull request commentapple/swift-package-manager

Cleanup PackageModel Module

Looking at the history of https://ci.swift.org/job/swift-package-manager-Linux-smoke-test/ it seems like this failure is caused by this PR, since it's not happening on any other PR tests before or after.

mattt

comment created time in 10 days

pull request commentapple/swift-package-manager

Cleanup PackageModel Module

No, that integration test issue looks unrelated to me. I can't see any way that sourcekit-lsp would cause this failure - we haven't changed anything about LinuxMain.swift. Instead it looks like swiftpm is incorrectly building LinuxMain.swift as a regular swift file instead of as a main file like it used to.

mattt

comment created time in 10 days

push eventapple/sourcekit-lsp

David Goldman

commit sha c537c2920e67b82596a9169b730ce2352313c470

Fix issue where a code-completion session at a specific offset would get stuck failing - Fix for https://bugs.swift.org/browse/SR-13561 by making sure the session close waits for the open to finish - Add a regression test Change-Id: Iff7217d7b03bc797e036c5329afb0765dcc1874b

view details

David Goldman

commit sha db63fce1c26f083da154ac1d9268cce4700d6e77

Remove unneeded textDocumentChange from code-complete regression test

view details

David Goldman

commit sha 2105fa53bcbd363790d6e800c2ed10dd0a21a36f

Better use of XCTest for code complete regression test

view details

Ben Langmuir

commit sha 4a199a88b5499e9ef2563b0243db0c8f095d83a0

Merge pull request #335 from DavidGoldman/codecomplete Fix code-completion session repeated failure issue

view details

push time in 10 days

PR merged apple/sourcekit-lsp

Fix code-completion session repeated failure issue
  • Fix for https://bugs.swift.org/browse/SR-13561 by making sure the session close waits for the open to finish

  • Add a regression test

+86 -10

3 comments

2 changed files

DavidGoldman

pr closed time in 10 days

Pull request review commentapple/sourcekit-lsp

convert tests from #file to using #filePath

 final class SupportTests: XCTestCase {       messages.append((message, level))     } -    func check(expected: [(String, LogLevel)], file: StaticString = #file, line: UInt = #line) {+    func check(expected: [(String, LogLevel)], file: StaticString = #filePath, line: UInt = #line) {       testLogger.flush()-      XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: file, line: line)-      XCTAssert(zip(messages, expected).allSatisfy({ $0.0 == $0.1 }), "\(messages) does not match expected \(expected)", file: file, line: line)+      XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: (file), line: line)

I see you updated some of the (file) cases, but it seems there are still a few more (you can search the patch for "(file)" to find the rest).

heckj

comment created time in 10 days

PullRequestReviewEvent

push eventapple/sourcekit-lsp

David Goldman

commit sha feb075b222a87c9bc534844cc1472f6a06a1436e

Add code-workspace file and vscode tasks file - This allows you to build and test sourcekit-lsp in VS Code with some support for swift diagnostics via `Tasks: Run Build Task` and `Tasks: Run Test Task` - In the future we could probably provide + document some way to use sourcekit-lsp on itself Change-Id: I8fa91409de406ec604570aac621bd7c009082e20

view details

David Goldman

commit sha ce756c8c2eeba8fecf47018dc6510177426824df

Show swift pm dependencies in the VS Code project Change-Id: If2cf5fc8da2eb7e2955e004fcfb0e839365b01bc

view details

Ben Langmuir

commit sha 0766b9150d8b1059976ade40ed37d6804fad90b6

Merge pull request #332 from DavidGoldman/vscode Add code-workspace file and vscode tasks file

view details

push time in 10 days

PR merged apple/sourcekit-lsp

Reviewers
Add code-workspace file and vscode tasks file
  • This allows you to build and test sourcekit-lsp in VS Code with some support for swift diagnostics viaTasks: Run Build Task and Tasks: Run Test Task

  • In the future we could probably provide + document some way to use the development version of sourcekit-lsp on itself

+98 -0

2 comments

2 changed files

DavidGoldman

pr closed time in 10 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public final class JSONRPCConnection {               continue MESSAGE_LOOP             }           case .unknown:-            log("error decoding message: \(error.message)", level: .error)+            send(.errorResponse(ResponseError(error), id: nil),

We can't test this behaviour directly due to the fatalError, but it might be good to add a test for the JSONRPCConnection receiving an error with nil id. For example, if you manually send an errorResponse(..., id: nil) make sure it doesn't crash the receiving connection. This would fit in Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift

flowtoolz

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public final class JSONRPCConnection {     }     return ready   }+  +  private func send(_ message: JSONRPCMessage, async: Bool = true) {

We should test the new async == false behaviour. We can underscore and make this public:

/// *Public for testing*
public func _send(...)

and add a test in Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift that uses this. There are other tests that do similar things like sending raw data.

flowtoolz

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public final class JSONRPCConnection {     send(_rawData: dispatchData)   } -  func send(encoding: (JSONEncoder) throws -> Data) {+  private func sendMessageSynchronously(_ messageData: Data) {+    let header = "Content-Length: \(messageData.count)\r\n\r\n"+    guard let headerData = header.data(using: .utf8) else {+      log("error encoding header", level: .error)+      return+    }+    let stdOutHandle = FileHandle(fileDescriptor: sendIO.fileDescriptor)

This seems unsafe since there may be other asynchronous writers. How about something like this?

let semaphore = DispatchSemaphore(value: 0)
sendIO.barrier {
  ... write to the file descriptor, which we now have exclusive access to ...
  semaphore.signal()
}

_ = semaphore.wait(timeout: .now() + .seconds(3))

Although perhaps the specific timeout should be passed in.

flowtoolz

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public final class JSONRPCConnection {     send(_rawData: dispatchData)   } -  func send(encoding: (JSONEncoder) throws -> Data) {+  private func sendMessageSynchronously(_ messageData: Data) {+    let header = "Content-Length: \(messageData.count)\r\n\r\n"+    guard let headerData = header.data(using: .utf8) else {+      log("error encoding header", level: .error)

This seems like it ought to be a fatalError. There is no reason this should ever happen.

flowtoolz

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Synchronously send error response on message decoding failure

 public enum JSONRPCMessage {   case notification(NotificationType)   case request(_RequestType, id: RequestID)   case response(ResponseType, id: RequestID)-  case errorResponse(ResponseError, id: RequestID)

We decode this value below like so:

      case (let id?, nil, _, let error?):
        msgKind = .response
        self = .errorResponse(error, id: id)

... which assumes that the id is non-nil. That probably needs to get updated to let id instead of let id?. Please add a test to Tests/LanguageServerProtocolJSONRPCTests/CodingTests.swift ensuring that we can round-trip this correctly when id == nil.

flowtoolz

comment created time in 11 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/sourcekit-lsp

Fix code-completion session repeated failure issue

 final class SwiftCompletionTests: XCTestCase {                                                 position: Position(line: 7, utf16index: 12),                                                 context:CompletionContext(triggerKind: .triggerFromIncompleteCompletions)))))   }++  /// Regression test for https://bugs.swift.org/browse/SR-13561 to make sure the a session+  /// close waits for its respective open to finish to prevent a session geting stuck open.+  func testSessionCloseWaitsforOpen() throws {+    initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))+    let url = URL(fileURLWithPath: "/\(#function)/file.swift")+    openDocument(text: """+      struct S {+        func forSomethingCrazy() {}+        func forSomethingCool() {}+        func test() {+          self.forSome+        }+        func print() {}+        func anotherOne() {+          self.prin+        }+      }+      """, url: url)++    let forSomeComplete = CompletionRequest(+          textDocument: TextDocumentIdentifier(url),+        position: Position(line: 4, utf16index: 12), // forS^+        context:CompletionContext(triggerKind: .invoked))+    let printComplete = CompletionRequest(+        textDocument: TextDocumentIdentifier(url),+      position: Position(line: 8, utf16index: 12), // prin^+      context:CompletionContext(triggerKind: .invoked))+    let coordinationGroup = DispatchGroup()++    // Code completion for "self.forSome"+    coordinationGroup.enter()+    _ = sk.send(forSomeComplete) { result in+      defer { coordinationGroup.leave() }+      guard let list = result.success else {+        XCTFail("Request failed: \(String(describing: result.failure))")+        return+      }+      XCTAssert(countFs(list) == 2)

XCTAssertEqual gives better reports if somethings fails.

DavidGoldman

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Fix code-completion session repeated failure issue

 final class SwiftCompletionTests: XCTestCase {                                                 position: Position(line: 7, utf16index: 12),                                                 context:CompletionContext(triggerKind: .triggerFromIncompleteCompletions)))))   }++  /// Regression test for https://bugs.swift.org/browse/SR-13561 to make sure the a session+  /// close waits for its respective open to finish to prevent a session geting stuck open.+  func testSessionCloseWaitsforOpen() throws {+    initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))+    let url = URL(fileURLWithPath: "/\(#function)/file.swift")+    openDocument(text: """+      struct S {+        func forSomethingCrazy() {}+        func forSomethingCool() {}+        func test() {+          self.forSome+        }+        func print() {}+        func anotherOne() {+          self.prin+        }+      }+      """, url: url)++    let forSomeComplete = CompletionRequest(+          textDocument: TextDocumentIdentifier(url),+        position: Position(line: 4, utf16index: 12), // forS^+        context:CompletionContext(triggerKind: .invoked))+    let printComplete = CompletionRequest(+        textDocument: TextDocumentIdentifier(url),+      position: Position(line: 8, utf16index: 12), // prin^+      context:CompletionContext(triggerKind: .invoked))+    let coordinationGroup = DispatchGroup()

Using XCTest expectations will behave better during testing. For one thing, they will provide better behaviour if something goes wrong (timeout indicating which request didn't finish). Another difference is that if there is anything in the service that needs to use the main thread, XCTest will automatically cycle the main run loop when waiting on an expectation, while blocking would otherwise cause a deadlock in that situation.

DavidGoldman

comment created time in 11 days

Pull request review commentapple/sourcekit-lsp

Fix code-completion session repeated failure issue

 final class SwiftCompletionTests: XCTestCase {                                                 position: Position(line: 7, utf16index: 12),                                                 context:CompletionContext(triggerKind: .triggerFromIncompleteCompletions)))))   }++  /// Regression test for https://bugs.swift.org/browse/SR-13561 to make sure the a session+  /// close waits for its respective open to finish to prevent a session geting stuck open.+  func testSessionCloseWaitsforOpen() throws {+    initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))+    let url = URL(fileURLWithPath: "/\(#function)/file.swift")+    openDocument(text: """+      struct S {+        func forSomethingCrazy() {}+        func forSomethingCool() {}+        func test() {+          self.forSome+        }+        func print() {}+        func anotherOne() {+          self.prin+        }+      }+      """, url: url)++    let forSomeComplete = CompletionRequest(+          textDocument: TextDocumentIdentifier(url),+        position: Position(line: 4, utf16index: 12), // forS^+        context:CompletionContext(triggerKind: .invoked))+    let printComplete = CompletionRequest(+        textDocument: TextDocumentIdentifier(url),+      position: Position(line: 8, utf16index: 12), // prin^+      context:CompletionContext(triggerKind: .invoked))+    let coordinationGroup = DispatchGroup()++    // Code completion for "self.forSome"+    coordinationGroup.enter()+    _ = sk.send(forSomeComplete) { result in+      defer { coordinationGroup.leave() }+      guard let list = result.success else {+        XCTFail("Request failed: \(String(describing: result.failure))")+        return+      }+      XCTAssert(countFs(list) == 2)+    }++    // Code completion for "self.prin", previously could immediately invalidate+    // the previous request.+    coordinationGroup.enter()+    _ = sk.send(printComplete) { result in+      defer { coordinationGroup.leave() }+      guard let list = result.success else {+        XCTFail("Request failed: \(String(describing: result.failure))")+        return+      }+      XCTAssertEqual(list.items.count, 1)+    }++    // Wait for the previous 2 completions to finish.+    coordinationGroup.wait()++    // Try code completion for "self.forSome" again to verify that it still works.+    let result = try sk.sendSync(forSomeComplete)+    XCTAssert(countFs(result) == 2)

Same here for XCTAssertEqual

DavidGoldman

comment created time in 11 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventapple/sourcekit-lsp

flowtoolz

commit sha 0427823d74c826dca6b32c8854e32f47f47049c5

Log error before fatalError(...) when message decoding fails

view details

Ben Langmuir

commit sha 875be4819e7492ef17c762addb39085c2e7d870c

Merge pull request #333 from flowtoolz/main Log error before fatalError(...) when message decoding fails

view details

push time in 12 days

PR merged apple/sourcekit-lsp

Log error before fatalError(...) when message decoding fails
  • Uses log(...) to give the client some feedback before terminating the process in response to an undecodable message
+4 -0

1 comment

1 changed file

flowtoolz

pr closed time in 12 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/sourcekit-lsp

Decrease verbosity of info-level logging

 open class LanguageServerEndpoint {     // Do nothing.   } -  open func _logRequest<R>(_ request: Request<R>) {-    logAsync { _ in-      "\(type(of: self)): \(request)"+  open func _logRequest<R>(_ request: Request<R>, method: String) {

R.method (or N.method in the notification case) should give you the method string. Only response should need this, since it doesn't statically know what the request type.

DavidGoldman

comment created time in 17 days

PullRequestReviewEvent

push eventapple/sourcekit-lsp

Saleem Abdulrasool

commit sha 3e32ce69f9612184f20b31a6512e8268031113ad

SKCore: support executable extensions on different platforms Similar to the dylib extension, introduce executable extensions. This is required for Windows which uses a `.exe` suffix for the executables.

view details

Ben Langmuir

commit sha 15d47d880e4975464a1c81b853775602d6fd78e1

Merge pull request #325 from compnerd/extensions SKCore: support executable extensions on different platforms

view details

push time in 17 days

PR merged apple/sourcekit-lsp

SKCore: support executable extensions on different platforms

Similar to the dylib extension, introduce executable extensions. This is required for Windows which uses a .exe suffix for the executables.

+18 -6

7 comments

3 changed files

compnerd

pr closed time in 17 days

push eventapple/swift-package-manager

Boris Buegling

commit sha 65c0f8f1cb81a2502cc18111ada45aeeaf8c66b4

Sync latest TSC changes from main

view details

Ben Langmuir

commit sha 568312fea1fed8e016ce9a32cec8d2c91f4207db

Merge pull request #2965 from neonichu/sync-tsc Sync latest TSC changes from main

view details

push time in 17 days

push eventapple/sourcekit-lsp

Saleem Abdulrasool

commit sha 67aaa09d70d5fe308dc5ae8fbd8c9e9c1aa7ba02

build: allow building with dispatch and Foundation from the toolchain This allows building without dispatch and Foundation build roots, which allows for a multi-phase build. This is intended to support the Windows staged build where dispatch and Foundation are part of the SDK and SourceKit-LSP is part of the devtools.

view details

Ben Langmuir

commit sha 6df9c68a127486206de661619ad58b927b9822e4

Merge pull request #328 from compnerd/staged build: allow building with dispatch and Foundation from the toolchain

view details

push time in 17 days

PR merged apple/sourcekit-lsp

build: allow building with dispatch and Foundation from the toolchain

This allows building without dispatch and Foundation build roots, which allows for a multi-phase build. This is intended to support the Windows staged build where dispatch and Foundation are part of the SDK and SourceKit-LSP is part of the devtools.

+20 -9

2 comments

4 changed files

compnerd

pr closed time in 17 days

pull request commentapple/sourcekit-lsp

Add --destination option for cross-compiled projects

We should add a test to SwiftPMWorkspaceTests for this. I think you could take a test like testBuildSetup and instead of checking the customization of BuildFlags, check the customization on the destination.

MaxDesiatov

comment created time in 17 days

PullRequestReviewEvent

pull request commentapple/swift-package-manager

Sync latest TSC changes from main

Please test with following PRs: apple/sourcekit-lsp#325

@swift-ci please smoke test

neonichu

comment created time in 17 days

push eventapple/sourcekit-lsp

David Goldman

commit sha 482a98893fc76c3457c8cfe83413e02d7a3626ae

Log to stderr instead of sending window/logMessage - clangd itself already logs to stderr so sourcekit-lsp should do the same for consistency (unless we want to capture clangd's stderr and forward it in the LSP) - Editors such as VS Code will show stderr output in the same output channel where it shows logMessage + traces Change-Id: Iaf00cffa2e64d8490e21b49a3a9d34a17f54aa9f

view details

Ben Langmuir

commit sha 833b36cf299e80cf85869ffd852c0789533785f3

Merge pull request #327 from DavidGoldman/main Log to stderr instead of sending window/logMessage

view details

push time in 17 days

PR merged apple/sourcekit-lsp

Log to stderr instead of sending window/logMessage
  • clangd itself already logs to stderr so sourcekit-lsp should do the same for consistency (unless we want to capture clangd's stderr and forward it in the LSP)

  • Editors such as VS Code will show stderr output in the same output channel where it shows logMessage + traces

+14 -4

2 comments

2 changed files

DavidGoldman

pr closed time in 17 days

Pull request review commentapple/sourcekit-lsp

Log to stderr instead of sending window/logMessage

 public final class Logger {     }   } +  private func logToStderr(_ message: String, level: LogLevel) {+    let time = self.dateFormatter.string(from: Date())+    let fullMessage = "[\(time)] \(message)\n"+    fputs(fullMessage, stderr)+  }+   private func logImpl(_ message: String, level: LogLevel, usedOSLog: Bool) {      if !self.disableNSLog && !usedOSLog {       // Fallback to NSLog if os_log isn't available.       NSLog(message)+    } else {+      self.logToStderr(message, level: level)

Ah sorry, I misread how it would work.

DavidGoldman

comment created time in 17 days

PullRequestReviewEvent

Pull request review commentapple/sourcekit-lsp

Log to stderr instead of sending window/logMessage

 public final class Logger {     }   } +  private func logToStderr(_ message: String, level: LogLevel) {+    let time = self.dateFormatter.string(from: Date())+    let fullMessage = "[\(time)] \(message)\n"+    fputs(fullMessage, stderr)+  }+   private func logImpl(_ message: String, level: LogLevel, usedOSLog: Bool) {      if !self.disableNSLog && !usedOSLog {       // Fallback to NSLog if os_log isn't available.       NSLog(message)+    } else {+      self.logToStderr(message, level: level)

I just checked: disableNSLog is never true except in unit tests. Should we just rely on NSLog?

DavidGoldman

comment created time in 18 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/sourcekit-lsp

build: repair build on Windows

@compnerd is this still relevant? It seems to need a rebase

compnerd

comment created time in 18 days

Pull request review commentapple/sourcekit-lsp

convert tests from #file to using #filePath

 final class SupportTests: XCTestCase {      func check(expected: [(String, LogLevel)], file: StaticString = #file, line: UInt = #line) {       testLogger.flush()-      XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: file, line: line)-      XCTAssert(zip(messages, expected).allSatisfy({ $0.0 == $0.1 }), "\(messages) does not match expected \(expected)", file: file, line: line)+        XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: (file), line: line)

I think the correct change here is that #file should be changed to #filePath in func check above.

There are a number of other places in this patch that are passing (file) that should be unnecessary once the declaration has been changed to use #filePath.

Also, there seems to be some unexpected changes to indentation that should be removed.

heckj

comment created time in 18 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/sourcekit-lsp

SKCore: support executable extensions on different platforms

Oh, since https://github.com/apple/swift-package-manager/pull/2898 has not landed yet I think you need to change the vendored copy of TSC that is in swiftpm as well.

compnerd

comment created time in 19 days

pull request commentapple/sourcekit-lsp

SKCore: support executable extensions on different platforms

@swift-ci please test macOS

compnerd

comment created time in 19 days

PullRequestReviewEvent

Pull request review commentapple/sourcekit-lsp

SKSwiftPMWorkspace: canonicalize the path prior to use

 extension SwiftPMWorkspace: SKCore.BuildSystem {       // We can't determine build settings for non-file URIs.       return nil     }-    guard let path = try? AbsolutePath(validating: url.path) else {-      return nil-    }+    guard let path = (url.withUnsafeFileSystemRepresentation {

I'm surprised this is only needed in one place - why don't we have the same issue for incoming URLs from the editor?

Is there a reason you preferred withUnsafeFileSystemRepresentation instead of standardizedURL.path?

compnerd

comment created time in 20 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/swift-corelibs-foundation

[5.3] SR-12696: Add JSONEncoder.OutputFormatting.withoutEscapingSlashes for Linux

@tomerd @millenomi I would like to nominate this for the next dot release.

Also CC'ing @spevans who authored the original commit.

benlangmuir

comment created time in 23 days

PR opened apple/swift-corelibs-foundation

[5.3] SR-12696: Add JSONEncoder.OutputFormatting.withoutEscapingSlashes for Linux

Cherry-pick https://github.com/apple/swift-corelibs-foundation/pull/2781/commits to 5.3.


The underlying functionality for .withoutEscapingSlashes is already in 5.3, but it is not currently exposed on JSONEncoder. Add it to match Darwin.

+13 -0

0 comment

2 changed files

pr created time in 23 days

delete branch benlangmuir/sourcekit-lsp

delete branch : test-resources

delete time in 23 days

push eventapple/sourcekit-lsp

Ben Langmuir

commit sha 41cf3a3764d745c31d971ff94cbd5a2f14e5e1d8

[test] Put shared test projects INPUTS into bundle resources This avoids depending on the absolute path to the INPUTS and allows looking it up at run time even if the tests have moved.

view details

Ben Langmuir

commit sha 49d13ce85bc2cca043ef0882391408939e176409

[docs] Update test documentation for INPUTS move

view details

Ben Langmuir

commit sha 283e6b8cc8f2e9798ed458f0ae7fb968575677ff

[package] Fix warnings about unknown files to be excluded

view details

Ben Langmuir

commit sha a7632523051b1c57523ffc43491c64dc00b8d405

[test] Fix resource directory on Linux

view details

Ben Langmuir

commit sha c49849bd5c4ab57564f1a519c31b5a2b12fea727

Merge pull request #323 from benlangmuir/test-resources [test] Put shared test projects INPUTS into bundle resources

view details

push time in 23 days

PR merged apple/sourcekit-lsp

[test] Put shared test projects INPUTS into bundle resources

This avoids depending on the absolute path to the INPUTS and allows looking it up at run time even if the tests have moved.

+84 -80

1 comment

61 changed files

benlangmuir

pr closed time in 23 days

pull request commentapple/sourcekit-lsp

[test] Put shared test projects INPUTS into bundle resources

@swift-ci please test

benlangmuir

comment created time in 23 days

more