Patch Copied LSP Sources
Use this skill whenever JetBrains LSP source files are copied or refreshed from the intellij-community repository into the dart-intellij-third-party plugin. The skill automates the file copying, packaging them under the isolated com.intellij.platform.dartlsp package namespace directly, and applies all necessary adjustments to prevent conflicts with the built-in LSP client of IntelliJ IDEA.
How to Refresh and Apply
To copy the sources from intellij-community and apply the adjustments automatically:
- Run the Python patch script located in the
scriptsdirectory from the repository root, passing the path to the localintellij-communityrepository as a positional argument:python3 .agents/skills/patch-copied-lsp-sources/scripts/patch.py /path/to/intellij-community - Verify the changes using
git diff. - Verify that the project compiles:
./gradlew clean compileKotlin --no-build-cache
[!NOTE] If you only need to re-apply the patches to the existing files in the workspace (without copying fresh files from
intellij-community), you can run the script without any arguments:python3 .agents/skills/patch-copied-lsp-sources/scripts/patch.py
Record of Adjustments Applied
Here is the details of the changes made by the patch script:
Direct Package Copy & Rename:
- Copies files directly from
platform/lsp/src/com/intellij/platform/lspintothird_party/thirdPartySrc/platform-lsp/src/com/intellij/platform/dartlsp. - Rename package namespace references from
com.intellij.platform.lsptocom.intellij.platform.dartlspacross all.kt,.java, and.xmlsource files to avoid split-package classloader collisions and wrong-namespace imports.
- Copies files directly from
Registry Key & Timeout Key:
- Rename key
lsp.server.connect.timeouttodart.lsp.server.connect.timeoutindart-lsp-impl.xmlandLsp4jServerConnector.ktto avoid conflicting with IntelliJ IDEA's default LSP settings.
- Rename key
Notification Groups:
- Prefix notification group IDs with
Dart:indart-lsp-impl.xmlandLspServerNotificationsHandlerImpl.ktto avoid conflicts with IntelliJ's platform groups.LSP window/showMessage->Dart: LSP window/showMessageLSP window/logMessage: errors, warnings->Dart: LSP window/logMessage: errors, warningsLSP window/logMessage: info, log; $/logTrace->Dart: LSP window/logMessage: info, log; $/logTrace
- Prefix notification group IDs with
Extension Element IDs:
- Remove optional
id="..."attributes from all extension definitions indart-lsp-impl.xml(except<notificationGroup>), as they are optional and avoid ID collision warnings/conflicts.
- Remove optional
Resource Bundle:
- Change bundle reference from
messages.LspBundletomessages.DartLspBundleindart-lsp-impl.xmlandLspBundle.kt. - Provide local
DartLspBundle.propertiesresource file underthird_party/src/main/resources/messages/containing the required localization keys.
- Change bundle reference from
Log Registry Defaults:
- Set
defaultValue="false"for registry keylsp.communication.standard.log.fileindart-lsp-impl.xmlto avoid spamming the mainidea.logwith LSP logs by default, storing them in session-specific files instead.
- Set
Intention Directory Names:
- Rename the intention descriptions folder
LspIntentiontoDartLspIntentionand updatedescriptionDirectoryNametoDartLspIntentionindart-lsp-impl.xmlto prevent collision.
- Rename the intention descriptions folder
Support External Library Files:
- Remove
if (!ProjectFileIndex.getInstance(project).isInContent(file)) return falsefromLspServerImpl.isSupportedFile(file)so that the Dart LSP bridge can serve external library files (such as pub-cache packages and Dart SDK libraries likedart:io).
- Remove