Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Quick pass at Swift Modernizing (#256)
Browse files Browse the repository at this point in the history
Just fixing dead-simple deprecations and warnings I noticed while writing
PR #255, broken out for easy reviewing.

No functionality changes and not comprehensive; just a quick tidy.
  • Loading branch information
cpsauer authored Aug 17, 2021
1 parent b88434c commit 09a015c
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Tulsi/ConfigEditorWizardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class ConfigEditorWizardViewController: NSViewController, NSPageController
viewController.representedObject = representedObject

// This index is guaranteed to exist due to fixed number of pages we have.
let newPageIndex = ConfigEditorWizardViewController.wizardPageIdentifiers.index(of: object as! String)!
let newPageIndex = ConfigEditorWizardViewController.wizardPageIdentifiers.firstIndex(of: object as! String)!
let subview = viewController as? WizardSubviewProtocol
subview?.presentingWizardViewController = self
if pageController.selectedIndex < newPageIndex {
Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/HeadlessXcodeProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct HeadlessXcodeProjectGenerator {
var config = try loadConfig(configURL, bazelURL: explicitBazelURL)
config = config.configByAppendingPathFilters(arguments.additionalPathFilters)
if let project = projectDocument.project {
config = config.configByResolvingInheritedSettingsFromProject(project);
config = config.configByResolvingInheritedSettingsFromProject(project)
}

let workspaceRootURL: URL
Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/NewGeneratorConfigViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Cocoa


/// Protocol used to inform receiver of a NewGeneratorConfigViewController's exit status.
protocol NewGeneratorConfigViewControllerDelegate: class {
protocol NewGeneratorConfigViewControllerDelegate: AnyObject {
func viewController(_ vc: NewGeneratorConfigViewController,
didCompleteWithReason: NewGeneratorConfigViewController.CompletionReason)
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/NewProjectViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Cocoa


/// Protocol used to inform receiver of a NewProjectViewController's exit status.
protocol NewProjectViewControllerDelegate: class {
protocol NewProjectViewControllerDelegate: AnyObject {
func viewController(_ vc: NewProjectViewController,
didCompleteWithReason: NewProjectViewController.CompletionReason)
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/OptionsEditorModelProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TulsiGenerator


/// Provides functionality for accessing and mutating an object capable of storing Tulsi options.
protocol OptionsEditorModelProtocol: class {
protocol OptionsEditorModelProtocol: AnyObject {
/// The name of the project that the model's options are associated with.
var projectName: String? { get }

Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/OptionsTargetSelectorController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OptionsTargetNode: UISelectableOutlineViewNode {
}


protocol OptionsTargetSelectorControllerDelegate: class {
protocol OptionsTargetSelectorControllerDelegate: AnyObject {
/// Invoked when the target selection has been changed.
func didSelectOptionsTargetNode(_ node: OptionsTargetNode)
}
Expand Down
8 changes: 4 additions & 4 deletions src/Tulsi/SplashScreenWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class SplashScreenWindowController: NSWindowController, NSTableViewDelegat
continue
}

var components: [String] = url.pathComponents
let components: [String] = url.pathComponents
var i = components.count - 1
repeat {
if (components[i] as NSString).pathExtension == projectExtension {
Expand All @@ -121,12 +121,12 @@ final class SplashScreenWindowController: NSWindowController, NSTableViewDelegat
projectURL = NSURL.fileURL(withPathComponents: projectComponents)! as URL
}
if (recentDocumentURLs.contains(projectURL)) {
continue;
continue
}
recentDocumentURLs.insert(projectURL);
recentDocumentURLs.insert(projectURL)

let viewController = SplashScreenRecentDocumentViewController()
viewController.url = projectURL;
viewController.url = projectURL
recentDocumentViewControllers.append(viewController)
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/TulsiGeneratorConfigDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Cocoa
import TulsiGenerator


protocol TulsiGeneratorConfigDocumentDelegate: class {
protocol TulsiGeneratorConfigDocumentDelegate: AnyObject {
/// Called when the TulsiGeneratorConfigDocument is saved successfully with a new name.
func didNameTulsiGeneratorConfigDocument(_ document: TulsiGeneratorConfigDocument, configName: String)

Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/TulsiProjectDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ final class TulsiProjectDocument: NSDocument,
}

deinit {
NotificationCenter.default.removeObserver(logEventObserver)
NotificationCenter.default.removeObserver(logEventObserver!)
}

func clearMessages() {
Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/UIMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Cocoa
import TulsiGenerator

/// Defines an object that holds an array of UIMessages.
protocol MessageLogProtocol: class {
protocol MessageLogProtocol: AnyObject {
var messages: [UIMessage] { get }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tulsi/UISelectableOutlineViewNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Cocoa


protocol Selectable: class {
protocol Selectable: AnyObject {
var selected: Bool { get set }
}

Expand Down
2 changes: 1 addition & 1 deletion src/TulsiGenerator/PBXProjSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Foundation
let XcodeProjectArchiveVersion = "1"


protocol PBXProjSerializable: class {
protocol PBXProjSerializable: AnyObject {
func serializeInto(_ serializer: PBXProjFieldSerializer) throws
}

Expand Down
2 changes: 1 addition & 1 deletion src/TulsiGenerator/PBXTargetGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct StubInfoPlistPaths {
}

/// Defines an object that can populate a PBXProject based on RuleEntry's.
protocol PBXTargetGeneratorProtocol: class {
protocol PBXTargetGeneratorProtocol: AnyObject {
static func getRunTestTargetBuildConfigPrefix() -> String

static func workingDirectoryForPBXGroup(_ group: PBXGroup) -> String
Expand Down
2 changes: 1 addition & 1 deletion src/TulsiGenerator/XcodeProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ final class XcodeProjectGenerator {
// Only over-write if needed.
if fileManager.fileExists(atPath: targetURL.path) {
guard !fileManager.contentsEqual(atPath: sourceURL.path, andPath: targetURL.path) else {
continue;
continue
}
print("Overwriting \(targetURL.path) as its contents changed.")
try fileManager.removeItem(at: targetURL)
Expand Down

0 comments on commit 09a015c

Please sign in to comment.