|
| 1 | +--- |
| 2 | +tags: [architecture, overview, layers] |
| 3 | +related: [architecture/extension-points, design/psi-mixin-injection] |
| 4 | +refs: [docs/architecture.md, docs/overview.md] |
| 5 | +--- |
| 6 | +# Plugin Architecture Layers |
| 7 | + |
| 8 | +IntelliJ Protobuf Language Plugin is a full-featured Protocol Buffers language plugin for JetBrains IDEs with deep semantic understanding, cross-file symbol resolution, multi-language integration, and Editions support. |
| 9 | + |
| 10 | +## Layer Diagram |
| 11 | + |
| 12 | +``` |
| 13 | +┌─────────────────────────────────────────────┐ |
| 14 | +│ UI & Settings │ |
| 15 | +│ Settings, Structure View, Icons, Actions │ |
| 16 | +├─────────────────────────────────────────────┤ |
| 17 | +│ Language Support │ |
| 18 | +│ Completion, Formatting, Annotations, │ |
| 19 | +│ References, Quick Fixes, Find Usages │ |
| 20 | +├─────────────────────────────────────────────┤ |
| 21 | +│ PSI (Program Structure) │ |
| 22 | +│ Elements, Mixins, Scope, Features │ |
| 23 | +├─────────────────────────────────────────────┤ |
| 24 | +│ Indexing & Stubs │ |
| 25 | +│ Stub Indices, Root Providers, Caching │ |
| 26 | +├─────────────────────────────────────────────┤ |
| 27 | +│ Parsing & Lexing │ |
| 28 | +│ Lexer (FLEX), Parser (BNF), Language Def │ |
| 29 | +├─────────────────────────────────────────────┤ |
| 30 | +│ Integration Modules (Optional) │ |
| 31 | +│ Java, Go, Sisyphus, gRPC, AIP │ |
| 32 | +└─────────────────────────────────────────────┘ |
| 33 | +``` |
| 34 | + |
| 35 | +Each layer depends only on the layer below it. Integration modules sit alongside, hooking into specific layers via extension points. |
| 36 | + |
| 37 | +## Key Concepts |
| 38 | + |
| 39 | +- **Proto Files as First-Class Code**: `.proto` files get full PSI trees, stub indices, and cross-project reference resolution like Java or Kotlin. |
| 40 | +- **Multi-Source Symbol Resolution**: Root providers aggregate proto files from project sources, library JARs, the protobuf SDK, and decompiled descriptors. |
| 41 | +- **Integration Modules**: Language-specific features activate only when relevant IDE plugins are present, keeping the core lightweight. |
| 42 | +- **Internal Compiler**: In-process protobuf compiler produces `FileDescriptorProto` from PSI without external `protoc`. |
| 43 | + |
| 44 | +## Parsing & Lexing |
| 45 | + |
| 46 | +Grammar files in `src/main/grammar/` define the syntax — `protobuf.bnf` for proto2/proto3/editions, `prototext.bnf` for text format. Grammar-Kit and JFlex generate the parser and lexer. Generated code goes to `build/generated/sources/grammar/`. |
0 commit comments