refactor(core): simplify search root protocol (#31060)
This commit is contained in:
@@ -13,7 +13,6 @@ const sessionID = SessionV2.ID.make("ses_glob_tool_test")
|
||||
const assertions: PermissionV2.AssertInput[] = []
|
||||
const resolutions: FileSystem.ListInput[] = []
|
||||
const searches: LocationSearch.FilesInput[] = []
|
||||
const roots: FileSystem.RootTarget[] = []
|
||||
let allow = true
|
||||
let result = new LocationSearch.FilesResult({ items: [], truncated: false, partial: false })
|
||||
|
||||
@@ -45,17 +44,13 @@ const filesystem = Layer.succeed(
|
||||
const relative = input.path ?? RelativePath.make(".")
|
||||
const resource = input.reference === undefined ? relative : `${input.reference}:${relative}`
|
||||
return new FileSystem.RootTarget({
|
||||
absolute: `/project/${relative}`,
|
||||
real: `/project/${relative}`,
|
||||
directory: "/project",
|
||||
root: "/project",
|
||||
resource,
|
||||
reference: input.reference,
|
||||
type: "directory",
|
||||
dev: 1,
|
||||
})
|
||||
}),
|
||||
revalidateRoot: Effect.succeed,
|
||||
resolveList: () => Effect.die("unused"),
|
||||
listResolved: () => Effect.die("unused"),
|
||||
listPage: () => Effect.die("unused"),
|
||||
@@ -69,10 +64,9 @@ const filesystem = Layer.succeed(
|
||||
const search = Layer.succeed(
|
||||
LocationSearch.Service,
|
||||
LocationSearch.Service.of({
|
||||
files: (input, root) =>
|
||||
files: (input) =>
|
||||
Effect.sync(() => {
|
||||
searches.push(input)
|
||||
if (root) roots.push(root)
|
||||
return result
|
||||
}),
|
||||
grep: () => Effect.die("unused"),
|
||||
@@ -92,7 +86,6 @@ const reset = () => {
|
||||
assertions.length = 0
|
||||
resolutions.length = 0
|
||||
searches.length = 0
|
||||
roots.length = 0
|
||||
allow = true
|
||||
result = new LocationSearch.FilesResult({ items: [], truncated: false, partial: false })
|
||||
}
|
||||
@@ -130,7 +123,6 @@ describe("GlobTool", () => {
|
||||
])
|
||||
expect(resolutions).toEqual([{ path: RelativePath.make("src"), reference: undefined }])
|
||||
expect(searches).toEqual([{ pattern: "**/*.ts", path: RelativePath.make("src"), limit: 12 }])
|
||||
expect(roots).toMatchObject([{ resource: "src" }])
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user