Files
sourcekit-lsp/Sources/LSPTestSupport/String+TrimTrailingWhitespace.swift
Alex Hoppen 2e76be7c96 Remove placeholders from code actions instead of replacinng them by snippets
#481 replaced SourceKit placeholders (like `<#code#>`) by LSP snippets for code actions, which are used to represent SourceKit refactoring and diagnostic Fix-Its. But LSP snippets are only supported for code completion, not for code actions. This results in LSP snippets like ${1:code} being inserted into the editor.

Instead of replacing SourceKit placeholders by LSP placeholders, we should just remove them altogether from the code action response.

rdar://92447079 [#488]
2022-04-28 10:59:33 +02:00

20 lines
784 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
public extension String {
// This implementation is really slow; to use it outside a test it should be optimized.
func trimmingTrailingWhitespace() -> String {
return self.replacingOccurrences(of: "[ ]+\\n", with: "\n", options: .regularExpression)
}
}