Search in sources :

Example 1 with EnhancedSymbolInformation

use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.

the class SpringIndexer method extractSymbolInformation.

private void extractSymbolInformation(Annotation node, String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
    ITypeBinding typeBinding = node.resolveTypeBinding();
    if (typeBinding != null) {
        Collection<SymbolProvider> providers = symbolProviders.get(typeBinding);
        Collection<ITypeBinding> metaAnnotations = AnnotationHierarchies.getMetaAnnotations(typeBinding, symbolProviders::containsKey);
        if (!providers.isEmpty()) {
            TextDocument doc = getTempTextDocument(docURI, docRef, content);
            for (SymbolProvider provider : providers) {
                Collection<EnhancedSymbolInformation> sbls = provider.getSymbols(node, typeBinding, metaAnnotations, doc);
                if (sbls != null) {
                    sbls.forEach(enhancedSymbol -> {
                        symbols.add(enhancedSymbol.getSymbol());
                        symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(enhancedSymbol.getSymbol());
                        if (enhancedSymbol.getAdditionalInformation() != null) {
                            addonInformation.addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                            addonInformationByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolAddOnInformation>()).addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                        }
                    });
                }
            }
        } else {
            SymbolInformation symbol = provideDefaultSymbol(node, docURI, docRef, content);
            if (symbol != null) {
                symbols.add(symbol);
                symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(symbol);
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) LoggerFactory(org.slf4j.LoggerFactory) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) FileASTRequestor(org.eclipse.jdt.core.dom.FileASTRequestor) ASTVisitor(org.eclipse.jdt.core.dom.ASTVisitor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Location(org.eclipse.lsp4j.Location) AnnotationHierarchyAwareLookup(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup) URI(java.net.URI) Path(java.nio.file.Path) ExceptionUtil(org.springframework.ide.vscode.commons.util.ExceptionUtil) Predicate(java.util.function.Predicate) SymbolAddOnInformation(org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) List(java.util.List) Stream(java.util.stream.Stream) ASTParser(org.eclipse.jdt.core.dom.ASTParser) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) AST(org.eclipse.jdt.core.dom.AST) Optional(java.util.Optional) SimpleWorkspaceService(org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService) SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) MarkerAnnotation(org.eclipse.jdt.core.dom.MarkerAnnotation) JavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder) SymbolKind(org.eclipse.lsp4j.SymbolKind) BootLanguageServerParams(org.springframework.ide.vscode.boot.BootLanguageServerParams) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) ProjectObserver(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) ImmutableList(com.google.common.collect.ImmutableList) Annotation(org.eclipse.jdt.core.dom.Annotation) AnnotationHierarchies(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies) UriUtil(org.springframework.ide.vscode.commons.util.UriUtil) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JavaCore(org.eclipse.jdt.core.JavaCore) Futures(org.springframework.ide.vscode.commons.util.Futures) FileUtils(org.apache.commons.io.FileUtils) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) File(java.io.File) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) Paths(java.nio.file.Paths) Collections(java.util.Collections) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) ArrayList(java.util.ArrayList) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)

Example 2 with EnhancedSymbolInformation

use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.

the class SpringIndexer method extractSymbolInformation.

private void extractSymbolInformation(TypeDeclaration typeDeclaration, String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
    Collection<SymbolProvider> providers = symbolProviders.getAll();
    if (!providers.isEmpty()) {
        TextDocument doc = getTempTextDocument(docURI, docRef, content);
        for (SymbolProvider provider : providers) {
            Collection<EnhancedSymbolInformation> sbls = provider.getSymbols(typeDeclaration, doc);
            if (sbls != null) {
                sbls.forEach(enhancedSymbol -> {
                    symbols.add(enhancedSymbol.getSymbol());
                    symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(enhancedSymbol.getSymbol());
                    if (enhancedSymbol.getAdditionalInformation() != null) {
                        addonInformation.addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                        addonInformationByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolAddOnInformation>()).addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                    }
                });
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) LoggerFactory(org.slf4j.LoggerFactory) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) FileASTRequestor(org.eclipse.jdt.core.dom.FileASTRequestor) ASTVisitor(org.eclipse.jdt.core.dom.ASTVisitor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Location(org.eclipse.lsp4j.Location) AnnotationHierarchyAwareLookup(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup) URI(java.net.URI) Path(java.nio.file.Path) ExceptionUtil(org.springframework.ide.vscode.commons.util.ExceptionUtil) Predicate(java.util.function.Predicate) SymbolAddOnInformation(org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) List(java.util.List) Stream(java.util.stream.Stream) ASTParser(org.eclipse.jdt.core.dom.ASTParser) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) AST(org.eclipse.jdt.core.dom.AST) Optional(java.util.Optional) SimpleWorkspaceService(org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService) SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) MarkerAnnotation(org.eclipse.jdt.core.dom.MarkerAnnotation) JavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder) SymbolKind(org.eclipse.lsp4j.SymbolKind) BootLanguageServerParams(org.springframework.ide.vscode.boot.BootLanguageServerParams) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) ProjectObserver(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) ImmutableList(com.google.common.collect.ImmutableList) Annotation(org.eclipse.jdt.core.dom.Annotation) AnnotationHierarchies(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies) UriUtil(org.springframework.ide.vscode.commons.util.UriUtil) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JavaCore(org.eclipse.jdt.core.JavaCore) Futures(org.springframework.ide.vscode.commons.util.Futures) FileUtils(org.apache.commons.io.FileUtils) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) File(java.io.File) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) Paths(java.nio.file.Paths) Collections(java.util.Collections) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) ArrayList(java.util.ArrayList) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)

