jtulach commented on code in PR #9749:
URL: https://github.com/apache/netbeans/pull/9749#discussion_r4430680066


##########
ide/lsp.client/nbproject/project.properties:
##########
@@ -18,6 +18,7 @@
 javac.release=17
 javac.compilerargs=-Xlint -Xlint:-serial
 javadoc.arch=${basedir}/arch.xml
+javadoc.apichanges=${basedir}/apichanges.xml

Review Comment:
   I am always glad, when a module with an API offers `apichanges.xml`



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/api/LanguageFeatures.java:
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.io.IOException;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.BracesMatcherFactoryImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.ToggleCommentActionImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.TypingCompletionImpl.FactoryImpl;
+import org.netbeans.modules.lsp.client.options.GenericEditorKit;
+import org.netbeans.modules.lsp.client.spi.friend.LanguageConfiguration;
+import org.openide.filesystems.FileObject;
+
+/**
+ * Callbacks that can be put into the layer to enable various editor features
+ * driven by a {@code language-configuration.json} file.
+ *
+ * <p>Each method is a factory suitable for use as a layer
+ * {@code instanceCreate} target and should be registered under the
+ * {@code Editors/<mime-type>}/...} folder or an appropriate sub-folder.
+ *
+ * @since 1.38
+ */
+//javadoc partially by qwen3.8
+public class LanguageFeatures {

Review Comment:
   I assume this is a utility class and creating instances makes no sense:
   ```suggestion
   public final class LanguageFeatures {
       private LanguageFeatures() {}
   ```



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/api/LanguageFeatures.java:
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.io.IOException;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.BracesMatcherFactoryImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.ToggleCommentActionImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.TypingCompletionImpl.FactoryImpl;
+import org.netbeans.modules.lsp.client.options.GenericEditorKit;
+import org.netbeans.modules.lsp.client.spi.friend.LanguageConfiguration;
+import org.openide.filesystems.FileObject;
+
+/**
+ * Callbacks that can be put into the layer to enable various editor features
+ * driven by a {@code language-configuration.json} file.
+ *
+ * <p>Each method is a factory suitable for use as a layer
+ * {@code instanceCreate} target and should be registered under the
+ * {@code Editors/<mime-type>}/...} folder or an appropriate sub-folder.
+ *
+ * @since 1.38
+ */
+//javadoc partially by qwen3.8
+public class LanguageFeatures {
+
+    /**
+     * Creates a {@code GenericEditorKit} for the given MIME type.
+     *
+     * <p>Requires the {@code mimeType} attribute (String) on the registration
+     * file. If absent, {@code text/plain} is used as a fallback.
+     *
+     * <p>Sample registration:

Review Comment:
   Nice example to copy!



##########
ide/lsp.client/nbproject/project.xml:
##########
@@ -102,6 +102,14 @@
                         <specification-version>1.0</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.jackson</code-name-base>

Review Comment:
   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?
   
   



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/friend/LanguageConfiguration.java:
##########
@@ -0,0 +1,280 @@
+/*
+ * 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.spi.friend;

Review Comment:
   ### "friend"!?
   
   - it is technically hard to have public and friend API in the same module
      - you cannot version them independently
      - you should probably treat it with the same stability as the other APIs
   - who's the friend?
      - I don't see this class being used from any other module than 
`lsp.client`
   - some justification why the class exists in a so weird package is needed



##########
cpplite/cpplite.editor/licenseinfo.xml:
##########
@@ -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>

Review Comment:
   - Do we have such a file also for Kotlin?
   - e.g. could it accompany  or replace
   - 
https://github.com/apache/netbeans/blob/e337e53eeccd036f5cb14d0261413b59484a70df/java/kotlin.editor/src/org/netbeans/modules/kotlin/editor/KtDataObject.java#L39-L48



##########
cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CDataObject.java:
##########
@@ -115,6 +116,7 @@
     )
 })
 @GrammarRegistration(grammar="resources/c.tmLanguage.json", 
mimeType=MIMETypes.C)
+@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json",
 mimeType=MIMETypes.C)

Review Comment:
   Very nice API.



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/api/LanguageFeatures.java:
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.io.IOException;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.BracesMatcherFactoryImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.ToggleCommentActionImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.TypingCompletionImpl.FactoryImpl;
+import org.netbeans.modules.lsp.client.options.GenericEditorKit;
+import org.netbeans.modules.lsp.client.spi.friend.LanguageConfiguration;
+import org.openide.filesystems.FileObject;
+
+/**
+ * Callbacks that can be put into the layer to enable various editor features
+ * driven by a {@code language-configuration.json} file.
+ *
+ * <p>Each method is a factory suitable for use as a layer
+ * {@code instanceCreate} target and should be registered under the
+ * {@code Editors/<mime-type>}/...} folder or an appropriate sub-folder.
+ *
+ * @since 1.38
+ */
+//javadoc partially by qwen3.8
+public class LanguageFeatures {
+
+    /**
+     * Creates a {@code GenericEditorKit} for the given MIME type.
+     *
+     * <p>Requires the {@code mimeType} attribute (String) on the registration
+     * file. If absent, {@code text/plain} is used as a fallback.
+     *
+     * <p>Sample registration:
+     * {@snippet language="xml":
+     * <folder name="Editors">
+     *     <folder name="text">
+     *         <folder name="x-c++">
+     *             <file name="EditorKit.instance">
+     *                 <attr 
methodvalue="org.netbeans.modules.lsp.client.api.LanguageFeatures.editorKit" 
name="instanceCreate"/>
+     *                 <attr name="instanceOf" 
stringvalue="javax.swing.text.EditorKit"/>
+     *                 <attr name="mimeType" stringvalue="text/x-c++"/>
+     *             </file>
+     *         </folder>
+     *     </folder>
+     * </folder>
+     * }
+     *
+     * @param file the registration file, typically provided by the layer 
infrastructure.
+     * @return a {@link GenericEditorKit} configured for the specified MIME 
type.
+     */
+    public static Object editorKit(FileObject file) {

Review Comment:
   ```suggestion
       public static javax.swing.EditorKit editorKit(Map file) {
   ```
   - unless I am mistaken, you don't have to depend on `FileObject`. You can 
use plain `java.util.Map`. 
   - what about the return type? Should it really be `Object`? Isn't it better 
to provide some reasonable Java type?



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/api/LanguageFeatures.java:
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.io.IOException;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.BracesMatcherFactoryImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.ToggleCommentActionImpl;
+import 
org.netbeans.modules.lsp.client.bindings.configuration.TypingCompletionImpl.FactoryImpl;
+import org.netbeans.modules.lsp.client.options.GenericEditorKit;
+import org.netbeans.modules.lsp.client.spi.friend.LanguageConfiguration;
+import org.openide.filesystems.FileObject;
+
+/**
+ * Callbacks that can be put into the layer to enable various editor features
+ * driven by a {@code language-configuration.json} file.
+ *
+ * <p>Each method is a factory suitable for use as a layer
+ * {@code instanceCreate} target and should be registered under the
+ * {@code Editors/<mime-type>}/...} folder or an appropriate sub-folder.

Review Comment:
   The wording here, gives me some idea, but explicit examples to copy would be 
more helpful. Maybe I find them near each individual method?



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/friend/LanguageConfiguration.java:
##########
@@ -0,0 +1,280 @@
+/*
+ * 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.spi.friend;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.json.JsonReadFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.tm4e.core.internal.parser.PropertySettable.ArrayList;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+import org.openide.util.Exceptions;
+
+//based on the VS Code API's "LanguageConfiguration" (MIT)

Review Comment:
   - I don't get the purpose of this API class, but:
   - there is 
[lsp.api](https://bits.netbeans.org/dev/javadoc/org-netbeans-api-lsp/index.html)
 which may be a better API to expose _mirrors of VSCode_ API
   - am I off?



##########
cpplite/cpplite.editor/licenseinfo.xml:
##########
@@ -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>

Review Comment:
   - 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`?



##########
ide/libs.jackson/nbproject/project.xml:
##########


Review Comment:
   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...



##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/api/LanguageConfigurationRegistration.java:
##########
@@ -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();

Review Comment:
   - Wouldn't [merging this attribute into 
@GrammarRegistration](https://bits.netbeans.org/dev/javadoc/org-netbeans-modules-textmate-lexer/org/netbeans/modules/textmate/lexer/api/GrammarRegistration.html)
 be **easier to use**?
   



##########
nbbuild/build.properties:
##########
@@ -176,6 +176,7 @@ config.javadoc.forwarded.devel=\
     editor.lib,\
     editor,\
     lib.uihandler,\
+    lsp.client,\

Review Comment:
   I cannot find `lsp.client` at https://bits.netbeans.org/dev/javadoc/ right 
now. I assume this change is going to fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to