Search in sources :

Example 1 with IDocument

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);
}
Also used : PropertiesHoverInfoProvider(org.springframework.ide.vscode.boot.properties.hover.PropertiesHoverInfoProvider) YamlHoverInfoProvider(org.springframework.ide.vscode.commons.yaml.hover.YamlHoverInfoProvider) HoverInfoProvider(org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider) PropertiesHoverInfoProvider(org.springframework.ide.vscode.boot.properties.hover.PropertiesHoverInfoProvider) YamlHoverInfoProvider(org.springframework.ide.vscode.commons.yaml.hover.YamlHoverInfoProvider) IDocument(org.springframework.ide.vscode.commons.util.text.IDocument) VscodeHoverEngineAdapter(org.springframework.ide.vscode.commons.languageserver.hover.VscodeHoverEngineAdapter)

Example 2 with IDocument

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)));
}
Also used : DocumentRegion(org.springframework.ide.vscode.commons.util.text.DocumentRegion) IDocument(org.springframework.ide.vscode.commons.util.text.IDocument)

Example 3 with IDocument

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;
}
Also used : DocumentEdits(org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits) IndentUtil(org.springframework.ide.vscode.commons.languageserver.completion.IndentUtil) IDocument(org.springframework.ide.vscode.commons.util.text.IDocument)

Example 4 with IDocument

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);
}
Also used : Path(java.nio.file.Path) ASTNode(org.eclipse.jdt.core.dom.ASTNode) SimpleTextDocumentService(org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) IDocument(org.springframework.ide.vscode.commons.util.text.IDocument) JavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) JavaCore(org.eclipse.jdt.core.JavaCore) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) List(java.util.List) Stream(java.util.stream.Stream) ASTParser(org.eclipse.jdt.core.dom.ASTParser) Annotation(org.eclipse.jdt.core.dom.Annotation) ReferencesHandler(org.springframework.ide.vscode.commons.languageserver.util.ReferencesHandler) Map(java.util.Map) AST(org.eclipse.jdt.core.dom.AST) Location(org.eclipse.lsp4j.Location) Path(java.nio.file.Path) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) ReferenceParams(org.eclipse.lsp4j.ReferenceParams) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath)

Example 5 with IDocument

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;
}
Also used : IDocument(org.springframework.ide.vscode.commons.util.text.IDocument) BasicYValueHint(org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint) YValueHint(org.springframework.ide.vscode.commons.yaml.schema.YValueHint)

Aggregations

IDocument (org.springframework.ide.vscode.commons.util.text.IDocument)5 Path (java.nio.file.Path)1 List (java.util.List)1 Map (java.util.Map)1 Stream (java.util.stream.Stream)1 JavaCore (org.eclipse.jdt.core.JavaCore)1 AST (org.eclipse.jdt.core.dom.AST)1 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1 ASTParser (org.eclipse.jdt.core.dom.ASTParser)1 Annotation (org.eclipse.jdt.core.dom.Annotation)1 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)1 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)1 NodeFinder (org.eclipse.jdt.core.dom.NodeFinder)1 Location (org.eclipse.lsp4j.Location)1 ReferenceParams (org.eclipse.lsp4j.ReferenceParams)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 PropertiesHoverInfoProvider (org.springframework.ide.vscode.boot.properties.hover.PropertiesHoverInfoProvider)1 IClasspath (org.springframework.ide.vscode.commons.java.IClasspath)1 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)1 DocumentEdits (org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits)1