Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to LemMinX-Maven 0.11.1 #1692

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.m2e.editor.lemminx.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: M2E Maven POM File Editor using Wild Web Developer, Lemminx and Maven LS extension Tests
Bundle-SymbolicName: org.eclipse.m2e.editor.lemminx.tests
Bundle-Version: 2.0.1.qualifier
Bundle-Version: 2.0.2.qualifier
Automatic-Module-Name: org.eclipse.m2e.editor.lemminx.tests
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Vendor: Eclipse.org - m2e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Set;
Expand All @@ -21,7 +22,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.TextSelection;
Expand All @@ -36,7 +37,6 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
Expand Down Expand Up @@ -74,66 +74,57 @@ public void closeAndDeleteAll() throws CoreException {

@Test
public void testGenericEditorHasMavenExtensionEnabled() throws Exception {
project = ResourcesPlugin.getWorkspace().getRoot().getProject("test" + System.currentTimeMillis());
project.create(null);
project.open(null);
project = createMavenProject("test" + System.currentTimeMillis(), "pom.xml");
IFile pomFile = project.getFile("pom.xml");
pomFile.create(getClass().getResourceAsStream("pom.xml"), true, null);
ITextEditor editorPart = (ITextEditor)IDE.openEditor(page, pomFile, GENERIC_EDITOR);

ITextEditor editorPart = (ITextEditor) IDE.openEditor(page, pomFile, GENERIC_EDITOR);
Display display = page.getWorkbenchWindow().getShell().getDisplay();
assertTrue("Missing diagnostic report", DisplayHelper.waitForCondition(display, WAIT_TIMEOUT, () -> {
try {
return Arrays.stream(pomFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)).anyMatch(marker ->
marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR &&
marker.getAttribute(IMarker.MESSAGE, "").contains("artifactId")
);
} catch (CoreException e) {
return false;
}
try {
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
return Arrays.stream(pomFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE))
.anyMatch(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR
&& marker.getAttribute(IMarker.MESSAGE, "").contains("artifactId"));
} catch (CoreException e) {
return false;
}
));
int offset = editorPart.getDocumentProvider().getDocument(editorPart.getEditorInput()).get().indexOf("</scope>");
Set<Shell> beforeShells = Arrays.stream(display.getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
}));
int offset = editorPart.getDocumentProvider().getDocument(editorPart.getEditorInput()).get()
.indexOf("</scope>");
Set<Shell> beforeShells = Arrays.stream(display.getShells()).filter(Shell::isVisible)
.collect(Collectors.toSet());
editorPart.getSelectionProvider().setSelection(new TextSelection(offset, 0));
editorPart.getAction(ITextEditorActionConstants.CONTENT_ASSIST).run();
assertTrue("Missing completion proposals", DisplayHelper.waitForCondition(display, WAIT_TIMEOUT, () -> {
Set<Shell> afterShells = Arrays.stream(display.getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
Set<Shell> afterShells = Arrays.stream(display.getShells()).filter(Shell::isVisible)
.collect(Collectors.toSet());
afterShells.removeAll(beforeShells);
return afterShells.stream()
.flatMap(shell -> Arrays.stream(shell.getChildren()))
.filter(Table.class::isInstance)
.map(Table.class::cast)
.findFirst()
.map(table -> Boolean.valueOf(Arrays.stream(table.getItems()).map(TableItem::getText).anyMatch("compile"::equals)))
.orElse(Boolean.FALSE).booleanValue();
return afterShells.stream().flatMap(shell -> Arrays.stream(shell.getChildren()))
.filter(Table.class::isInstance).map(Table.class::cast).findFirst()
.map(table -> Arrays.stream(table.getItems()).map(TableItem::getText).anyMatch("compile"::equals))
.orElse(Boolean.FALSE).booleanValue();
}));
}

