Search in sources :

Example 6 with InvalidMethodReason

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

the class TemplateGetResolvedJavaTypeTest method string.

@Test
public void string() throws Exception {
    loadMavenProject(QuteMavenProjectName.qute_quickstart);
    QuteResolvedJavaTypeParams params = new QuteResolvedJavaTypeParams("java.lang.String", QuteMavenProjectName.qute_quickstart);
    ResolvedJavaTypeInfo result = QuteSupportForTemplate.getInstance().getResolvedJavaType(params, getJDTUtils(), new NullProgressMonitor());
    Assert.assertNotNull(result);
    Assert.assertEquals("java.lang.String", result.getSignature());
    Assert.assertFalse(result.isIterable());
    Assert.assertNotNull(result.getMethods());
    // Valid method isEmpty()
    JavaMethodInfo isEmptyMethod = findMethod(result, "isEmpty");
    Assert.assertNotNull(isEmptyMethod);
    // Invalid method void getChars(int srcBegin, int srcEnd, char dst[], int
    // dstBegin) {
    JavaMethodInfo getCharsMethod = findMethod(result, "getChars");
    Assert.assertNull(getCharsMethod);
    InvalidMethodReason reason = result.getInvalidMethodReason("getChars");
    Assert.assertEquals(InvalidMethodReason.VoidReturn, reason);
    // Extended types
    // public final class String implements java.io.Serializable,
    // Comparable<String>, CharSequence {
    List<String> extendedTypes = result.getExtendedTypes();
    Assert.assertNotNull(extendedTypes);
    assertExtendedTypes("java.lang.String", "java.io.Serializable", extendedTypes);
    assertExtendedTypes("java.lang.String", "java.lang.CharSequence", extendedTypes);
}
Also used : QuteResolvedJavaTypeParams(com.redhat.qute.commons.QuteResolvedJavaTypeParams) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JavaMethodInfo(com.redhat.qute.commons.JavaMethodInfo) ResolvedJavaTypeInfo(com.redhat.qute.commons.ResolvedJavaTypeInfo) InvalidMethodReason(com.redhat.qute.commons.InvalidMethodReason) Test(org.junit.Test)

Aggregations

InvalidMethodReason (com.redhat.qute.commons.InvalidMethodReason)6 JavaMethodInfo (com.redhat.qute.commons.JavaMethodInfo)6 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)6 QuteResolvedJavaTypeParams (com.redhat.qute.commons.QuteResolvedJavaTypeParams)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 JavaFieldInfo (com.redhat.qute.commons.JavaFieldInfo)1 JavaParameterInfo (com.redhat.qute.commons.JavaParameterInfo)1 ITypeResolver (com.redhat.qute.jdt.internal.resolver.ITypeResolver)1 Expression (com.redhat.qute.parser.template.Expression)1 Parameter (com.redhat.qute.parser.template.Parameter)1 JavaMemberResult (com.redhat.qute.project.JavaMemberResult)1 DiagnosticDataFactory.createDiagnostic (com.redhat.qute.services.diagnostics.DiagnosticDataFactory.createDiagnostic)1 QuteErrorCode (com.redhat.qute.services.diagnostics.QuteErrorCode)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IField (org.eclipse.jdt.core.IField)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1