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

Code folding is buggy #1419

Closed
Yanpas opened this issue Apr 27, 2020 · 18 comments · Fixed by #1424
Closed

Code folding is buggy #1419

Yanpas opened this issue Apr 27, 2020 · 18 comments · Fixed by #1424
Assignees

Comments

@Yanpas
Copy link

Yanpas commented Apr 27, 2020

Sometimes folding ranges are out of sync and located 1 line below or upwards. Sometimes they are completely broken with following exception:

[Error - 18:29:56] 27 апр. 2020 г., 18:29:56 Problem with folding range for XXX.java:
Invalid_Char_In_String
org.eclipse.jdt.core.compiler.InvalidInputException: Invalid_Char_In_String
	at org.eclipse.jdt.internal.core.util.PublicScanner.getNextToken(PublicScanner.java:1564)
	at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeFoldingRanges(FoldingRangeHandler.java:112)
	at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.foldingRange(FoldingRangeHandler.java:63)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$27(JDTLanguageServer.java:814)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$49(JDTLanguageServer.java:950)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

STR:

  1. Add some parameter to the method used across class
  2. For some time method call will be causing compile error
  3. Fix it by adding desired argument
  4. Code folding is broken!!!
@fbricon
Copy link
Contributor

fbricon commented Apr 27, 2020

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

More details:

  • extension version 0.60
  • jdk 13
  • arch linux
  • I use eclipse project (.project, .settings etc)
  • I use splitting the same editor.

@fbricon
Copy link
Contributor

fbricon commented Apr 27, 2020

0.60.0 as in vscode-java?

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

Yes, it's vscode extension's version.

More traces (not sure if they are related) Even without splitting editor foldings disappear after some edits:


[Error - 19:14:23] Request textDocument/codeAction failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:373)
	at java.base/java.util.ArrayList.get(ArrayList.java:425)
	at org.eclipse.jdt.core.dom.ASTNode$NodeList.get(ASTNode.java:1472)
	at org.eclipse.jdt.internal.corext.refactoring.code.SourceProvider.getParameterData(SourceProvider.java:316)
	at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.computeRealArguments(CallInliner.java:474)
	at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.initialize(CallInliner.java:256)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkFinalConditions(InlineMethodRefactoring.java:311)
	at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:86)
	at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:122)
	at org.eclipse.jdt.ls.core.internal.corrections.RefactorProcessor.getInlineProposal(RefactorProcessor.java:353)
	at org.eclipse.jdt.ls.core.internal.corrections.RefactorProcessor.getProposals(RefactorProcessor.java:143)
	at org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler.getCodeActionCommands(CodeActionHandler.java:121)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$14(JDTLanguageServer.java:620)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:74)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	... 6 more

[Error - 19:15:02] 27 апр. 2020 г., 19:15:02 Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
null
java.lang.NullPointerException

@fbricon
Copy link
Contributor

fbricon commented Apr 27, 2020

If you can reproduce the issue reliably, do you mind recording the steps you follow to see this issue?

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

Here it is: https://gist.github.com/Yanpas/7c92234ea1f2b2398dc5f6d4b94de6bf

Recorded with "java.trace.server": "messages",

What I was doing?

  1. Folded several if's
  2. Between class methods inserted this snippet:
int var;
    void foo() {}
    {

It makes whole piece of code uncompilable
3. then removed extra curly brace and folding is gone

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

Editing only one file causes a lot of files (I guess all) to recompile for some reasong, according to inotify watcher (inotifywait -r -m ~/ssd/work/trunk/EclipseBuild/)

@fbricon
Copy link
Contributor

fbricon commented Apr 27, 2020

how many files do you have open?

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

2 or 3. Both from one package and project. My .classpath looks like:

<classpath>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
        <classpathentry kind="output" path="EclipseBuild"/>
        <classpathentry kind="lib" path="tmp/release/some.jar"/>
        <classpathentry kind="lib" path="tmp/release/another.jar"/>
        <!--... and 300+ more lib projects-->
        <classpathentry kind="src" path="projects/p1/java/src"/>
        <classpathentry kind="src" path="projects/p2/java/src"/>
        <!--... and 120+ more src projects-->
</classpath>

@snjeza
Copy link
Contributor

snjeza commented Apr 27, 2020

@Yanpas could you send us the following:

  • your VS Code settings.json
  • the LANG environment variable
$ echo $LANG
  • ImageDataflow.java or non ASCII characters from this file

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

  1. java settings:
    "[java]": {
        "editor.defaultFormatter": "redhat.java"
    },
    "java.errors.incompleteClasspath.severity": "ignore",
    "java.jdt.ls.vmargs": "-noverify -Xmx5G -XX:+UseG1GC -XX:+UseStringDeduplication",
    "java.configuration.checkProjectSettingsExclusions": false,
    "java.configuration.updateBuildConfiguration": "automatic",
    "java.import.gradle.enabled": false,
    "java.import.maven.enabled": false,

2.$ echo $LANG:
ru_RU.UTF-8
3. This file is utf8 encoded and has the following nonascii line for instance:
temp, // Директория с временными данными

@snjeza
Copy link
Contributor

snjeza commented Apr 27, 2020

@Yanpas could you check it?

$ iconv -f UTF-8 ImageDataflow.java > /dev/null; echo $?

The command should return 0.

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

Return code is zero. Checked env of java process, it's correct:

pgrep java
cat /proc/91283/environ | tr '\0' '\n' |grep  LANG

@snjeza
Copy link
Contributor

snjeza commented Apr 27, 2020

It makes whole piece of code uncompilable
3. then removed extra curly brace and folding is gone

I can't reproduce the issue.
Could you attach a sample project reproducing this issue?

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

Peek 2020-04-28 01-32

Here is a screencast with two dummy files, one with non utf8 encoding. (Whi knows whether files with bad encoding exist in my real big project)

files.tgz.zip (is not zip, but tar.gz)

@Yanpas
Copy link
Author

Yanpas commented Apr 27, 2020

On my main project I guess it reproduces due to another issue - editing one file causes recalculation of all publishDiagnostics, some file may be broken.

@snjeza snjeza self-assigned this Apr 28, 2020
@snjeza
Copy link
Contributor

snjeza commented Apr 28, 2020

@Yanpas could you try to reproduce the issue related to code folding using https://raw.githubusercontent.com/snjeza/vscode-test/master/java-0.61.1.vsix ?

@Yanpas
Copy link
Author

Yanpas commented Apr 28, 2020

Played for a while, seems to be fixed, thank you!

Open new performance related issue #1425

@fbricon fbricon added this to the End April 2020 milestone Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants