use of com.redhat.qute.project.QuteProjectRegistry in project quarkus-ls by redhat-developer.
the class QuteAssert method testCompletionFor.
public static void testCompletionFor(String value, boolean snippetSupport, String fileUri, String templateId, String projectUri, String templateBaseDir, Integer expectedCount, CompletionItem... expectedItems) throws Exception {
int offset = value.indexOf('|');
value = value.substring(0, offset) + value.substring(offset + 1);
QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
template.setTemplateId(templateId);
Position position = template.positionAt(offset);
// Add snippet support for completion
QuteCompletionSettings completionSettings = new QuteCompletionSettings();
CompletionItemCapabilities completionItemCapabilities = new CompletionItemCapabilities();
completionItemCapabilities.setSnippetSupport(snippetSupport);
CompletionCapabilities completionCapabilities = new CompletionCapabilities(completionItemCapabilities);
completionSettings.setCapabilities(completionCapabilities);
QuteFormattingSettings formattingSettings = new QuteFormattingSettings();
QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
CompletionList list = languageService.doComplete(template, position, completionSettings, formattingSettings, () -> {
}).get();
// no duplicate labels
List<String> labels = list.getItems().stream().map(i -> i.getLabel()).sorted().collect(Collectors.toList());
String previous = null;
for (String label : labels) {
if (expectedCount != null) {
continue;
}
assertNotEquals(previous, label, () -> {
return "Duplicate label " + label + " in " + labels.stream().collect(Collectors.joining(",")) + "}";
});
previous = label;
}
if (expectedCount != null) {
assertEquals(expectedCount.intValue(), list.getItems().size());
}
if (expectedItems != null) {
for (CompletionItem item : expectedItems) {
assertCompletion(list, item, expectedCount);
}
}
}
use of com.redhat.qute.project.QuteProjectRegistry in project quarkus-ls by redhat-developer.
the class QuteAssert method testCodeLensFor.
private static void testCodeLensFor(String value, String fileUri, String templateId, String projectUri, String templateBaseDir, CodeLens... expected) throws Exception {
QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
template.setTemplateId(templateId);
QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
SharedSettings sharedSettings = new SharedSettings();
CommandCapabilities commandCapabilities = new CommandCapabilities();
CommandKindCapabilities kinds = new CommandKindCapabilities(Arrays.asList(QuteClientCommandConstants.COMMAND_JAVA_DEFINITION));
commandCapabilities.setCommandKind(kinds);
sharedSettings.getCommandCapabilities().setCapabilities(commandCapabilities);
List<? extends CodeLens> actual = languageService.getCodeLens(template, sharedSettings, () -> {
}).get();
assertCodeLens(actual, expected);
}
Aggregations