YouCompleteMe icon indicating copy to clipboard operation
YouCompleteMe copied to clipboard

java import package error

Open dassio opened this issue 5 years ago • 16 comments

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

  • [ ] I have read and understood YCM's CONTRIBUTING document.
  • [ ] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm about to report and couldn't find an answer to my problem. (Example Google search.)
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS version) I am using.
  • [ ] If filing a bug report, I have included a minimal test case that reproduces my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I expected to happen and what actually happened.
  • [ ] If filing a installation failure report, I have included the entire output of install.py (or cmake/make/ninja) including its invocation
  • [ ] I understand this is an open-source project staffed by volunteers and that any help I receive is a selfless, heartfelt gift of their free time. I know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key questions:

create an Gradle project, start editing one class file, when trying to import the packages, if the package include a wildcard, can't select the popovers. youcompleteme

If you made changes to vimrc_ycm_minimal, pase them here:

set encoding=utf-8

call plug#begin('~/.vim/plugged')

Plug 'ycm-core/YouCompleteMe'

call plug#end()


let g:ycm_keep_logfiles = 1 
let g:ycm_log_level = 'debug'
let &rtp .= ',' . expand( '<sfile>:p:h' )
filetype plugin indent on
  • What did you expect to happen?

then select the package, either type SPACE or ctr+y can select the suggestion.

  • What actually happened?

the whole line got deleted

Diagnostic data

Output of vim --version

