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

BadLocationException and diagnostic with negative line number send to client #1374

Closed
mfussenegger opened this issue Mar 1, 2020 · 0 comments · Fixed by #1379
Closed

BadLocationException and diagnostic with negative line number send to client #1374

mfussenegger opened this issue Mar 1, 2020 · 0 comments · Fixed by #1379
Assignees
Labels

Comments

@mfussenegger
Copy link
Contributor

Steps to reproduce

  • Open an existing file and save the file under a different filename.
  • Open the newly created file. This triggers a BadLocationException and the client receives diagnostics with negative line numbers in the range.

(I'm using the LSP support being added to neovim - currently only available in master)

Environment

  • openjdk version "13.0.2" 2020-01-14
  • eclipse.jdt.ls from master 9eb5a29
Diagnostics
diagnostics = {
    {
      code = "16777541",
      message = "The public type Lists must be defined in its own file",
      range = {
        end = {
          character = 24,
          line = 9          
        },
        start = {
          character = 19,
          line = 9
        }
      },
      severity = 1,
      source = "Java"
    },
    {
      code = "0",
      message = "The type Lists is already defined",
      range = {
        end = {
          character = 0,
          line = -2
        }
      },
      start = {
        character = 0,
        line = -2
      }
    },
    severity = 1,
    source = "Java"
}
Stacktrace
org.eclipse.jface.text.BadLocationException
  at org.eclipse.jface.text.ListLineTracker.getLineOffset(ListLineTracker.java:197)
  at org.eclipse.jface.text.AbstractLineTracker.getLineOffset(AbstractLineTracker.java:161)
  at org.eclipse.jface.text.AbstractDocument.getLineOffset(AbstractDocument.java:876)
  at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineOffset(SynchronizableDocument.java:323)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.convertRange(WorkspaceDiagnosticsHandler.java:371)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.toDiagnostic(WorkspaceDiagnosticsHandler.java:348)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.lambda$3(WorkspaceDiagnosticsHandler.java:332)
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
  at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
  at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
  at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.toDiagnosticsArray(WorkspaceDiagnosticsHandler.java:334)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.visit(WorkspaceDiagnosticsHandler.java:171)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:67)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:77)
  at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:51)
  at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.resourceChanged(WorkspaceDiagnosticsHandler.java:95)
  at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:305)
  at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
  at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:295)
  at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:158)
  at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:380)
  at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1502)
  at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:169)
  at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
  at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
@mfussenegger mfussenegger changed the title BadLocationException and negative line number send to client BadLocationException and diagnostic with negative line number send to client Mar 1, 2020
@snjeza snjeza self-assigned this Mar 3, 2020
@fbricon fbricon added this to the End March 2020 milestone Mar 11, 2020
@fbricon fbricon added the bug label Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants