Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"indentation": {
"spaces": 2
},
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": false,
"lineBreakBetweenDeclarationAttributes": false,
"lineLength": 120,
"maximumBlankLines": 1,
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether": true,
"reflowMultilineStringLiterals": {
"never": {

}
},
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AlwaysUseLowerCamelCase": false,
"AmbiguousTrailingClosureOverload": false,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": false,
"DontRepeatTypeInStaticProperties": false,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": false,
"NoAssignmentInExpressions": true,
"NoBlockComments": false,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": false,
"UseExplicitNilCheckInConditions": true,
"UseLetInEveryBoundCaseVariable": false,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": false,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
},
"spacesAroundRangeFormationOperators": false,
"spacesBeforeEndOfLineComments": 2,
"version": 1,
}
56 changes: 36 additions & 20 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ var useLocalDependencies: Bool { hasEnvironmentVariable("SWIFTCI_USE_LOCAL_DEPS"
var dependencies: [Package.Dependency] {
if useLocalDependencies {
return [
.package(path: "../swift-lmdb"),
.package(path: "../swift-lmdb")
]
} else {
return [
.package(url: "https://github.com/swiftlang/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/swiftlang/swift-lmdb.git", branch: "main")
]
}
}
Expand All @@ -29,19 +29,24 @@ let package = Package(
products: [
.library(
name: "IndexStoreDB",
targets: ["IndexStoreDB"]),
targets: ["IndexStoreDB"]
),
.library(
name: "IndexStoreDB_CXX",
targets: ["IndexStoreDB_Index"]),
targets: ["IndexStoreDB_Index"]
),
.library(
name: "ISDBTestSupport",
targets: ["ISDBTestSupport"]),
targets: ["ISDBTestSupport"]
),
.executable(
name: "tibs",
targets: ["tibs"]),
targets: ["tibs"]
),
.library(
name: "IndexStore",
targets: ["IndexStore"]),
targets: ["IndexStore"]
),
],
dependencies: dependencies,
targets: [
Expand All @@ -57,7 +62,7 @@ let package = Package(
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableExperimentalFeature("Lifetimes"),
.swiftLanguageMode(.v6)
.swiftLanguageMode(.v6),
]
),

Expand All @@ -74,7 +79,8 @@ let package = Package(
.target(
name: "IndexStoreDB",
dependencies: ["IndexStoreDB_CIndexStoreDB"],
exclude: ["CMakeLists.txt"]),
exclude: ["CMakeLists.txt"]
),

.testTarget(
name: "IndexStoreDBTests",
Expand All @@ -87,16 +93,19 @@ let package = Package(
// The Test Index Build System (tibs) library.
.target(
name: "ISDBTibs",
dependencies: []),
dependencies: []
),

.testTarget(
name: "ISDBTibsTests",
dependencies: ["ISDBTibs", "ISDBTestSupport"]),
dependencies: ["ISDBTibs", "ISDBTestSupport"]
),

// Commandline tool for working with tibs projects.
.executableTarget(
name: "tibs",
dependencies: ["ISDBTibs"]),
dependencies: ["ISDBTibs"]
),

// Test support library, built on top of tibs.
.target(
Expand All @@ -107,7 +116,8 @@ let package = Package(
],
linkerSettings: [
.linkedFramework("XCTest", .when(platforms: [.iOS, .macOS, .tvOS, .watchOS]))
]),
]
),

// MARK: C++ interface

Expand All @@ -118,13 +128,15 @@ let package = Package(
exclude: [
"CMakeLists.txt",
"indexstore_functions.def",
]),
]
),

// C wrapper for IndexStoreDB_Index.
.target(
name: "IndexStoreDB_CIndexStoreDB",
dependencies: ["IndexStoreDB_Index"],
exclude: ["CMakeLists.txt"]),
exclude: ["CMakeLists.txt"]
),

// The lmdb database layer.
.target(
Expand All @@ -134,20 +146,23 @@ let package = Package(
.product(name: "CLMDB", package: "swift-lmdb"),
],
exclude: [
"CMakeLists.txt",
]),
"CMakeLists.txt"
]
),

// Core index types.
.target(
name: "IndexStoreDB_Core",
dependencies: ["IndexStoreDB_Support"],
exclude: ["CMakeLists.txt"]),
exclude: ["CMakeLists.txt"]
),

// Support code that is generally useful to the C++ implementation.
.target(
name: "IndexStoreDB_Support",
dependencies: ["IndexStoreDB_LLVMSupport"],
exclude: ["CMakeLists.txt"]),
exclude: ["CMakeLists.txt"]
),

