Search in sources :

Example 6 with JavaTypeInfo

use of com.redhat.qute.commons.JavaTypeInfo in project quarkus-ls by redhat-developer.

the class TemplateGetJavaTypeTest method item.

@Test
public void item() throws Exception {
    loadMavenProject(QuteMavenProjectName.qute_quickstart);
    QuteJavaTypesParams params = new QuteJavaTypesParams("Item", QuteMavenProjectName.qute_quickstart);
    List<JavaTypeInfo> actual = QuteSupportForTemplate.getInstance().getJavaTypes(params, getJDTUtils(), new NullProgressMonitor());
    assertJavaTypes(// 
    actual, // 
    t("org.acme.qute.Item", JavaTypeKind.Class), t("org.acme.qute.ItemResource", JavaTypeKind.Class));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QuteJavaTypesParams(com.redhat.qute.commons.QuteJavaTypesParams) JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo) Test(org.junit.Test)

Example 7 with JavaTypeInfo

use of com.redhat.qute.commons.JavaTypeInfo in project quarkus-ls by redhat-developer.

the class TemplateGetJavaTypeTest method assertJavaType.

/**
 * Assert Java type.
 *
 * @param actual   the actual java types.
 * @param expected the expected Java type.
 */
private static void assertJavaType(List<JavaTypeInfo> actualTypes, JavaTypeInfo expected) {
    List<JavaTypeInfo> matches = actualTypes.stream().filter(completion -> {
        return expected.getSignature().equals(completion.getSignature());
    }).collect(Collectors.toList());
    Assert.assertEquals(// 
    expected.getSignature() + " should only exist once: Actual: " + // 
    actualTypes.stream().map(c -> c.getSignature()).collect(Collectors.joining(",")), 1, matches.size());
    JavaTypeInfo actual = matches.get(0);
    Assert.assertEquals("Test 'type name' for '" + expected.getSignature() + "'", expected.getSignature(), actual.getSignature());
    Assert.assertEquals("Test 'kind' for '" + expected.getSignature() + "'", expected.getJavaElementKind(), actual.getJavaElementKind());
}
Also used : QuteSupportForTemplate(com.redhat.qute.jdt.QuteSupportForTemplate) QuteProjectTest.loadMavenProject(com.redhat.qute.jdt.QuteProjectTest.loadMavenProject) List(java.util.List) JavaTypeKind(com.redhat.qute.commons.JavaTypeKind) QuteProjectTest.getJDTUtils(com.redhat.qute.jdt.QuteProjectTest.getJDTUtils) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo) Test(org.junit.Test) QuteMavenProjectName(com.redhat.qute.jdt.QuteProjectTest.QuteMavenProjectName) Assert(org.junit.Assert) Collectors(java.util.stream.Collectors) QuteJavaTypesParams(com.redhat.qute.commons.QuteJavaTypesParams) JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo)

Example 8 with JavaTypeInfo

use of com.redhat.qute.commons.JavaTypeInfo in project quarkus-ls by redhat-developer.

the class TemplateGetJavaTypeTest method packages.

@Test
public void packages() throws Exception {
    loadMavenProject(QuteMavenProjectName.qute_quickstart);
    QuteJavaTypesParams params = new QuteJavaTypesParams("java.", QuteMavenProjectName.qute_quickstart);
    List<JavaTypeInfo> actual = QuteSupportForTemplate.getInstance().getJavaTypes(params, getJDTUtils(), new NullProgressMonitor());
    assertJavaTypes(// 
    actual, // 
    t("java.util", JavaTypeKind.Package), t("java.lang", JavaTypeKind.Package));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QuteJavaTypesParams(com.redhat.qute.commons.QuteJavaTypesParams) JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo) Test(org.junit.Test)

Example 9 with JavaTypeInfo

use of com.redhat.qute.commons.JavaTypeInfo in project quarkus-ls by redhat-developer.

the class TemplateGetJavaTypeTest method list.

@Test
public void list() throws Exception {
    loadMavenProject(QuteMavenProjectName.qute_quickstart);
    QuteJavaTypesParams params = new QuteJavaTypesParams("List", QuteMavenProjectName.qute_quickstart);
    List<JavaTypeInfo> actual = QuteSupportForTemplate.getInstance().getJavaTypes(params, getJDTUtils(), new NullProgressMonitor());
    assertJavaTypes(// 
    actual, t("java.util.List<E>", JavaTypeKind.Interface));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QuteJavaTypesParams(com.redhat.qute.commons.QuteJavaTypesParams) JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo) Test(org.junit.Test)

Example 10 with JavaTypeInfo

use of com.redhat.qute.commons.JavaTypeInfo in project quarkus-ls by redhat-developer.

the class TemplateGetJavaTypeTest method t.

public static JavaTypeInfo t(String typeName, JavaTypeKind kind) {
    JavaTypeInfo javaType = new JavaTypeInfo();
    javaType.setSignature(typeName);
    javaType.setKind(kind);
    return javaType;
}
Also used : JavaTypeInfo(com.redhat.qute.commons.JavaTypeInfo)

Aggregations

JavaTypeInfo (com.redhat.qute.commons.JavaTypeInfo)14 QuteJavaTypesParams (com.redhat.qute.commons.QuteJavaTypesParams)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)4 JavaMemberInfo (com.redhat.qute.commons.JavaMemberInfo)2 List (java.util.List)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 Range (org.eclipse.lsp4j.Range)2 InvalidMethodReason (com.redhat.qute.commons.InvalidMethodReason)1 JavaElementInfo (com.redhat.qute.commons.JavaElementInfo)1 JavaParameterInfo (com.redhat.qute.commons.JavaParameterInfo)1 JavaTypeKind (com.redhat.qute.commons.JavaTypeKind)1 QuteJavaDefinitionParams (com.redhat.qute.commons.QuteJavaDefinitionParams)1 NamespaceResolverInfo (com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)1 QuteMavenProjectName (com.redhat.qute.jdt.QuteProjectTest.QuteMavenProjectName)1 QuteProjectTest.getJDTUtils (com.redhat.qute.jdt.QuteProjectTest.getJDTUtils)1 QuteProjectTest.loadMavenProject (com.redhat.qute.jdt.QuteProjectTest.loadMavenProject)1 QuteSupportForTemplate (com.redhat.qute.jdt.QuteSupportForTemplate)1 ObjectPart (com.redhat.qute.parser.expression.ObjectPart)1