Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
Enable save actions to auto fix them from now on and also fix other
warnings (as reported by JDT and SonarLint) in edited files.
  • Loading branch information
akurtakov authored and mickaelistria committed Oct 6, 2022
1 parent 28122b7 commit f25569d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Red Hat Inc. and others.
* Copyright (c) 2020, 2022 Red Hat Inc. and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -8,8 +8,6 @@
*******************************************************************************/
package org.eclipse.lemminx.extensions.maven.utils;

import java.io.File;

public class MarkdownUtils {
public static final String LINE_BREAK = "\n\n";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Red Hat Inc. and others.
* Copyright (c) 2020, 2022 Red Hat Inc. and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -102,9 +101,8 @@ public static Set<Parameter> collectPluginConfigurationParameters(IPositionReque
mojosToConsiderList = mojosToConsiderList.stream().filter(mojo -> interestingMojos.contains(mojo.getGoal()))
.collect(Collectors.toList());
}
Set<Parameter> parameters = mojosToConsiderList.stream().flatMap(mojo -> mojo.getParameters().stream())
return mojosToConsiderList.stream().flatMap(mojo -> mojo.getParameters().stream())
.collect(Collectors.toSet());
return parameters;
}

public static Set<MojoParameter> collectPluginConfigurationMojoParameters(IPositionRequest request,
Expand All @@ -129,10 +127,9 @@ public static Set<MojoParameter> collectPluginConfigurationMojoParameters(IPosit
return Collections.emptySet();
}
plugin.getMavenSession().setProjects(Collections.singletonList(project));
Set<MojoParameter> mojoParams = mojosToConsiderList.stream().flatMap(mojo -> PlexusConfigHelper
return mojosToConsiderList.stream().flatMap(mojo -> PlexusConfigHelper
.loadMojoParameters(pluginDescriptor, mojo, plugin.getMavenSession(), plugin.getBuildPluginManager())
.stream()).collect(Collectors.toSet());
return mojoParams;
}

public static RemoteRepository toRemoteRepo(Repository modelRepo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;

import org.eclipse.lemminx.dom.DOMDocument;
import org.eclipse.lemminx.extensions.maven.NoMavenCentralExtension;
import org.eclipse.lemminx.services.XMLLanguageService;
import org.eclipse.lemminx.settings.SharedSettings;
import org.eclipse.lemminx.settings.XMLHoverSettings;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.HoverCapabilities;
import org.eclipse.lsp4j.MarkupContent;
import org.eclipse.lsp4j.MarkupKind;
import org.eclipse.lsp4j.Position;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -36,7 +33,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith(NoMavenCentralExtension.class)
public class ManagedVersionHoverTest {
class ManagedVersionHoverTest {

private XMLLanguageService languageService;

Expand All @@ -53,10 +50,10 @@ public void tearDown() throws InterruptedException, ExecutionException {

@Test
@Timeout(90000)
public void testManagedVersionHoverInDependencyChild() throws IOException, URISyntaxException {
void testManagedVersionHoverInDependencyChild() throws IOException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-dependencyManagement-child.xml", languageService);
Hover hover = languageService.doHover(document, new Position(15, 25), createSharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testManagedVersionHoverInDependencyChild: [" + value + "]");
assertNotNull(value);
assertTrue(value.contains("The managed version is"));
Expand All @@ -68,10 +65,10 @@ public void testManagedVersionHoverInDependencyChild() throws IOException, URISy

@Test
@Timeout(90000)
public void testManagedVersionHoverInDependencyParent() throws IOException, URISyntaxException {
void testManagedVersionHoverInDependencyParent() throws IOException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-dependencyManagement-parent.xml", languageService);
Hover hover = languageService.doHover(document, new Position(13, 29), createSharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testManagedVersionHoverInDependencyParent: [" + value + "]");
assertNotNull(value);
assertFalse(value.contains("The managed version is"));
Expand All @@ -80,10 +77,10 @@ public void testManagedVersionHoverInDependencyParent() throws IOException, URIS

@Test
@Timeout(90000)
public void testManagedVersionHoverInPluginChild() throws IOException, URISyntaxException {
void testManagedVersionHoverInPluginChild() throws IOException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-pluginManagement-child.xml", languageService);
Hover hover = languageService.doHover(document, new Position(18, 33), createSharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testManagedVersionHoverInPluginChild: [" + value + "]");
assertNotNull(value);
assertTrue(value.contains("The managed version is"));
Expand All @@ -95,10 +92,10 @@ public void testManagedVersionHoverInPluginChild() throws IOException, URISyntax

@Test
@Timeout(90000)
public void testManagedVersionHoverInPluginParent() throws IOException, URISyntaxException {
void testManagedVersionHoverInPluginParent() throws IOException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-pluginManagement-parent.xml", languageService);
Hover hover = languageService.doHover(document, new Position(14, 33), createSharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testManagedVersionHoverInPluginParent: [" + value + "]");
assertNotNull(value);
assertFalse(value.contains("The managed version is"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.eclipse.lemminx.extensions.maven.participants.hover;

import static org.eclipse.lemminx.extensions.maven.utils.MavenLemminxTestsUtils.createDOMDocument;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
Expand All @@ -21,13 +20,12 @@
import org.eclipse.lemminx.services.XMLLanguageService;
import org.eclipse.lemminx.settings.SharedSettings;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.MarkupContent;
import org.eclipse.lsp4j.Position;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class MavenHoverParticipantVerionWithPropertyTest {
class MavenHoverParticipantVerionWithPropertyTest {
private XMLLanguageService languageService;

@BeforeEach
Expand All @@ -43,60 +41,60 @@ public void tearDown() throws InterruptedException, ExecutionException {
}

@Test
public void testPluginManagementPluginWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
void testPluginManagementPluginWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-with-property-in-version.xml", languageService);
Hover hover = languageService.doHover(document, new Position(14, 30), new SharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testPluginManagementPluginWithVerionProperty: on group: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Apache Maven AntRun Plugin")));
assertTrue((hover.getContents().getRight().getValue().contains("Apache Maven AntRun Plugin")));

hover = languageService.doHover(document, new Position(15, 33), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testPluginManagementPluginWithVerionProperty: on artifact: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Apache Maven AntRun Plugin")));
assertTrue((hover.getContents().getRight().getValue().contains("Apache Maven AntRun Plugin")));

hover = languageService.doHover(document, new Position(16, 32), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testPluginManagementPluginWithVerionProperty: on version: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("1.8")));
assertTrue((hover.getContents().getRight().getValue().contains("1.8")));
}

@Test
public void testPluginWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
void testPluginWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-with-property-in-version.xml", languageService);
Hover hover = languageService.doHover(document, new Position(22, 26), new SharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testPluginWithVerionProperty: on group: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Apache Maven Compiler Plugin")));
assertTrue((hover.getContents().getRight().getValue().contains("Apache Maven Compiler Plugin")));

hover = languageService.doHover(document, new Position(23, 29), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testPluginWithVerionProperty: on artifact: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Apache Maven Compiler Plugin")));
assertTrue((hover.getContents().getRight().getValue().contains("Apache Maven Compiler Plugin")));

hover = languageService.doHover(document, new Position(24, 28), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testPluginWithVerionProperty: on version: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("3.5.1")));
assertTrue((hover.getContents().getRight().getValue().contains("3.5.1")));
}

@Test
public void testDependencyWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
void testDependencyWithVerionProperty() throws IOException, InterruptedException, ExecutionException, URISyntaxException {
DOMDocument document = createDOMDocument("/pom-with-property-in-version.xml", languageService);
Hover hover = languageService.doHover(document, new Position(30, 23), new SharedSettings());
String value = ((MarkupContent) hover.getContents().getRight()).getValue();
String value = hover.getContents().getRight().getValue();
System.out.println("testDependencyWithVerionProperty: on group: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Maven Embedder")));
assertTrue((hover.getContents().getRight().getValue().contains("Maven Embedder")));

hover = languageService.doHover(document, new Position(31, 25), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testDependencyWithVerionProperty: on artifact: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("Maven Embedder")));
assertTrue((hover.getContents().getRight().getValue().contains("Maven Embedder")));

hover = languageService.doHover(document, new Position(32, 24), new SharedSettings());
value = ((MarkupContent) hover.getContents().getRight()).getValue();
value = hover.getContents().getRight().getValue();
System.out.println("testDependencyWithVerionProperty: on version: " + value);
assertTrue((((MarkupContent) hover.getContents().getRight()).getValue().contains("3.0")));
assertTrue((hover.getContents().getRight().getValue().contains("3.0")));
}

}

0 comments on commit f25569d

Please sign in to comment.