Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content assist breaks when using multiline strings #1811

Closed
maxandersen opened this issue Feb 19, 2021 · 2 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1819
Closed

content assist breaks when using multiline strings #1811

maxandersen opened this issue Feb 19, 2021 · 2 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1819

Comments

@maxandersen
Copy link
Contributor

Enable Java 15, use multiline strings and content assist does not work.

This works:

        em.createNativeQuery("whatever").|

This does not:

        em.createNativeQuery("""
            SELECT first_name, last_name, count(*) films
            FROM actor AS a
            JOIN film_actor AS fa USING (actor_id)
            GROUP BY actor_id, first_name, last_name
            ORDER BY films DESC
            LIMIT 1;
        """).|
Environment
  • Operating System: OSX
  • JDK version: Java 15
  • Visual Studio Code version: vscodium 1.53.2
  • Java extension version: v0.75.0
Steps To Reproduce

here is a jbang example, look for em.createNativeQuery and try content assist.

///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 15
//  Update the Quarkus version to what you want here or run jbang with
// `-Dquarkus.version=<version>` to override it.
//DEPS io.quarkus:quarkus-bom:${quarkus.version:1.11.3.Final}@pom
//DEPS io.quarkus:quarkus-picocli
//DEPS io.quarkus:quarkus-hibernate-orm-panache
//DEPS io.quarkus:quarkus-jdbc-postgresql
//DEPS org.postgresql:postgresql:42.2.14
//DEPS org.testcontainers:postgresql:1.15.2
//DEPS io.quarkus:quarkus-hibernate-orm

//Q:CONFIG quarkus.banner.enabled=false
//Q:CONFIG quarkus.log.level=INFO
//Q:CONFIG quarkus.hibernate-orm.log.sql=true
//Q:CONFIG quarkus.hibernate-orm.log.format-sql=true
//Q:CONFIG quarkus.datasource.db-kind=postgresql
//Q:CONFIG quarkus.datasource.username=postgres
//Q:CONFIG quarkus.datasource.password=sakila
//Q:CONFIG quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/sakila
//SOURCES *.java

import java.sql.Date;
import java.util.Arrays;
import java.util.stream.Stream;

import javax.enterprise.context.Dependent;
import javax.enterprise.context.control.ActivateRequestContext;
import javax.inject.Inject;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.transaction.Transactional;

import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import picocli.CommandLine;

@CommandLine.Command
@QuarkusMain
public class db implements Runnable, QuarkusApplication {

    @CommandLine.Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
    String name;

    @Inject
    CommandLine.IFactory factory;

    private final GreetingService greetingService;

    public db(GreetingService greetingService) {
        this.greetingService = greetingService;
    }

    @Override
    public int run(String... args) {
        return new CommandLine(this, factory).execute(args);
    }

    @Override
    @ActivateRequestContext
    @Transactional
    public void run() {
        greetingService.sayHello(name);
    }

    @Entity
    @Table(name = "actor")
    static public class Actor extends PanacheEntityBase {
        @Id
        public long actor_id;

        public String first_name;
        public String last_name;
        public Date last_update;

        @Override
        public String toString() {
            return actor_id + ": " + first_name + " " + last_name;
        }
    }
}

@Dependent
class GreetingService {

    @Inject
    EntityManager em;

    @SuppressWarnings("unchecked") // here as we are dealing with non-type-safe streams
    void sayHello(String name) {
        System.out.println("Hello " + name + "!");
        
        db.Actor.listAll().forEach(System.out::println);
        em.createNativeQuery("select * from Actor").getResultStream()
                .forEach(x -> System.out.println(Arrays.toString((Object[]) x)));
        
        em.createNativeQuery("""
            SELECT first_name, last_name, count(*) films
            FROM actor AS a
            JOIN film_actor AS fa USING (actor_id)
            GROUP BY actor_id, first_name, last_name
            ORDER BY films DESC
            LIMIT 1;
        """);
        
    }
}
Current Result

content assist only show text options, not typed java.

Expected Result

content assist should show proper typed java.

@snjeza
Copy link
Contributor

snjeza commented Feb 20, 2021

This is an upstream issue - https://bugs.eclipse.org/bugs/show_bug.cgi?id=553097

@fbricon
Copy link
Collaborator

fbricon commented Jul 19, 2021

@rgrunber @snjeza upstream issue has been fixed today, please update the jdt.ls TP once it's published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants