-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InjectionStandalone for Cursor. (#29)
* InjectionStandalone for Cursor. * Move injections to .main queue. * Generic superclass patching. * Testing with Cursor. * Additional logging/mixed mode. * Fail over to log parser. * Case where bundle and package configured. * Mangled stacktrace on SIGPIPE. * Filter out more options. * Precompiled bridging headers. * More linking logging.
- Loading branch information
1 parent
1c1ebac
commit dc3474d
Showing
13 changed files
with
189 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// InjectionHybrid.swift | ||
// InjectionNext | ||
// | ||
// Created by John Holdsworth on 09/11/2024. | ||
// Copyright © 2024 John Holdsworth. All rights reserved. | ||
// | ||
// Provide file watcher/log parser fallback | ||
// for use outside Xcode (i.e. Cursor/VSCode) | ||
// | ||
import Cocoa | ||
|
||
extension AppDelegate { | ||
static var watchers = [InjectionHybrid]() | ||
|
||
@IBAction func watchProject(_ sender: NSMenuItem) { | ||
let open = NSOpenPanel() | ||
open.prompt = "Select Project Directory" | ||
open.canChooseDirectories = true | ||
open.canChooseFiles = false | ||
// open.showsHiddenFiles = TRUE; | ||
if open.runModal() == .OK, let url = open.url { | ||
setenv("INJECTION_DIRECTORIES", | ||
NSHomeDirectory()+"/Library/Developer,"+url.path, 1) | ||
Reloader.injectionQueue = .main | ||
Self.watchers.append(InjectionHybrid()) | ||
sender.state = .on | ||
} | ||
} | ||
} | ||
|
||
class InjectionHybrid: InjectionBase { | ||
/// InjectionNext compiler that uses InjectionLite log parser | ||
let mixRecompiler = HybridCompiler() | ||
/// Minimum seconds between injections | ||
let minInterval = 1.0 | ||
|
||
/// Called from file watcher when file is edited. | ||
override func inject(source: String) { | ||
guard Date().timeIntervalSince1970 - (MonitorXcode.runningXcode? | ||
.recompiler.lastInjected[source] ?? 0.0) > minInterval else { | ||
return | ||
} | ||
MonitorXcode.compileQueue.async { | ||
guard let running = MonitorXcode.runningXcode, | ||
running.recompiler.inject(source: source) else { | ||
_ = self.mixRecompiler.inject(source: source) | ||
return | ||
} | ||
} | ||
} | ||
} | ||
|
||
class HybridCompiler: NextCompiler { | ||
/// Legacy log parsing version of recomilation | ||
var liteRecompiler = Recompiler() | ||
|
||
override func recompile(source: String, platform: String) -> String? { | ||
return liteRecompiler.recompile(source: source, dylink: false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.