How fwcd/kotlin-language-server works
This repository implements a Kotlin Language Server Protocol server. An editor sends document and workspace requests; the server maintains source files and compiler state, then returns language features such as completion, diagnostics, navigation, and symbols. The README documents the feature set and classpath discovery; the excerpts show document handling, compilation/indexing, and custom protocol extensions. Several feature implementations are present in the tree but were not sampled, so their nodes are included without speculative call edges.
Main entry points: KotlinTextDocumentService.kt Document service · KotlinWorkspaceService.kt Workspace service · SourcePath.kt Source compilation · CompilerClassPath.kt Classpath management
Components 23
Server and LSP
- Server entry
server/src/main/kotlin/org/javacs/kt/Main.kt - Language server
server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt - Document service
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Workspace service
server/src/main/kotlin/org/javacs/kt/KotlinWorkspaceService.kt - Protocol extensions
server/src/main/kotlin/org/javacs/kt/KotlinProtocolExtensionService.kt
Workspace and compilation
- Configuration
server/src/main/kotlin/org/javacs/kt/Configuration.kt - Open source files
server/src/main/kotlin/org/javacs/kt/SourceFiles.kt - Source compilation
server/src/main/kotlin/org/javacs/kt/SourcePath.kt - Compiled file model
server/src/main/kotlin/org/javacs/kt/CompiledFile.kt - Kotlin compiler
server/src/main/kotlin/org/javacs/kt/compiler/Compiler.kt - Symbol index
server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt
Language features
- Completion
server/src/main/kotlin/org/javacs/kt/completion/Completions.kt - Diagnostics
server/src/main/kotlin/org/javacs/kt/diagnostic/ConvertDiagnostic.kt - Navigation and references
server/src/main/kotlin/org/javacs/kt/definition/GoToDefinition.kt - Document and workspace symbols
server/src/main/kotlin/org/javacs/kt/symbols/Symbols.kt - Code actions
server/src/main/kotlin/org/javacs/kt/codeaction/CodeAction.kt - Formatting
server/src/main/kotlin/org/javacs/kt/formatting/FormattingService.kt - Other language features
server/src/main/kotlin/org/javacs/kt
Project dependencies
- Classpath management
server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt - Classpath resolvers
shared/src/main/kotlin/org/javacs/kt/classpath - Persistent database
shared/src/main/kotlin/org/javacs/kt/database/DatabaseService.kt
Other components
- LSP editor
- Maven or Gradle projects
Connections 26
- LSP editor → Server entry: starts server
README.md - Server entry → Language server: starts
server/src/main/kotlin/org/javacs/kt/Main.kt - LSP editor → Document service: sends document requests
README.md - LSP editor → Workspace service: sends workspace requests
README.md - Document service → Open source files: opens documents
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Document service → Source compilation: recovers compiled files
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Document service → Completion: requests completions
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Document service → Code actions: requests actions
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Document service → Formatting: formats documents
server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt - Document service → Diagnostics: publishes diagnostics
README.md - Workspace service → Configuration: updates settings
server/src/main/kotlin/org/javacs/kt/KotlinWorkspaceService.kt - Workspace service → Open source files: changes workspace roots
server/src/main/kotlin/org/javacs/kt/KotlinWorkspaceService.kt - Workspace service → Classpath management: refreshes project paths
server/src/main/kotlin/org/javacs/kt/KotlinWorkspaceService.kt - Protocol extensions → Source compilation: compiles requested file
server/src/main/kotlin/org/javacs/kt/KotlinProtocolExtensionService.kt - Protocol extensions → Classpath management: reads build output
server/src/main/kotlin/org/javacs/kt/KotlinProtocolExtensionService.kt - Source compilation → Kotlin compiler: compiles sources
server/src/main/kotlin/org/javacs/kt/SourcePath.kt - Source compilation → Compiled file model: creates compiled state
README.md - Source compilation → Symbol index: updates declarations
server/src/main/kotlin/org/javacs/kt/SourcePath.kt - Compiled file model → Kotlin compiler: recompiles expressions
README.md - Completion → Symbol index: queries symbols
server/src/main/kotlin/org/javacs/kt/completion/Completions.kt - Code actions → Symbol index: queries symbols
server/src/main/kotlin/org/javacs/kt/codeaction/CodeAction.kt - Workspace service → Document and workspace symbols: serves workspace symbols
server/src/main/kotlin/org/javacs/kt/KotlinWorkspaceService.kt - Classpath management → Classpath resolvers: resolves dependencies
server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt - Classpath resolvers → Maven or Gradle projects: invokes build tools
README.md - Classpath management → Persistent database: initializes storage
server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt - Classpath management → Kotlin compiler: configures compiler
server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt