mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Refactor tree-sitter
This commit is contained in:
@@ -45,7 +45,7 @@ When given a task in an existing project, Claude will look for the most relevant
|
|||||||
|
|
||||||
1. **File Structure**: When a task is started, Claude is given an overview of your project's file structure. It turns out Claude 3.5 Sonnet is _really_ good at inferring what it needs to process further just from these file names alone.
|
1. **File Structure**: When a task is started, Claude is given an overview of your project's file structure. It turns out Claude 3.5 Sonnet is _really_ good at inferring what it needs to process further just from these file names alone.
|
||||||
|
|
||||||
2. **Source Code Definitions**: Claude may then use the `list_code_definition_names` tool on specific directories of interest. This tool uses [tree-sitter](https://github.com/tree-sitter/tree-sitter) to parse source code with custom tag queries that extract names of classes, functions, methods, and other definitions. It works by first identifying source code files that tree-sitter can parse (currently supports `python`, `javascript`, `typescript`, `ruby`, `go`, `java`, `php`, `rust`, `c`, `c++`, `c#`, `swift`), then parsing each file into an abstract syntax tree, and finally applying a language-specific query to extract definition names (you can see the exact query used for each language in `src/parse-source-code/queries`). The results are formatted into a concise & readable output that Claude can easily interpret to quickly understand the code's structure and purpose.
|
2. **Source Code Definitions**: Claude may then use the `list_code_definition_names` tool on specific directories of interest. This tool uses [tree-sitter](https://github.com/tree-sitter/tree-sitter) to parse source code with custom tag queries that extract names of classes, functions, methods, and other definitions. It works by first identifying source code files that tree-sitter can parse (currently supports `python`, `javascript`, `typescript`, `ruby`, `go`, `java`, `php`, `rust`, `c`, `c++`, `c#`, `swift`), then parsing each file into an abstract syntax tree, and finally applying a language-specific query to extract definition names. The results are formatted into a concise & readable output that Claude can easily interpret to quickly understand the code's structure and purpose.
|
||||||
|
|
||||||
3. **Search Files**: Claude can also use the `search_files` tool to search for specific patterns or content across multiple files. This tool uses [ripgrep](https://github.com/BurntSushi/ripgrep) to perform regex searches on files in a specified directory. The results are formatted into a concise & readable output that Claude can easily interpret to quickly understand the code's structure and purpose. This can be useful for tasks like refactoring function names, updating imports, addressing TODOs and FIXMEs, etc.
|
3. **Search Files**: Claude can also use the `search_files` tool to search for specific patterns or content across multiple files. This tool uses [ripgrep](https://github.com/BurntSushi/ripgrep) to perform regex searches on files in a specified directory. The results are formatted into a concise & readable output that Claude can easily interpret to quickly understand the code's structure and purpose. This can be useful for tasks like refactoring function names, updating imports, addressing TODOs and FIXMEs, etc.
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { serializeError } from "serialize-error"
|
|||||||
import * as vscode from "vscode"
|
import * as vscode from "vscode"
|
||||||
import { ApiHandler, buildApiHandler } from "./api"
|
import { ApiHandler, buildApiHandler } from "./api"
|
||||||
import { TerminalManager } from "./integrations/TerminalManager"
|
import { TerminalManager } from "./integrations/TerminalManager"
|
||||||
import { listFiles, parseSourceCodeForDefinitionsTopLevel } from "./parse-source-code"
|
import { listFiles, parseSourceCodeForDefinitionsTopLevel } from "./core/tree-sitter"
|
||||||
import { ClaudeDevProvider } from "./providers/ClaudeDevProvider"
|
import { ClaudeDevProvider } from "./providers/ClaudeDevProvider"
|
||||||
import { ApiConfiguration } from "./shared/api"
|
import { ApiConfiguration } from "./shared/api"
|
||||||
import { ClaudeRequestResult } from "./shared/ClaudeRequestResult"
|
import { ClaudeRequestResult } from "./shared/ClaudeRequestResult"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { globby, Options } from "globby"
|
|||||||
import os from "os"
|
import os from "os"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { LanguageParser, loadRequiredLanguageParsers } from "./languageParser"
|
import { LanguageParser, loadRequiredLanguageParsers } from "./languageParser"
|
||||||
import { arePathsEqual } from "../utils/path-helpers"
|
import { arePathsEqual } from "../../utils/path-helpers"
|
||||||
|
|
||||||
// TODO: implement caching behavior to avoid having to keep analyzing project for new tasks.
|
// TODO: implement caching behavior to avoid having to keep analyzing project for new tasks.
|
||||||
export async function parseSourceCodeForDefinitionsTopLevel(dirPath: string): Promise<string> {
|
export async function parseSourceCodeForDefinitionsTopLevel(dirPath: string): Promise<string> {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as vscode from "vscode"
|
import * as vscode from "vscode"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { listFiles } from "../parse-source-code/index"
|
import { listFiles } from "../core/tree-sitter/index"
|
||||||
import { ClaudeDevProvider } from "../providers/ClaudeDevProvider"
|
import { ClaudeDevProvider } from "../providers/ClaudeDevProvider"
|
||||||
|
|
||||||
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
|
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user