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

Easy to get m2e pom.xml editor fatally confused #1518

Closed
davidmichaelkarr opened this issue Aug 22, 2023 · 14 comments
Closed

Easy to get m2e pom.xml editor fatally confused #1518

davidmichaelkarr opened this issue Aug 22, 2023 · 14 comments

Comments

@davidmichaelkarr
Copy link

I'm using Eclipse 2023-06.

In the last few days I've been seeing the m2e pom.xml editor get very confused, being unable to edit portions of the text, having it display blank lines where blank lines don't exist. I find I have to close the editor and reopen the file. I have to be very careful entering text or it will get confused.

I am starting with this content:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.att.idp</groupId>
  <artifactId>debugproblem</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
</project>

For example, I can go to the blank line and enter TAB, and then enter the following:

<properties>>

By entering that errant ">", I've basically hosed that editor. If I try to erase one of those and then hit ENTER at the end of the line, it gets confused about what text is in the file and what it is displaying. At this point I also see an error dialog like the following:

An error has occurred. See error log for more details.
startLine(5) does not match endLine(6)

The error log has this:

!ENTRY org.eclipse.ui 4 0 2023-08-22 14:40:10.449
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalStateException: startLine (5) does not match endLine (6)
	at org.eclipse.jface.text.projection.ProjectionMapping.toImageLine(ProjectionMapping.java:462)
	at org.eclipse.jface.text.TextViewer.modelLine2WidgetLine(TextViewer.java:5208)
	at org.eclipse.jface.text.source.MatchingCharacterPainter.handleDrawRequest(MatchingCharacterPainter.java:215)
	at org.eclipse.jface.text.source.MatchingCharacterPainter.paintControl(MatchingCharacterPainter.java:185)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4274)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1536)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4800)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5040)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3658)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
@davidmichaelkarr
Copy link
Author

This is pretty easy to repeat. If I simply add an additional ">" after entering a start tag (ending with ">"), it gets confused. At that point, it adds a blank line that doesn't get a line number. In fact, reverting the file doesn't fix it. I can reset it back to normal by closing the editor buffer and reopening the file.

I can start with this:

image

If I then put the cursor at the end of "dependencies" and enter ">>" and then try moving around, I find it has lost its mind.

@davidmichaelkarr
Copy link
Author

It seems like it's even worse than this. I'm starting from a valid pom.xml, and this is a snapshot of it:
image

I put my cursor at the end of the "<exclusions>" line and pressed Enter. Ok so far:
image

I then entered "<exclusion>":
image
Note that I did NOT press enter. After typing the ending "`>'", the text cursor stayed to the left of that character. If I try to move the cursor to the right, it jumps to the beginning of the next line. If I then try to move the cursor to the left, nothing happens.

I do note that if I accept the completion choices, it stays sane. I usually take those recommendations, but sometimes I don't. I shouldn't expect that the editor will break if I don't.

@HannesWell
Copy link
Contributor

@mickaelistria or @vrubezhny, as this is an Editor issue, could you please take a look?

@r-eis
Copy link

r-eis commented Aug 28, 2023

Hey there!

I can confirm all of these problems with pom.xmls and they've been there for a good while.

I would love to provide a simple example file, but it seems that state beyond the file itself has an influence (maybe the current editor session or something). Last time, I copied a pom.xml that showed the problem to a pom2.xml and it did not show the problem when editing exactly the same spot.

If I disable the Language Server for XML in the preferences, the problems are gone. But obviously, there is no more code completion and even formatting doesn't work any more, so that's barely a workaround.

@r-eis
Copy link

r-eis commented Aug 28, 2023

I did a lot of testing and I found a reproducible use case and also the solution (or a workaround) for it:
Switch back to org.eclipse.lsp4e version 0.16.1. The problem happens with 0.17.0., 0.17.1 and the latest 0.17.2

Eclipse 2023-06 (for Java Developers) brings lsp4e 0.16.1 by default, but by installing (edited:) Wild Web Developer HTML, CSS, JSON, Yaml, JavaScript, TypeScript, Node tools 1.2.1.202308101949 from the market place, it gets updated to 0.17.0.

EDIT:
Switching back to 0.16.1 is also the "fix"for @davidmichaelkarr's use case.
So is this an m2e or an lsp4e problem?
Or both? 😃

My use case:
Start with this pom.xml in the Maven POM Editor:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>myGroup</groupId>
	<artifactId>myArtifact</artifactId>
	<version>1.0</version>
</project>

Then add a new line somewhere, add the opening tag for a comment (without using the quick-fix that adds the closing tag), write the comment and so far, everything is ok

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>myGroup</groupId>
	<artifactId>myArtifact</artifactId>
	<version>1.0</version>
	<!-- comment --
</project>

But as soon as you type the closing bracket (>), everything is broken. The bracket won't show up, but the following errors are in the log.

First one:

