lahodaj commented on code in PR #9749: URL: https://github.com/apache/netbeans/pull/9749#discussion_r4434777314
########## 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: So, the `languageConfiguration` reads the content of the file, so it (currently) needs the `FileObject`. It is, of course, debatable whether the content shouldn't be specified indirectly using an attribute. And given there's already a method taking `FileObject`, it is, I think, better to keep some consistency across the methods, and use `FileObject` instead of `Map`. (For the methods that need neither the file nor the attributes, I opted for no arguments - that's not 100% consistent, but we have only two shapes of the methods, not 3. I would be open to add the parameter to improve the consistency, though.) For the return type, I believe that a) it doesn't really matter what the return type is; b) for `languageConfiguration`, I am not at this time convinced the type should be a public type; so I used `Object` for `languageConfiguration`. And, for consistency, it seems better to use the same return type everywhere. (Even not considering `languageConfiguration`, some of the methods here also return factories that don't really feel much useful as return types - like `org.netbeans.spi.editor.typinghooks.TypedTextInterceptor.Factory`.) -- 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
