├── bundles ├── org.eclipse.cdt.lsp │ ├── .gitignore │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.launching.prefs │ │ ├── org.eclipse.pde.ds.annotations.prefs │ │ └── org.eclipse.pde.prefs │ ├── icons │ │ ├── c.png │ │ ├── h.png │ │ ├── cpp.png │ │ ├── etool16 │ │ │ └── watch_exp.gif │ │ ├── elcl16 │ │ │ ├── line_brkpt_co.gif │ │ │ ├── move_to_line_co.gif │ │ │ └── resume_at_line_co.gif │ │ └── dlcl16 │ │ │ ├── move_to_line_co.gif │ │ │ └── resume_at_line_co.gif │ ├── .classpath │ ├── src │ │ └── org │ │ │ └── eclipse │ │ │ └── cdt │ │ │ └── lsp │ │ │ ├── internal │ │ │ ├── ui │ │ │ │ ├── DefaultConfigurationVisibility.java │ │ │ │ ├── navigator │ │ │ │ │ └── FileBufferListenerAdapter.java │ │ │ │ └── SaveActionsConfigurationPage.java │ │ │ ├── switchtolsp │ │ │ │ ├── ILsProvider.java │ │ │ │ ├── SwitchBack.java │ │ │ │ ├── SwitchToLsp.java │ │ │ │ ├── SwitchToLspBannerTraditional.java │ │ │ │ ├── SwitchToLspBannerNewExperience.java │ │ │ │ ├── ISwitchBackToTraditional.java │ │ │ │ ├── Messages.java │ │ │ │ └── messages.properties │ │ │ ├── editor │ │ │ │ ├── CSpellingReconcileStrategy.java │ │ │ │ ├── EditorMetadataDefaults.java │ │ │ │ ├── CSpellingReconciler.java │ │ │ │ ├── EditorPreferenceInitializer.java │ │ │ │ ├── FormatOnSave.java │ │ │ │ ├── SpellingEnabled.java │ │ │ │ ├── EditorPreferredOptions.java │ │ │ │ ├── DebugHoverProvider.java │ │ │ │ ├── InitialFileManager.java │ │ │ │ └── LspEditorFileImageDescriptor.java │ │ │ ├── server │ │ │ │ ├── AbstractProviderRegistry.java │ │ │ │ ├── LogProviderRegistry.java │ │ │ │ └── AsyncStreamPipe.java │ │ │ └── messages │ │ │ │ ├── LspUiMessages.java │ │ │ │ └── LspUiMessages.properties │ │ │ ├── LspQualifier.java │ │ │ ├── server │ │ │ ├── ICLanguageServerProvider3.java │ │ │ ├── ICLanguageServerCommandLineValidator.java │ │ │ ├── ICLanguageServerProvider2.java │ │ │ ├── ILogProvider.java │ │ │ └── ICLanguageServerProvider.java │ │ │ ├── editor │ │ │ ├── InitialUri.java │ │ │ ├── LanguageServerEnable.java │ │ │ ├── EditorConfiguration.java │ │ │ ├── ConfigurationVisibility.java │ │ │ └── EditorOptions.java │ │ │ ├── ResolveProjectScope.java │ │ │ ├── config │ │ │ ├── ConfigurationMetadata.java │ │ │ ├── ConfigurationAccess.java │ │ │ ├── Configuration.java │ │ │ └── ConfigurationPreferencesDefaults.java │ │ │ ├── ExistingResource.java │ │ │ ├── ResolveProject.java │ │ │ ├── PreferredOptions.java │ │ │ └── plugin │ │ │ └── LspPlugin.java │ ├── OSGI-INF │ │ ├── org.eclipse.cdt.lsp.internal.editor.EditorMetadataDefaults.xml │ │ ├── org.eclipse.cdt.lsp.internal.switchtolsp.SwitchToLsp.xml │ │ ├── org.eclipse.cdt.lsp.internal.switchtolsp.SwitchBack.xml │ │ ├── org.eclipse.cdt.lsp.internal.ui.DefaultConfigurationVisibility.xml │ │ ├── org.eclipse.cdt.lsp.internal.editor.InitialFileManager.xml │ │ ├── org.eclipse.cdt.lsp.internal.editor.FormatOnSave.xml │ │ ├── org.eclipse.cdt.lsp.internal.ui.EditorConfigurationAccess.xml │ │ └── l10n │ │ │ └── bundle.properties │ ├── build.properties │ ├── .project │ └── META-INF │ │ └── MANIFEST.MF ├── org.eclipse.cdt.lsp.doc │ ├── .gitignore │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── images │ │ ├── command_link.png │ │ ├── lsp_clangd_prefs.png │ │ ├── lsp_decoration.png │ │ ├── lsp_editor_prefs.png │ │ ├── lsp_save_prefs.png │ │ ├── lsp_editor_properties.png │ │ └── lsp_content_assist_prefs.png │ ├── .asciidoctorconfig.adoc │ ├── META-INF │ │ └── MANIFEST.MF │ ├── .project │ ├── README.md │ ├── plugin.xml │ ├── toc_editor.xml │ ├── OSGI-INF │ │ └── l10n │ │ │ └── bundle.properties │ ├── build.properties │ ├── toc_prefs.xml │ ├── src │ │ └── asciidoc │ │ │ ├── lsp_save_prefs.adoc │ │ │ ├── lsp_cpp_editor_prefs.adoc │ │ │ ├── lsp_content_assist_prefs.adoc │ │ │ ├── lsp_clangd_prefs.adoc │ │ │ └── lsp_cpp_editor.adoc │ └── about.html ├── org.eclipse.cdt.lsp.test │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.launching.prefs │ │ └── org.eclipse.pde.prefs │ ├── build.properties │ ├── fragment.xml │ ├── META-INF │ │ └── MANIFEST.MF │ ├── .classpath │ ├── .project │ └── src │ │ └── org │ │ └── eclipse │ │ └── cdt │ │ └── lsp │ │ └── test │ │ ├── internal │ │ └── server │ │ │ ├── CLanguageServerProviderTest.java │ │ │ └── MockCLanguageServerProvider.java │ │ └── util │ │ └── LspUtilsTest.java └── org.eclipse.cdt.lsp.clangd │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.launching.prefs │ ├── org.eclipse.pde.ds.annotations.prefs │ └── org.eclipse.pde.prefs │ ├── .classpath │ ├── src │ └── org │ │ └── eclipse │ │ └── cdt │ │ └── lsp │ │ ├── clangd │ │ ├── internal │ │ │ ├── config │ │ │ │ ├── .clang-format-project │ │ │ │ ├── ClangdPreferenceInitializer.java │ │ │ │ ├── ClangdMetadataDefaults.java │ │ │ │ ├── MacroResolver.java │ │ │ │ ├── ClangdLsProvider.java │ │ │ │ ├── DefaultClangdCompilationDatabaseSettings.java │ │ │ │ └── ClangdPreferredOptions.java │ │ │ └── ui │ │ │ │ ├── ContentAssistConfigurationArea.java │ │ │ │ └── ContentAssistConfigurationPage.java │ │ ├── ClangdFallbackFlags.java │ │ ├── ClangdQualifier.java │ │ ├── ClangdCompilationDatabaseSettings.java │ │ ├── format │ │ │ └── CLanguageServerCheckEnabledProvider.java │ │ ├── IClangdCommandLineValidator.java │ │ ├── ClangFormatFile.java │ │ ├── ClangdCProjectDescriptionListener.java │ │ ├── ClangdConfiguration.java │ │ ├── ClangdCompilationDatabaseProvider.java │ │ └── console │ │ │ └── ClangdConsole.java │ │ └── internal │ │ └── clangd │ │ └── editor │ │ └── expressions │ │ └── LspEditorActiveTester.java │ ├── OSGI-INF │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangFormatFileHandler.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangdCommandLineValidator.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangdLsProvider.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationAccess.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseProvider.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings.xml │ ├── org.eclipse.cdt.lsp.clangd.internal.config.ClangdFallbackManager.xml │ └── l10n │ │ └── bundle.properties │ ├── build.properties │ ├── .project │ ├── about.html │ └── META-INF │ └── MANIFEST.MF ├── images ├── editor.png ├── properties.png ├── screenshot.png ├── clang-format.png ├── hello-world.png └── preferences.png ├── features └── org.eclipse.cdt.lsp.feature │ ├── .settings │ └── org.eclipse.core.resources.prefs │ ├── p2.inf │ ├── .project │ ├── build.properties │ ├── feature.xml │ └── feature.properties ├── releng ├── org.eclipse.cdt.lsp.target │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ └── .project └── org.eclipse.cdt.lsp.repository │ ├── .project │ ├── category.xml │ └── pom.xml ├── tests └── org.eclipse.cdt.lsp.clangd.tests │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.launching.prefs │ └── org.eclipse.pde.prefs │ ├── .classpath │ ├── META-INF │ └── MANIFEST.MF │ ├── build.properties │ ├── .project │ ├── OSGI-INF │ └── l10n │ │ └── bundle.properties │ └── src │ └── org │ └── eclipse │ └── cdt │ └── lsp │ └── clangd │ └── tests │ └── TestUtils.java ├── examples └── org.eclipse.cdt.lsp.examples.preferences │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs │ ├── .classpath │ ├── src │ └── org │ │ └── eclipse │ │ └── cdt │ │ └── lsp │ │ └── examples │ │ └── preferences │ │ ├── HidePreferLsp.java │ │ ├── MyClangdEnable.java │ │ ├── MyClangdOptionsDefaults.java │ │ └── HideTryNewExperienceBanner.java │ ├── OSGI-INF │ ├── org.eclipse.cdt.lsp.examples.preferences.HidePreferLsp.xml │ ├── org.eclipse.cdt.lsp.examples.preferences.MyClangdEnable.xml │ ├── org.eclipse.cdt.lsp.examples.preferences.MyClangdOptionsDefaults.xml │ └── org.eclipse.cdt.lsp.examples.preferences.HideTryNewExperienceBanner.xml │ ├── build.properties │ ├── META-INF │ └── MANIFEST.MF │ └── .project ├── .mvn └── extensions.xml ├── .gitignore ├── .project ├── .github └── workflows │ ├── licensecheck.yml │ └── tycho-build.yaml ├── CHANGELOG.md ├── NOTICE.md ├── jenkins └── pod-templates │ └── cdt-full-pod-plus-eclipse-install.yaml └── CONTRIBUTING.md /bundles/org.eclipse.cdt.lsp/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/.gitignore: -------------------------------------------------------------------------------- 1 | /html/ 2 | /workspace/ 3 | -------------------------------------------------------------------------------- /images/editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/editor.png -------------------------------------------------------------------------------- /images/properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/properties.png -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/screenshot.png -------------------------------------------------------------------------------- /images/clang-format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/clang-format.png -------------------------------------------------------------------------------- /images/hello-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/hello-world.png -------------------------------------------------------------------------------- /images/preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/images/preferences.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/c.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/h.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/cpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/cpp.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /releng/org.eclipse.cdt.lsp.target/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/command_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/command_link.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/etool16/watch_exp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/etool16/watch_exp.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/.asciidoctorconfig.adoc: -------------------------------------------------------------------------------- 1 | // support image rendering within the Asciidoctor Editor (#873) 2 | :imagesdir: {asciidoctorconfigdir}/images 3 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_clangd_prefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_clangd_prefs.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_decoration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_decoration.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_editor_prefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_editor_prefs.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_save_prefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_save_prefs.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/elcl16/line_brkpt_co.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/elcl16/line_brkpt_co.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | fragment.xml 6 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/dlcl16/move_to_line_co.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/dlcl16/move_to_line_co.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/elcl16/move_to_line_co.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/elcl16/move_to_line_co.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_editor_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_editor_properties.png -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/dlcl16/resume_at_line_co.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/dlcl16/resume_at_line_co.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/icons/elcl16/resume_at_line_co.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp/icons/elcl16/resume_at_line_co.gif -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/images/lsp_content_assist_prefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-cdt/cdt-lsp/HEAD/bundles/org.eclipse.cdt.lsp.doc/images/lsp_content_assist_prefs.png -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.eclipse.tycho 5 | tycho-build 6 | 5.0.1 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning 3 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning 4 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning 3 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning 4 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning 3 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning 4 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning 3 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*/*/bin 2 | /*/*/index 3 | /*/*/target 4 | /workspace/ 5 | .DS_Store 6 | .nfs* 7 | .polyglot.* 8 | check_code_cleanliness_workspace/ 9 | .META-INF_MANIFEST.MF 10 | *.takari_issue_192 11 | *.log 12 | pom.tycho 13 | .tycho-consumer-pom.xml 14 | /eclipse/ 15 | /*~ 16 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.settings/org.eclipse.pde.ds.annotations.prefs: -------------------------------------------------------------------------------- 1 | dsVersion=V1_3 2 | eclipse.preferences.version=1 3 | enabled=true 4 | generateBundleActivationPolicyLazy=true 5 | path=OSGI-INF 6 | validationErrorLevel=error 7 | validationErrorLevel.missingImplicitUnbindMethod=error 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.settings/org.eclipse.pde.ds.annotations.prefs: -------------------------------------------------------------------------------- 1 | dsVersion=V1_3 2 | eclipse.preferences.version=1 3 | enabled=true 4 | generateBundleActivationPolicyLazy=true 5 | path=OSGI-INF 6 | validationErrorLevel=error 7 | validationErrorLevel.missingImplicitUnbindMethod=error 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %Bundle-Name 4 | Bundle-SymbolicName: org.eclipse.cdt.lsp.doc;singleton:=true 5 | Bundle-Version: 3.5.0.qualifier 6 | Bundle-Vendor: %Bundle-Vendor 7 | Bundle-ActivationPolicy: lazy 8 | -------------------------------------------------------------------------------- /releng/org.eclipse.cdt.lsp.repository/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.repository 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/p2.inf: -------------------------------------------------------------------------------- 1 | instructions.configure=\ 2 | org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:https${#58}//download.eclipse.org/tools/cdt/releases/cdt-lsp-latest,type:0,name:CDT-LSP,enabled:true); \ 3 | org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:https${#58}//download.eclipse.org/tools/cdt/releases/cdt-lsp-latest,type:1,name:CDT-LSP,enabled:true); 4 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/.clang-format-project: -------------------------------------------------------------------------------- 1 | # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. 2 | BasedOnStyle: LLVM 3 | UseTab: Always 4 | IndentWidth: 4 5 | TabWidth: 4 6 | PackConstructorInitializers: NextLineOnly 7 | BreakConstructorInitializers: AfterColon 8 | IndentAccessModifiers: false 9 | AccessModifierOffset: -4 -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Tests for CDT language server bundle (Incubation) 4 | Bundle-SymbolicName: org.eclipse.cdt.lsp.test;singleton:=true 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-Vendor: Eclipse.org 7 | Fragment-Host: org.eclipse.cdt.lsp 8 | Require-Bundle: junit-jupiter-api 9 | Automatic-Module-Name: org.eclipse.cdt.lsp.test 10 | Bundle-RequiredExecutionEnvironment: JavaSE-17 11 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.doc 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.ManifestBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.PluginNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /releng/org.eclipse.cdt.lsp.target/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.target 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/README.md: -------------------------------------------------------------------------------- 1 | # Language Server based C/C++ Editor Documentation 2 | 3 | ## AsciiDoc content 4 | 5 | The Asciidoctor Maven Plugin is configured to generate an HTML file in the `html/` folder for each AsciiDoc source file (`*.adoc`) placed in the `src/asciidoc/` folder. 6 | 7 | All AsciiDoc source files should include GitHub rendering support. 8 | 9 | During content development, HTML files may be generated by invoking Maven locally: 10 | 11 | ``` 12 | mvn generate-resources 13 | ``` 14 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/ui/DefaultConfigurationVisibility.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.cdt.lsp.internal.ui; 2 | 3 | import org.eclipse.cdt.lsp.editor.ConfigurationVisibility; 4 | import org.osgi.service.component.annotations.Component; 5 | 6 | @Component(property = { "service.ranking:Integer=0" }) 7 | public class DefaultConfigurationVisibility implements ConfigurationVisibility { 8 | 9 | @Override 10 | public boolean showPreferLsp(boolean isProjectScope) { 11 | return true; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.editor.EditorMetadataDefaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.switchtolsp.SwitchToLsp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/src/org/eclipse/cdt/lsp/examples/preferences/HidePreferLsp.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.cdt.lsp.examples.preferences; 2 | 3 | import org.eclipse.cdt.lsp.editor.ConfigurationVisibility; 4 | import org.osgi.service.component.annotations.Component; 5 | 6 | @Component(property = { "service.ranking:Integer=100" }) 7 | public class HidePreferLsp implements ConfigurationVisibility { 8 | 9 | @Override 10 | public boolean showPreferLsp(boolean isProjectScope) { 11 | return false; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.switchtolsp.SwitchBack.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.ui.DefaultConfigurationVisibility.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.HidePreferLsp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.MyClangdEnable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangFormatFileHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.editor.InitialFileManager.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 3 | org.eclipse.jdt.core.compiler.compliance=17 4 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 8 | org.eclipse.jdt.core.compiler.release=enabled 9 | org.eclipse.jdt.core.compiler.source=17 10 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.MyClangdOptionsDefaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdCommandLineValidator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.HideTryNewExperienceBanner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.root 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1683785130314 14 | 15 | 30 16 | 17 | org.eclipse.ui.ide.multiFilter 18 | 1.0-projectRelativePath-matches-false-true-.*/org\.eclipse.*/.* 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Automatic-Module-Name: org.eclipse.cdt.lsp.clangd.tests 3 | Bundle-ManifestVersion: 2 4 | Bundle-SymbolicName: org.eclipse.cdt.lsp.clangd.tests 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-Name: %Bundle-Name 7 | Bundle-Vendor: %Bundle-Vendor 8 | Bundle-Copyright: %Bundle-Copyright 9 | Fragment-Host: org.eclipse.cdt.lsp.clangd;bundle-version="0.0.0" 10 | Bundle-RequiredExecutionEnvironment: JavaSE-17 11 | Require-Bundle: junit-jupiter-api, 12 | org.eclipse.cdt.lsp, 13 | org.yaml.snakeyaml, 14 | org.mockito.mockito-core 15 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdLsProvider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.editor.FormatOnSave.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/. 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # See git history 12 | ############################################################################### 13 | 14 | source.. = src/ 15 | output.. = bin/ 16 | bin.includes = META-INF/,\ 17 | .,\ 18 | OSGI-INF/ 19 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/. 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # See git history 12 | ############################################################################### 13 | 14 | bin.includes = META-INF/,\ 15 | .,\ 16 | OSGI-INF/ 17 | source.. = src/ 18 | output.. = bin/ 19 | -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 ArSysOp. 3 | # 4 | # This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License 2.0 6 | # which accompanies this distribution, and is available at 7 | # https://www.eclipse.org/legal/epl-2.0/ 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # ArSysOp - initial API and implementation 13 | ############################################################################### 14 | bin.includes = feature.xml,\ 15 | feature.properties,\ 16 | p2.inf 17 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/toc_editor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/OSGI-INF/l10n/bundle.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2024 John Dallaway and others. 3 | # 4 | # This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License 2.0 6 | # which accompanies this distribution, and is available at 7 | # https://www.eclipse.org/legal/epl-2.0/ 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # John Dallaway - initial implementation (#963) 13 | ############################################################################### 14 | Bundle-Name=Language Server based C/C++ Editor Documentation 15 | Bundle-Vendor=Eclipse CDT 16 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 Contributors to Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/. 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # See git history 12 | ############################################################################### 13 | source.. = src/ 14 | output.. = bin/ 15 | bin.includes = .,\ 16 | META-INF/,\ 17 | plugin.xml,\ 18 | icons/,\ 19 | OSGI-INF/ -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationAccess.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseProvider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 ArSysOp and others 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/. 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # ArSysOp - initial API and implementation 12 | ############################################################################### 13 | 14 | source.. = src/ 15 | output.. = bin/ 16 | bin.includes = .,\ 17 | about.html,\ 18 | META-INF/,\ 19 | OSGI-INF/,\ 20 | plugin.xml 21 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/licensecheck.yml: -------------------------------------------------------------------------------- 1 | # This workflow will check for Maven projects if the licenses of all (transitive) dependencies are vetted. 2 | 3 | name: License check 4 | 5 | on: 6 | push: 7 | pull_request: 8 | paths: 9 | - '**/pom.xml' 10 | - '**/*.target' 11 | - '.github/workflows/licensecheck.yml' 12 | issue_comment: 13 | types: [created] 14 | 15 | jobs: 16 | call: 17 | if: github.event_name == 'pull_request' || github.event_name == 'issue_comment' || github.repository_owner == 'eclipse-cdt' 18 | uses: eclipse-dash/dash-licenses/.github/workflows/mavenLicenseCheck.yml@master 19 | with: 20 | projectId: tools.cdt 21 | secrets: 22 | gitlabAPIToken: ${{ secrets.GITLAB_API_TOKEN }} 23 | permissions: 24 | pull-requests: write 25 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.test 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.clangd.tests 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/org.eclipse.cdt.lsp.internal.ui.EditorConfigurationAccess.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdFallbackManager.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/LspQualifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp; 15 | 16 | import java.util.function.Supplier; 17 | 18 | public final class LspQualifier implements Supplier { 19 | 20 | @Override 21 | public String get() { 22 | return "org.eclipse.cdt.lsp"; //$NON-NLS-1$ 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2024 John Dallaway and others. 3 | # 4 | # This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License 2.0 6 | # which accompanies this distribution, and is available at 7 | # https://www.eclipse.org/legal/epl-2.0/ 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # John Dallaway - initial implementation (#963) 13 | ############################################################################### 14 | bin.includes = META-INF/,\ 15 | OSGI-INF/,\ 16 | .,\ 17 | html/,\ 18 | images/,\ 19 | help.css,\ 20 | toc_editor.xml,\ 21 | toc_prefs.xml,\ 22 | plugin.xml 23 | src.includes = about.html 24 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdFallbackFlags.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Alexander Fedorov (ArSysOp) - initial API 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.clangd; 13 | 14 | import java.net.URI; 15 | 16 | /** 17 | * 18 | * Retrieves data for https://clangd.llvm.org/extensions#compilation-commands 19 | * 20 | * @since 2.0 21 | */ 22 | public interface ClangdFallbackFlags { 23 | 24 | Object getFallbackFlagsFromInitialUri(URI root); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ICLanguageServerProvider3.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.server; 14 | 15 | /** 16 | * @since 3.0 17 | */ 18 | public interface ICLanguageServerProvider3 extends ICLanguageServerProvider { 19 | 20 | /** 21 | * Enable logging to console 22 | * @return true if language server log shall be written to console 23 | */ 24 | public boolean logToConsole(); 25 | } 26 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/toc_prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %Bundle-Name 4 | Bundle-SymbolicName: org.eclipse.cdt.lsp.examples.preferences;singleton:=true 5 | Bundle-Vendor: %Bundle-Vendor 6 | Bundle-Version: 3.0.200.qualifier 7 | Require-Bundle: org.eclipse.ui, 8 | org.eclipse.core.runtime, 9 | org.eclipse.cdt.lsp.clangd, 10 | org.eclipse.core.resources, 11 | org.eclipse.cdt.lsp, 12 | org.eclipse.cdt.core 13 | Bundle-RequiredExecutionEnvironment: JavaSE-17 14 | Automatic-Module-Name: org.eclipse.cdt.lsp.examples.preferences 15 | Bundle-ActivationPolicy: lazy 16 | Service-Component: OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.HidePreferLsp.xml, 17 | OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.HideTryNewExperienceBanner.xml, 18 | OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.MyClangdEnable.xml, 19 | OSGI-INF/org.eclipse.cdt.lsp.examples.preferences.MyClangdOptionsDefaults.xml 20 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.examples.preferences 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.ds.core.builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdQualifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.clangd; 15 | 16 | import java.util.function.Supplier; 17 | 18 | /** 19 | * @since 2.0 20 | */ 21 | public final class ClangdQualifier implements Supplier { 22 | 23 | @Override 24 | public String get() { 25 | return "org.eclipse.cdt.lsp.clangd"; //$NON-NLS-1$ 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/editor/InitialUri.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Alexander Fedorov (ArSysOp) - initial API 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.editor; 13 | 14 | import java.net.URI; 15 | import java.util.Optional; 16 | 17 | /** 18 | * Access to initial URI used determine the compiler flags 19 | * for the clangd fallback settings on Windows machines 20 | * 21 | * @since 2.0 22 | */ 23 | public interface InitialUri { 24 | 25 | Optional find(URI root); 26 | 27 | void register(URI requested); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/ILsProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.switchtolsp; 14 | 15 | public interface ILsProvider { 16 | 17 | /** 18 | * Get the language server executable path. 19 | * 20 | * @param context the file/project to get the path for, or {@code null} for the default 21 | * @return the language server executable path or an empty string 22 | */ 23 | String getLsPath(Object context); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/tycho-build.yaml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up JDK 21 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: '21' 15 | distribution: 'temurin' 16 | - name: Setup Maven 17 | uses: stCarolas/setup-maven@v5 18 | with: 19 | maven-version: 3.9.9 20 | - name: Download clangd 21 | run: | 22 | curl -L https://github.com/clangd/clangd/releases/download/15.0.6/clangd-linux-15.0.6.zip > clangd.zip 23 | unzip clangd.zip 24 | - name: Build with Maven 25 | run: | 26 | export DISPLAY=:99 27 | export PATH=$PWD/clangd_15.0.6/bin:$PATH 28 | echo $PATH 29 | sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & 30 | mvn -B -V -X -e clean verify -P baseline-compare-and-replace -P api-baseline-check 31 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/SwitchBack.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.swt.widgets.Composite; 15 | import org.eclipse.ui.texteditor.ITextEditor; 16 | 17 | public class SwitchBack implements ISwitchBackToTraditional { 18 | 19 | @Override 20 | public Composite createSwitchBackToTraditional(ITextEditor part, Composite parent) { 21 | SwitchToLspBanner banner = new SwitchToLspBannerTraditional(part); 22 | return banner.create(parent); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/OSGI-INF/l10n/bundle.properties: -------------------------------------------------------------------------------- 1 | #Properties file for org.eclipse.cdt.lsp.clangd.tests 2 | ############################################################################### 3 | # Copyright (c) 2023 ArSysOp and others 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Eclipse Public License 2.0 which is available at 7 | # https://www.eclipse.org/legal/epl-2.0/. 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # ArSysOp - initial API and implementation 13 | ############################################################################### 14 | 15 | Bundle-Vendor = Eclipse CDT 16 | Bundle-Name = Clangd Language Server Support Tests 17 | Bundle-Copyright =\ 18 | Copyright (c) 2023 ArSysOp and others.\n\ 19 | \n\ 20 | This program and the accompanying materials are made\n\ 21 | available under the terms of the Eclipse Public License 2.0\n\ 22 | which is available at https://www.eclipse.org/legal/epl-2.0/\n\ 23 | \n\ 24 | SPDX-License-Identifier: EPL-2.0\n\ 25 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ICLanguageServerCommandLineValidator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.server; 14 | 15 | import org.eclipse.core.runtime.IStatus; 16 | 17 | /** 18 | * @since 3.0 19 | */ 20 | public interface ICLanguageServerCommandLineValidator { 21 | 22 | /** 23 | * Validates the language servers command line options prior to a LS start. Prevents LS from being started if returned IStatus is not OK. 24 | * @return validation status. 25 | */ 26 | public IStatus validateCommandLineOptions(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/SwitchToLsp.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.cdt.internal.ui.switchtolsp.ISwitchToLsp; 15 | import org.eclipse.swt.widgets.Composite; 16 | import org.eclipse.ui.texteditor.ITextEditor; 17 | 18 | public class SwitchToLsp implements ISwitchToLsp { 19 | 20 | @Override 21 | public Composite createTryLspEditor(ITextEditor part, Composite parent) { 22 | SwitchToLspBanner banner = new SwitchToLspBannerNewExperience(part); 23 | return banner.create(parent); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.api.tools.apiAnalysisBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.pde.ds.core.builder 30 | 31 | 32 | 33 | 34 | 35 | org.eclipse.pde.PluginNature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.pde.api.tools.apiAnalysisNature 38 | 39 | 40 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ICLanguageServerProvider2.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.server; 14 | 15 | import org.eclipse.core.resources.IProject; 16 | 17 | /** 18 | * @since 3.0 19 | * 20 | * This interface is deprecated and will be removed in the next release. 21 | */ 22 | @Deprecated 23 | public interface ICLanguageServerProvider2 extends ICLanguageServerProvider { 24 | 25 | /** 26 | * This function gets always called prior a C/C++ source file from the given project gets opened by LSP4E. 27 | * @param project 28 | */ 29 | public void preFileOpening(IProject project); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ILogProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.server; 14 | 15 | import java.io.OutputStream; 16 | 17 | /** 18 | * @since 3.0 19 | */ 20 | public interface ILogProvider { 21 | 22 | /** 23 | * Provides an output stream for the language servers log output. 24 | * This could be a console stream. 25 | * 26 | * @return OutputStream for language server log messages 27 | */ 28 | OutputStream getOutputStream(); 29 | 30 | /** 31 | * Close all open streams. Will be called when the language server process has been terminated. 32 | */ 33 | void close(); 34 | } 35 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/CSpellingReconcileStrategy.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.internal.editor; 15 | 16 | import org.eclipse.cdt.internal.ui.text.spelling.CSpellingService; 17 | import org.eclipse.jface.text.source.ISourceViewer; 18 | import org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy; 19 | 20 | public final class CSpellingReconcileStrategy extends SpellingReconcileStrategy { 21 | 22 | public CSpellingReconcileStrategy(ISourceViewer viewer) { 23 | super(viewer, CSpellingService.getInstance()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.eclipse.cdt.lsp.clangd 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.api.tools.apiAnalysisBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.pde.ds.core.builder 30 | 31 | 32 | 33 | 34 | 35 | org.eclipse.pde.PluginNature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.pde.api.tools.apiAnalysisNature 38 | 39 | 40 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/editor/LanguageServerEnable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.editor; 14 | 15 | import org.eclipse.core.resources.IProject; 16 | 17 | public interface LanguageServerEnable { 18 | 19 | /** 20 | * Checks whether the language server and the LSP based C/C++ Editor should be enabled for the given project. 21 | * The enable can be linked with certain project properties (e.g. project natures). 22 | * @param project 23 | * @return true when language server and LSP based editor should be enabled for the given project 24 | */ 25 | public boolean isEnabledFor(IProject project); 26 | } 27 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/editor/EditorConfiguration.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.editor; 15 | 16 | import org.eclipse.cdt.lsp.config.Configuration; 17 | import org.eclipse.core.runtime.preferences.IScopeContext; 18 | 19 | /** 20 | * Provides access to the editor options according to the required scope 21 | * 22 | * @see EditorOptions 23 | * @see IScopeContext 24 | * 25 | * @since 3.0 26 | */ 27 | public interface EditorConfiguration extends Configuration { 28 | 29 | @Override 30 | EditorOptions defaults(); 31 | 32 | @Override 33 | EditorOptions options(Object context); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdCompilationDatabaseSettings.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024, 2025 Contributors to the Eclipse Foundation. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * See git history 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.clangd; 15 | 16 | import org.eclipse.core.resources.IProject; 17 | 18 | /** 19 | * @since 2.0 20 | */ 21 | public interface ClangdCompilationDatabaseSettings { 22 | 23 | /** 24 | * Checks if the automatic setting of the compilation database (compile_commands.json) path in the .clangd configuration file is enabled for the given project. 25 | * Can be overridden for customization. 26 | * @param project 27 | * @return true if the database path should be written to .clangd file in the project root. 28 | */ 29 | boolean enableSetCompilationDatabasePath(IProject project); 30 | 31 | } -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/EditorMetadataDefaults.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.editor; 14 | 15 | import java.util.List; 16 | 17 | import org.eclipse.cdt.lsp.config.ConfigurationMetadataBase; 18 | import org.eclipse.cdt.lsp.editor.EditorMetadata; 19 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 20 | import org.osgi.service.component.annotations.Component; 21 | 22 | @Component(property = { "service.ranking:Integer=0" }) 23 | public final class EditorMetadataDefaults extends ConfigurationMetadataBase implements EditorMetadata { 24 | 25 | @Override 26 | protected List> definePreferences() { 27 | return Predefined.defaults; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /releng/org.eclipse.cdt.lsp.repository/category.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 17 | 18 | C/C++ Language Server Protocol Support 19 | 20 | 21 | 23 | 24 | 25 | 28 | 29 | C/C++ Language Server Protocol Support Developer Resources: 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdPreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.clangd.internal.config; 15 | 16 | import org.eclipse.cdt.lsp.clangd.ClangdConfiguration; 17 | import org.eclipse.cdt.lsp.config.ConfigurationPreferencesDefaults; 18 | import org.eclipse.core.runtime.ServiceCaller; 19 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 20 | 21 | public final class ClangdPreferenceInitializer extends AbstractPreferenceInitializer { 22 | 23 | @Override 24 | public void initializeDefaultPreferences() { 25 | ServiceCaller.callOnce(getClass(), ClangdConfiguration.class, new ConfigurationPreferencesDefaults<>()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/format/CLanguageServerCheckEnabledProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.clangd.format; 14 | 15 | import java.util.Optional; 16 | 17 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 18 | import org.eclipse.core.resources.IProject; 19 | 20 | public class CLanguageServerCheckEnabledProvider { 21 | 22 | /** 23 | * Checks if the language server is enabled for the given project. 24 | * 25 | * @param project 26 | * @return true if the language server is enabled for the project. 27 | */ 28 | boolean isEnabledFor(IProject project) { 29 | return Optional.ofNullable(LspPlugin.getDefault()).map(LspPlugin::getCLanguageServerProvider) 30 | .map(provider -> provider.isEnabledFor(project)).orElse(Boolean.FALSE); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/IClangdCommandLineValidator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.clangd; 14 | 15 | import java.util.List; 16 | 17 | import org.eclipse.core.runtime.IStatus; 18 | 19 | /** 20 | * Validator interface for clangd command line options. 21 | * 22 | * @since 3.0 23 | */ 24 | public interface IClangdCommandLineValidator { 25 | 26 | /** 27 | * Validates the clangd command line options prior to a LS start. Prevents LS from being started if returned IStatus is not OK. 28 | * @param commands the language servers command line options to be validated 29 | * @return validation status or IStatus.CANCEL if validation is not supported for the clangd binary 30 | */ 31 | public IStatus validateCommandLineOptions(final List commands); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/src/asciidoc/lsp_save_prefs.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | Copyright (c) 2024, 2025 John Dallaway and others 3 | This program and the accompanying materials 4 | are made available under the terms of the Eclipse Public License 2.0 5 | which accompanies this distribution, and is available at 6 | https://www.eclipse.org/legal/epl-2.0/ 7 | 8 | SPDX-License-Identifier: EPL-2.0 9 | 10 | Contributors: 11 | John Dallaway - initial content (#963) 12 | //// 13 | 14 | // support image rendering and table of contents within GitHub 15 | ifdef::env-github[] 16 | :imagesdir: ../../images 17 | :toc: 18 | :toc-placement!: 19 | endif::[] 20 | 21 | = Save actions 22 | 23 | Use the image:command_link.png[] link:javascript:executeCommand('org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.lsp.editor.SaveActionsPreferencePage)')[Save Actions] preference page to configure actions performed by the C/{cpp} editor (LSP) while saving a file: 24 | 25 | image:lsp_save_prefs.png[width=550] 26 | 27 | .Save Actions Preference Options 28 | :!table-caption: 29 | [%autowidth] 30 | [options="header"] 31 | |=== 32 | |Option |Description 33 | |Format source code |While saving a file, the editor will format all lines or edited lines only. 34 | |=== 35 | 36 | Related concepts: 37 | 38 | * xref:lsp_cpp_editor.adoc[C/C++ editor (LSP)] 39 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/editor/ConfigurationVisibility.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | package org.eclipse.cdt.lsp.editor; 14 | 15 | /** 16 | * Provides access to the visibility of configuration elements in the UI taking into account the scope (project or workspace). 17 | * Should be implemented as OSGi service when {@link org.eclipse.cdt.lsp.editor.LanguageServerEnable} service has been provided 18 | * to hide the 'Prefer C/C++ Editor (LSP)' check-box. 19 | */ 20 | public interface ConfigurationVisibility { 21 | 22 | /** 23 | * Changes the visibility of the 'Prefer C/C++ Editor (LSP)' check-box. 24 | * @param isProjectScope 25 | * @return true when the check-box should be displayed. 26 | */ 27 | boolean showPreferLsp(boolean isProjectScope); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/ResolveProjectScope.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp; 15 | 16 | import java.util.Optional; 17 | import java.util.function.Function; 18 | 19 | import org.eclipse.core.resources.IWorkspace; 20 | import org.eclipse.core.resources.ProjectScope; 21 | 22 | /** 23 | * @since 2.0 24 | */ 25 | public final class ResolveProjectScope implements Function> { 26 | 27 | private final ResolveProject project; 28 | 29 | public ResolveProjectScope(IWorkspace workspace) { 30 | this.project = new ResolveProject(workspace); 31 | } 32 | 33 | @Override 34 | public Optional apply(Object context) { 35 | return project.apply(context).map(ProjectScope::new); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdMetadataDefaults.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.clangd.internal.config; 15 | 16 | import java.util.List; 17 | 18 | import org.eclipse.cdt.lsp.clangd.ClangdMetadata; 19 | import org.eclipse.cdt.lsp.config.ConfigurationMetadataBase; 20 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 21 | import org.osgi.service.component.annotations.Component; 22 | 23 | @Component(property = { "service.ranking:Integer=0" }) 24 | public final class ClangdMetadataDefaults extends ConfigurationMetadataBase implements ClangdMetadata { 25 | 26 | @Override 27 | protected List> definePreferences() { 28 | return Predefined.defaults; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangFormatFile.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.clangd; 14 | 15 | import org.eclipse.core.resources.IProject; 16 | 17 | /** 18 | * @since 3.0 19 | */ 20 | public interface ClangFormatFile { 21 | 22 | /** 23 | * Opens the .clang-format file in the given project or in one of its parent directories. 24 | * Creates a file with default values, if not yet existing prior to the opening. 25 | * @param formatFile 26 | */ 27 | void openClangFormatFile(IProject project); 28 | 29 | /** 30 | * Creates a new .clang-format file with default settings in the project root directory if not yet existing 31 | * or uses an existing file on one of the project's parent directories. 32 | * @param project 33 | */ 34 | void createClangFormatFile(IProject project); 35 | 36 | } -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/MacroResolver.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.clangd.internal.config; 15 | 16 | import org.eclipse.cdt.core.CCorePlugin; 17 | import org.eclipse.cdt.core.cdtvariables.CdtVariableException; 18 | import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 19 | 20 | /** 21 | * Helper class to resolve macros in builder CWD 22 | */ 23 | public class MacroResolver { 24 | 25 | public String resolveValue(String value, String nonexistentMacrosValue, String listDelimiter, 26 | ICConfigurationDescription cfg) throws CdtVariableException { 27 | return CCorePlugin.getDefault().getCdtVariableManager().resolveValue(value, nonexistentMacrosValue, 28 | listDelimiter, cfg); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/src/org/eclipse/cdt/lsp/examples/preferences/MyClangdEnable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.examples.preferences; 13 | 14 | import org.eclipse.cdt.lsp.editor.LanguageServerEnable; 15 | import org.eclipse.core.resources.IProject; 16 | import org.eclipse.core.runtime.CoreException; 17 | import org.osgi.service.component.annotations.Component; 18 | 19 | @Component(property = { "service.ranking:Integer=100" }) 20 | public class MyClangdEnable implements LanguageServerEnable { 21 | 22 | @Override 23 | public boolean isEnabledFor(IProject project) { 24 | if (project != null) { 25 | try { 26 | return project.hasNature("org.eclipse.cdt.cmake.core.cmakeNature"); 27 | } catch (CoreException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/SwitchToLspBannerTraditional.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.swt.widgets.Event; 15 | import org.eclipse.ui.texteditor.ITextEditor; 16 | 17 | public class SwitchToLspBannerTraditional extends SwitchToLspBanner { 18 | 19 | public SwitchToLspBannerTraditional(ITextEditor part) { 20 | super(part); 21 | } 22 | 23 | @Override 24 | protected String tryLspBannerLink() { 25 | return Messages.SwitchToLsp_SwitchBackBannerLink + LinkHelper.LINK_SPACER + LinkHelper.getLinks(false); 26 | } 27 | 28 | @Override 29 | protected void tryLspAction(Event event) { 30 | if (!LinkHelper.handleLinkClick(getPart().getSite().getShell(), event)) { 31 | new SwitchToLspWizard().startSwitch(getPart(), false); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## CDT LSP Change Log 2 | 3 | ### v3.4.0 (Dec 2024) 4 | 5 | Fixed issues: 6 | 7 | ### v3.3.0 (Sep 2024) 8 | 9 | Fixed issues: 10 | 11 | ### v3.2.0 (Jun 2024) 12 | 13 | Fixed issues: 14 | 15 | ### v3.1.0 (Apr 2024) 16 | 17 | Fixed issues: 18 | 19 | ### v3.0.0 (Mar 2024) 20 | 21 | Fixed issues: 22 | 23 | ### v2.0.0 (Jun 2024) 24 | 25 | Fixed issues: 26 | 27 | ### v1.1.0 (Feb 2024) 28 | 29 | - Added basic spelling support 30 | - Added .clangd configuration file syntax checker 31 | - Added basic clangd LSP extension support for textDocument/ast and textDocument/symbolInfo 32 | - There is no API guarantee between 1.0.0 and 1.1.0. API stability will be added starting in a future release. See [#212](https://github.com/eclipse-cdt/cdt-lsp/issues/212) 33 | 34 | Fixed issues: 35 | 36 | ### v1.0.0 (Sep 2023) 37 | 38 | - First release of CDT LSP 39 | 40 | Fixed issues: 41 | 42 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/src/asciidoc/lsp_cpp_editor_prefs.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | Copyright (c) 2024, 2025 John Dallaway and others 3 | This program and the accompanying materials 4 | are made available under the terms of the Eclipse Public License 2.0 5 | which accompanies this distribution, and is available at 6 | https://www.eclipse.org/legal/epl-2.0/ 7 | 8 | SPDX-License-Identifier: EPL-2.0 9 | 10 | Contributors: 11 | John Dallaway - initial content (#963) 12 | //// 13 | 14 | // support image rendering and table of contents within GitHub 15 | ifdef::env-github[] 16 | :imagesdir: ../../images 17 | :toc: 18 | :toc-placement!: 19 | endif::[] 20 | 21 | = C/{cpp} editor (LSP) preferences 22 | 23 | Use the image:command_link.png[] link:javascript:executeCommand('org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.lsp.editor.preferencePage)')[Editor (LSP)] preference page to configure general behaviour of the C/{cpp} editor (LSP): 24 | 25 | image:lsp_editor_prefs.png[width=550] 26 | 27 | .C/{cpp} Editor (LSP) Preference Options 28 | :!table-caption: 29 | [%autowidth] 30 | [options="header"] 31 | |=== 32 | |Option |Description 33 | |Set C/{cpp} Editor (LSP) as default |When opening a C/{cpp} source file, the C/C++ editor (LSP) will be used by default. 34 | |=== 35 | 36 | Related concepts: 37 | 38 | * xref:lsp_cpp_editor.adoc[C/C++ editor (LSP)] 39 | -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 19 | 20 | 21 | %description 22 | 23 | 24 | 25 | %copyright 26 | 27 | 28 | 29 | %license 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/.settings/org.eclipse.pde.prefs: -------------------------------------------------------------------------------- 1 | compilers.f.unresolved-features=1 2 | compilers.f.unresolved-plugins=1 3 | compilers.incompatible-environment=1 4 | compilers.p.build=1 5 | compilers.p.build.bin.includes=0 6 | compilers.p.build.encodings=2 7 | compilers.p.build.java.compiler=2 8 | compilers.p.build.java.compliance=1 9 | compilers.p.build.missing.output=2 10 | compilers.p.build.output.library=1 11 | compilers.p.build.source.library=1 12 | compilers.p.build.src.includes=0 13 | compilers.p.deprecated=1 14 | compilers.p.discouraged-class=1 15 | compilers.p.exec-env-too-low=1 16 | compilers.p.internal=1 17 | compilers.p.missing-packages=2 18 | compilers.p.missing-version-export-package=2 19 | compilers.p.missing-version-import-package=2 20 | compilers.p.missing-version-require-bundle=2 21 | compilers.p.no-required-att=0 22 | compilers.p.no.automatic.module=1 23 | compilers.p.not-externalized-att=1 24 | compilers.p.service.component.without.lazyactivation=1 25 | compilers.p.unknown-attribute=1 26 | compilers.p.unknown-class=0 27 | compilers.p.unknown-element=1 28 | compilers.p.unknown-identifier=0 29 | compilers.p.unknown-resource=0 30 | compilers.p.unresolved-ex-points=0 31 | compilers.p.unresolved-import=0 32 | compilers.s.create-docs=false 33 | compilers.s.doc-folder=doc 34 | compilers.s.open-tags=1 35 | compilers.use-project=true 36 | eclipse.preferences.version=1 37 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/.settings/org.eclipse.pde.prefs: -------------------------------------------------------------------------------- 1 | compilers.f.unresolved-features=1 2 | compilers.f.unresolved-plugins=1 3 | compilers.incompatible-environment=1 4 | compilers.p.build=1 5 | compilers.p.build.bin.includes=0 6 | compilers.p.build.encodings=2 7 | compilers.p.build.java.compiler=2 8 | compilers.p.build.java.compliance=1 9 | compilers.p.build.missing.output=2 10 | compilers.p.build.output.library=1 11 | compilers.p.build.source.library=1 12 | compilers.p.build.src.includes=0 13 | compilers.p.deprecated=1 14 | compilers.p.discouraged-class=1 15 | compilers.p.exec-env-too-low=1 16 | compilers.p.internal=1 17 | compilers.p.missing-packages=2 18 | compilers.p.missing-version-export-package=2 19 | compilers.p.missing-version-import-package=2 20 | compilers.p.missing-version-require-bundle=2 21 | compilers.p.no-required-att=0 22 | compilers.p.no.automatic.module=1 23 | compilers.p.not-externalized-att=1 24 | compilers.p.service.component.without.lazyactivation=1 25 | compilers.p.unknown-attribute=1 26 | compilers.p.unknown-class=0 27 | compilers.p.unknown-element=1 28 | compilers.p.unknown-identifier=0 29 | compilers.p.unknown-resource=0 30 | compilers.p.unresolved-ex-points=0 31 | compilers.p.unresolved-import=0 32 | compilers.s.create-docs=false 33 | compilers.s.doc-folder=doc 34 | compilers.s.open-tags=1 35 | compilers.use-project=true 36 | eclipse.preferences.version=1 37 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/.settings/org.eclipse.pde.prefs: -------------------------------------------------------------------------------- 1 | compilers.f.unresolved-features=1 2 | compilers.f.unresolved-plugins=1 3 | compilers.incompatible-environment=1 4 | compilers.p.build=1 5 | compilers.p.build.bin.includes=0 6 | compilers.p.build.encodings=2 7 | compilers.p.build.java.compiler=2 8 | compilers.p.build.java.compliance=1 9 | compilers.p.build.missing.output=2 10 | compilers.p.build.output.library=1 11 | compilers.p.build.source.library=1 12 | compilers.p.build.src.includes=0 13 | compilers.p.deprecated=1 14 | compilers.p.discouraged-class=1 15 | compilers.p.exec-env-too-low=1 16 | compilers.p.internal=1 17 | compilers.p.missing-packages=2 18 | compilers.p.missing-version-export-package=2 19 | compilers.p.missing-version-import-package=2 20 | compilers.p.missing-version-require-bundle=2 21 | compilers.p.no-required-att=0 22 | compilers.p.no.automatic.module=1 23 | compilers.p.not-externalized-att=2 24 | compilers.p.service.component.without.lazyactivation=1 25 | compilers.p.unknown-attribute=1 26 | compilers.p.unknown-class=0 27 | compilers.p.unknown-element=1 28 | compilers.p.unknown-identifier=0 29 | compilers.p.unknown-resource=0 30 | compilers.p.unresolved-ex-points=0 31 | compilers.p.unresolved-import=0 32 | compilers.s.create-docs=false 33 | compilers.s.doc-folder=doc 34 | compilers.s.open-tags=1 35 | compilers.use-project=true 36 | eclipse.preferences.version=1 37 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/.settings/org.eclipse.pde.prefs: -------------------------------------------------------------------------------- 1 | compilers.f.unresolved-features=1 2 | compilers.f.unresolved-plugins=1 3 | compilers.incompatible-environment=1 4 | compilers.p.build=1 5 | compilers.p.build.bin.includes=0 6 | compilers.p.build.encodings=2 7 | compilers.p.build.java.compiler=2 8 | compilers.p.build.java.compliance=1 9 | compilers.p.build.missing.output=2 10 | compilers.p.build.output.library=1 11 | compilers.p.build.source.library=1 12 | compilers.p.build.src.includes=0 13 | compilers.p.deprecated=1 14 | compilers.p.discouraged-class=1 15 | compilers.p.exec-env-too-low=1 16 | compilers.p.internal=1 17 | compilers.p.missing-packages=2 18 | compilers.p.missing-version-export-package=2 19 | compilers.p.missing-version-import-package=2 20 | compilers.p.missing-version-require-bundle=2 21 | compilers.p.no-required-att=0 22 | compilers.p.no.automatic.module=1 23 | compilers.p.not-externalized-att=2 24 | compilers.p.service.component.without.lazyactivation=1 25 | compilers.p.unknown-attribute=1 26 | compilers.p.unknown-class=0 27 | compilers.p.unknown-element=1 28 | compilers.p.unknown-identifier=0 29 | compilers.p.unknown-resource=0 30 | compilers.p.unresolved-ex-points=0 31 | compilers.p.unresolved-import=0 32 | compilers.s.create-docs=false 33 | compilers.s.doc-folder=doc 34 | compilers.s.open-tags=1 35 | compilers.use-project=true 36 | eclipse.preferences.version=1 37 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/src/asciidoc/lsp_content_assist_prefs.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | Copyright (c) 2025 John Dallaway and others 3 | This program and the accompanying materials 4 | are made available under the terms of the Eclipse Public License 2.0 5 | which accompanies this distribution, and is available at 6 | https://www.eclipse.org/legal/epl-2.0/ 7 | 8 | SPDX-License-Identifier: EPL-2.0 9 | 10 | Contributors: 11 | John Dallaway - initial content (#963) 12 | //// 13 | 14 | // support image rendering and table of contents within GitHub 15 | ifdef::env-github[] 16 | :imagesdir: ../../images 17 | :toc: 18 | :toc-placement!: 19 | endif::[] 20 | 21 | = Content assist 22 | 23 | Use the image:command_link.png[] link:javascript:executeCommand('org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.lsp.clangd.editor.contentAssistPreferencePage)')[Content Assist] preference page to configure the content assistance provided by the C/{cpp} editor (LSP): 24 | 25 | image:lsp_content_assist_prefs.png[width=550] 26 | 27 | .Content Assist Preference Options 28 | :!table-caption: 29 | [%autowidth] 30 | [options="header"] 31 | |=== 32 | |Option |Description 33 | |Fill function arguments and show guessed arguments |While editing a file, the editor will provide function argument assistance. 34 | |=== 35 | 36 | Related concepts: 37 | 38 | * xref:lsp_cpp_editor.adoc[C/C++ editor (LSP)] 39 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/SwitchToLspBannerNewExperience.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.swt.widgets.Event; 15 | import org.eclipse.ui.texteditor.ITextEditor; 16 | 17 | public class SwitchToLspBannerNewExperience extends SwitchToLspBanner { 18 | 19 | public SwitchToLspBannerNewExperience(ITextEditor part) { 20 | super(part); 21 | } 22 | 23 | @Override 24 | protected String tryLspBannerLink() { 25 | return LinkHelper.SPARKLES + LinkHelper.A(Messages.SwitchToLsp_TryNewExperienceBannerLink) 26 | + LinkHelper.LINK_SPACER + LinkHelper.getLinks(false); 27 | } 28 | 29 | @Override 30 | protected void tryLspAction(Event event) { 31 | if (!LinkHelper.handleLinkClick(getPart().getSite().getShell(), event)) { 32 | new SwitchToLspWizard().startSwitch(getPart(), true); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/AbstractProviderRegistry.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.server; 14 | 15 | import org.eclipse.core.runtime.Adapters; 16 | import org.eclipse.core.runtime.CoreException; 17 | import org.eclipse.core.runtime.IConfigurationElement; 18 | import org.eclipse.core.runtime.Platform; 19 | 20 | public class AbstractProviderRegistry { 21 | private static final String CLASS = "class"; //$NON-NLS-1$ 22 | 23 | protected static Object getInstanceFromExtension(IConfigurationElement configurationElement, Class clazz) { 24 | Object result = null; 25 | try { 26 | Object obj = configurationElement.createExecutableExtension(CLASS); 27 | result = Adapters.adapt(obj, clazz); 28 | } catch (CoreException e) { 29 | Platform.getLog(LogProviderRegistry.class).log(e.getStatus()); 30 | } 31 | return result; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdCProjectDescriptionListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024, 2025 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.clangd; 15 | 16 | import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; 17 | 18 | /** 19 | * Vendors may implement this interface as OSGi service 20 | * with a service.ranking property > 0 to replace the default 21 | * implementation {@code ClangdConfigurationFileManager} 22 | * 23 | * @since 2.0 24 | * @deprecated use {@link ClangdCompilationDatabaseProvider} instead 25 | */ 26 | @Deprecated 27 | public interface ClangdCProjectDescriptionListener { 28 | 29 | /** 30 | * Called when the configuration of a CDT C/C++ project changes. 31 | * @param event 32 | * @deprecated use {@link ClangdCompilationDatabaseProvider#getCompilationDatabasePath(CProjectDescriptionEvent)} 33 | */ 34 | @Deprecated 35 | void handleEvent(CProjectDescriptionEvent event); 36 | 37 | } -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | # Notices for Eclipse C/C++ Development Tools 2 | 3 | This content is produced and maintained by the Eclipse C/C++ Development Tools 4 | project. 5 | 6 | * Project home: https://projects.eclipse.org/projects/tools.cdt 7 | 8 | ## Trademarks 9 | 10 | CDT™ is a trademark of the Eclipse Foundation. 11 | 12 | ## Copyright 13 | 14 | All content is the property of the respective authors or their employers. For 15 | more information regarding authorship of content, please consult the listed 16 | source code repository logs. 17 | 18 | ## Declared Project Licenses 19 | 20 | This program and the accompanying materials are made available under the terms 21 | of the Eclipse Public License v. 2.0 which is available at 22 | https://www.eclipse.org/legal/epl-2.0. 23 | 24 | SPDX-License-Identifier: EPL-2.0 25 | 26 | ## Source Code 27 | 28 | The project maintains the following source code repositories: 29 | 30 | * https://github.com/eclipse-cdt/.github 31 | * https://github.com/eclipse-cdt/cdt 32 | * https://github.com/eclipse-cdt/cdt-infra 33 | * https://github.com/eclipse-cdt/cdt-lsp 34 | 35 | ## Cryptography 36 | 37 | Content may contain encryption software. The country in which you are currently 38 | may have restrictions on the import, possession, and use, and/or re-export to 39 | another country, of encryption software. BEFORE using any encryption software, 40 | please check the country's laws, regulations and policies concerning the import, 41 | possession, or use, and re-export of encryption software, to see if this is 42 | permitted. -------------------------------------------------------------------------------- /features/org.eclipse.cdt.lsp.feature/feature.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023 ArSysOp. 3 | # 4 | # This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License 2.0 6 | # which accompanies this distribution, and is available at 7 | # https://www.eclipse.org/legal/epl-2.0/ 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # ArSysOp - initial API and implementation 13 | ############################################################################### 14 | # features.properties 15 | # contains externalized strings for feature.xml 16 | # "%foo" in feature.xml corresponds to the key "foo" in this file 17 | # java.io.Properties file (ISO 8859-1 with "\" escapes) 18 | # This file should be translated. 19 | 20 | # "featureName" property - name of the feature 21 | featureName=C/C++ LSP Support 22 | 23 | # "providerName" property - name of the company that provides the feature 24 | providerName=Eclipse CDT 25 | 26 | # "description" property - description of the feature 27 | description=Eclipse C/C++ Language Server Protocol support. 28 | 29 | # copyright 30 | copyright=\ 31 | Copyright (c) 2023 Contributors to the Eclipse Foundation.\n\ 32 | \n\ 33 | This program and the accompanying materials are made\n\ 34 | available under the terms of the Eclipse Public License 2.0\n\ 35 | which is available at https://www.eclipse.org/legal/epl-2.0/\n\ 36 | \n\ 37 | SPDX-License-Identifier: EPL-2.0\n\ 38 | 39 | -------------------------------------------------------------------------------- /releng/org.eclipse.cdt.lsp.repository/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 15 | 4.0.0 16 | 17 | 18 | org.eclipse.cdt.lsp 19 | org.eclipse.cdt.lsp.root 20 | 3.5.0-SNAPSHOT 21 | ../../pom.xml 22 | 23 | 24 | 3.5.0-SNAPSHOT 25 | org.eclipse.cdt.lsp.repository 26 | eclipse-repository 27 | 28 | 29 | ${project.artifactId} 30 | 31 | 32 | 33 | production 34 | 35 | 36 | 37 | org.eclipse.tycho 38 | tycho-gpg-plugin 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/CSpellingReconciler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.internal.editor; 15 | 16 | import org.eclipse.jface.text.IDocument; 17 | import org.eclipse.jface.text.ITextViewer; 18 | import org.eclipse.jface.text.reconciler.Reconciler; 19 | import org.eclipse.jface.text.source.ISourceViewer; 20 | 21 | public final class CSpellingReconciler extends Reconciler { 22 | 23 | @Override 24 | public void install(ITextViewer textViewer) { 25 | if (textViewer instanceof ISourceViewer sourceViewer) { 26 | this.setReconcilingStrategy(new CSpellingReconcileStrategy(sourceViewer), IDocument.DEFAULT_CONTENT_TYPE); 27 | } 28 | // call super.install AFTER the CSpellingReconcileStrategy has been added to the super class via setReconcilingStrategy call, 29 | // otherwise reconcilerDocumentChanged (which is called during super.install) would not be performed on our CSpellingReconcileStrategy 30 | super.install(textViewer); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdLsProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.clangd.internal.config; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | import java.util.Optional; 18 | import java.util.stream.Collectors; 19 | 20 | import org.eclipse.cdt.lsp.clangd.ClangdConfiguration; 21 | import org.eclipse.cdt.lsp.internal.switchtolsp.ILsProvider; 22 | import org.osgi.service.component.annotations.Component; 23 | import org.osgi.service.component.annotations.Reference; 24 | 25 | @Component 26 | public class ClangdLsProvider implements ILsProvider { 27 | 28 | @Reference 29 | ClangdConfiguration configuration; 30 | 31 | @Override 32 | public String getLsPath(Object context) { 33 | List result = new ArrayList<>(); 34 | Optional.ofNullable(configuration).map(c -> result.addAll(c.commands(context).stream() 35 | .map(ClangdLanguageServerProvider::resolveVariables).collect(Collectors.toList()))); 36 | return result.isEmpty() ? "" : result.get(0); //$NON-NLS-1$ 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/config/ConfigurationMetadata.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - initial API and implementation 13 | *******************************************************************************/ 14 | 15 | package org.eclipse.cdt.lsp.config; 16 | 17 | import java.util.List; 18 | import java.util.Optional; 19 | 20 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 21 | 22 | /** 23 | * Provider interface to customize defined preferences and its defaults 24 | * 25 | * @see ConfigurationMetadataBase 26 | * 27 | * @since 3.0 28 | */ 29 | public interface ConfigurationMetadata { 30 | 31 | /** 32 | * 33 | * @return the {@link List} of defined preferences 34 | */ 35 | List> defined(); 36 | 37 | /** 38 | * 39 | * @param the value type for the preference 40 | * @param id the preference identifier 41 | * @param type the {@link Class} representing type for the preference 42 | * @return the {@link Optional} with {@link PreferenceMetadata} or {@link Optional#empty()} if not defined 43 | */ 44 | Optional> defined(String id, Class type); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | About 7 | 8 | 9 | 10 |

