Git Product home page Git Product logo

Comments (9)

Nacoma avatar Nacoma commented on June 24, 2024 1

It’s difficult to say what the correct handling is.

I’ve opened an issue requesting clarification on the handling of negative positions.

from intellij-lsp.

Nacoma avatar Nacoma commented on June 24, 2024

Possibly related, another exception being thrown from the same function in DocumentUtils

java.lang.IndexOutOfBoundsException: Wrong line: 253. Available lines count: 253
	at com.intellij.openapi.editor.impl.LineSet.checkLineIndex(LineSet.java:202)
	at com.intellij.openapi.editor.impl.LineSet.getLineStart(LineSet.java:187)
	at com.intellij.openapi.editor.impl.DocumentImpl.getLineStartOffset(DocumentImpl.java:1020)
	at com.intellij.util.DocumentUtil.getLineTextRange(DocumentUtil.java:104)
	at com.github.gtache.lsp.utils.DocumentUtils$.$anonfun$LSPPosToOffset$1(DocumentUtils.scala:81)
	at com.github.gtache.lsp.utils.DocumentUtils$.$anonfun$LSPPosToOffset$1$adapted(DocumentUtils.scala:78)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:963)
	at com.github.gtache.lsp.utils.ApplicationUtils$.computableReadAction(ApplicationUtils.scala:26)
	at com.github.gtache.lsp.utils.DocumentUtils$.LSPPosToOffset(DocumentUtils.scala:78)
	at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$4(EditorEventManager.scala:443)
	at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$4$adapted(EditorEventManager.scala:437)
	at scala.collection.Iterator.foreach(Iterator.scala:937)
	at scala.collection.Iterator.foreach$(Iterator.scala:937)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
	at scala.collection.IterableLike.foreach(IterableLike.scala:70)
	at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$1(EditorEventManager.scala:437)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

As a side note, this looks to be the same exception seen in #67

from intellij-lsp.

gtache avatar gtache commented on June 24, 2024

Both should be fixed in #72.
Thanks for all the reports by the way!

from intellij-lsp.

Nacoma avatar Nacoma commented on June 24, 2024

The problem happening in the first trace is happening here still.

pos.getCharacter has the value -1.

val lineTextForPosition = if (lineText.nonEmpty) lineText.substring(0, min(lineText.length, pos.getCharacter)) else ""

I would expect that the author of psalm-language-server is using -1 to indicate EOL (which is standard in the language it's written in).

I've checked the LSP spec briefly and I have been unable to determine if negative values are permitted for positions.

from intellij-lsp.

gtache avatar gtache commented on June 24, 2024

Ok, I looked a bit into psalm and it seems to use phan on the backend for diagnostics, and like you said phan probably uses -1 for this purpose, but I'm not familiar at all with php.
I could add a special case for -1, but all that the LSP specification says is that Position is zero-based and if the character offset is greater than the length of the line, it equals to the length of the line. So It seems to me that sending -1 is invalid.
Have you also checked the VSCode behaviour?

from intellij-lsp.

gtache avatar gtache commented on June 24, 2024

Great thanks !

from intellij-lsp.

muglug avatar muglug commented on June 24, 2024

Hey! I created Psalm, let me know if I can help. Psalm doesn't use anything but PHP Parser on the backend. Psalm shouldn't be sending any -1 data - if it does, that's a bug that needs to be fixed in Psalm.

from intellij-lsp.

Nacoma avatar Nacoma commented on June 24, 2024

In LanguageServer/LanguageServer::emitIssues the value of $end_column - 1 is -1 with the following code snippet:

function test(): int {
    return (new Something())
        ->any();
}

I’m away from my computer but I can provide some more info later if necessary.

from intellij-lsp.

Nacoma avatar Nacoma commented on June 24, 2024

This appears to have been resolved.

from intellij-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.