PT #164842647: Boot properties proposals in parallel
This commit is contained in:
@@ -18,7 +18,6 @@ import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -87,11 +86,11 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
return typeCache.get(fqName, () -> {
|
||||
JavaDataParams params = new JavaDataParams(projectUri.toString(), "L" + fqName.replace('.', '/') + ";", false);
|
||||
try {
|
||||
TypeData data = client.javaType(params).get(500, TimeUnit.MILLISECONDS);
|
||||
TypeData data = client.javaType(params).get();
|
||||
if (data != null) {
|
||||
return Optional.ofNullable(toType(data));
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("", e);
|
||||
}
|
||||
return Optional.empty();
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.hints.HintProvider;
|
||||
@@ -45,7 +47,6 @@ import org.springframework.ide.vscode.commons.util.CollectionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap.Match;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMatcher;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.java.properties.antlr.parser.AntlrParser;
|
||||
@@ -59,6 +60,8 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PropertiesCompletionProposalsCalculator {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PropertiesCompletionProposalsCalculator.class);
|
||||
|
||||
private static final PrefixFinder valuePrefixFinder = new PrefixFinder() {
|
||||
@Override
|
||||
protected boolean isPrefixChar(char c) {
|
||||
@@ -160,7 +163,7 @@ public class PropertiesCompletionProposalsCalculator {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
log.error("{}", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -219,7 +222,7 @@ public class PropertiesCompletionProposalsCalculator {
|
||||
//TODO: other cases ']' or '[' ?
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
log.error("{}", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -334,7 +337,7 @@ public class PropertiesCompletionProposalsCalculator {
|
||||
Collection<Match<PropertyInfo>> matches = findMatches(prefix);
|
||||
if (matches!=null && !matches.isEmpty()) {
|
||||
ArrayList<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(matches.size());
|
||||
for (final Match<PropertyInfo> match : matches) {
|
||||
matches.parallelStream().forEach(match -> {
|
||||
DocumentEdits docEdits;
|
||||
try {
|
||||
docEdits = LazyProposalApplier.from(() -> {
|
||||
@@ -345,15 +348,17 @@ public class PropertiesCompletionProposalsCalculator {
|
||||
edits.insert(offset, match.data.getId() + propertyCompletionPostfix(typeUtil, type));
|
||||
return edits;
|
||||
} catch (Throwable t) {
|
||||
Log.log(t);
|
||||
log.error("{}", t);
|
||||
return new DocumentEdits(doc);
|
||||
}
|
||||
});
|
||||
proposals.add(completionFactory.property(doc, docEdits, match, typeUtil));
|
||||
synchronized (proposals) {
|
||||
proposals.add(completionFactory.property(doc, docEdits, match, typeUtil));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.log(e);
|
||||
log.error("{}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return proposals;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@ import org.springframework.ide.vscode.boot.common.InformationTemplates;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.metadata.IndexNavigator;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
@@ -446,16 +444,22 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
|
||||
Collection<Match<PropertyInfo>> matchingProps = indexNav.findMatching(query);
|
||||
if (!matchingProps.isEmpty()) {
|
||||
ArrayList<ICompletionProposal> completions = new ArrayList<ICompletionProposal>();
|
||||
for (Match<PropertyInfo> match : matchingProps) {
|
||||
DocumentEdits edits = createEdits(doc, node, offset, query, match);
|
||||
ScoreableProposal completion = completionFactory.property(
|
||||
doc.getDocument(), edits, match, typeUtil
|
||||
);
|
||||
if (getContextRoot(doc).exists(YamlPath.fromProperty(match.data.getId()))) {
|
||||
completion.deemphasize(DEEMP_EXISTS);
|
||||
matchingProps.parallelStream().forEach(match -> {
|
||||
try {
|
||||
DocumentEdits edits = createEdits(doc, node, offset, query, match);
|
||||
ScoreableProposal completion = completionFactory.property(
|
||||
doc.getDocument(), edits, match, typeUtil
|
||||
);
|
||||
if (getContextRoot(doc).exists(YamlPath.fromProperty(match.data.getId()))) {
|
||||
completion.deemphasize(DEEMP_EXISTS);
|
||||
}
|
||||
synchronized (completions) {
|
||||
completions.add(completion);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("{}", e);
|
||||
}
|
||||
completions.add(completion);
|
||||
}
|
||||
});
|
||||
return completions;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user