About This Content

11 | 12 |

November 30, 2017

13 |

License

14 | 15 |

16 | The Eclipse Foundation makes available all content in this plug-in 17 | ("Content"). Unless otherwise indicated below, the Content 18 | is provided to you under the terms and conditions of the Eclipse 19 | Public License Version 2.0 ("EPL"). A copy of the EPL is 20 | available at https://www.eclipse.org/legal/epl-2.0. 21 | For purposes of the EPL, "Program" will mean the Content. 22 |

23 | 24 |

25 | If you did not receive this Content directly from the Eclipse 26 | Foundation, the Content is being redistributed by another party 27 | ("Redistributor") and different terms and conditions may 28 | apply to your use of any object code in the Content. Check the 29 | Redistributor's license that was provided with the Content. If no such 30 | license exists, contact the Redistributor. Unless otherwise indicated 31 | below, the terms and conditions of the EPL still apply to any source 32 | code in the Content and such source code may be obtained at https://www.eclipse.org. 34 |

35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | About 7 | 8 | 9 | 10 |

About This Content

11 | 12 |

November 30, 2017

13 |

License

14 | 15 |

16 | The Eclipse Foundation makes available all content in this plug-in 17 | ("Content"). Unless otherwise indicated below, the Content 18 | is provided to you under the terms and conditions of the Eclipse 19 | Public License Version 2.0 ("EPL"). A copy of the EPL is 20 | available at https://www.eclipse.org/legal/epl-2.0. 21 | For purposes of the EPL, "Program" will mean the Content. 22 |