Example 3 with EnhancedSymbolInformation

use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.

the class SpringIndexer method extractSymbolInformation.

private void extractSymbolInformation(MethodDeclaration methodDeclaration, String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
    Collection<SymbolProvider> providers = symbolProviders.getAll();
    if (!providers.isEmpty()) {
        TextDocument doc = getTempTextDocument(docURI, docRef, content);
        for (SymbolProvider provider : providers) {
            Collection<EnhancedSymbolInformation> sbls = provider.getSymbols(methodDeclaration, doc);
            if (sbls != null) {
                sbls.forEach(enhancedSymbol -> {
                    symbols.add(enhancedSymbol.getSymbol());
                    symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(enhancedSymbol.getSymbol());
                    if (enhancedSymbol.getAdditionalInformation() != null) {
                        addonInformation.addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                        addonInformationByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolAddOnInformation>()).addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
                    }
                });
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) LoggerFactory(org.slf4j.LoggerFactory) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) FileASTRequestor(org.eclipse.jdt.core.dom.FileASTRequestor) ASTVisitor(org.eclipse.jdt.core.dom.ASTVisitor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Location(org.eclipse.lsp4j.Location) AnnotationHierarchyAwareLookup(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup) URI(java.net.URI) Path(java.nio.file.Path) ExceptionUtil(org.springframework.ide.vscode.commons.util.ExceptionUtil) Predicate(java.util.function.Predicate) SymbolAddOnInformation(org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) List(java.util.List) Stream(java.util.stream.Stream) ASTParser(org.eclipse.jdt.core.dom.ASTParser) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) AST(org.eclipse.jdt.core.dom.AST) Optional(java.util.Optional) SimpleWorkspaceService(org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService) SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) MarkerAnnotation(org.eclipse.jdt.core.dom.MarkerAnnotation) JavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder) SymbolKind(org.eclipse.lsp4j.SymbolKind) BootLanguageServerParams(org.springframework.ide.vscode.boot.BootLanguageServerParams) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) ProjectObserver(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) ImmutableList(com.google.common.collect.ImmutableList) Annotation(org.eclipse.jdt.core.dom.Annotation) AnnotationHierarchies(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies) UriUtil(org.springframework.ide.vscode.commons.util.UriUtil) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JavaCore(org.eclipse.jdt.core.JavaCore) Futures(org.springframework.ide.vscode.commons.util.Futures) FileUtils(org.apache.commons.io.FileUtils) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) File(java.io.File) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) Paths(java.nio.file.Paths) Collections(java.util.Collections) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) ArrayList(java.util.ArrayList) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)

Example 4 with EnhancedSymbolInformation

use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.

the class RouteUtils method createRouteSymbol.

public static EnhancedSymbolInformation createRouteSymbol(Location location, String path, String[] httpMethods, String[] contentTypes, String[] acceptTypes, SymbolAddOnInformation[] enhancedInformation) {
    if (path != null && path.length() > 0) {
        String label = "@" + (path.startsWith("/") ? path : ("/" + path));
        label += (httpMethods == null || httpMethods.length == 0 ? "" : " -- " + WebfluxUtils.getStringRep(httpMethods, string -> string));
        String acceptType = WebfluxUtils.getStringRep(acceptTypes, WebfluxUtils::getMediaType);
        label += acceptType != null ? " - Accept: " + acceptType : "";
        String contentType = WebfluxUtils.getStringRep(contentTypes, WebfluxUtils::getMediaType);
        label += contentType != null ? " - Content-Type: " + contentType : "";
        return new EnhancedSymbolInformation(new SymbolInformation(label, SymbolKind.Interface, location), enhancedInformation);
    } else {
        return null;
    }
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)

Example 5 with EnhancedSymbolInformation

use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.

the class ComponentSymbolProvider method createSymbol.

protected EnhancedSymbolInformation createSymbol(Annotation node, ITypeBinding annotationType, Collection<ITypeBinding> metaAnnotations, TextDocument doc) throws BadLocationException {
    String annotationTypeName = annotationType.getName();
    Collection<String> metaAnnotationNames = metaAnnotations.stream().map(ITypeBinding::getName).collect(Collectors.toList());
    String beanName = getBeanName(node);
    String beanType = getBeanType(node);
    SymbolInformation symbol = new SymbolInformation(beanLabel("+", annotationTypeName, metaAnnotationNames, beanName, beanType), SymbolKind.Interface, new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength())));
    return new EnhancedSymbolInformation(symbol, null);
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) Location(org.eclipse.lsp4j.Location)

Aggregations

EnhancedSymbolInformation (org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)8 Location (org.eclipse.lsp4j.Location)6 SymbolInformation (org.eclipse.lsp4j.SymbolInformation)6 ImmutableList (com.google.common.collect.ImmutableList)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Collection (java.util.Collection)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Stream (java.util.stream.Stream)4 ASTVisitor (org.eclipse.jdt.core.dom.ASTVisitor)4 Annotation (org.eclipse.jdt.core.dom.Annotation)4 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)4 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)4 NormalAnnotation (org.eclipse.jdt.core.dom.NormalAnnotation)4 SingleMemberAnnotation (org.eclipse.jdt.core.dom.SingleMemberAnnotation)4 TypeDeclaration (org.eclipse.jdt.core.dom.TypeDeclaration)4 File (java.io.File)3 URI (java.net.URI)3 Files (java.nio.file.Files)3