java.lang.NoSuchMethodError: 'org.eclipse.lsp4j.services.LanguageServer org.eclipse.lsp4e.LanguageServiceAccessor$LSPDocumentInfo.getLanguageClient()'
	at org.eclipse.wildwebdeveloper.xml.internal.autoclose.XMLAutoCloseTagReconciler$Listener.lambda$1(XMLAutoCloseTagReconciler.java:125)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
	at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findAny(ReferencePipeline.java:652)
	at org.eclipse.wildwebdeveloper.xml.internal.autoclose.XMLAutoCloseTagReconciler$Listener.autoInsert(XMLAutoCloseTagReconciler.java:125)
	at org.eclipse.wildwebdeveloper.xml.internal.autoclose.XMLAutoCloseTagReconciler$Listener.documentChanged(XMLAutoCloseTagReconciler.java:78)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireDocumentChanged(BasicStructuredDocument.java:464)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1206)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1983)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2426)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2411)
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:137)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replace(BasicStructuredDocument.java:2371)
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replace(JobSafeStructuredDocument.java:100)
	at org.eclipse.jface.text.projection.ProjectionTextStore.replace(ProjectionTextStore.java:106)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1093)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1118)
	at org.eclipse.jface.text.projection.ProjectionDocument.replace(ProjectionDocument.java:627)
	at org.eclipse.jface.text.DefaultDocumentAdapter.replaceTextRange(DefaultDocumentAdapter.java:223)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:7129)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:8029)
	at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2035)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5716)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5747)
	at org.eclipse.swt.custom.StyledText.lambda$28(StyledText.java:5426)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4274)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1117)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1594)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4865)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4743)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5040)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3658)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

Second one:

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4899)
	at org.eclipse.swt.SWT.error(SWT.java:4833)
	at org.eclipse.swt.SWT.error(SWT.java:4804)
	at org.eclipse.swt.custom.StyledText.getRanges(StyledText.java:4345)
	at org.eclipse.swt.custom.StyledText.setStyleRanges(StyledText.java:10136)
	at org.eclipse.swt.custom.StyledText.replaceStyleRanges(StyledText.java:7729)
	at org.eclipse.jface.text.TextViewer.addPresentation(TextViewer.java:4777)
	at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4854)
	at org.eclipse.tm4e.ui.text.TMPresentationReconciler.applyTextRegionCollection(TMPresentationReconciler.java:691)
	at org.eclipse.tm4e.ui.text.TMPresentationReconciler.colorize(TMPresentationReconciler.java:596)
	at org.eclipse.tm4e.ui.text.TMPresentationReconciler$InternalListener.colorize(TMPresentationReconciler.java:410)
	at org.eclipse.tm4e.ui.text.TMPresentationReconciler$InternalListener.lambda$0(TMPresentationReconciler.java:386)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4047)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3663)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

Now, crazy stuff happens, e.g. if I press the up or down arrow keys, new lines without line numbers appear, as @davidmichaelkarr described it.

The only thing that helps now is closing and reopening the editor.

@davidmichaelkarr
Copy link
Author

By the way, I don't know if it matters, but if this is involving lsp, it might be useful to point out that I had filed an issue with SpringBoot, concerning some other issues with the Language Server: spring-projects/sts4#1103 .

@HannesWell
Copy link
Contributor

Thank you both for the detailed reports and testing.

I did a lot of testing and I found a reproducible use case and also the solution (or a workaround) for it:
Switch back to org.eclipse.lsp4e version 0.16.1. The problem happens with 0.17.0., 0.17.1 and the latest 0.17.2

In that case, can you please report this to the lsp4e-project?
In general most of the Editor functionality often associated with m2e is actually provided by one of the following projects and therefore m2e cannot do much about bugs:

@r-eis
Copy link

r-eis commented Aug 30, 2023

I opened another issue for it at lemminx-maven:
eclipse-lemminx/lemminx-maven#510

@chicobento
Copy link

Hi, was facing this error on eclipse 2023-06.
Just ran an update (Help->Check for updates) which updated m2e components / wildwebdeveloper and the bug is now gone.
Should this be closed ?

@HannesWell
Copy link
Contributor

HannesWell commented Sep 14, 2023

Thanks for the report.

@davidmichaelkarr can you confirm this?

@davidmichaelkarr
Copy link
Author

That will take a little while. I'm going to test this when I install 2023-09.

@chicobento
Copy link

chicobento commented Sep 15, 2023

Just an additional info: I ran another round of "Help->Check for updates" and now my 2023-06 installation has been upgraded to 2023-09 and the error is still gone. Thanks whoever that fixed it, this was really annoying!

@mickaelistria
Copy link
Contributor

Thanks for checking

@davidmichaelkarr
Copy link
Author

Ok, I finally got 2023-09 set up and loaded up a project. I'm not seeing the error dialogs or the messed-up view. I can still get it moderately confused, although it's easy to recover from it.

I tried inserting a new "dependency" block. At the proper place, I inserted exactly this text:

    <dependency>

As soon as I typed the closing ">", it produced this:

    <dependency></dependency></dependency>

I then manually removed the extra "" to fix it. This was repeatable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants