Skip to content

Commit e1a8916

Browse files
committed
Project refactoring
1 parent ae29506 commit e1a8916

39 files changed

Lines changed: 11723 additions & 11564 deletions

docs/ARCHITECTURE.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,57 @@ PHPantomLSP is a language server that provides completion and go-to-definition f
1515

1616
```
1717
src/
18-
├── lib.rs # Backend struct, state, constructors
19-
├── server.rs # LSP protocol handlers (initialize, didOpen, completion, …)
20-
├── parser.rs # PHP parsing → ClassInfo / FunctionInfo extraction
21-
├── types.rs # Data structures (ClassInfo, MethodInfo, PropertyInfo, …)
22-
├── composer.rs # composer.json / PSR-4 autoload parsing
23-
├── stubs.rs # Embedded phpstorm-stubs (build-time generated index)
24-
├── docblock.rs # PHPDoc tag extraction (@return, @var, @property, …)
25-
├── util.rs # Position conversion, class lookup, find_or_load_class
18+
├── lib.rs # Backend struct, state, constructors
19+
├── main.rs # Entry point (stdin/stdout LSP transport)
20+
├── server.rs # LSP protocol handlers (initialize, didOpen, completion, …)
21+
├── types.rs # Data structures (ClassInfo, MethodInfo, PropertyInfo, …)
22+
├── composer.rs # composer.json / PSR-4 autoload parsing
23+
├── stubs.rs # Embedded phpstorm-stubs (build-time generated index)
24+
├── resolution.rs # Multi-phase class/function lookup and name resolution
25+
├── inheritance.rs # Class inheritance merging (traits, mixins, parent chain)
26+
├── subject_extraction.rs # Shared helpers for extracting subjects before ->, ?->, ::
27+
├── util.rs # Position conversion, class lookup, logging
28+
├── parser/
29+
│ ├── mod.rs # Top-level parse entry points (parse_php, parse_functions, …)
30+
│ ├── classes.rs # Class, interface, trait, and enum extraction
31+
│ ├── functions.rs # Standalone function and define() constant extraction
32+
│ ├── use_statements.rs # use statement and namespace extraction
33+
│ └── ast_update.rs # update_ast orchestrator and name resolution helpers
34+
├── docblock/
35+
│ ├── mod.rs # Re-exports from submodules
36+
│ ├── tags.rs # PHPDoc tag extraction (@return, @var, @property, @mixin, …)
37+
│ ├── conditional.rs # PHPStan conditional return type parsing
38+
│ └── types.rs # Type cleaning utilities (clean_type, strip_nullable, …)
2639
├── completion/
27-
│ ├── target.rs # Extract what the user is completing (subject + access kind)
28-
│ ├── resolver.rs # Resolve subject → ClassInfo (type resolution engine)
29-
│ └── builder.rs # Build LSP CompletionItems from resolved ClassInfo
40+
│ ├── mod.rs # Submodule declarations
41+
│ ├── handler.rs # Top-level completion request orchestration
42+
│ ├── target.rs # Extract what the user is completing (subject + access kind)
43+
│ ├── resolver.rs # Resolve subject → ClassInfo (type resolution engine)
44+
│ ├── builder.rs # Build LSP CompletionItems from resolved ClassInfo
45+
│ ├── class_completion.rs # Class name, constant, and function completions
46+
│ ├── variable_completion.rs # Variable name completions and scope collection
47+
│ ├── variable_resolution.rs # Variable type resolution via assignment scanning
48+
│ ├── closure_resolution.rs # Closure and arrow-function parameter resolution
49+
│ ├── type_narrowing.rs # instanceof / assert / custom type guard narrowing
50+
│ ├── conditional_resolution.rs # PHPStan conditional return type resolution at call sites
51+
│ ├── named_args.rs # Named argument completion inside function/method call parens
52+
│ ├── phpdoc.rs # PHPDoc tag completion inside /** … */ blocks
53+
│ └── use_edit.rs # Use-statement insertion helpers
3054
├── definition/
31-
│ └── resolve.rs # Go-to-definition resolution
32-
build.rs # Parses PhpStormStubsMap.php, generates stub index
33-
stubs/ # Composer vendor dir for jetbrains/phpstorm-stubs
55+
│ ├── mod.rs # Submodule declarations
56+
│ ├── resolve.rs # Core go-to-definition resolution (classes, functions)
57+
│ ├── member.rs # Member-access resolution (->method, ::$prop, ::CONST)
58+
│ └── variable.rs # Variable definition resolution ($var jump-to-definition)
59+
build.rs # Parses PhpStormStubsMap.php, generates stub index
60+
stubs/ # Composer vendor dir for jetbrains/phpstorm-stubs
61+
tests/
62+
├── common/mod.rs # Shared test helpers and minimal PHP stubs
63+
├── completion_*.rs # Completion integration tests (by feature area)
64+
├── definition_*.rs # Go-to-definition integration tests
65+
├── docblock_*.rs # Docblock parsing and type tests
66+
├── parser.rs # PHP parser / AST extraction tests
67+
├── composer.rs # Composer integration tests
68+
└── …
3469
```
3570

3671
## Symbol Resolution: `find_or_load_class`

0 commit comments

Comments
 (0)