dbalek commented on a change in pull request #2812: URL: https://github.com/apache/netbeans/pull/2812#discussion_r601681194
########## File path: ide/api.lsp/src/org/netbeans/api/lsp/Completion.java ########## @@ -0,0 +1,405 @@ +/* + * 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.api.lsp; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import javax.swing.text.Document; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.editor.mimelookup.MimePath; +import org.netbeans.lib.editor.util.swing.DocumentUtilities; +import org.netbeans.modules.lsp.CompletionAccessor; +import org.netbeans.spi.lsp.CompletionCollector; + +/** + * Represents a completion proposal. + * + * @author Dusan Balek + */ +public final class Completion { + + static { + CompletionAccessor.setDefault(new CompletionAccessor() { + @Override + public Completion createCompletion(String label, Kind kind, List<Tag> tags, CompletableFuture<String> detail, CompletableFuture<String> documentation, + boolean preselect, String sortText, String filterText, String insertText, TextFormat insertTextFormat, TextEdit textEdit, CompletableFuture<List<TextEdit>> additionalTextEdits, + List<Character> commitCharacters, Command command) { + return new Completion(label, kind, tags, detail, documentation, preselect, sortText, filterText, insertText, insertTextFormat, textEdit, additionalTextEdits, commitCharacters, command); + } + }); + } + + private final String label; + private final Kind kind; + private final List<Tag> tags; + private final CompletableFuture<String> detail; + private final CompletableFuture<String> documentation; + private final boolean preselect; + private final String sortText; + private final String filterText; + private final String insertText; + private final TextFormat insertTextFormat; + private final TextEdit textEdit; + private final CompletableFuture<List<TextEdit>> additionalTextEdits; + private final List<Character> commitCharacters; + private final Command command; + + private Completion(String label, Kind kind, List<Tag> tags, CompletableFuture<String> detail, CompletableFuture<String> documentation, + boolean preselect, String sortText, String filterText, String insertText, TextFormat insertTextFormat, + TextEdit textEdit, CompletableFuture<List<TextEdit>> additionalTextEdits, List<Character> commitCharacters, Command command) { + this.label = label; + this.kind = kind; + this.tags = tags; + this.detail = detail; + this.documentation = documentation; + this.preselect = preselect; + this.sortText = sortText; + this.filterText = filterText; + this.insertText = insertText; + this.insertTextFormat = insertTextFormat; + this.textEdit = textEdit; + this.additionalTextEdits = additionalTextEdits; + this.commitCharacters = commitCharacters; + this.command = command; + } + + /** + * The label of this completion. By default also the text that is inserted + * when selecting this completion. + */ + @NonNull + public String getLabel() { + return label; + } + + /** + * The kind of this completion. + */ + @CheckForNull + public Kind getKind() { + return kind; + } + + /** + * Tags for this completion. + */ + @CheckForNull + public List<Tag> getTags() { + return tags != null ? Collections.unmodifiableList(tags) : null; Review comment: OK -- 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. 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