// Copy of a subset of llvm's ADT and Support libraries.
.target(
Expand Down Expand Up @@ -178,7 +193,8 @@ let package = Package(
"Windows/Signals.inc",
"Windows/Threading.inc",
"Windows/Watchdog.inc",
]),
]
),
],
swiftLanguageModes: [.v5],
cxxLanguageStandard: .cxx17
Expand Down
2 changes: 1 addition & 1 deletion Sources/ISDBTestSupport/ForwardingIndexDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//

import IndexStoreDB
import Dispatch
import IndexStoreDB

/// A wrapper that forwards to another delegate that can be mutated at runtime.
final class ForwardingIndexDelegate: IndexDelegate {
Expand Down
12 changes: 9 additions & 3 deletions Sources/ISDBTestSupport/TestLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct TestLocation: Hashable {
}

extension TestLocation: Comparable {
public static func <(a: TestLocation, b: TestLocation) -> Bool {
public static func < (a: TestLocation, b: TestLocation) -> Bool {
return (a.url.path, a.line, a.utf8Column) < (b.url.path, b.line, b.utf8Column)
}
}
Expand All @@ -55,14 +55,20 @@ extension SymbolLocation {
moduleName: moduleName,
isSystem: isSystem,
line: loc.line,
utf8Column: loc.utf8Column)
utf8Column: loc.utf8Column
)
}
}

extension Symbol {

/// Returns a SymbolOccurrence with the given location and roles.
public func at(_ location: TestLocation, moduleName: String = TestLocation.unknownModuleName, roles: SymbolRole, symbolProvider: SymbolProviderKind) -> SymbolOccurrence {
public func at(
_ location: TestLocation,
moduleName: String = TestLocation.unknownModuleName,
roles: SymbolRole,
symbolProvider: SymbolProviderKind
) -> SymbolOccurrence {
return self.at(SymbolLocation(location, moduleName: moduleName), symbolProvider: symbolProvider, roles: roles)
}
}
Expand Down
28 changes: 16 additions & 12 deletions Sources/ISDBTestSupport/TestLocationScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public struct TestLocationScanner {
let locIndex: String.Index
if str[start] == "<" {
nameStart = str.index(after: start)
locIndex = str.index(start, offsetBy: -2) // subtract '/' and '*'
locIndex = str.index(start, offsetBy: -2) // subtract '/' and '*'
} else {
nameStart = start
locIndex = str.index(after: i) // after trailing '/'
locIndex = str.index(after: i) // after trailing '/'
}

let name = String(str[nameStart..<str.index(before: i)])
Expand All @@ -103,7 +103,8 @@ public struct TestLocationScanner {
url: url,
line: line,
utf8Column: 1 + str.utf8.distance(from: lineStart, to: locIndex),
utf16Column: 1 + str.utf16.distance(from: lineStart, to: locIndex))
utf16Column: 1 + str.utf16.distance(from: lineStart, to: locIndex)
)

if let prevLoc = result.updateValue(loc, forKey: name) {
throw Error.duplicateKey(name, prevLoc, loc)
Expand All @@ -112,11 +113,14 @@ public struct TestLocationScanner {
state = .normal(prev: "_")

case (.comment(_, "/"), "*"):
throw Error.nestedComment(TestLocation(
url: url,
line: line,
utf8Column: 1 + str.utf8.distance(from: lineStart, to: i),
utf16Column: 1 + str.utf16.distance(from: lineStart, to: i)))
throw Error.nestedComment(
TestLocation(
url: url,
line: line,
utf8Column: 1 + str.utf8.distance(from: lineStart, to: i),
utf16Column: 1 + str.utf16.distance(from: lineStart, to: i)
)
)

case (.comment(let start, _), _):
state = .comment(bodyStart: start, prev: c)
Expand Down Expand Up @@ -165,9 +169,9 @@ public func scanLocations(

func isSourceFileExtension(_ ext: String) -> Bool {
switch ext {
case "swift", "c", "cpp", "m", "mm", "h", "hpp":
return true
default:
return false
case "swift", "c", "cpp", "m", "mm", "h", "hpp":
return true
default:
return false
}
}
2 changes: 1 addition & 1 deletion Sources/ISDBTestSupport/TestSources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public final class TestSources {
/// * returns: The ChangeSet corresponding to these changes.
/// * throws: Any file system errors seen while modifying the sources. If this happens, the state
/// of the source files is not defined.
public func edit(_ block: (_ builder: inout ChangeBuilder) throws -> ()) throws -> ChangeSet {
public func edit(_ block: (_ builder: inout ChangeBuilder) throws -> Void) throws -> ChangeSet {
var builder = ChangeBuilder()
try block(&builder)
try apply(builder.changes)
Expand Down
Loading