23 | 24 |

25 | If you did not receive this Content directly from the Eclipse 26 | Foundation, the Content is being redistributed by another party 27 | ("Redistributor") and different terms and conditions may 28 | apply to your use of any object code in the Content. Check the 29 | Redistributor's license that was provided with the Content. If no such 30 | license exists, contact the Redistributor. Unless otherwise indicated 31 | below, the terms and conditions of the EPL still apply to any source 32 | code in the Content and such source code may be obtained at https://www.eclipse.org. 34 |

35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/src/org/eclipse/cdt/lsp/examples/preferences/MyClangdOptionsDefaults.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 COSEDA Technologies GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Dominic Scharfe (COSEDA Technologies GmbH) - initial implementation 12 | * Alexander Fedorov (ArSysOp) - options API evolution 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.examples.preferences; 15 | 16 | import java.util.List; 17 | import java.util.stream.Collectors; 18 | 19 | import org.eclipse.cdt.lsp.clangd.ClangdMetadata; 20 | import org.eclipse.cdt.lsp.config.ConfigurationMetadataBase; 21 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 22 | import org.osgi.service.component.annotations.Component; 23 | 24 | @Component(property = { "service.ranking:Integer=100" }) 25 | public class MyClangdOptionsDefaults extends ConfigurationMetadataBase implements ClangdMetadata { 26 | 27 | @Override 28 | protected List> definePreferences() { 29 | return overrideOne(Predefined.defaults, overrideString(Predefined.additionalOptions, // 30 | List.of("--header-insertion=never", "--default-config").stream() 31 | .collect(Collectors.joining(System.lineSeparator())))); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/src/org/eclipse/cdt/lsp/test/internal/server/CLanguageServerProviderTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.test.internal.server; 14 | 15 | import static org.junit.jupiter.api.Assertions.assertTrue; 16 | 17 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 18 | import org.eclipse.cdt.lsp.server.ICLanguageServerProvider; 19 | import org.eclipse.core.runtime.CoreException; 20 | import org.junit.jupiter.api.Test; 21 | 22 | public class CLanguageServerProviderTest { 23 | 24 | /** 25 | * Tests whether the ICLanguageServerProvider with the largest priority is used. 26 | */ 27 | @Test 28 | public void testLsProvidersPriority() throws CoreException { 29 | //WHEN a language server provider gets created from the serverProvider extension point: 30 | ICLanguageServerProvider cLanguageServerProvider = LspPlugin.getDefault().getCLanguageServerProvider(); 31 | //THEN its the mocked one, because its priority is larger than the CdtLanguageServerProvider's priority 32 | assertTrue(cLanguageServerProvider instanceof MockCLanguageServerProvider); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/LogProviderRegistry.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.server; 14 | 15 | import java.util.Optional; 16 | 17 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 18 | import org.eclipse.cdt.lsp.server.ILogProvider; 19 | import org.eclipse.core.runtime.IConfigurationElement; 20 | import org.eclipse.core.runtime.Platform; 21 | 22 | public final class LogProviderRegistry extends AbstractProviderRegistry { 23 | private static final String EXTENSION_ID = LspPlugin.PLUGIN_ID + ".logProvider"; //$NON-NLS-1$ 24 | private static final String LOGGER_ELEMENT = "logger"; //$NON-NLS-1$ 25 | 26 | public static Optional createLogProvider() { 27 | for (IConfigurationElement configurationElement : Platform.getExtensionRegistry() 28 | .getExtensionPoint(EXTENSION_ID).getConfigurationElements()) { 29 | if (LOGGER_ELEMENT.equals(configurationElement.getName())) { 30 | return Optional 31 | .ofNullable((ILogProvider) getInstanceFromExtension(configurationElement, ILogProvider.class)); 32 | } 33 | } 34 | return Optional.empty(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/EditorPreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.editor; 14 | 15 | import org.eclipse.cdt.lsp.config.ConfigurationPreferencesDefaults; 16 | import org.eclipse.cdt.lsp.editor.EditorConfiguration; 17 | import org.eclipse.core.runtime.ServiceCaller; 18 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 19 | import org.eclipse.jface.preference.IPreferenceStore; 20 | import org.eclipse.lsp4e.LanguageServerPlugin; 21 | 22 | public final class EditorPreferenceInitializer extends AbstractPreferenceInitializer { 23 | 24 | @Override 25 | public void initializeDefaultPreferences() { 26 | ServiceCaller.callOnce(getClass(), EditorConfiguration.class, new ConfigurationPreferencesDefaults<>()); 27 | IPreferenceStore store = LanguageServerPlugin.getDefault().getPreferenceStore(); 28 | // increase timeout from 5 to 30 seconds. Fetching formatting regions from the language server for large files (>20k lines of code) can take more than 5 sec.: 29 | store.setValue("org.eclipse.cdt.lsp.server.timeout.willSaveWaitUntil", 30); //$NON-NLS-1$ 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/DefaultClangdCompilationDatabaseSettings.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Contributors to the Eclipse Foundation. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * See git history 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.clangd.internal.config; 15 | 16 | import java.util.Optional; 17 | 18 | import org.eclipse.cdt.lsp.clangd.ClangdCompilationDatabaseSettings; 19 | import org.eclipse.cdt.lsp.clangd.ClangdConfiguration; 20 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 21 | import org.eclipse.core.resources.IProject; 22 | import org.osgi.service.component.annotations.Component; 23 | import org.osgi.service.component.annotations.Reference; 24 | 25 | @Component(property = { "service.ranking:Integer=0" }) 26 | public class DefaultClangdCompilationDatabaseSettings implements ClangdCompilationDatabaseSettings { 27 | 28 | @Reference 29 | ClangdConfiguration configuration; 30 | 31 | @Override 32 | public boolean enableSetCompilationDatabasePath(IProject project) { 33 | return Optional.ofNullable(LspPlugin.getDefault()).map(LspPlugin::getCLanguageServerProvider) 34 | .map(provider -> provider.isEnabledFor(project)).orElse(Boolean.FALSE) 35 | && configuration.options(project).setCompilationDatabase(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/src/org/eclipse/cdt/lsp/test/util/LspUtilsTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.test.util; 15 | 16 | import static org.junit.jupiter.api.Assertions.assertTrue; 17 | 18 | import org.eclipse.cdt.core.CCorePlugin; 19 | import org.eclipse.cdt.lsp.util.LspUtils; 20 | import org.junit.jupiter.api.Test; 21 | 22 | class LspUtilsTest { 23 | 24 | @Test 25 | void testIsCContentType_EmptyId() { 26 | assertTrue(!LspUtils.isCContentType("")); 27 | } 28 | 29 | @Test 30 | void testIsCContentType_CONTENT_TYPE_CSOURCE() { 31 | assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CSOURCE)); 32 | } 33 | 34 | @Test 35 | void testIsCContentType_CONTENT_TYPE_CHEADER() { 36 | assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CHEADER)); 37 | } 38 | 39 | @Test 40 | void testIsCContentType_CONTENT_TYPE_CXXSOURCE() { 41 | assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE)); 42 | } 43 | 44 | @Test 45 | void testIsCContentType_CONTENT_TYPE_CXXHEADER() { 46 | assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER)); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /jenkins/pod-templates/cdt-full-pod-plus-eclipse-install.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | containers: 5 | - name: cdt 6 | image: quay.io/eclipse-cdt/cdt-infra-plus-eclipse-install@sha256:7146f40a39f75e364c473aa26044803582428f41f1f911e4b44a8ee8e72f89d1 7 | tty: true 8 | args: ["/bin/sh", "-c", "/home/vnc/.vnc/xstartup.sh && cat"] 9 | resources: 10 | requests: 11 | memory: "10000Mi" 12 | cpu: "1" 13 | limits: 14 | memory: "10000Mi" 15 | cpu: "1" 16 | volumeMounts: 17 | - name: settings-xml 18 | mountPath: /home/jenkins/.m2/settings.xml 19 | subPath: settings.xml 20 | readOnly: true 21 | - name: m2-repo 22 | mountPath: /home/jenkins/.m2/repository 23 | - name: volume-known-hosts 24 | mountPath: /home/jenkins/.ssh 25 | - name: "jenkins-home" 26 | mountPath: "/home/jenkins" 27 | readOnly: false 28 | - name: tools 29 | mountPath: /jipp/tools 30 | - name: jnlp 31 | resources: 32 | requests: 33 | memory: "512Mi" 34 | cpu: "200m" 35 | limits: 36 | memory: "512Mi" 37 | cpu: "500m" 38 | volumeMounts: 39 | - name: volume-known-hosts 40 | mountPath: /home/jenkins/.ssh 41 | volumes: 42 | - name: settings-xml 43 | secret: 44 | secretName: m2-secret-dir 45 | items: 46 | - key: settings.xml 47 | path: settings.xml 48 | - name: m2-repo 49 | emptyDir: {} 50 | - name: volume-known-hosts 51 | configMap: 52 | name: known-hosts 53 | - name: "jenkins-home" 54 | emptyDir: {} 55 | - name: tools 56 | persistentVolumeClaim: 57 | claimName: tools-claim-jiro-cdt 58 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/OSGI-INF/l10n/bundle.properties: -------------------------------------------------------------------------------- 1 | #Properties file for org.eclipse.cdt.lsp.clangd 2 | ############################################################################### 3 | # Copyright (c) 2023 ArSysOp and others 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Eclipse Public License 2.0 which is available at 7 | # https://www.eclipse.org/legal/epl-2.0/. 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # ArSysOp - initial API and implementation 13 | ############################################################################### 14 | 15 | Bundle-Vendor = Eclipse CDT 16 | Bundle-Name = Clangd Language Server Support 17 | Bundle-Copyright =\ 18 | Copyright (c) 2023 ArSysOp and others.\n\ 19 | \n\ 20 | This program and the accompanying materials are made\n\ 21 | available under the terms of the Eclipse Public License 2.0\n\ 22 | which is available at https://www.eclipse.org/legal/epl-2.0/\n\ 23 | \n\ 24 | SPDX-License-Identifier: EPL-2.0\n\ 25 | 26 | Commands.ToggleSourceAndHeader.name=Toggle Source/Header 27 | Commands.ToggleSourceAndHeader.description=Toggles between corresponding source and header files 28 | PopupMenu.ToggleSourceAndHeader.label=Toggle Source/Header 29 | Commands.OpenDeclaration=Open Declaration 30 | Commands.OpenDeclaration.description=Open an editor on the selected elements declaration 31 | Commands.Category.name=Clangd 32 | Commands.Category.name.description=Commands used by the clangd based C/C++ editor 33 | PopupMenu.FindReferences.label=Find References 34 | ClangdConfigurationPage.name=clangd 35 | ClangFormatConfigurationPage.name=Formatter 36 | ContentAssistPreferencePage.name=Content Assist 37 | -------------------------------------------------------------------------------- /examples/org.eclipse.cdt.lsp.examples.preferences/src/org/eclipse/cdt/lsp/examples/preferences/HideTryNewExperienceBanner.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.examples.preferences; 13 | 14 | import java.util.List; 15 | 16 | import org.eclipse.cdt.lsp.config.ConfigurationMetadataBase; 17 | import org.eclipse.cdt.lsp.editor.EditorMetadata; 18 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 19 | import org.osgi.service.component.annotations.Component; 20 | 21 | /** 22 | * Demonstrates how to change default of showTryLspBanner 23 | *

24 | * NOTE: Because this example code also includes HidePreferLsp the effect of 25 | * this change is not apparent because hiding prefer LSP overrides the banner. 26 | * Change {@link HidePreferLsp#showPreferLsp(boolean)} to return true (or remove 27 | * the HidePreferLsp Service-Component entry in MANIFEST.MF) 28 | */ 29 | @Component(property = { "service.ranking:Integer=100" }) 30 | public class HideTryNewExperienceBanner extends ConfigurationMetadataBase implements EditorMetadata { 31 | 32 | @Override 33 | protected List> definePreferences() { 34 | return overrideOne(Predefined.defaults, overrideBoolean(Predefined.showTryLspBanner, false)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/ISwitchBackToTraditional.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.cdt.lsp.internal.editor.CLspEditor; 15 | import org.eclipse.swt.widgets.Composite; 16 | import org.eclipse.ui.texteditor.ITextEditor; 17 | 18 | /** 19 | * This interface can be implemented by CDT-LSP to display a banner in the {@link CLspEditor} 20 | * to switch back to the traditional C/C++ editing experience 21 | * 22 | * This interface is not public API 23 | * 24 | * @apiNote this interface, at time of initial implementation, is expected to work 25 | * with CDT 11.6 and CDT 12. There should be no requirements on API 26 | * added in CDT 12 (specifically ISwitchToLsp) 27 | * 28 | * See org.eclipse.cdt.internal.ui.switchtolsp.ISwitchToLsp 29 | */ 30 | public interface ISwitchBackToTraditional { 31 | 32 | /** 33 | * Create the banner controls for the "switch back to traditional" 34 | * 35 | * @param part the editor part that the banner is added on 36 | * @param parent the parent control 37 | * @return the new parent control the editor should use 38 | */ 39 | public Composite createSwitchBackToTraditional(ITextEditor part, Composite parent); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/ExistingResource.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Alexander Fedorov (ArSysOp) - initial API 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp; 13 | 14 | import java.net.URI; 15 | import java.util.Arrays; 16 | import java.util.Objects; 17 | import java.util.Optional; 18 | import java.util.function.Function; 19 | 20 | import org.eclipse.core.resources.IResource; 21 | import org.eclipse.core.resources.IWorkspace; 22 | 23 | public final class ExistingResource implements Function> { 24 | 25 | private final IWorkspace workspace; 26 | 27 | public ExistingResource(IWorkspace workspace) { 28 | this.workspace = Objects.requireNonNull(workspace); 29 | } 30 | 31 | @Override 32 | public Optional apply(URI uri) { 33 | return forContainer(uri).or(() -> forFile(uri)); 34 | } 35 | 36 | private Optional forContainer(URI uri) { 37 | return Arrays.stream(workspace.getRoot().findContainersForLocationURI(uri))// 38 | .map(IResource.class::cast)// 39 | .filter(c -> c.exists())// 40 | .findFirst(); 41 | } 42 | 43 | private Optional forFile(URI uri) { 44 | return Arrays.stream(workspace.getRoot().findFilesForLocationURI(uri))// 45 | .map(IResource.class::cast)// 46 | .filter(c -> c.exists())// 47 | .findFirst(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/editor/EditorOptions.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.editor; 14 | 15 | public interface EditorOptions { 16 | 17 | /** 18 | * Prefer to use LSP based C/C++ Editor 19 | * 20 | * @return if LSP based C/C++ Editor should be preferred 21 | */ 22 | boolean preferLspEditor(); 23 | 24 | /** 25 | * Show the try new experience banner in the editor 26 | * 27 | * @return if banner should be displayed 28 | * @since 3.0 29 | */ 30 | boolean showTryLspBanner(); 31 | 32 | /** 33 | * Enable sub-word navigation in the editor 34 | * 35 | * @return if sub-word navigation should be enabled 36 | * @since 3.1 37 | */ 38 | default boolean enableSubWordNavigation() { 39 | return true; 40 | } 41 | 42 | /** 43 | * Format source code on file save action 44 | * 45 | * @return if source code should be formatted on file save action 46 | */ 47 | boolean formatOnSave(); 48 | 49 | /** 50 | * Format all lines in source file 51 | * 52 | * @return if all lines should be formatted 53 | */ 54 | boolean formatAllLines(); 55 | 56 | /** 57 | * Format edited lines only 58 | * 59 | * @return if only edited lines should be formatted 60 | */ 61 | boolean formatEditedLines(); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.test/src/org/eclipse/cdt/lsp/test/internal/server/MockCLanguageServerProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | * Alexander Fedorov (ArSysOp) - rework access to preferences 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.test.internal.server; 15 | 16 | import java.net.URI; 17 | import java.util.Collections; 18 | import java.util.List; 19 | 20 | import org.eclipse.cdt.lsp.editor.EditorConfiguration; 21 | import org.eclipse.cdt.lsp.editor.LanguageServerEnable; 22 | import org.eclipse.cdt.lsp.server.ICLanguageServerProvider; 23 | import org.eclipse.core.resources.IProject; 24 | import org.eclipse.core.runtime.ServiceCaller; 25 | 26 | public class MockCLanguageServerProvider implements ICLanguageServerProvider { 27 | private final ServiceCaller editorConfiguration = new ServiceCaller<>(getClass(), 28 | EditorConfiguration.class); 29 | 30 | @Override 31 | public List getCommands(URI rootUri) { 32 | return Collections.emptyList(); 33 | } 34 | 35 | @Override 36 | public boolean isEnabledFor(IProject project) { 37 | boolean[] enabled = new boolean[1]; 38 | editorConfiguration.call(c -> enabled[0] = ((LanguageServerEnable) c.options(project)).isEnabledFor(project)); 39 | return enabled[0]; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdConfiguration.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.clangd; 15 | 16 | import java.net.URI; 17 | import java.util.List; 18 | 19 | import org.eclipse.cdt.lsp.config.Configuration; 20 | import org.eclipse.core.resources.IResource; 21 | import org.eclipse.core.runtime.preferences.IScopeContext; 22 | import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; 23 | 24 | /** 25 | * Provides access to the clangd options according to the required scope 26 | * 27 | * @see ClangdOptions 28 | * @see IScopeContext 29 | * 30 | * @since 2.0 31 | */ 32 | public interface ClangdConfiguration extends Configuration { 33 | 34 | /** 35 | * @since 3.0 36 | */ 37 | @Override 38 | ClangdOptions defaults(); 39 | 40 | /** 41 | * @since 3.0 42 | */ 43 | @Override 44 | ClangdOptions options(Object context); 45 | 46 | /** 47 | * Provides list of commands suitable for {@link ProcessStreamConnectionProvider} for the given context like {@link IResource} or {@link URI}, must not return null 48 | * @param context to be adapter to the proper scope 49 | * 50 | * @return list of commands 51 | */ 52 | List commands(Object context); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/config/ConfigurationAccess.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.config; 14 | 15 | import java.util.Optional; 16 | 17 | import org.eclipse.cdt.lsp.ResolveProjectScope; 18 | import org.eclipse.core.resources.IWorkspace; 19 | import org.eclipse.core.resources.ProjectScope; 20 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; 21 | import org.eclipse.core.runtime.preferences.IScopeContext; 22 | import org.eclipse.osgi.util.NLS; 23 | 24 | /** 25 | * @since 2.0 26 | */ 27 | public abstract class ConfigurationAccess { 28 | protected final String qualifier; 29 | 30 | public ConfigurationAccess(String qualifier) { 31 | this.qualifier = qualifier; 32 | } 33 | 34 | protected Optional projectScope(IWorkspace workspace, Object context) { 35 | return new ResolveProjectScope(workspace).apply(context); 36 | } 37 | 38 | protected IEclipsePreferences preferences(IScopeContext scope) { 39 | return Optional.ofNullable(scope.getNode(qualifier))// 40 | .filter(IEclipsePreferences.class::isInstance)// 41 | .map(IEclipsePreferences.class::cast)// 42 | .orElseThrow(() -> new IllegalStateException(// 43 | NLS.bind("Unable to get preferences for node: {0}", // //$NON-NLS-1$ 44 | qualifier))); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/internal/clangd/editor/expressions/LspEditorActiveTester.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 COSEDA Technologies GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Dominic Scharfe (COSEDA Technologies GmbH) - initial implementation 12 | *******************************************************************************/ 13 | package org.eclipse.cdt.lsp.internal.clangd.editor.expressions; 14 | 15 | import java.util.Optional; 16 | 17 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 18 | import org.eclipse.core.expressions.PropertyTester; 19 | import org.eclipse.core.runtime.Adapters; 20 | import org.eclipse.ui.IEditorPart; 21 | import org.eclipse.ui.texteditor.ITextEditor; 22 | 23 | /** 24 | * Property tester for checking if a receiver is a c editor. Will evaluate 25 | * {@code true} if the receiver can adapt to {@link ITextEditor} and has the c 26 | * editor id. 27 | */ 28 | public class LspEditorActiveTester extends PropertyTester { 29 | public final static String IS_LSP_CEDITOR_PROPERTY = "active"; 30 | 31 | @Override 32 | public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { 33 | if (receiver instanceof IEditorPart && IS_LSP_CEDITOR_PROPERTY.equals(property)) { 34 | IEditorPart innerEditor = Optional.ofNullable((IEditorPart) Adapters.adapt(receiver, ITextEditor.class)) 35 | .orElse((IEditorPart) receiver); 36 | 37 | return LspPlugin.LSP_C_EDITOR_ID.equals(innerEditor.getSite().getId()); 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/OSGI-INF/l10n/bundle.properties: -------------------------------------------------------------------------------- 1 | #Properties file for org.eclipse.cdt.lsp 2 | ############################################################################### 3 | # Copyright (c) 2023 Bachmann electronic GmbH and others 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Eclipse Public License 2.0 which is available at 7 | # https://www.eclipse.org/legal/epl-2.0/. 8 | # 9 | # SPDX-License-Identifier: EPL-2.0 10 | # 11 | # Contributors: 12 | # Bachmann electronic GmbH - initial API and implementation 13 | ############################################################################### 14 | 15 | Bundle-Vendor = Eclipse CDT 16 | Bundle-Name = Language Server based C/C++ Editor 17 | Bundle-Copyright =\ 18 | Copyright (c) 2023, 2025 Bachmann electronic GmbH and others.\n\ 19 | \n\ 20 | This program and the accompanying materials are made\n\ 21 | available under the terms of the Eclipse Public License 2.0\n\ 22 | which is available at https://www.eclipse.org/legal/epl-2.0/\n\ 23 | \n\ 24 | SPDX-License-Identifier: EPL-2.0\n\ 25 | 26 | SaveActionsPreferencePage.name=Save Actions 27 | EditorPreferencePage.name=Editor (LSP) 28 | CEditor.name=C/C++ Editor (LSP) 29 | CEditor.description=Editor (LSP) for C/C++ Source Files 30 | Server.name=C/C++ Language Server 31 | Logger.name=Log Provider for C/C++ Language Server 32 | SymbolsLabelProvider.name=LS Symbols 33 | 34 | AddBreakpoint.label=Toggle Brea&kpoint 35 | AddBreakpointInteractive.label=&Add Breakpoint... 36 | EnableBreakpoint.label=&Toggle Breakpoint Enabled 37 | AddDynamicPrintfInteractive.label=Add &Dynamic-Printf... 38 | RulerBreakpointProperties.label=Breakpoint P&roperties... 39 | AddExpressionAction.label=Add Watch Expression... 40 | RunToLineAction.label=Run to &Line 41 | ResumeAtLineAction.label=Resume at Li&ne 42 | MoveToLineAction.label=&Move to Line\u0020 43 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ICLanguageServerProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | * Alexander Fedorov (ArSysOp) - rework access to preferences 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.server; 15 | 16 | import java.net.URI; 17 | import java.util.List; 18 | 19 | import org.eclipse.core.resources.IProject; 20 | 21 | public interface ICLanguageServerProvider { 22 | 23 | /** 24 | * The command list includes the location of the language server followed by its calling arguments. 25 | * @param rootUri {@link IProject} or standalone File 26 | * 27 | * @return Command list to run language server 28 | */ 29 | public List getCommands(URI rootUri); 30 | 31 | /** 32 | * Optional initialization options for the language server during. Will be put in the initialize jsonrpc call. 33 | * 34 | * @param rootUri {@link IProject} or standalone File 35 | * @return 36 | */ 37 | public default Object getInitializationOptions(URI rootUri) { 38 | return null; 39 | } 40 | 41 | /** 42 | * Check whether the LSP based C/C++ Editor and the language server shall be used for the given project. 43 | * 44 | * @param project 45 | * @return true if LSP based C/C++ Editor and language server shall be enabled for the given project, otherwise false. 46 | */ 47 | public boolean isEnabledFor(IProject project); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/src/asciidoc/lsp_clangd_prefs.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | Copyright (c) 2024, 2025 John Dallaway and others 3 | This program and the accompanying materials 4 | are made available under the terms of the Eclipse Public License 2.0 5 | which accompanies this distribution, and is available at 6 | https://www.eclipse.org/legal/epl-2.0/ 7 | 8 | SPDX-License-Identifier: EPL-2.0 9 | 10 | Contributors: 11 | John Dallaway - initial content (#963) 12 | //// 13 | 14 | // support image rendering and table of contents within GitHub 15 | ifdef::env-github[] 16 | :imagesdir: ../../images 17 | :toc: 18 | :toc-placement!: 19 | endif::[] 20 | 21 | = clangd 22 | 23 | Use the image:command_link.png[] link:javascript:executeCommand('org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.lsp.clangd.editor.preferencePage)')[clangd] preference page to configure the behaviour of the `clangd` language server: 24 | 25 | image:lsp_clangd_prefs.png[width=550] 26 | 27 | .clangd Preference Options 28 | :!table-caption: 29 | [%autowidth] 30 | [options="header"] 31 | |=== 32 | |Option |Description 33 | |Path |The absolute path of the `clangd` command-line tool. 34 | |Enable clang-tidy diagnostics |Enables the link:https://clang.llvm.org/extra/clang-tidy[_ClangTidy_] {cpp} linter tool. 35 | |Index project code in the background and persist index on disk |Enables building of files in the background to generate a project index. 36 | |Completion |The granularity of code completion suggestions. 37 | |Pretty-print JSON output |Enables the pretty-printing of JSON output. 38 | |Drivers |A comma-separated list of globs for the extraction of system includes. 39 | |Additional |Miscellaneous `clangd` command-line arguments. 40 | |=== 41 | 42 | Related concepts: 43 | 44 | * xref:lsp_cpp_editor.adoc[C/C++ editor (LSP)] 45 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/ui/navigator/FileBufferListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.ui.navigator; 14 | 15 | import org.eclipse.core.filebuffers.IFileBuffer; 16 | import org.eclipse.core.filebuffers.IFileBufferListener; 17 | import org.eclipse.core.runtime.IPath; 18 | 19 | abstract class FileBufferListenerAdapter implements IFileBufferListener { 20 | 21 | @Override 22 | public void bufferCreated(IFileBuffer buffer) { 23 | } 24 | 25 | @Override 26 | public void bufferDisposed(IFileBuffer buffer) { 27 | } 28 | 29 | @Override 30 | public void bufferContentAboutToBeReplaced(IFileBuffer buffer) { 31 | } 32 | 33 | @Override 34 | public void bufferContentReplaced(IFileBuffer buffer) { 35 | } 36 | 37 | @Override 38 | public void stateChanging(IFileBuffer buffer) { 39 | } 40 | 41 | @Override 42 | public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) { 43 | } 44 | 45 | @Override 46 | public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) { 47 | } 48 | 49 | @Override 50 | public void underlyingFileMoved(IFileBuffer buffer, IPath path) { 51 | } 52 | 53 | @Override 54 | public void underlyingFileDeleted(IFileBuffer buffer) { 55 | } 56 | 57 | @Override 58 | public void stateChangeFailed(IFileBuffer buffer) { 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/ResolveProject.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp; 15 | 16 | import java.net.URI; 17 | import java.util.Optional; 18 | import java.util.function.Function; 19 | 20 | import org.eclipse.core.resources.IProject; 21 | import org.eclipse.core.resources.IResource; 22 | import org.eclipse.core.resources.IWorkspace; 23 | import org.eclipse.core.runtime.Adapters; 24 | 25 | public final class ResolveProject implements Function> { 26 | 27 | private final ExistingResource resolve; 28 | 29 | public ResolveProject(IWorkspace workspace) { 30 | this.resolve = new ExistingResource(workspace); 31 | } 32 | 33 | @Override 34 | public Optional apply(Object context) { 35 | return Optional.ofNullable(context)// 36 | .flatMap(this::resource)// 37 | .map(IResource::getProject); 38 | } 39 | 40 | private Optional resource(Object object) { 41 | return uri(object).or(() -> adapt(object)); 42 | } 43 | 44 | private Optional uri(Object object) { 45 | return Optional.ofNullable(object)// 46 | .filter(URI.class::isInstance)// 47 | .map(URI.class::cast)// 48 | .flatMap(resolve); 49 | } 50 | 51 | private Optional adapt(Object object) { 52 | return Optional.ofNullable(Adapters.adapt(object, IResource.class)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/FormatOnSave.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.editor; 14 | 15 | import org.eclipse.cdt.lsp.editor.EditorConfiguration; 16 | import org.eclipse.core.runtime.NullProgressMonitor; 17 | import org.eclipse.jface.text.IDocument; 18 | import org.eclipse.jface.text.IRegion; 19 | import org.eclipse.lsp4e.LSPEclipseUtils; 20 | import org.eclipse.lsp4e.format.IFormatRegionsProvider; 21 | import org.osgi.service.component.annotations.Component; 22 | import org.osgi.service.component.annotations.Reference; 23 | 24 | @Component(property = { "serverDefinitionId:String=org.eclipse.cdt.lsp.server" }) 25 | public class FormatOnSave implements IFormatRegionsProvider { 26 | 27 | @Reference 28 | private EditorConfiguration configuration; 29 | 30 | @Override 31 | public IRegion[] getFormattingRegions(IDocument document) { 32 | var file = LSPEclipseUtils.getFile(document); 33 | if (file != null) { 34 | var editorOptions = configuration.options(file); 35 | if (editorOptions != null && editorOptions.formatOnSave()) { 36 | if (editorOptions.formatAllLines()) { 37 | return IFormatRegionsProvider.allLines(document); 38 | } 39 | if (editorOptions.formatEditedLines()) { 40 | return IFormatRegionsProvider.calculateEditedLineRegions(document, new NullProgressMonitor()); 41 | } 42 | } 43 | } 44 | return null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/config/Configuration.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.config; 14 | 15 | import java.net.URI; 16 | 17 | import org.eclipse.core.resources.IResource; 18 | import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore; 19 | 20 | /** 21 | * @since 2.0 22 | */ 23 | public interface Configuration { 24 | 25 | /** 26 | * Returns the defaults 27 | * 28 | * @return defaults 29 | * 30 | * @since 3.0 31 | */ 32 | Object defaults(); 33 | 34 | /** 35 | * Returns the options for the given context like {@link IResource} or {@link URI}, must not return null 36 | * @param context to be adapter to the proper scope 37 | * 38 | * @return options 39 | */ 40 | Object options(Object context); 41 | 42 | /** 43 | * Returns the editor preference store for the given context like {@link IResource} or {@link URI}, must not return null 44 | * @param context to be adapter to the proper scope 45 | * 46 | * @return preference store 47 | */ 48 | IPreferenceMetadataStore storage(Object context); 49 | 50 | /** 51 | * Return the metadata for options, must not return null 52 | * 53 | * @return the option metadata 54 | * 55 | * @since 3.0 56 | */ 57 | ConfigurationMetadata metadata(); 58 | 59 | /** 60 | * Default qualifier to use for preference storage 61 | * @return preference qualifier 62 | */ 63 | String qualifier(); 64 | } 65 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/config/ConfigurationPreferencesDefaults.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - initial API and implementation 13 | *******************************************************************************/ 14 | 15 | package org.eclipse.cdt.lsp.config; 16 | 17 | import java.util.function.Consumer; 18 | 19 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 20 | import org.eclipse.core.runtime.preferences.DefaultScope; 21 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 22 | 23 | /** 24 | * Does actual default preferences initialization with provided {@link Configuration} instance 25 | * 26 | * Example usage: 27 | *

28 |  * ServiceCaller.callOnce(getClass(), EditorConfiguration.class, new ConfigurationPreferencesDefaults<>())
29 |  * 
30 | * 31 | * @see AbstractPreferenceInitializer 32 | * 33 | * @since 3.0 34 | */ 35 | public final class ConfigurationPreferencesDefaults implements Consumer { 36 | 37 | @Override 38 | public void accept(C configuration) { 39 | configuration.metadata().defined().forEach(a -> initializePreferences(configuration.qualifier(), a)); 40 | } 41 | 42 | private void initializePreferences(String qualifier, PreferenceMetadata pm) { 43 | if (pm.defaultValue() instanceof Boolean value) { 44 | DefaultScope.INSTANCE.getNode(qualifier).putBoolean(pm.identifer(), value); 45 | } else if (pm.defaultValue() instanceof String value) { 46 | DefaultScope.INSTANCE.getNode(qualifier).put(pm.identifer(), value); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Eclipse C/C++ Development Tools 2 | 3 | Thanks for your interest in this project. 4 | 5 | The CDT LSP project is a part of the Eclipse CDT project. 6 | Please refer to CDT's [main contributing](https://github.com/eclipse-cdt/cdt/blob/main/CONTRIBUTING.md) file for details on CDT contribution processes and below for some specifics on CDT LSP. 7 | 8 | ## Setup CDT LSP for development 9 | 10 | To try out and develop the plug-ins in you can edit and run them from source. 11 | 12 | 1. Setup a CDT development environment following the instructions in [CDT's contributing instructions](https://github.com/eclipse-cdt/cdt/blob/main/CONTRIBUTING.md#contributing-to-cdt). 13 | 2. Clone this repo 14 | 3. Import the plug-ins in this repo into Eclipse development environment from Step 1 15 | 4. Consider closing the `org.eclipse.cdt.lsp.examples.*` projects as they demonstrate how to extend CDT LSP and may affect the overall behaviour, for example by removing the "Prefer C/C++ Editor (LSP)" checkbox. 16 | 5. Launch the Eclipse IDE with this Pug-ins tab settings from the launch config: *All workspace and enabled target Pug-ins* from your development IDE 17 | 18 | ## CI Builds 19 | 20 | All PRs are built using GitHub Actions using the workflows in the [.github/workflows](.github/workflows) directory. 21 | 22 | All branches are built using the [Jenkinsfile](Jenkinsfile) on the [Eclipse Foundations Jenkins infrastructure](https://wiki.eclipse.org/Jenkins) in the [cdt-lsp](https://ci.eclipse.org/cdt/job/cdt-lsp) multi-branch pipeline. 23 | The pipeline publishes continuously to download.eclipse.org, for example the `main` branch publishes to https://download.eclipse.org/tools/cdt/builds/cdt-lsp/main/ 24 | 25 | ## CI Milestone and Release Builds 26 | 27 | The [cdt-lsp](https://ci.eclipse.org/cdt/job/cdt-lsp) multi-branch pipeline's build results can be published as milestones or release builds by using the [promote-a-build](https://ci.eclipse.org/cdt/job/promote-a-build/) building with parameters and choosing the CDT repo and branch to publish. 28 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.doc/src/asciidoc/lsp_cpp_editor.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | Copyright (c) 2024, 2025 John Dallaway and others 3 | This program and the accompanying materials 4 | are made available under the terms of the Eclipse Public License 2.0 5 | which accompanies this distribution, and is available at 6 | https://www.eclipse.org/legal/epl-2.0/ 7 | 8 | SPDX-License-Identifier: EPL-2.0 9 | 10 | Contributors: 11 | John Dallaway - initial content (#963) 12 | //// 13 | 14 | // support image rendering and table of contents within GitHub 15 | ifdef::env-github[] 16 | :imagesdir: ../../images 17 | :toc: 18 | :toc-placement!: 19 | endif::[] 20 | 21 | // enable support for button, menu and keyboard macros 22 | :experimental: 23 | 24 | = C/{cpp} editor (LSP) 25 | 26 | The CDT provides a Language Server based editor that gives you specific support for editing C/{cpp} code. 27 | This editor uses _Language Server Protocol_ (LSP) to provide better support for modern C/{cpp} language features than the legacy C/{cpp} editor. 28 | The Language Server based editor is invoked automatically when you open a C/{cpp} source file within new projects. 29 | Projects created using an older version of CDT may be configured to use this editor from the menu:Project[Preferences > C/{cpp} General > Editor (LSP)] properties page: 30 | 31 | image:lsp_editor_properties.png[width=526] 32 | 33 | When the C/{cpp} editor (LSP) is enabled for a project, source code files are presented with a decorated icon (image:lsp_decoration.png[]) in the _Project Explorer_ view. 34 | 35 | The C/{cpp} editor (LSP) includes the following features: 36 | 37 | - Syntax highlighting 38 | - Content/code assist 39 | - Code folding 40 | - Integrated debugging features 41 | 42 | You can customize formatting behaviour of the editor by modifying style options in the _link:https://clang.llvm.org/docs/ClangFormatStyleOptions.html[ClangFormat]_ configuration file from the menu:Project[Preferences > C/{cpp} General > Editor (LSP) > Formatter] properties page. 43 | 44 | IMPORTANT: The C/{cpp} editor (LSP) requires an installation of the `link:https://clangd.llvm.org[clangd]` command-line tool. Refer to link:lsp_clangd_prefs.html[clangd preferences] for setup details. 45 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/AsyncStreamPipe.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.server; 14 | 15 | import java.io.BufferedInputStream; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.io.OutputStream; 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | 21 | import org.eclipse.core.runtime.Platform; 22 | 23 | public final class AsyncStreamPipe { 24 | 25 | /** 26 | * Starts a pipe from @input to @output 27 | * Returns a runnable that can stop the pipe 28 | */ 29 | public Runnable pipeTo(final String threadName, final InputStream input, final OutputStream output) { 30 | if (output != null) { 31 | final InputStream bufferedInput = new BufferedInputStream(input); 32 | final AtomicBoolean stop = new AtomicBoolean(false); 33 | final Runnable writer = () -> { 34 | try { 35 | final byte[] buffer = new byte[1024]; 36 | int size = 0; 37 | do { 38 | if (stop.get()) { 39 | break; 40 | } 41 | size = bufferedInput.read(buffer); 42 | if (size > -1) { 43 | output.write(buffer, 0, size); 44 | } 45 | } while (size > -1 && !Thread.interrupted()); 46 | } catch (IOException ioe) { 47 | if (!stop.get()) { 48 | Platform.getLog(getClass()).error(ioe.getMessage(), ioe); 49 | } 50 | } 51 | }; 52 | final Thread writerThread = new Thread(writer, threadName); 53 | final Runnable stopper = () -> { 54 | stop.set(true); 55 | }; 56 | writerThread.setDaemon(true); 57 | writerThread.start(); 58 | return stopper; 59 | } 60 | final Runnable emptyRunner = () -> { 61 | }; 62 | return emptyRunner; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdCompilationDatabaseProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * See git history 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.clangd; 15 | 16 | import java.util.Optional; 17 | 18 | import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; 19 | import org.eclipse.core.resources.IProject; 20 | import org.eclipse.core.resources.IResourceChangeEvent; 21 | 22 | /** 23 | * This interface will be called to set the the compilation database (compile_commands.json) path in the .clangd configuration file. 24 | * 25 | * @since 3.0 26 | */ 27 | public interface ClangdCompilationDatabaseProvider { 28 | 29 | /** 30 | * Gets the project relative path to the folder which contains the compilation database (compile_commands.json) based on the affected IResourceChangeEvent and IProject. 31 | * It will be called if {@link ClangdCompilationDatabaseSettings#enableSetCompilationDatabasePath(IProject)} returns true. 32 | * @param event 33 | * @param project 34 | * @return project relative path to compilation database (compile_commands.json) or empty optional 35 | */ 36 | Optional getCompilationDatabasePath(IResourceChangeEvent event, IProject project); 37 | 38 | /** 39 | * Gets the project relative path to the folder which contains the compilation database (compile_commands.json) based on the given CProjectDescriptionEvent. 40 | * It will be called if {@link ClangdCompilationDatabaseSettings#enableSetCompilationDatabasePath(IProject)} returns true. 41 | * @param event 42 | * @return project relative path to compilation database (compile_commands.json) or empty optional 43 | */ 44 | Optional getCompilationDatabasePath(CProjectDescriptionEvent event); 45 | } 46 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/SpellingEnabled.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2024 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.internal.editor; 15 | 16 | import java.util.Optional; 17 | 18 | import org.eclipse.cdt.lsp.util.LspUtils; 19 | import org.eclipse.core.expressions.PropertyTester; 20 | import org.eclipse.core.runtime.CoreException; 21 | import org.eclipse.ui.IEditorInput; 22 | import org.eclipse.ui.IFileEditorInput; 23 | import org.eclipse.ui.editors.text.EditorsUI; 24 | import org.eclipse.ui.editors.text.TextEditor; 25 | import org.eclipse.ui.texteditor.spelling.SpellingService; 26 | 27 | public final class SpellingEnabled extends PropertyTester { 28 | private static final String EMPTY = ""; //$NON-NLS-1$ 29 | 30 | @Override 31 | public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { 32 | return isSpellingEnabled() && isCContentType(receiver); 33 | } 34 | 35 | private static boolean isSpellingEnabled() { 36 | return EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED); 37 | } 38 | 39 | private static boolean isCContentType(Object receiver) { 40 | if (receiver instanceof TextEditor editor) { 41 | return LspUtils.isCContentType(getContentType(editor.getEditorInput())); 42 | } 43 | return false; 44 | } 45 | 46 | private static String getContentType(IEditorInput editorInput) { 47 | if (editorInput instanceof IFileEditorInput fileEditorInput) { 48 | try { 49 | return Optional.ofNullable(fileEditorInput.getFile().getContentDescription()) 50 | .map(cd -> cd.getContentType()).map(ct -> ct.getId()).orElse(EMPTY); 51 | } catch (CoreException e) { 52 | // do nothing 53 | } 54 | } 55 | return EMPTY; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/console/ClangdConsole.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.clangd.console; 14 | 15 | import java.io.IOException; 16 | import java.io.OutputStream; 17 | 18 | import org.eclipse.cdt.lsp.server.ILogProvider; 19 | import org.eclipse.core.runtime.Platform; 20 | import org.eclipse.ui.console.ConsolePlugin; 21 | import org.eclipse.ui.console.IConsole; 22 | import org.eclipse.ui.console.IConsoleManager; 23 | import org.eclipse.ui.console.MessageConsole; 24 | 25 | public final class ClangdConsole implements ILogProvider { 26 | private static final String CLANGD_CONSOLE = "Clangd"; //$NON-NLS-1$ 27 | private OutputStream outputStream; 28 | 29 | @Override 30 | public OutputStream getOutputStream() { 31 | if (outputStream == null) { 32 | outputStream = findConsole().newOutputStream(); 33 | } 34 | return outputStream; 35 | } 36 | 37 | @Override 38 | public void close() { 39 | if (outputStream != null) { 40 | try { 41 | outputStream.close(); 42 | outputStream = null; 43 | } catch (IOException e) { 44 | Platform.getLog(ClangdConsole.class).error(e.getMessage(), e); 45 | } 46 | } 47 | 48 | } 49 | 50 | private MessageConsole findConsole() { 51 | ConsolePlugin plugin = ConsolePlugin.getDefault(); 52 | IConsoleManager conMan = plugin.getConsoleManager(); 53 | for (IConsole existing : conMan.getConsoles()) { 54 | if (CLANGD_CONSOLE.equals(existing.getName())) 55 | return (MessageConsole) existing; 56 | } 57 | // no console found, so create a new one 58 | final var myConsole = new MessageConsole(CLANGD_CONSOLE, null); 59 | myConsole.setWaterMarks(80000, 800000); // limit text buffer size to prevent OOM 60 | conMan.addConsoles(new IConsole[] { myConsole }); 61 | return myConsole; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/ui/SaveActionsConfigurationPage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.ui; 14 | 15 | import org.eclipse.cdt.lsp.editor.EditorConfiguration; 16 | import org.eclipse.cdt.lsp.editor.EditorMetadata; 17 | import org.eclipse.cdt.lsp.editor.EditorOptions; 18 | import org.eclipse.cdt.lsp.ui.ConfigurationArea; 19 | import org.eclipse.cdt.lsp.ui.ConfigurationPage; 20 | import org.eclipse.core.runtime.IAdaptable; 21 | import org.eclipse.swt.widgets.Composite; 22 | import org.eclipse.ui.IWorkbench; 23 | 24 | public final class SaveActionsConfigurationPage extends ConfigurationPage { 25 | private final String id = "org.eclipse.cdt.lsp.editor.SaveActionsPreferencePage"; //$NON-NLS-1$ 26 | 27 | @Override 28 | protected EditorConfiguration getConfiguration(IWorkbench workbench) { 29 | return workbench.getService(EditorConfiguration.class); 30 | } 31 | 32 | @Override 33 | protected EditorOptions configurationDefaults() { 34 | return configuration.defaults(); 35 | } 36 | 37 | @Override 38 | protected EditorOptions configurationOptions(IAdaptable element) { 39 | return configuration.options(element); 40 | } 41 | 42 | @Override 43 | protected ConfigurationArea getConfigurationArea(Composite composite, boolean isProjectScope) { 44 | return new SaveActionsConfigurationArea(composite, isProjectScope); 45 | } 46 | 47 | @Override 48 | protected String getPreferenceId() { 49 | return id; 50 | } 51 | 52 | @Override 53 | protected boolean hasProjectSpecificOptions() { 54 | return projectScope()// 55 | .map(p -> p.getNode(configuration.qualifier()))// 56 | .map(n -> n.get(EditorMetadata.Predefined.formatAllLines.identifer(), null))// 57 | .isPresent(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %Bundle-Name 4 | Bundle-SymbolicName: org.eclipse.cdt.lsp;singleton:=true 5 | Bundle-Version: 3.1.100.qualifier 6 | Export-Package: org.eclipse.cdt.lsp, 7 | org.eclipse.cdt.lsp.config, 8 | org.eclipse.cdt.lsp.editor, 9 | org.eclipse.cdt.lsp.internal.switchtolsp;x-friends:="org.eclipse.cdt.lsp.clangd", 10 | org.eclipse.cdt.lsp.plugin;x-friends:="org.eclipse.cdt.lsp.clangd", 11 | org.eclipse.cdt.lsp.server, 12 | org.eclipse.cdt.lsp.services, 13 | org.eclipse.cdt.lsp.services.ast, 14 | org.eclipse.cdt.lsp.services.symbolinfo, 15 | org.eclipse.cdt.lsp.ui;x-friends:="org.eclipse.cdt.lsp.clangd", 16 | org.eclipse.cdt.lsp.util;x-friends:="org.eclipse.cdt.lsp.clangd" 17 | Bundle-Activator: org.eclipse.cdt.lsp.plugin.LspPlugin 18 | Bundle-Vendor: %Bundle-Vendor 19 | Require-Bundle: org.eclipse.ui, 20 | org.eclipse.core.runtime, 21 | org.eclipse.lsp4e;bundle-version="0.18.14", 22 | org.eclipse.tm4e.ui, 23 | org.eclipse.tm4e.languageconfiguration, 24 | org.eclipse.ui.genericeditor, 25 | org.eclipse.ui.editors, 26 | org.eclipse.ui.ide, 27 | org.eclipse.core.resources, 28 | org.eclipse.ui.navigator, 29 | org.eclipse.cdt.ui, 30 | org.eclipse.cdt.core, 31 | org.eclipse.ui.workbench, 32 | org.eclipse.core.expressions, 33 | org.eclipse.jface.text, 34 | org.eclipse.debug.ui, 35 | org.eclipse.lsp4j;bundle-version="0.22.0", 36 | org.eclipse.lsp4j.jsonrpc;bundle-version="0.22.0", 37 | org.eclipse.cdt.codan.core, 38 | org.eclipse.cdt.debug.ui, 39 | org.eclipse.ui.workbench.texteditor, 40 | org.eclipse.tm4e.language_pack, 41 | org.eclipse.jface.notifications, 42 | org.eclipse.core.filesystem 43 | Bundle-RequiredExecutionEnvironment: JavaSE-21 44 | Automatic-Module-Name: org.eclipse.cdt.lsp 45 | Bundle-ActivationPolicy: lazy 46 | Service-Component: OSGI-INF/org.eclipse.cdt.lsp.internal.editor.EditorMetadataDefaults.xml, 47 | OSGI-INF/org.eclipse.cdt.lsp.internal.editor.FormatOnSave.xml, 48 | OSGI-INF/org.eclipse.cdt.lsp.internal.editor.InitialFileManager.xml, 49 | OSGI-INF/org.eclipse.cdt.lsp.internal.switchtolsp.SwitchBack.xml, 50 | OSGI-INF/org.eclipse.cdt.lsp.internal.switchtolsp.SwitchToLsp.xml, 51 | OSGI-INF/org.eclipse.cdt.lsp.internal.ui.DefaultConfigurationVisibility.xml, 52 | OSGI-INF/org.eclipse.cdt.lsp.internal.ui.EditorConfigurationAccess.xml 53 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Automatic-Module-Name: org.eclipse.cdt.lsp.clangd 3 | Bundle-ActivationPolicy: lazy 4 | Bundle-ManifestVersion: 2 5 | Bundle-SymbolicName: org.eclipse.cdt.lsp.clangd;singleton:=true 6 | Bundle-Version: 3.0.500.qualifier 7 | Export-Package: org.eclipse.cdt.lsp.clangd 8 | Import-Package: org.yaml.snakeyaml;version="1.27.0", 9 | org.yaml.snakeyaml.error;version="1.27.0", 10 | org.yaml.snakeyaml.scanner;version="1.27.0" 11 | Bundle-Name: %Bundle-Name 12 | Bundle-Vendor: %Bundle-Vendor 13 | Bundle-Copyright: %Bundle-Copyright 14 | Bundle-RequiredExecutionEnvironment: JavaSE-21 15 | Require-Bundle: org.eclipse.cdt.lsp;bundle-version="0.0.0", 16 | org.eclipse.cdt.core;bundle-version="0.0.0", 17 | org.eclipse.cdt.ui;bundle-version="0.0.0", 18 | org.eclipse.core.expressions;bundle-version="0.0.0", 19 | org.eclipse.core.resources;bundle-version="0.0.0", 20 | org.eclipse.core.runtime;bundle-version="0.0.0", 21 | org.eclipse.jface;bundle-version="0.0.0", 22 | org.eclipse.jface.text;bundle-version="0.0.0", 23 | org.eclipse.lsp4e;bundle-version="0.18.14", 24 | org.eclipse.lsp4j;bundle-version="0.22.0", 25 | org.eclipse.ui.editors;bundle-version="0.0.0", 26 | org.eclipse.ui.ide;bundle-version="0.0.0", 27 | org.eclipse.ui.workbench;bundle-version="0.0.0", 28 | org.eclipse.ui.workbench.texteditor;bundle-version="0.0.0", 29 | org.eclipse.core.variables;bundle-version="0.0.0", 30 | org.yaml.snakeyaml;bundle-version="0.0.0", 31 | org.eclipse.tm4e.language_pack;bundle-version="0.0.0", 32 | org.eclipse.ui.console;bundle-version="0.0.0", 33 | org.eclipse.core.filesystem 34 | Bundle-Activator: org.eclipse.cdt.lsp.clangd.plugin.ClangdPlugin 35 | Service-Component: OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangFormatFileHandler.xml, 36 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdCommandLineValidator.xml, 37 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationAccess.xml, 38 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdFallbackManager.xml, 39 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdLsProvider.xml, 40 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults.xml, 41 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseProvider.xml, 42 | OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings.xml 43 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/Messages.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Kichwa Coders Canada Inc. and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.cdt.lsp.internal.switchtolsp; 13 | 14 | import org.eclipse.osgi.util.NLS; 15 | 16 | public class Messages extends NLS { 17 | private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$ 18 | public static String SwitchToLsp_LearnMoreMessage; 19 | public static String SwitchToLsp_NewExperienceTitile; 20 | public static String SwitchToLsp_GiveFeedbackLink; 21 | public static String SwitchToLsp_Cancel; 22 | public static String SwitchToLsp_DontShowThisBannerAgainLink; 23 | public static String SwitchToLsp_EditorsWitllReopenToClassicExperience; 24 | public static String SwitchToLsp_EditorsWitllReopenToNewExperience; 25 | public static String SwitchToLsp_LearnMoreLink; 26 | public static String SwitchToLsp_NewExperienceTitle; 27 | public static String SwitchToLsp_OpenPreferencesLink; 28 | public static String SwitchToLsp_OpenProjectSettings; 29 | public static String SwitchToLsp_ProjectSpecificSettingsLabel; 30 | public static String SwitchToLsp_SwitchBackBannerLink; 31 | public static String SwitchToLsp_UseClassicExperience; 32 | public static String SwitchToLsp_UseNewExperience; 33 | public static String SwitchToLsp_TryNewExperienceBannerLink; 34 | public static String SwitchToLsp_ClangdNotFoundTitle; 35 | public static String SwitchToLsp_ClangdNotFoundMessage; 36 | public static String SwitchToLsp_ClangdOutdatedTitle; 37 | public static String SwitchToLsp_ClangdOutdatedMessage; 38 | public static String SwitchToLsp_WhatIsClangdLink; 39 | public static String SwitchToLsp_InstallClangdLink; 40 | public static String SwitchToLsp_OpenClangdPreferencesLink; 41 | public static String SwitchToLsp_OK; 42 | 43 | static { 44 | // initialize resource bundle 45 | NLS.initializeMessages(BUNDLE_NAME, Messages.class); 46 | } 47 | 48 | private Messages() { 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/EditorPreferredOptions.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.editor; 14 | 15 | import org.eclipse.cdt.lsp.PreferredOptions; 16 | import org.eclipse.cdt.lsp.editor.EditorMetadata; 17 | import org.eclipse.cdt.lsp.editor.EditorOptions; 18 | import org.eclipse.cdt.lsp.editor.LanguageServerEnable; 19 | import org.eclipse.core.resources.IProject; 20 | import org.eclipse.core.runtime.preferences.IScopeContext; 21 | 22 | public final class EditorPreferredOptions extends PreferredOptions implements EditorOptions, LanguageServerEnable { 23 | private final LanguageServerEnable enable; 24 | 25 | public EditorPreferredOptions(EditorMetadata metadata, String qualifier, IScopeContext[] scopes, 26 | LanguageServerEnable enable) { 27 | super(metadata, qualifier, scopes); 28 | this.enable = enable; 29 | } 30 | 31 | @Override 32 | public boolean preferLspEditor() { 33 | return booleanValue(EditorMetadata.Predefined.preferLspEditor); 34 | } 35 | 36 | @Override 37 | public boolean showTryLspBanner() { 38 | return booleanValue(EditorMetadata.Predefined.showTryLspBanner); 39 | } 40 | 41 | @Override 42 | public boolean enableSubWordNavigation() { 43 | return booleanValue(EditorMetadata.Predefined.enableSubWordNavigation); 44 | } 45 | 46 | @Override 47 | public boolean formatOnSave() { 48 | return booleanValue(EditorMetadata.Predefined.formatOnSave); 49 | } 50 | 51 | @Override 52 | public boolean formatAllLines() { 53 | return booleanValue(EditorMetadata.Predefined.formatAllLines); 54 | } 55 | 56 | @Override 57 | public boolean formatEditedLines() { 58 | return booleanValue(EditorMetadata.Predefined.formatEditedLines); 59 | } 60 | 61 | @Override 62 | public boolean isEnabledFor(IProject project) { 63 | if (enable != null) { 64 | return enable.isEnabledFor(project); 65 | } 66 | return booleanValue(EditorMetadata.Predefined.preferLspEditor); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/switchtolsp/messages.properties: -------------------------------------------------------------------------------- 1 | SwitchToLsp_LearnMoreMessage=Learn more about the new C/C++ editing experience. 2 | SwitchToLsp_NewExperienceTitile=\u2728 New C/C++ editing experience 3 | SwitchToLsp_GiveFeedbackLink=Give feedback 4 | SwitchToLsp_Cancel=Cancel 5 | SwitchToLsp_DontShowThisBannerAgainLink=Don't show the editing experience banner again 6 | SwitchToLsp_EditorsWitllReopenToClassicExperience=C/C++ Editors will re-open in the classic C/C++ editing experience.\n\nThis will use the CDT editor for C/C++ editing and the workspace\ndefault setting will be to not use the CDT LSP Editor.\n\n 7 | SwitchToLsp_EditorsWitllReopenToNewExperience=C/C++ Editors will re-open in the new C/C++ editing experience.\n\nThis will use the CDT LSP Editor for C/C++ editing and the\nworkspace default setting will be to use the CDT LSP Editor.\n\n 8 | SwitchToLsp_LearnMoreLink=Learn more 9 | SwitchToLsp_NewExperienceTitle=\u2728 New C/C++ editing experience 10 | SwitchToLsp_OpenPreferencesLink=Open preferences 11 | SwitchToLsp_OpenProjectSettings=Open project settings 12 | SwitchToLsp_ProjectSpecificSettingsLabel=The selected project has project specific settings.\nOpen the project settings to change which editor is used.\n\n 13 | SwitchToLsp_SwitchBackBannerLink=Switch back to the classic C/C++ editing experience 14 | SwitchToLsp_UseClassicExperience=Use classic experience 15 | SwitchToLsp_UseNewExperience=Use new experience 16 | SwitchToLsp_TryNewExperienceBannerLink=Try the new C/C++ editing experience 17 | SwitchToLsp_ClangdNotFoundTitle=clangd not found 18 | SwitchToLsp_ClangdNotFoundMessage=The new C/C++ editing experience requires clangd to be installed and available on your system.\n\nInstall clangd, ensure that its parent directory has been added to the PATH environment variable\nand restart Eclipse to use the new C/C++ editing experience.\n\nIf you already have clangd installed somewhere on your system,\nopen the clangd preferences page and set the Path accordingly.\n\n 19 | SwitchToLsp_ClangdOutdatedTitle=clangd outdated 20 | SwitchToLsp_ClangdOutdatedMessage=The new C/C++ editing experience requires clangd version {0} or later.\n\nThe clangd version found on your system is {1}.\n\nUpdate clangd and restart Eclipse to ensure that all features provided by the new C/C++ editor are supported.\n\n 21 | SwitchToLsp_WhatIsClangdLink=What is clangd? 22 | SwitchToLsp_InstallClangdLink=How to install clangd 23 | SwitchToLsp_OpenClangdPreferencesLink=Open clangd preferences 24 | SwitchToLsp_OK=OK 25 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/DebugHoverProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp.internal.editor; 14 | 15 | import java.util.Objects; 16 | import java.util.Optional; 17 | 18 | import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; 19 | import org.eclipse.debug.ui.DebugUITools; 20 | import org.eclipse.jface.text.IInformationControlCreator; 21 | import org.eclipse.jface.text.IRegion; 22 | import org.eclipse.jface.text.ITextHover; 23 | import org.eclipse.jface.text.ITextHoverExtension; 24 | import org.eclipse.jface.text.ITextHoverExtension2; 25 | import org.eclipse.jface.text.ITextViewer; 26 | 27 | /** 28 | * Delegates hover to the text hover implementation of cdt. 29 | */ 30 | public class DebugHoverProvider implements ITextHover, ITextHoverExtension, ITextHoverExtension2 { 31 | @Override 32 | public IInformationControlCreator getHoverControlCreator() { 33 | return getDelegate(ITextHoverExtension.class).map(ITextHoverExtension::getHoverControlCreator).orElse(null); 34 | } 35 | 36 | @SuppressWarnings("deprecation") 37 | @Override 38 | public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { 39 | return getDelegate(ITextHover.class).map(delegate -> delegate.getHoverInfo(textViewer, hoverRegion)) 40 | .orElse(null); 41 | } 42 | 43 | @Override 44 | public IRegion getHoverRegion(ITextViewer textViewer, int offset) { 45 | return getDelegate(ITextHover.class).map(delegate -> delegate.getHoverRegion(textViewer, offset)).orElse(null); 46 | } 47 | 48 | @Override 49 | public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { 50 | return getDelegate(ITextHoverExtension2.class).map(delegate -> delegate.getHoverInfo2(textViewer, hoverRegion)) 51 | .orElse(null); 52 | } 53 | 54 | private Optional getDelegate(Class clazz) { 55 | return Optional.ofNullable(DebugUITools.getDebugContext()) 56 | .map(adaptable -> adaptable.getAdapter(ICEditorTextHover.class)).filter(Objects::nonNull) 57 | .filter(clazz::isInstance).map(clazz::cast); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/InitialFileManager.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | * Alexander Fedorov (ArSysOp) - rework to OSGi component 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.internal.editor; 15 | 16 | import java.net.URI; 17 | import java.net.URISyntaxException; 18 | import java.util.Optional; 19 | 20 | import org.eclipse.cdt.lsp.ExistingResource; 21 | import org.eclipse.cdt.lsp.editor.InitialUri; 22 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 23 | import org.eclipse.core.resources.IWorkspace; 24 | import org.eclipse.core.runtime.CoreException; 25 | import org.eclipse.core.runtime.Platform; 26 | import org.eclipse.core.runtime.QualifiedName; 27 | import org.osgi.service.component.annotations.Component; 28 | import org.osgi.service.component.annotations.Reference; 29 | 30 | @Component 31 | public final class InitialFileManager implements InitialUri { 32 | 33 | private static final QualifiedName INITIAL_URI = new QualifiedName(LspPlugin.PLUGIN_ID, "initialUri"); //$NON-NLS-1$ 34 | private URI uri; 35 | 36 | @Reference 37 | private IWorkspace workspace; 38 | 39 | @Override 40 | public synchronized void register(URI uri) { 41 | if (this.uri == null && new ExistingResource(workspace).apply(uri).isPresent()) { 42 | try { 43 | workspace.getRoot().setPersistentProperty(INITIAL_URI, uri.toString()); 44 | this.uri = uri; 45 | } catch (CoreException e) { 46 | Platform.getLog(InitialFileManager.class).error(e.getMessage(), e); 47 | } 48 | } 49 | } 50 | 51 | @Override 52 | public Optional find(URI root) { 53 | if (this.uri == null) { 54 | String initialUriString = null; 55 | try { 56 | initialUriString = workspace.getRoot().getPersistentProperty(INITIAL_URI); 57 | if (initialUriString != null) { 58 | this.uri = new URI(initialUriString); 59 | } 60 | } catch (CoreException | URISyntaxException e) { 61 | Platform.getLog(InitialFileManager.class).error(e.getMessage(), e); 62 | } 63 | } 64 | return Optional.ofNullable(this.uri); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/PreferredOptions.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | 13 | package org.eclipse.cdt.lsp; 14 | 15 | import java.util.Objects; 16 | import java.util.Optional; 17 | 18 | import org.eclipse.cdt.lsp.config.ConfigurationMetadata; 19 | import org.eclipse.core.runtime.preferences.IScopeContext; 20 | import org.eclipse.core.runtime.preferences.PreferenceMetadata; 21 | 22 | public abstract class PreferredOptions { 23 | /** 24 | * @since 3.0 25 | */ 26 | protected final ConfigurationMetadata metadata; 27 | protected final String qualifier; 28 | protected final IScopeContext[] scopes; 29 | 30 | /** 31 | * 32 | * @param metadata 33 | * @param qualifier 34 | * @param scopes 35 | * 36 | * @since 3.0 37 | */ 38 | public PreferredOptions(ConfigurationMetadata metadata, String qualifier, IScopeContext[] scopes) { 39 | this.metadata = Objects.requireNonNull(metadata); 40 | this.qualifier = Objects.requireNonNull(qualifier); 41 | this.scopes = Objects.requireNonNull(scopes); 42 | } 43 | 44 | private String commonValue(PreferenceMetadata meta) { 45 | String actual = String.valueOf(meta.defaultValue()); 46 | for (int i = scopes.length - 1; i >= 0; i--) { 47 | IScopeContext scope = scopes[i]; 48 | String previous = actual; 49 | actual = scope.getNode(qualifier).get(meta.identifer(), previous); 50 | } 51 | return actual; 52 | } 53 | 54 | protected final boolean booleanValue(PreferenceMetadata predefined) { 55 | PreferenceMetadata customized = metadata.defined(predefined.identifer(), Boolean.class) 56 | .orElse(predefined); 57 | return Optional.of(customized)// 58 | .map(this::commonValue)// 59 | .map(Boolean::valueOf)// 60 | .orElseGet(customized::defaultValue); 61 | } 62 | 63 | protected final String stringValue(PreferenceMetadata predefined) { 64 | PreferenceMetadata customized = metadata.defined(predefined.identifer(), String.class) 65 | .orElse(predefined); 66 | return Optional.of(customized)// 67 | .map(this::commonValue)// 68 | .orElseGet(customized::defaultValue); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /tests/org.eclipse.cdt.lsp.clangd.tests/src/org/eclipse/cdt/lsp/clangd/tests/TestUtils.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | * Alexander Fedorov (ArSysOp) - extract headless part 13 | * Alexander Fedorov (ArSysOp) - rework access to preferences 14 | *******************************************************************************/ 15 | 16 | package org.eclipse.cdt.lsp.clangd.tests; 17 | 18 | import org.eclipse.cdt.lsp.editor.EditorConfiguration; 19 | import org.eclipse.cdt.lsp.editor.EditorMetadata; 20 | import org.eclipse.core.resources.IProject; 21 | import org.eclipse.core.resources.IProjectDescription; 22 | import org.eclipse.core.resources.ResourcesPlugin; 23 | import org.eclipse.core.runtime.CoreException; 24 | import org.eclipse.core.runtime.NullProgressMonitor; 25 | import org.eclipse.core.runtime.ServiceCaller; 26 | import org.junit.jupiter.api.TestInfo; 27 | 28 | public final class TestUtils { 29 | 30 | public static void setLspPreferred(IProject project, boolean value) { 31 | ServiceCaller.callOnce(TestUtils.class, EditorConfiguration.class, // 32 | cc -> cc.storage(project).save(value, EditorMetadata.Predefined.preferLspEditor)); 33 | } 34 | 35 | public static IProject createCProject(String projectName) throws CoreException { 36 | IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); 37 | if (project.exists()) { 38 | return project; 39 | } 40 | project.create(null); 41 | project.open(null); 42 | // configure C nature 43 | IProjectDescription description = project.getDescription(); 44 | if (description != null) { 45 | String[] natureIds = { "org.eclipse.cdt.core.cnature" }; 46 | description.setNatureIds(natureIds); 47 | project.setDescription(description, null); 48 | } 49 | return project; 50 | } 51 | 52 | public static void deleteProject(IProject project) throws CoreException { 53 | if (project != null) { 54 | project.delete(true, new NullProgressMonitor()); 55 | } 56 | } 57 | 58 | public static String getName(TestInfo testInfo) { 59 | String displayName = testInfo.getDisplayName(); 60 | String replaceFirst = displayName.replaceFirst("\\(.*\\)", ""); 61 | return replaceFirst; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/messages/LspUiMessages.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 Bachmann electronic GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.internal.messages; 15 | 16 | import org.eclipse.osgi.util.NLS; 17 | 18 | public class LspUiMessages extends NLS { 19 | private static final String BUNDLE_NAME = "org.eclipse.cdt.lsp.internal.messages.LspUiMessages"; //$NON-NLS-1$ 20 | 21 | static { 22 | // initialize resource bundle 23 | NLS.initializeMessages(BUNDLE_NAME, LspUiMessages.class); 24 | } 25 | 26 | public static String NavigatorView_ErrorOnLoad; 27 | 28 | public static String LspEditorConfigurationPage_spelling_link; 29 | public static String LspEditorConfigurationPage_spelling_link_tooltip; 30 | public static String LspEditorConfigurationPage_content_assist_link; 31 | public static String LspEditorConfigurationPage_content_assist_link_tooltip; 32 | public static String LspEditorConfigurationPage_task_tags_link; 33 | public static String LspEditorConfigurationPage_task_tags_link_tooltip; 34 | 35 | public static String LspEditorConfigurationPage_enable_project_specific; 36 | public static String LspEditorConfigurationPage_configure_ws_specific; 37 | public static String LspEditorConfigurationPage_preferLspEditor; 38 | public static String LspEditorConfigurationPage_preferLspEditor_description; 39 | public static String LspEditorConfigurationPage_showTryLspBanner; 40 | public static String LspEditorConfigurationPage_showTryLspBanner_description; 41 | public static String LspEditorConfigurationPage_gneral_behavior_group; 42 | public static String LspEditorConfigurationPage_enableSubWordNavigation; 43 | public static String LspEditorConfigurationPage_enableSubWordNavigation_description; 44 | 45 | public static String SaveActionsConfigurationPage_FormatSourceCode; 46 | public static String SaveActionsConfigurationPage_FormatSourceCode_description; 47 | public static String SaveActionsConfigurationPage_FormatAllLines; 48 | public static String SaveActionsConfigurationPage_FormatAllLines_description; 49 | public static String SaveActionsConfigurationPage_FormatEditedLines; 50 | public static String SaveActionsConfigurationPage_FormatEditedLines_description; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/ui/ContentAssistConfigurationArea.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.clangd.internal.ui; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import org.eclipse.cdt.lsp.clangd.ClangdMetadata; 18 | import org.eclipse.cdt.lsp.clangd.ClangdOptions; 19 | import org.eclipse.cdt.lsp.ui.ConfigurationArea; 20 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; 21 | import org.eclipse.core.runtime.preferences.OsgiPreferenceMetadataStore; 22 | import org.eclipse.jface.layout.GridLayoutFactory; 23 | import org.eclipse.swt.SWT; 24 | import org.eclipse.swt.layout.GridData; 25 | import org.eclipse.swt.widgets.Button; 26 | import org.eclipse.swt.widgets.Composite; 27 | import org.eclipse.swt.widgets.Group; 28 | 29 | public final class ContentAssistConfigurationArea extends ConfigurationArea { 30 | 31 | private final Button fillFunctionArguments; 32 | private final Group group; 33 | 34 | public ContentAssistConfigurationArea(Composite parent, boolean isProjectScope) { 35 | super(1); 36 | Composite composite = new Composite(parent, SWT.NONE); 37 | composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 38 | composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(columns).create()); 39 | this.group = createGroup(composite, LspEditorUiMessages.ContentAssistConfigurationPage_insertion_group_name, 3); 40 | this.fillFunctionArguments = createButton(ClangdMetadata.Predefined.fillFunctionArguments, group, SWT.CHECK, 0); 41 | } 42 | 43 | @Override 44 | public void load(ClangdOptions options, boolean enable) { 45 | fillFunctionArguments.setSelection(options.fillFunctionArguments()); 46 | fillFunctionArguments.setEnabled(enable); 47 | } 48 | 49 | @Override 50 | public void store(IEclipsePreferences prefs) { 51 | OsgiPreferenceMetadataStore store = new OsgiPreferenceMetadataStore(prefs); 52 | buttons.entrySet().forEach(e -> store.save(e.getValue().getSelection(), e.getKey())); 53 | } 54 | 55 | @Override 56 | public List getPreferenceKeys() { 57 | var list = new ArrayList(1); 58 | list.add(ClangdMetadata.Predefined.fillFunctionArguments.identifer()); 59 | return list; 60 | } 61 | 62 | public boolean optionsChanged(ClangdOptions options) { 63 | return options.fillFunctionArguments() != fillFunctionArguments.getSelection(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/ui/ContentAssistConfigurationPage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2025 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.clangd.internal.ui; 13 | 14 | import org.eclipse.cdt.lsp.clangd.ClangdConfiguration; 15 | import org.eclipse.cdt.lsp.clangd.ClangdOptions; 16 | import org.eclipse.cdt.lsp.ui.ConfigurationArea; 17 | import org.eclipse.cdt.lsp.ui.ConfigurationPage; 18 | import org.eclipse.cdt.lsp.util.LspUtils; 19 | import org.eclipse.core.runtime.IAdaptable; 20 | import org.eclipse.swt.widgets.Composite; 21 | import org.eclipse.ui.IWorkbench; 22 | 23 | public final class ContentAssistConfigurationPage extends ConfigurationPage { 24 | private final String id = "org.eclipse.cdt.lsp.clangd.editor.contentAssistPreferencePage"; //$NON-NLS-1$ 25 | 26 | @Override 27 | protected ClangdConfiguration getConfiguration(IWorkbench workbench) { 28 | return workbench.getService(ClangdConfiguration.class); 29 | } 30 | 31 | @Override 32 | protected ClangdOptions configurationDefaults() { 33 | return configuration.defaults(); 34 | } 35 | 36 | @Override 37 | protected ClangdOptions configurationOptions(IAdaptable element) { 38 | return configuration.options(element); 39 | } 40 | 41 | @Override 42 | protected ConfigurationArea getConfigurationArea(Composite composite, boolean isProjectScope) { 43 | return new ContentAssistConfigurationArea(composite, isProjectScope); 44 | } 45 | 46 | @Override 47 | protected String getPreferenceId() { 48 | return id; 49 | } 50 | 51 | @Override 52 | public boolean performOk() { 53 | var settingsChanged = configurationSettingsChanged(); // must be called prior to super.performOK(), otherwise we cannot detect pref changes. 54 | var done = super.performOk(); 55 | if (done && LspUtils.isLsActive() && settingsChanged) { 56 | LspUtils.restartClangd(); 57 | } 58 | return done; 59 | } 60 | 61 | /** 62 | * Returns true when the page settings differ from the stored. 63 | * @return 64 | */ 65 | private boolean configurationSettingsChanged() { 66 | return ((ContentAssistConfigurationArea) area).optionsChanged(configuration.options(getElement())); 67 | } 68 | 69 | @Override 70 | protected boolean hasProjectSpecificOptions() { 71 | // We support only workspace wide settings for content assist. Because we currently only support a single LS for the whole workspace. 72 | return false; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdPreferredOptions.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2025 ArSysOp. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Contributors: 12 | * Alexander Fedorov (ArSysOp) - Initial API and implementation 13 | *******************************************************************************/ 14 | package org.eclipse.cdt.lsp.clangd.internal.config; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import java.util.List; 19 | 20 | import org.eclipse.cdt.lsp.PreferredOptions; 21 | import org.eclipse.cdt.lsp.clangd.ClangdMetadata; 22 | import org.eclipse.cdt.lsp.clangd.ClangdOptions; 23 | import org.eclipse.core.runtime.preferences.IScopeContext; 24 | 25 | final class ClangdPreferredOptions extends PreferredOptions implements ClangdOptions { 26 | 27 | ClangdPreferredOptions(ClangdMetadata metadata, String qualifier, IScopeContext[] scopes) { 28 | super(metadata, qualifier, scopes); 29 | } 30 | 31 | @Override 32 | public String clangdPath() { 33 | return stringValue(ClangdMetadata.Predefined.clangdPath); 34 | } 35 | 36 | @Override 37 | public boolean useTidy() { 38 | return booleanValue(ClangdMetadata.Predefined.useTidy); 39 | } 40 | 41 | @Override 42 | public boolean useBackgroundIndex() { 43 | return booleanValue(ClangdMetadata.Predefined.useBackgroundIndex); 44 | } 45 | 46 | @Override 47 | public String completionStyle() { 48 | return stringValue(ClangdMetadata.Predefined.completionStyle); 49 | } 50 | 51 | @Override 52 | public boolean prettyPrint() { 53 | return booleanValue(ClangdMetadata.Predefined.prettyPrint); 54 | } 55 | 56 | @Override 57 | public String queryDriver() { 58 | return stringValue(ClangdMetadata.Predefined.queryDriver); 59 | } 60 | 61 | @Override 62 | public List additionalOptions() { 63 | var options = stringValue(ClangdMetadata.Predefined.additionalOptions); 64 | if (options.isBlank()) { 65 | return new ArrayList<>(); 66 | } 67 | return Arrays.asList(options.split("\\R")); //$NON-NLS-1$ 68 | } 69 | 70 | @Override 71 | public boolean logToConsole() { 72 | return booleanValue(ClangdMetadata.Predefined.logToConsole); 73 | } 74 | 75 | @Override 76 | public boolean validateClangdOptions() { 77 | return booleanValue(ClangdMetadata.Predefined.validateClangdOptions); 78 | } 79 | 80 | @Override 81 | public boolean fillFunctionArguments() { 82 | return booleanValue(ClangdMetadata.Predefined.fillFunctionArguments); 83 | } 84 | 85 | @Override 86 | public boolean setCompilationDatabase() { 87 | return booleanValue(ClangdMetadata.Predefined.setCompilationDatabase); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/messages/LspUiMessages.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2023, 2025 Eclipse Foundation and others 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/. 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # Eclipse Foundation - initial API and implementation 12 | ############################################################################### 13 | 14 | NavigatorView_ErrorOnLoad = Loading the symbols encountered an error; see the Error Log for more information 15 | 16 | LspEditorConfigurationPage_spelling_link=Spelling preferences are set via Text Editors Spelling. 17 | LspEditorConfigurationPage_spelling_link_tooltip=Show the shared text editor spelling preferences 18 | LspEditorConfigurationPage_content_assist_link=General Content Assist preferences are set via Generic Text Editors. 19 | LspEditorConfigurationPage_content_assist_link_tooltip=Show the generic text editors content assist preferences 20 | LspEditorConfigurationPage_task_tags_link=The task tags preferences for the LSP-based C++ editor are set via TextMate Task Tags. 21 | LspEditorConfigurationPage_task_tags_link_tooltip=Show the TextMate task tags preferences 22 | 23 | LspEditorConfigurationPage_enable_project_specific=Enable project-specific settings 24 | LspEditorConfigurationPage_configure_ws_specific=Configure Workspace Settings... 25 | LspEditorConfigurationPage_preferLspEditor=Set C/C++ Editor (LSP) as default 26 | LspEditorConfigurationPage_preferLspEditor_description=The language server based C/C++ Editor will be used to open C/C++ source files. 27 | LspEditorConfigurationPage_showTryLspBanner=Show the editing experience banner 28 | LspEditorConfigurationPage_showTryLspBanner_description=Show the try the new editing experience banner when opening C/C++ editors 29 | LspEditorConfigurationPage_gneral_behavior_group=General behavior 30 | LspEditorConfigurationPage_enableSubWordNavigation=Smart &caret positioning in identifiers 31 | LspEditorConfigurationPage_enableSubWordNavigation_description=Enables smart caret positioning within camelCase and snake_case identifiers when navigating with arrow keys. 32 | 33 | SaveActionsConfigurationPage_FormatSourceCode=Format source code 34 | SaveActionsConfigurationPage_FormatSourceCode_description=Formats source code when file is saved 35 | SaveActionsConfigurationPage_FormatAllLines=Format all lines 36 | SaveActionsConfigurationPage_FormatAllLines_description=Formats all source code lines 37 | SaveActionsConfigurationPage_FormatEditedLines=Format edited lines 38 | SaveActionsConfigurationPage_FormatEditedLines_description=Formats edited source code lines only 39 | 40 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/plugin/LspPlugin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023, 2024, 2025 Bachmann electronic GmbH and others. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation 11 | * Alexander Fedorov (ArSysOp) - use Platform for logging 12 | *******************************************************************************/ 13 | 14 | package org.eclipse.cdt.lsp.plugin; 15 | 16 | import java.util.logging.Level; 17 | import java.util.logging.Logger; 18 | 19 | import org.eclipse.cdt.lsp.internal.server.CLanguageServerEnableCache; 20 | import org.eclipse.cdt.lsp.internal.server.CLanguageServerRegistry; 21 | import org.eclipse.cdt.lsp.server.ICLanguageServerProvider; 22 | import org.eclipse.ui.plugin.AbstractUIPlugin; 23 | import org.osgi.framework.BundleContext; 24 | 25 | /** 26 | * The activator class controls the plug-in life cycle 27 | */ 28 | public class LspPlugin extends AbstractUIPlugin { 29 | 30 | // The plug-in ID 31 | public static final String PLUGIN_ID = "org.eclipse.cdt.lsp"; //$NON-NLS-1$ 32 | public static final String LSP_C_EDITOR_ID = "org.eclipse.cdt.lsp.CEditor"; //$NON-NLS-1$ 33 | public static final String C_EDITOR_ID = "org.eclipse.cdt.ui.editor.CEditor"; //$NON-NLS-1$ 34 | 35 | // The shared instance 36 | private static LspPlugin plugin; 37 | 38 | private ICLanguageServerProvider cLanguageServerProvider; 39 | 40 | // Disable warnings, see https://github.com/eclipse-cdt/cdt-lsp/issues/88 and https://github.com/eclipse-cdt/cdt-lsp/issues/101. 41 | // We keep this reference to avoid the logger being garbage collected. 42 | private static final Logger logger = Logger.getLogger("org.eclipse.tm4e.core.internal.oniguruma.OnigRegExp"); //$NON-NLS-1$ 43 | 44 | /** 45 | * The constructor 46 | */ 47 | public LspPlugin() { 48 | } 49 | 50 | @Override 51 | public void start(BundleContext context) throws Exception { 52 | super.start(context); 53 | plugin = this; 54 | cLanguageServerProvider = new CLanguageServerRegistry().createCLanguageServerProvider(); 55 | 56 | // Disable warnings, see https://github.com/eclipse-cdt/cdt-lsp/issues/88 and https://github.com/eclipse-cdt/cdt-lsp/issues/101 57 | logger.setLevel(Level.SEVERE); 58 | } 59 | 60 | @Override 61 | public void stop(BundleContext context) throws Exception { 62 | CLanguageServerEnableCache.stop(); 63 | plugin = null; 64 | super.stop(context); 65 | } 66 | 67 | /** 68 | * Returns the shared instance 69 | * 70 | * @return the shared instance 71 | */ 72 | public static LspPlugin getDefault() { 73 | return plugin; 74 | } 75 | 76 | public ICLanguageServerProvider getCLanguageServerProvider() { 77 | return cLanguageServerProvider; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/editor/LspEditorFileImageDescriptor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * See git history 11 | *******************************************************************************/ 12 | package org.eclipse.cdt.lsp.internal.editor; 13 | 14 | import java.net.URL; 15 | import java.util.HashMap; 16 | 17 | import org.eclipse.cdt.lsp.plugin.LspPlugin; 18 | import org.eclipse.cdt.lsp.server.ICLanguageServerProvider; 19 | import org.eclipse.cdt.ui.lsp.ICFileImageDescriptor; 20 | import org.eclipse.core.resources.IProject; 21 | import org.eclipse.core.runtime.FileLocator; 22 | import org.eclipse.core.runtime.Path; 23 | import org.eclipse.core.runtime.Platform; 24 | import org.eclipse.jface.resource.ImageDescriptor; 25 | import org.osgi.framework.Bundle; 26 | 27 | public class LspEditorFileImageDescriptor implements ICFileImageDescriptor { 28 | private final ICLanguageServerProvider cLanguageServerProvider; 29 | private static HashMap imageRegistry = new HashMap<>(2); 30 | private static final String ICONS_PATH = "$nl$/icons/"; //$NON-NLS-1$ 31 | 32 | public static final String IMG_HFILE = "IMG_HFILE"; //$NON-NLS-1$ 33 | public static final String IMG_CFILE = "IMG_CFILE"; //$NON-NLS-1$ 34 | public static final String IMG_CXXFILE = "IMG_CXXFILE"; //$NON-NLS-1$ 35 | 36 | public LspEditorFileImageDescriptor() { 37 | cLanguageServerProvider = LspPlugin.getDefault().getCLanguageServerProvider(); 38 | declareRegistryImage(IMG_HFILE, ICONS_PATH + "h.png"); //$NON-NLS-1$ 39 | declareRegistryImage(IMG_CFILE, ICONS_PATH + "c.png"); //$NON-NLS-1$ 40 | declareRegistryImage(IMG_CXXFILE, ICONS_PATH + "cpp.png"); //$NON-NLS-1$ 41 | } 42 | 43 | @Override 44 | public ImageDescriptor getCImageDescriptor() { 45 | return imageRegistry.get(IMG_CFILE); 46 | } 47 | 48 | @Override 49 | public ImageDescriptor getCXXImageDescriptor() { 50 | return imageRegistry.get(IMG_CXXFILE); 51 | } 52 | 53 | @Override 54 | public ImageDescriptor getHeaderImageDescriptor() { 55 | return imageRegistry.get(IMG_HFILE); 56 | } 57 | 58 | @Override 59 | public boolean isEnabled(IProject project) { 60 | return cLanguageServerProvider != null ? cLanguageServerProvider.isEnabledFor(project) : false; 61 | } 62 | 63 | private final void declareRegistryImage(String key, String path) { 64 | ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); 65 | Bundle bundle = Platform.getBundle(LspPlugin.PLUGIN_ID); 66 | URL url = null; 67 | if (bundle != null) { 68 | url = FileLocator.find(bundle, new Path(path), null); 69 | if (url != null) { 70 | desc = ImageDescriptor.createFromURL(url); 71 | } 72 | } 73 | imageRegistry.put(key, desc); 74 | } 75 | } 76 | --------------------------------------------------------------------------------