Search in sources :

Example 1 with VSCodeSourceLinks

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

the class VSCodeSourceLinksTest method testJarUrl.

@Test
public void testJarUrl() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "org.springframework.boot.autoconfigure.SpringBootApplication");
    assertTrue(url.isPresent());
    String headerPart = url.get().substring(0, url.get().indexOf('?'));
    assertEquals("jdt://contents/spring-boot-autoconfigure-1.5.8.RELEASE.jar/org.springframework.boot.autoconfigure/SpringBootApplication.class", headerPart);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#55,19", positionPart);
}
Also used : VSCodeSourceLinks(org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) Test(org.junit.Test)

Example 2 with VSCodeSourceLinks

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

the class VSCodeSourceLinksTest method testJavaSourceUrl.

@Test
public void testJavaSourceUrl() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "com.example.EmptyBoot15WebAppApplication");
    assertTrue(url.isPresent());
    Path projectPath = Paths.get(project.pom().getParent());
    URI uri = URI.create(url.get());
    // Use File to get rid of the fragment parts of the URL. The URL may have fragments that indicate line and column numbers
    uri = new File(uri.getPath()).toURI();
    Path relativePath = projectPath.relativize(Paths.get(uri));
    assertEquals(Paths.get("src/main/java/com/example/EmptyBoot15WebAppApplication.java"), relativePath);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#7,14", positionPart);
}
Also used : VSCodeSourceLinks(org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks) Path(java.nio.file.Path) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Example 3 with VSCodeSourceLinks

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

the class VSCodeSourceLinksTest method testJarUrlInnerType.

@Test
public void testJarUrlInnerType() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback");
    assertTrue(url.isPresent());
    String headerPart = url.get().substring(0, url.get().indexOf('?'));
    assertEquals("jdt://contents/spring-web-4.3.12.RELEASE.jar/org.springframework.web.client/RestTemplate$AcceptHeaderRequestCallback.class", headerPart);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#747,16", positionPart);
}
Also used : VSCodeSourceLinks(org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 VSCodeSourceLinks (org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks)3 MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)3 File (java.io.File)1 URI (java.net.URI)1 Path (java.nio.file.Path)1