use of org.springframework.ide.vscode.commons.util.text.IDocument in project sts4 by spring-projects.
the class BootPropertiesLanguageServerComponents method getHoverProvider.
@Override
public HoverHandler getHoverProvider() {
HoverInfoProvider propertiesHovers = new PropertiesHoverInfoProvider(indexProvider, typeUtilProvider, javaProjectFinder);
HoverInfoProvider ymlHovers = new YamlHoverInfoProvider(parser, yamlStructureProvider, yamlAssistContextProvider);
HoverInfoProvider combined = (IDocument document, int offset) -> {
String uri = document.getUri();
if (uri != null) {
if (uri.endsWith(PROPERTIES)) {
return propertiesHovers.getHoverInfo(document, offset);
} else if (uri.endsWith(YML)) {
return ymlHovers.getHoverInfo(document, offset);
}
}
return null;
};
return new VscodeHoverEngineAdapter(server, combined);
}
use of org.springframework.ide.vscode.commons.util.text.IDocument in project sts4 by spring-projects.
the class ApplicationYamlASTReconciler method valueParseError.
private void valueParseError(YamlFileAST root, ScalarNode scalar, ValueParseException e) {
IDocument doc = root.getDocument();
DocumentRegion containingRegion = new DocumentRegion(doc, scalar.getStartMark().getIndex(), scalar.getEndMark().getIndex());
problems.accept(problem(ApplicationYamlProblemType.YAML_VALUE_TYPE_MISMATCH, e.getHighlightRegion(containingRegion), ExceptionUtil.getMessage(e)));
}
use of org.springframework.ide.vscode.commons.util.text.IDocument in project sts4 by spring-projects.
the class JavaSnippetBuilder method createEdit.
public DocumentEdits createEdit(DocumentRegion query, String template) {
IDocument doc = query.getDocument();
IndentUtil indentUtil = new IndentUtil(doc);
DocumentEdits edit = new DocumentEdits(doc);
String snippet = createSnippet(template);
String referenceIndent = indentUtil.getReferenceIndent(query.getStart(), doc);
if (!referenceIndent.contains("\t")) {
snippet = indentUtil.covertTabsToSpace(snippet);
}
String indentedSnippet = indentUtil.applyIndentation(snippet, referenceIndent);
edit.replace(query.getStart(), query.getEnd(), indentedSnippet);
return edit;
}
use of org.springframework.ide.vscode.commons.util.text.IDocument in project sts4 by spring-projects.
the class BootJavaReferencesHandler method getClasspathEntries.
private String[] getClasspathEntries(IDocument doc) throws Exception {
IJavaProject project = this.projectFinder.find(new TextDocumentIdentifier(doc.getUri())).get();
IClasspath classpath = project.getClasspath();
Stream<Path> classpathEntries = classpath.getClasspathEntries().stream();
return classpathEntries.filter(path -> path.toFile().exists()).map(path -> path.toAbsolutePath().toString()).toArray(String[]::new);
}
use of org.springframework.ide.vscode.commons.util.text.IDocument in project sts4 by spring-projects.
the class ConcourseModel method getResourceTypeNameHints.
public Collection<YValueHint> getResourceTypeNameHints(DynamicSchemaContext dc) {
IDocument doc = dc.getDocument();
Multiset<String> userDefined = getStringsFromAst(doc, RESOURCE_TYPE_NAMES_PATH);
if (userDefined != null) {
Builder<YValueHint> builder = ImmutableMultiset.builder();
builder.addAll(YTypeFactory.hints(userDefined));
builder.addAll(Arrays.stream(PipelineYmlSchema.BUILT_IN_RESOURCE_TYPES).map(h -> addExtraInsertion(h, dc)).collect(Collectors.toList()));
return builder.build();
}
return null;
}
Aggregations