Skip to content

Commit e17ce5a

Browse files
committed
Allow all file types to have a filespace
1 parent f6c6488 commit e17ce5a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Tool/Sources/Workspace/Filespace.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public final class Filespace {
7676
public let fileURL: URL
7777
public private(set) lazy var language: CodeLanguage = languageIdentifierFromFileURL(fileURL)
7878
public var codeMetadata: FilespaceCodeMetadata = .init()
79+
public var isTextReadable: Bool {
80+
fileURL.pathExtension != "mlmodel"
81+
}
7982

8083
// MARK: Suggestions
8184

Tool/Sources/Workspace/WorkspacePool.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public class WorkspacePool {
8888
public func fetchOrCreateWorkspaceAndFilespace(fileURL: URL) async throws
8989
-> (workspace: Workspace, filespace: Filespace)
9090
{
91-
let ignoreFileExtensions = ["mlmodel"]
92-
if ignoreFileExtensions.contains(fileURL.pathExtension) {
93-
throw Workspace.UnsupportedFileError(extensionName: fileURL.pathExtension)
94-
}
95-
9691
// If we can get the workspace URL directly.
9792
if let currentWorkspaceURL = await XcodeInspector.shared.safe.realtimeActiveWorkspaceURL {
9893
if let existed = workspaces[currentWorkspaceURL] {

Tool/Sources/WorkspaceSuggestionService/SuggestionWorkspacePlugin.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public final class SuggestionServiceWorkspacePlugin: WorkspacePlugin {
9696

9797
public func notifyOpenFile(filespace: Filespace) {
9898
Task {
99+
guard filespace.isTextReadable else { return }
99100
guard !(await filespace.isGitIgnored) else { return }
100101
// check if file size is larger than 15MB, if so, return immediately
101102
if let attrs = try? FileManager.default
@@ -113,6 +114,7 @@ public final class SuggestionServiceWorkspacePlugin: WorkspacePlugin {
113114

114115
public func notifyUpdateFile(filespace: Filespace, content: String) {
115116
Task {
117+
guard filespace.isTextReadable else { return }
116118
guard !(await filespace.isGitIgnored) else { return }
117119
try await suggestionService?.notifyChangeTextDocument(
118120
fileURL: filespace.fileURL,
@@ -123,6 +125,7 @@ public final class SuggestionServiceWorkspacePlugin: WorkspacePlugin {
123125

124126
public func notifySaveFile(filespace: Filespace) {
125127
Task {
128+
guard filespace.isTextReadable else { return }
126129
guard !(await filespace.isGitIgnored) else { return }
127130
try await suggestionService?.notifySaveTextDocument(fileURL: filespace.fileURL)
128131
}

0 commit comments

Comments
 (0)