root@0c05fb76f276:~# vim --version 
VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31)
Included patches: 1-2269
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       +tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
+balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
+browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl              +toolbar
+cindent           +job               +persistent_undo   +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           +python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          -ruby              +wildmenu
+cursorbind        +lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con_gui    +mksession         +smartindent       +X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             +xim
+dnd               +mouseshape        +startuptime       +xpm
-ebcdic            +mouse_dec         +statusline        +xsmp_interact
+emacs_tags        +mouse_gpm         -sun_workshop      +xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-iU6mZD/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.30/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm 

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Completion API: 1
-- Client logfile: /tmp/ycm_z4qfuz90.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.8.2
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- Java completer debug information:
--   jdt.ls running
--   jdt.ls process ID: 16706
--   jdt.ls executable: ['/usr/bin/java', '-Dfile.encoding=UTF-8', '-Declipse.application=org.eclipse.jdt.ls.core.id1', '-Dosgi.bundles.defaultStartLevel=4', '-Declipse.product=org.eclipse.jdt.ls.core.pr
oduct', '-Dlog.level=ALL', '-jar', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/target/repository/plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar', '-conf
iguration', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/workspace/config_linux', '-data', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/w
orkspace/temp/tmphti9mhgr']
--   jdt.ls logfiles:
--     /tmp/jdt_ls_stderr1ic61esy.log
--     /root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/workspace/temp/tmphti9mhgr/.metadata/.log
--   jdt.ls Server State: Initialized
--   jdt.ls Project Directory: /root/server
--   jdt.ls Settings: {
--   "bundles": []
-- }
--   jdt.ls Startup Status: Ready
--   jdt.ls Java Path: /usr/bin/java
--   jdt.ls Launcher Config.: /root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/workspace/config_linux
--   jdt.ls Workspace Path: /root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/workspace/temp/tmphti9mhgr
--   jdt.ls Extension Path: ['/root/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/extensions']
-- Server running at: http://127.0.0.1:42109
-- Server process ID: 16665
-- Server logfiles:
--   /tmp/ycmd_42109_stdout_2kgqncdp.log
--   /tmp/ycmd_42109_stderr_r64ei2ia.log

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

37a149ee028bfb61a6e33dbfe30d7ce1343c9519

Contents of YCM, ycmd and completion engine logfiles

gist for log file: https://gist.github.com/dassio/94957be29141cd3827899d9b8ef359cd

OS version, distribution, etc.

Ubuntu 20

Output of build/install commands

python3 install.py --java-completer

dassio avatar Sep 10 '20 21:09 dassio

I couldn't repro this. Can you test with the actual minimal vimrc that we provide, like explained in the issue template?

bstaletic avatar Sep 11 '20 08:09 bstaletic

I couldn't repro this. Can you test with the actual minimal vimrc that we provide, like explained in the issue template?

i copied the content of vimrc.minimal to my vimrc, as you can see, except for vim-plug to load the plug, there is nothing there

i suspect that it has something to do with the unused import feature, if i select the import with wildcard, YCM will delete it since no code is using the whole package

dassio avatar Sep 11 '20 09:09 dassio

i copied the content of vimrc.minimal to my vimrc, as you can see, except for vim-plug to load the plug, there is nothing there

If that were the same, I wouldn't be asking you to do that. I am not trying to waste your time, nor mine for that matter.

i suspect that it has something to do with the unused import feature, if i select the import with wildcard, YCM will delete it since no code is using the whole package

YCM never randomly deletes imports. A user needs to request that action.

bstaletic avatar Sep 11 '20 09:09 bstaletic

@dassio could you provide a minimal repro case using the minimal vimrc per the instructions in CONTRIBUTING.md

We need the minimal files required to repro and exact steps? I can see what's happening in the gif, and it's clearly wrong. I guess I have a suspicion about what might be happening, but per CONTRIBUTING.md if we can't repro, we can't fix it. We have to be able to repro, because we have to write tests. It's really that simple.

The reason we ask for this is not to waste your time, but to ensure that we're fully understanding and properly fixing issues, and to minimise the time we have to spend to solve it. Ultimately, it's better for you because you get a faster resolution.

Otherwise, most regrettably, we may have to exercise:

If filing a bug report, I have included a minimal test case that reproduces my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I expected to happen and what actually happened.

and

I understand my issue may be closed if it becomes obvious I didn't actually perform all of these steps.

puremourning avatar Sep 11 '20 10:09 puremourning

i suspect that it has something to do with the unused import feature, if i select the import with wildcard, YCM will delete it since no code is using the whole package

Yeah I don't think so. I think it's more likely that we're miscalculating some offset or other when applying the completion.

Looking at the logs, I can see this is the completion item that ycmd provided:

{
   "completions":[
      ,
      ,
      {
         "insertion_text":"concurrent.atomic.*;",
         "extra_menu_info":"(package) java.util.concurrent.atomic",
         "menu_text":"java.util.concurrent.atomic",
         "detailed_info":"java.util.concurrent.atomic\n\n",
         "kind":"Module",
         "extra_data":{
            "fixits":[
               {
                  "location":{
                     "line_num":1,
                     "column_num":26,
                     "filepath":"/root/server/src/main/java/dassio/me/server/Greeting.java"
                  },
                  "chunks":[
                     {
                        "replacement_text":"\n\n",
                        "range":{
                           "start":{
                              "line_num":1,
                              "column_num":26,
                              "filepath":"/root/server/src/main/java/dassio/me/server/Greeting.java"
                           },
                           "end":{
                              "line_num":5,
                              "column_num":1,
                              "filepath":"/root/server/src/main/java/dassio/me/server/Greeting.java"
                           }
                        }
                     }
                  ],
                  "text":"",
                  "resolve":false
               }
            ]
         }
      },
      
   ],
   "completion_start_column":18,
   "errors":[
      
   ]
}

It looks like jdt.ls is asking us to insert 2 newlines covering line1/col 26 to line 5/col 1 after applying the insert. This (I guess) is overwriting the insertion of the import.

I feel like this has been reported before, but I don't remember the context.

puremourning avatar Sep 11 '20 10:09 puremourning

thanks for the prompt reply , this is really suprise me

i am trying to reproduce this one in an docker container , so i can push an image based on that, you guys can pull that image and give it a try

dassio avatar Sep 11 '20 10:09 dassio

you can run the docker image: @puremourning

docker run -it pdassio/ycm:import-error /bin/bash
cd ~/server
vim src/main/java/dassio/me/server/Greeting.java

and try to import the cocurrent.ato package

dassio avatar Sep 11 '20 11:09 dassio

Thanks so much. We will give it a go

puremourning avatar Sep 11 '20 11:09 puremourning

I still can't repro even with the linked docker image. Here's a recording.

https://asciinema.org/a/TSmspTXw3K9aGwqoOSlsnYFPC

bstaletic avatar Sep 20 '20 20:09 bstaletic

Yes,I also meet this bug!....hahaha..When it will be fixed.....

Decodetalkers avatar Dec 23 '20 13:12 Decodetalkers

I've the same issue. Just a simple case of a new file, typing in import java.io.F<Tab> until I want to autocomplete File, after enter, or space the whole import is removed. I get a The import java.io.F cannot be resolved [268435846] error on the statusbar.

soderluk avatar Mar 09 '21 13:03 soderluk

As you can see, I tried to repro and couldn't. Does it happen with the vimrc_ycm_minimal?

bstaletic avatar Mar 09 '21 13:03 bstaletic

@bstaletic No. But with the minimal I can't get it to autocomplete after import java.io. -> So cannot autocomplete java.io.File at all. Which is a bit weird.

soderluk avatar Mar 09 '21 13:03 soderluk

@soderluk Sorry for the (very) late reply. If you can't get any completion to work, check that YCM was loaded. Does :YcmDebugInfo work?

bstaletic avatar Apr 01 '21 22:04 bstaletic

@bstaletic no problem. I did a complete restructuring of my vimrc and setup, removed redundant plugins and such. Now it seems this issue is gone. No idea which plugin it was that caused this issue.

Note: I did have now an issue where the autocomplete popup window got stuck on the screen, and I couldn't get into insert mode. I just got a "E523 not allowed here" error... I added the completeopt-=preview in my vimrc which apparently fixed this issue.

soderluk avatar Apr 06 '21 07:04 soderluk

Note: I did have now an issue where the autocomplete popup window got stuck on the screen, and I couldn't get into insert mode. I just got a "E523 not allowed here" error

check your vim version. There was a vim bug a while ago which was causing this.

puremourning avatar Apr 06 '21 08:04 puremourning

This issue does not appear to have a solid reproducer and as such cannot be resolved, so closing. If a user continues to see issues, let's rase a new GH issue with a reliable reproducer.

puremourning avatar Aug 27 '22 21:08 puremourning

cannot repro

puremourning avatar Aug 27 '22 21:08 puremourning