Each language adapter implements the LanguageAdapter interface and provides:
- AST Parsing — Extract symbols (classes, functions, interfaces, etc.)
- Dependency Resolution — Resolve imports to file paths
- Documentation Extraction — Extract doc comments
interface LanguageAdapter {
readonly language: SupportedLanguage
readonly fileExtensions: string[]
supports(filePath: string): boolean
parseFile(filePath: string, projectRoot: string): Promise<ParsedFile>
resolveImport(importPath: string, fromFile: string, projectRoot: string): Promise<string | null>
}| Adapter | Language | File Extensions | Parser |
|---|---|---|---|
pnftrading_codei-adapter-typescript |
TypeScript | .ts, .tsx |
ts-morph |
pnftrading_codei-adapter-python |
Python | .py |
Regex |
pnftrading_codei-adapter-go |
Go | .go |
Regex |
pnftrading_codei-adapter-rust |
Rust | .rs |
Regex |
pnftrading_codei-adapter-java |
Java | .java |
Regex |
pnftrading_codei-adapter-csharp |
C# | .cs |
Regex |
pnftrading_codei-adapter-cpp |
C/C++ | .cpp, .cc, .hpp, .h |
Regex |
pnftrading_codei-adapter-php |
PHP | .php |
Regex |
pnftrading_codei-adapter-swift |
Swift | .swift |
Regex |
Package: pnftrading_codei-adapter-typescript
Parser: ts-morph (full AST)
- Full TypeScript AST parsing
- Interface, type alias, enum extraction
- Generic type parameter support
- JSX/TSX support
class,interface,enum,type,function,method
Package: pnftrading_codei-adapter-python
Parser: Regex-based
- Class, function extraction
- Import/from-import resolution
- Docstring extraction (Google, NumPy, Epydoc styles)
- Decorator detection
class,function,method
import os
from pathlib import Path
from collections import defaultdict as ddPackage: pnftrading_codei-adapter-go
Parser: Regex-based
- Package-level symbols
- Import resolution
- Struct, interface, function extraction
- GOPATH/module resolution
struct,interface,function,method
import (
"fmt"
"net/http"
mypkg "github.com/user/pkg"
)Package: pnftrading_codei-adapter-rust
Parser: Regex-based
- Crate/module hierarchy
- Struct, enum, trait extraction
- Use statement resolution
- Doc comment extraction
struct,enum,trait,function,method
use std::collections::HashMap;
use crate::module::Item;Package: pnftrading_codei-adapter-java
Parser: Regex-based
- Class, interface, enum extraction
- Package resolution
- Javadoc extraction
- Method visibility detection
class,interface,enum,method,annotation
import java.util.List;
import com.example.MyClass;Package: pnftrading_codei-adapter-csharp
Parser: Regex-based
- Class, struct, interface, enum extraction
- Namespace resolution
- XML doc comment extraction
- Access modifier detection
class,struct,interface,enum,delegate,method
using System;
using System.Collections.Generic;
using MyNamespace.MyClass;Package: pnftrading_codei-adapter-cpp
Parser: Regex-based
- Class, struct, enum, union extraction
- Header include resolution
- Namespace support
- Template detection
class,struct,enum,union,function,method
#include <iostream>
#include "myheader.hpp"Package: pnftrading_codei-adapter-php
Parser: Regex-based
- Class, interface, trait extraction
- PHP namespace resolution
- DocBlock extraction
- PSR-4 autoload support
class,interface,trait,function,method
use Illuminate\Database\Eloquent\Model;
use App\Models\User;Package: pnftrading_codei-adapter-swift
Parser: Regex-based
- Class, struct, enum, protocol extraction
- Extension handling
- Swift import resolution
- Swift doc comment extraction
class,struct,enum,protocol,extension,function,method
import Foundation
import UIKit
import MyLocalModulemkdir -p packages/adapter-newlang/src{
"name": "pnftrading_codei-adapter-newlang",
"version": "0.1.0",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"build": "tsc"
},
"dependencies": {
"pnftrading_codei-core": "workspace:*"
}
}// src/NewlangAdapter.ts
import type { LanguageAdapter, ParsedFile } from "pnftrading_codei-core"
export class NewlangAdapter implements LanguageAdapter {
readonly language = "newlang" as const
readonly fileExtensions = [".nl"]
async parseFile(filePath: string, projectRoot: string): Promise<ParsedFile> {
// Parse file and extract symbols
}
async resolveImport(importPath: string, fromFile: string, projectRoot: string): Promise<string | null> {
// Resolve import to file path
}
supports(filePath: string): boolean {
return filePath.endsWith(".nl")
}
}// src/index.ts
export { NewlangAdapter } from "./NewlangAdapter.js"Update packages/core/src/types/RawSymbol.ts:
export type SupportedLanguage = "typescript" | "python" | "go" | "rust" | "java" | "csharp" | "cpp" | "php" | "swift" | "newlang"// Python
/\bclass\s+(\w+)/
// Go
/\btype\s+(\w+)\s+struct|interface/
// Rust
/\bstruct\s+(\w+)|\benum\s+(\w+)|\btrait\s+(\w+)/// Python
/\bdef\s+(\w+)\s*\(/g
// Go
/\bfunc\s+(\w+)\s*\(/g
// Rust
/\bfn\s+(\w+)\s*\(/g// Python
/(?:from\s+([\w.]+)\s+)?import\s+([\w*\s,]+)/g
// Go
/"([^"]+)"|`([^`]+)`/g
// JavaScript/TypeScript
/import\s+(?:{[^}]+}|[^;]+)\s+from\s+['"]([^'"]+)['"]/g