Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cpplite/cpplite.editor/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<license ref="MIT-cpp-textmate-grammars" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/jeff-hykin/cpp-textmate-grammar</comment>
</fileset>
<fileset>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/language-configuration.json</file>
<license ref="MIT-vscode" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/microsoft/vscode/blob/main/extensions/cpp/language-configuration.json</comment>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • What's the relation between TextMate grammar and this language configuration?
  • Couldn't both these files be consumed by @GrammarRegistration?
  • e.g. add an optional languageConfiguration attribute to @GrammarRegistration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the language configuration and grammars are independent (after all, they are two independent files). I admit that in practice, it is hard to image a language configuration for a language with a non-Textmate lexer lexer, so, in practice, these are likely to be used together.

I am, however, not convinced that putting "language configuration" into "GrammarRegistration" is appropriate: the language configuration is not really a grammar, and it is certainly not a place where I would look for the registration of the language configuration.

</fileset>
<fileset>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/CCSrcIcon.gif</file>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/HDataIcon.gif</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json", mimeType=MIMETypes.C)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.C)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice API.

public class CDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json", mimeType=MIMETypes.CPP)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.CPP)
public class CPPDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json", mimeType=MIMETypes.H)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.H)
public class HDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json", mimeType=MIMETypes.HPP)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.HPP)
public class HPPDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"comments": {
"lineComment": "//",
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{
"open": "[",
"close": "]"
},
{
"open": "{",
"close": "}"
},
{
"open": "(",
"close": ")"
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "/*",
"close": "*/",
"notIn": [
"string",
"comment"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"<",
">"
]
],
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
"folding": {
"markers": {
"start": "^\\s*#\\s*pragma\\s+region\\b",
"end": "^\\s*#\\s*pragma\\s+endregion\\b"
}
},
"indentationRules": {
"decreaseIndentPattern": {
"pattern": "^\\s*[\\}\\]\\)].*$"
},
"increaseIndentPattern": {
"pattern": "^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"
},
},
"onEnterRules": [
{
// Decrease indentation after single line if/else if/else, for, or while
"previousLineText": "^\\s*(((else ?)?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$",
// But make sure line doesn't have braces or is not another if statement
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
"action": {
"indent": "outdent"
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": "^\\s*//\\s*\\S|\\s//\\s+\\S",
"afterText": "^(?!\\s*$)",
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
under the License.

-->
<project basedir="." default="build" name="enterprise/libs.jackson">
<project basedir="." default="build" name="ide/libs.jackson">
<import file="../../nbbuild/templates/projectized.xml"/>
</project>
File renamed without changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the module was already in the enterprise cluster:

nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-annotations-2.17.2.jar         Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-core-2.17.2.jar                Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-databind-2.17.2.jar            Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-dataformat-cbor-2.17.2.jar     Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-dataformat-yaml-2.17.2.jar     Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-datatype-jsr310-2.17.2.jar     Apache-2.0
nbbuild/netbeans/LICENSE:enterprise/modules/ext/jackson/jackson-module-jaxb-annotations-2.17.2.jar Apache-2.0

moving it to ide causes no harm...

File renamed without changes.
17 changes: 16 additions & 1 deletion ide/lsp.client/apichanges.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@
under the License.

-->
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../../nbbuild/javadoctools/apichanges.dtd">
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.1//EN" "../../nbbuild/javadoctools/apichanges-1.1.dtd">
<apichanges>
<apidefs>
<apidef name="lsp_client">LSP Client API</apidef>
</apidefs>
<changes>
<change id="LanguageConfigurationJSON">
<api name="lsp_client" />
<summary>Adding LanguageIdProvider</summary>
<version major="0" minor="1.38" />
<date day="2" month="11" year="2026" />
<author login="jlahoda" />
<compatibility addition="yes" binary="compatible" source="compatible" />
<description>
<p>
Basic support for language-configuration.json added.
</p>
</description>
<class name="LanguageFeatures" package="org.netbeans.modules.lsp.client.api"/>
<class name="LanguageConfiguration" package="org.netbeans.modules.lsp.client.spi"/>
</change>
<change id="LanguageIdProvider">
<api name="lsp_client" />
<summary>Adding LanguageIdProvider</summary>
Expand Down
5 changes: 5 additions & 0 deletions ide/lsp.client/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@
<license ref="Apache-2.0-ASF" />
<comment type="COMMENT_UNSUPPORTED" />
</fileset>
<fileset>
<file>test/unit/src/org/netbeans/modules/lsp/client/bindings/configuration/c.tmLanguage.json</file>
<license ref="MIT-cpp-textmate-grammars" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/jeff-hykin/cpp-textmate-grammar</comment>
</fileset>
</licenseinfo>
3 changes: 2 additions & 1 deletion ide/lsp.client/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml

@jtulach jtulach Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am always glad, when a module with an API offers apichanges.xml and they are actually used. It helps to run ant javadoc and read thru the result.

release.external/org.eclipse.lsp4j-0.24.0.jar=modules/ext/org.eclipse.lsp4j-0.24.0.jar
release.external/org.eclipse.lsp4j.generator-0.24.0.jar=modules/ext/org.eclipse.lsp4j.generator-0.24.0.jar
release.external/org.eclipse.lsp4j.jsonrpc-0.24.0.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.24.0.jar
Expand All @@ -26,4 +27,4 @@ release.external/org.eclipse.lsp4j.jsonrpc.debug-0.24.0.jar=modules/ext/org.ecli
release.external/org.eclipse.xtend.lib-2.32.0.jar=modules/ext/org.eclipse.xtend.lib-2.32.0.jar
release.external/org.eclipse.xtend.lib.macro-2.32.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.32.0.jar
release.external/org.eclipse.xtext.xbase.lib-2.32.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.32.0.jar
spec.version.base=1.37.0
spec.version.base=1.38.0
22 changes: 22 additions & 0 deletions ide/lsp.client/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.jackson</code-name-base>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can already see:

  • ide/c.google.gson
  • libs.json_simple

I assume both the existing libraries could parse the JSON as well. What's your motivation to add Jackson?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, unfortunately, the real-world language configurations (at least the C/C++ one) contain things like comments:
https://github.com/microsoft/vscode/blob/1306698e328e5e531f5e632301d30020aa994eff/extensions/cpp/language-configuration.json#L110

or trailing commas in object definitions:
https://github.com/microsoft/vscode/blob/1306698e328e5e531f5e632301d30020aa994eff/extensions/cpp/language-configuration.json#L106

Given the goal here is to be able to use the unmodified language configuration files, we need a parser that can tolerate both of these, and I believe Gson cannot be configured to tolerate the trailing commas, and the simple json does not tolerate the comments (although I admit I didn't know about the simple json). Jackson can be configured to tolerate both of these misbehaviors.

<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor</code-name-base>
<build-prerequisite/>
Expand All @@ -111,6 +119,15 @@
<specification-version>1.90</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.bracesmatching</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>0</release-version>
<specification-version>1.72</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.breadcrumbs</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -445,6 +462,10 @@
<recursive/>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.lexer.nbbridge</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.masterfs</code-name-base>
<compile-dependency/>
Expand Down Expand Up @@ -474,6 +495,7 @@
</test-type>
</test-dependencies>
<public-packages>
<package>org.netbeans.modules.lsp.client.api</package>
<package>org.netbeans.modules.lsp.client.debugger.api</package>
<package>org.netbeans.modules.lsp.client.debugger.spi</package>
<package>org.netbeans.modules.lsp.client.spi</package>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.lsp.client.api;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;

/**Register a {@code language-configuration.json} for a given mime type.
*
* Will also register language features defined in {@link LanguageFeatures}
* as appropriate.
*
* @since 1.38
*/
@Repeatable(LanguageConfigurationRegistrations.class)
@Target({ElementType.PACKAGE, ElementType.TYPE})
public @interface LanguageConfigurationRegistration {
/** The mime-type under which the grammar should be registered.
*
* @return mime-type
*/
public String mimeType();

/** The language configuration to register.
*
* @return language configuration
*/
public String languageConfiguration();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


}
Loading
Loading