Search in sources :

Example 6 with IType

use of org.springframework.ide.vscode.commons.java.IType in project sts4 by spring-projects.

the class HtmlJavadocTest method html_testNoJavadocClass.

@Test
public void html_testNoJavadocClass() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    ;
    IType type = project.getClasspath().findType("hello.GreetingController");
    assertNotNull(type);
    assertNull(type.getJavaDoc());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 7 with IType

use of org.springframework.ide.vscode.commons.java.IType in project sts4 by spring-projects.

the class JavaIndexTest method findClassInJar.

@Test
public void findClassInJar() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("org.springframework.test.web.client.ExpectedCount");
    assertNotNull(type);
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 8 with IType

use of org.springframework.ide.vscode.commons.java.IType in project sts4 by spring-projects.

the class JavaIndexTest method voidConstructor.

@Test
public void voidConstructor() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod m = type.getMethod("<init>", Stream.empty());
    assertEquals(type.getElementName(), m.getElementName());
    assertEquals(IVoidType.DEFAULT, m.getReturnType());
    assertEquals(0, m.parameters().count());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 9 with IType

use of org.springframework.ide.vscode.commons.java.IType in project sts4 by spring-projects.

the class JavaIndexTest method constructorMethodWithParams.

@Test
public void constructorMethodWithParams() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod m = type.getMethod("<init>", Stream.of(IPrimitiveType.INT));
    assertEquals(m.getDeclaringType().getElementName(), m.getElementName());
    assertEquals(IVoidType.DEFAULT, m.getReturnType());
    assertEquals(Collections.singletonList(IPrimitiveType.INT), m.parameters().collect(Collectors.toList()));
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 10 with IType

use of org.springframework.ide.vscode.commons.java.IType in project sts4 by spring-projects.

the class TypeUtil method getSetter.

public Optional<IMethod> getSetter(Type beanType, String propName) {
    try {
        String setterName = "set" + StringUtil.hyphensToCamelCase(propName, true);
        IType type = findType(beanType);
        return type.getMethods().filter(m -> setterName.equals(m.getElementName())).findFirst();
    } catch (Exception e) {
        Log.log(e);
    }
    return Optional.empty();
}
Also used : Arrays(java.util.Arrays) Provider(javax.inject.Provider) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) IMethod(org.springframework.ide.vscode.commons.java.IMethod) LazyProvider(org.springframework.ide.vscode.commons.util.LazyProvider) ArrayUtils.firstElement(org.springframework.ide.vscode.commons.util.ArrayUtils.firstElement) ArrayList(java.util.ArrayList) IJavaElement(org.springframework.ide.vscode.commons.java.IJavaElement) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) Charset(java.nio.charset.Charset) ImmutableList(com.google.common.collect.ImmutableList) IField(org.springframework.ide.vscode.commons.java.IField) Locale(java.util.Locale) Flags(org.springframework.ide.vscode.commons.java.Flags) Map(java.util.Map) DeprecationUtil(org.springframework.ide.vscode.boot.metadata.util.DeprecationUtil) ValueProviderStrategy(org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy) ResourceHintProvider(org.springframework.ide.vscode.boot.metadata.ResourceHintProvider) ValueParser(org.springframework.ide.vscode.commons.util.ValueParser) ImmutableSet(com.google.common.collect.ImmutableSet) StsValueHint(org.springframework.ide.vscode.boot.metadata.hints.StsValueHint) Log(org.springframework.ide.vscode.commons.util.Log) Collection(java.util.Collection) ArrayUtils(org.springframework.ide.vscode.commons.util.ArrayUtils) Set(java.util.Set) Collectors(java.util.stream.Collectors) Assert(org.springframework.ide.vscode.commons.util.Assert) Flux(reactor.core.publisher.Flux) ArrayUtils.lastElement(org.springframework.ide.vscode.commons.util.ArrayUtils.lastElement) List(java.util.List) CollectionUtil(org.springframework.ide.vscode.commons.util.CollectionUtil) Stream(java.util.stream.Stream) EnumValueParser(org.springframework.ide.vscode.commons.util.EnumValueParser) MimeTypes(org.springframework.ide.vscode.commons.util.MimeTypes) Entry(java.util.Map.Entry) Optional(java.util.Optional) IType(org.springframework.ide.vscode.commons.java.IType) Collections(java.util.Collections) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation) AlwaysFailingParser(org.springframework.ide.vscode.commons.util.AlwaysFailingParser) IType(org.springframework.ide.vscode.commons.java.IType)

Aggregations

IType (org.springframework.ide.vscode.commons.java.IType)30 Test (org.junit.Test)19 MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)18 IMethod (org.springframework.ide.vscode.commons.java.IMethod)14 IJavadoc (org.springframework.ide.vscode.commons.javadoc.IJavadoc)11 IField (org.springframework.ide.vscode.commons.java.IField)9 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 StsValueHint (org.springframework.ide.vscode.boot.metadata.hints.StsValueHint)4 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Optional (java.util.Optional)3 Set (java.util.Set)3 Stream (java.util.stream.Stream)3 Deprecation (org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)3 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)3 Cache (com.google.common.cache.Cache)2