|
| 1 | +--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java |
| 2 | ++++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java |
| 3 | +@@ -19,6 +19,7 @@ |
| 4 | + package org.netbeans.modules.java.lsp.server.protocol; |
| 5 | + |
| 6 | + import com.google.gson.Gson; |
| 7 | ++import com.google.gson.JsonArray; |
| 8 | + import com.google.gson.JsonElement; |
| 9 | + import com.google.gson.JsonObject; |
| 10 | + import com.google.gson.JsonPrimitive; |
| 11 | +@@ -292,6 +293,8 @@ |
| 12 | + private static final String NETBEANS_JAVADOC_LOAD_TIMEOUT = "javadoc.load.timeout";// NOI18N |
| 13 | + private static final String NETBEANS_COMPLETION_WARNING_TIME = "completion.warning.time";// NOI18N |
| 14 | + private static final String NETBEANS_JAVA_ON_SAVE_ORGANIZE_IMPORTS = "java.onSave.organizeImports";// NOI18N |
| 15 | ++ private static final String NETBEANS_CODE_COMPLETION_COMMIT_CHARS = "java.completion.commit.chars";// NOI18N |
| 16 | ++ |
| 17 | + private static final String URL = "url";// NOI18N |
| 18 | + private static final String INDEX = "index";// NOI18N |
| 19 | + |
| 20 | +@@ -368,6 +371,7 @@ |
| 21 | + AtomicReference<Sampler> samplerRef = new AtomicReference<>(); |
| 22 | + AtomicLong samplingStart = new AtomicLong(); |
| 23 | + AtomicLong samplingWarningLength = new AtomicLong(DEFAULT_COMPLETION_WARNING_LENGTH); |
| 24 | ++ AtomicReference<List<String>> codeCompletionCommitChars = new AtomicReference<>(List.of()); |
| 25 | + long completionStart = System.currentTimeMillis(); |
| 26 | + COMPLETION_SAMPLER_WORKER.post(() -> { |
| 27 | + if (!done.get()) { |
| 28 | +@@ -412,7 +416,10 @@ |
| 29 | + ConfigurationItem completionWarningLength = new ConfigurationItem(); |
| 30 | + completionWarningLength.setScopeUri(uri); |
| 31 | + completionWarningLength.setSection(client.getNbCodeCapabilities().getConfigurationPrefix() + NETBEANS_COMPLETION_WARNING_TIME); |
| 32 | +- return client.configuration(new ConfigurationParams(Arrays.asList(conf, completionWarningLength))).thenApply(c -> { |
| 33 | ++ ConfigurationItem commitCharacterConfig = new ConfigurationItem(); |
| 34 | ++ commitCharacterConfig.setScopeUri(uri); |
| 35 | ++ commitCharacterConfig.setSection(client.getNbCodeCapabilities().getConfigurationPrefix() + NETBEANS_CODE_COMPLETION_COMMIT_CHARS); |
| 36 | ++ return client.configuration(new ConfigurationParams(Arrays.asList(conf, completionWarningLength, commitCharacterConfig))).thenApply(c -> { |
| 37 | + if (c != null && !c.isEmpty()) { |
| 38 | + if (c.get(0) instanceof JsonPrimitive) { |
| 39 | + JsonPrimitive javadocTimeSetting = (JsonPrimitive) c.get(0); |
| 40 | +@@ -424,7 +431,11 @@ |
| 41 | + |
| 42 | + samplingWarningLength.set(samplingWarningsLengthSetting.getAsLong()); |
| 43 | + } |
| 44 | ++ if(c.get(2) instanceof JsonArray){ |
| 45 | ++ JsonArray commitCharsJsonArray = (JsonArray) c.get(2); |
| 46 | ++ codeCompletionCommitChars.set(commitCharsJsonArray.asList().stream().map(ch -> ch.toString()).collect(Collectors.toList())); |
| 47 | + } |
| 48 | ++ } |
| 49 | + final int caret = Utils.getOffset(doc, params.getPosition()); |
| 50 | + List<CompletionItem> items = new ArrayList<>(); |
| 51 | + Completion.Context context = params.getContext() != null |
| 52 | +@@ -486,8 +497,8 @@ |
| 53 | + }).collect(Collectors.toList())); |
| 54 | + } |
| 55 | + } |
| 56 | +- if (completion.getCommitCharacters() != null) { |
| 57 | +- item.setCommitCharacters(completion.getCommitCharacters().stream().map(ch -> ch.toString()).collect(Collectors.toList())); |
| 58 | ++ if (codeCompletionCommitChars.get() != null) { |
| 59 | ++ item.setCommitCharacters(codeCompletionCommitChars.get()); |
| 60 | + } |
| 61 | + lastCompletions.add(completion); |
| 62 | + item.setData(new CompletionData(uri, index.getAndIncrement())); |
0 commit comments