-
Notifications
You must be signed in to change notification settings - Fork 13
[#394] Add clangd console view for log data #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c77046
[#394] Add clangd console view for log data
ghentschke 1cbf0e3
update api-baseline repo
ghentschke fc0bae9
Increase since tag in ICLanguageServerProvider2
ghentschke e8fcd34
Increase since tag in ClangFormatFile
ghentschke c526f77
close output stream
ghentschke f5b509c
hide Log to console in project preference page
ghentschke 9cb4178
add description to Log-to-console-checkbox tooltip
ghentschke a04cad5
clean up
ghentschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...lsp.clangd/OSGI-INF/org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults"> | ||
<service> | ||
<provide interface="org.eclipse.cdt.lsp.clangd.ClangdMetadata"/> | ||
<provide interface="org.eclipse.cdt.lsp.clangd.ClangdMetadata2"/> | ||
</service> | ||
<reference cardinality="1..1" field="defaults" interface="org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults" name="defaults"/> | ||
<reference cardinality="1..1" field="defaults" interface="org.eclipse.cdt.lsp.clangd.ClangdOptions2Defaults" name="defaults"/> | ||
<implementation class="org.eclipse.cdt.lsp.clangd.internal.config.ClangdMetadataDefaults"/> | ||
</scr:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdMetadata2.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.cdt.lsp.clangd; | ||
|
||
import org.eclipse.core.runtime.preferences.PreferenceMetadata; | ||
|
||
/** | ||
* @since 2.2 | ||
*/ | ||
public interface ClangdMetadata2 extends ClangdMetadata { | ||
|
||
/** | ||
* Returns the metadata for the "Log to Console" option, must not return <code>null</code>. | ||
* | ||
* @return the metadata for the "Log to Console" option | ||
* | ||
* @see ClangdOptions2#logToConsole() | ||
*/ | ||
PreferenceMetadata<Boolean> logToConsole(); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdOptions2.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.cdt.lsp.clangd; | ||
|
||
/** | ||
* @since 2.2 | ||
*/ | ||
public interface ClangdOptions2 extends ClangdOptions { | ||
|
||
/** | ||
* Enable logging to Clangd console | ||
* | ||
* @return true if clangd logging is enabled | ||
*/ | ||
boolean logToConsole(); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...les/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdOptions2Defaults.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.cdt.lsp.clangd; | ||
|
||
/** | ||
* @since 2.2 | ||
*/ | ||
public interface ClangdOptions2Defaults extends ClangdOptions2 { | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/console/ClangdConsole.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.cdt.lsp.clangd.console; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
import org.eclipse.cdt.lsp.server.ILogProvider; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.ui.console.ConsolePlugin; | ||
import org.eclipse.ui.console.IConsole; | ||
import org.eclipse.ui.console.IConsoleManager; | ||
import org.eclipse.ui.console.MessageConsole; | ||
|
||
public final class ClangdConsole implements ILogProvider { | ||
private static final String CLANGD_CONSOLE = "Clangd"; //$NON-NLS-1$ | ||
private OutputStream outputStream; | ||
|
||
@Override | ||
public OutputStream getOutputStream() { | ||
if (outputStream == null) { | ||
outputStream = findConsole().newOutputStream(); | ||
} | ||
return outputStream; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
if (outputStream != null) { | ||
try { | ||
outputStream.close(); | ||
outputStream = null; | ||
} catch (IOException e) { | ||
Platform.getLog(ClangdConsole.class).error(e.getMessage(), e); | ||
} | ||
} | ||
|
||
} | ||
|
||
private MessageConsole findConsole() { | ||
ConsolePlugin plugin = ConsolePlugin.getDefault(); | ||
IConsoleManager conMan = plugin.getConsoleManager(); | ||
for (IConsole existing : conMan.getConsoles()) { | ||
if (CLANGD_CONSOLE.equals(existing.getName())) | ||
return (MessageConsole) existing; | ||
} | ||
// no console found, so create a new one | ||
final var myConsole = new MessageConsole(CLANGD_CONSOLE, null); | ||
conMan.addConsoles(new IConsole[] { myConsole }); | ||
return myConsole; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this increment was necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise it hadn't build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very strange. Does this mean that we had this interface for 2.1 already and now we need to redeclare the same interface for 2.2 as well? Or do we have a baseline configuration issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it didn't build because of that:

I was wondering as well and hadn't had the time for further investigations.