@Test
public void testEditorOpenOnSourcePage() throws CoreException {
public void testEditorOpenOnSourcePage() throws Exception {
IPreferenceStore preferenceStore = M2EUIPluginActivator.getDefault().getPreferenceStore();
preferenceStore.setValue(MavenPreferenceConstants.P_DEFAULT_POM_EDITOR_PAGE, true);
project = ResourcesPlugin.getWorkspace().getRoot().getProject("test" + System.currentTimeMillis());
project.create(null);
project.open(null);

project = createMavenProject("test" + System.currentTimeMillis(), "pom.xml");
IFile pomFile = project.getFile("pom.xml");
pomFile.create(getClass().getResourceAsStream("pom.xml"), true, null);
MavenPomEditor editor = (MavenPomEditor)page.openEditor(new FileEditorInput(pomFile), MavenPomEditor.EDITOR_ID);

MavenPomEditor editor = (MavenPomEditor) IDE.openEditor(page, pomFile, MavenPomEditor.EDITOR_ID);
Assert.assertNotNull(editor.getSourcePage());
Assert.assertEquals(editor.getSourcePage(), editor.getActiveEditor());
}

@Test
public void testOpenChildThenParentResolvesParent() throws Exception {
try (InputStream content = getClass().getResourceAsStream("pom-parent.xml")) {
createProject("parent", content);
}
IProject child = null;
try (InputStream content = getClass().getResourceAsStream("pom-child.xml")) {
child = createProject("child", content);
}
createMavenProject("parent", "pom-parent.xml");
IProject child = createMavenProject("child", "pom-child.xml");
IFile pomFile = child.getFile("pom.xml");
page.openEditor(new FileEditorInput(pomFile), GENERIC_EDITOR);
IDE.openEditor(page, pomFile, GENERIC_EDITOR);
Display display = page.getWorkbenchWindow().getShell().getDisplay();
assertTrue("Expected marker not published", DisplayHelper.waitForCondition(display, WAIT_TIMEOUT, () -> {
try {
Expand All @@ -147,4 +138,11 @@ public void testOpenChildThenParentResolvesParent() throws Exception {
}
}));
}

private IProject createMavenProject(String projectName, String pomFileName) throws CoreException, IOException {
try (InputStream pomContent = getClass().getResourceAsStream(pomFileName)) {
return createProject(projectName, pomContent);
}
}

}
3 changes: 2 additions & 1 deletion org.eclipse.m2e.editor.lemminx/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: M2E Maven POM File Editor using Wild Web Developer, LemMinX and Maven LS extension (requires Incubating components)
Bundle-SymbolicName: org.eclipse.m2e.editor.lemminx;singleton:=true
Bundle-Version: 2.0.5.qualifier
Bundle-Version: 2.0.600.qualifier
Automatic-Module-Name: org.eclipse.m2e.xmlls.extension
Import-Package: javax.inject;version="[1.0.0,2.0.0)",
org.apache.commons.cli;version="1.6.0",
org.eclipse.core.runtime;version="3.5.0",
org.osgi.framework;version="1.10.0",
org.slf4j;version="[1.7.0,3.0.0)"
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.m2e.editor.lemminx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<artifactId>org.eclipse.m2e.editor.lemminx</artifactId>
<name>M2E Maven POM File Editor (Wild Web Developer, LemMinX, LS)</name>
<packaging>eclipse-plugin</packaging>
<version>2.0.5-SNAPSHOT</version>
<version>2.0.600-SNAPSHOT</version>

<build>
<plugins>
Expand All @@ -45,7 +45,7 @@
<groupId>org.eclipse.lemminx</groupId>
<artifactId>lemminx-maven</artifactId>
<!-- Don't release m2e if this points to SNAPSHOT -->
<version>0.11.0</version>
<version>0.11.1</version>
<outputDirectory>${project.basedir}</outputDirectory>
<destFileName>lemminx-maven.jar</destFileName>
<!-- Edit forceQualifierUpdate.txt to force usage of newer SNAPSHOT, otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;

import org.apache.commons.cli.CommandLine;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Platform;
Expand Down Expand Up @@ -71,7 +71,7 @@ public List<File> get() {
addJarsFromBundle(FrameworkUtil.getBundle(org.apache.maven.Maven.class), "/jars/", mavenRuntimeJars);
// Libraries that are also required and not included in
// org.eclipse.m2e.maven.runtime
Stream.of(javax.inject.Inject.class, org.slf4j.Logger.class)//
Stream.of(javax.inject.Inject.class, org.slf4j.Logger.class, CommandLine.class)//
.map(FrameworkUtil::getBundle).map(FileLocator::getBundleFileLocation)//
.flatMap(Optional::stream).forEach(mavenRuntimeJars::add);
return mavenRuntimeJars;
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.lemminx.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.m2e.lemminx.feature"
label="%featureName"
version="2.0.6.qualifier"
version="2.0.600.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
Loading