neowit / vim-force.com

Vim plugin for force.com
113 stars 25 forks source link

Auto-completion doesn't work #87

Open kgrzywacz opened 7 years ago

kgrzywacz commented 7 years ago

In theory I have everything set up correctly(I think) because whenever I use omni competition on small project (Developer Edition org with few classes) it works.

But when I switch to my company's organizastion I'm getting following errors:

Operation failed
Error detected while processing function apexComplete#Complete[9]..<SNR>93_listOptions[13]..apexTooling#listCompletions[13]..apexToolingAsync#executeBlocking[17]..280[52]..<SNR>108_parseErrorLog[42]..apexMessages#process:
line    8:
E121: Undefined variable: null
Error detected while processing function apexComplete#Complete[9]..<SNR>93_listOptions[13]..apexTooling#listCompletions[13]..apexToolingAsync#executeBlocking[17]..280[52]..<SNR>108_parseErrorLog[42]..apexMessages#process:
line    8:
E15: Invalid expression: {"id":1,"text":null,"type":"ERROR"}
Error detected while processing function apexComplete#Complete[9]..<SNR>93_listOptions[13]..apexTooling#listCompletions[13]..apexToolingAsync#executeBlocking[17]..280[52]..<SNR>108_parseErrorLog[42]..apexMessages#process:
line    9:
E715: Dictionary required
0

When trying to use omni-completition with pressing Ctrl-x,Ctrl-o in insert mode with following text before cursor: system.

Any idea what it might be?

neowit commented 7 years ago

Before you add system. - does the file where you are trying to execute completion pass :ApexCheckSyntax ?

If it does pass syntax check - can you extract this file into its own local project (i.e. remove all other files except the class where you get the error) and check if you get same error ?

If you still get the error - it would be interesting to see what you file looks like. Perhaps you could try to reduce the file in question to bare minimum - remove everything you can while error still happens so you could share it here.

Can you also share the content of path-to-project/.vim-force.com/response_listCompletions generated when you executed failed call to auto completion ?

Thanks

kgrzywacz commented 7 years ago

:ApexCheckSyntax doesn't return any message, but contents of project/.vim-force.com/response_checkSyntax is following: RESULT=SUCCESS

Contents of project/.vim-force.com/response_listCompletions:

RESULT=FAILURE
MESSAGE: {"id":7,"text":null,"type":"ERROR"}

For this test I've created and deployed new file in this project:

public class SyntaxTest {
    public static void method() {
    }
}

Problem occurs in this file as well.

neowit commented 7 years ago

Interesting... looks like grammar/syntax is not an issue in your case. Must be something config related.

if you move that test "SyntaxTest.cls" to your small "Developer Edition" project - do you get completion or do you get an error ?

If you do not get the error - perhaps path or file permissions of your work project cause a problem somehow. Can you try moving your "work" project to a simpler path to see if this makes a difference ?

Also, please post here:

Thanks

kgrzywacz commented 7 years ago

All my projects are in the same path dev project: projects/project_test1 working projects/project_test2 not-working

Just to double check, I've just inited both work org and dev org with :ApexInitProject and the result is as before.

Java:

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

OS: macOS Sierra v10.12.4 ApexTooling: INFO: tooling-force.com - version: 0.3.8.0; SFDC API Version: 38.0 vim version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 25 2017 08:55:37)
MacOS X (unix) version
Included patches: 1-604
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             -clientserver    +cursorbind      +ex_extra        -gettext         +libcall         +mouse           +mouse_xterm     +persistent_undo +ruby            +tag_old_static  -toolbar         +wildmenu        -xterm_save
+arabic          +clipboard       +cursorshape     +extra_search    -hangul_input    +linebreak       -mouseshape      +multi_byte      +postscript      +scrollbind      -tag_any_white   +user_commands   +windows
+autocmd         +cmdline_compl   +dialog_con      +farsi           +iconv           +lispindent      +mouse_dec       +multi_lang      +printer         +signs           -tcl             +vertsplit       +writebackup
-balloon_eval    +cmdline_hist    +diff            +file_in_path    +insert_expand   +listcmds        -mouse_gpm       -mzscheme        +profile         +smartindent     +termguicolors   +virtualedit     -X11
-browse          +cmdline_info    +digraphs        +find_in_path    +job             +localmap        -mouse_jsbterm   +netbeans_intg   +python          +startuptime     +terminfo        +visual          -xfontset
++builtin_terms  +comments        -dnd             +float           +jumplist        -lua             +mouse_netterm   +num64           -python3         +statusline      +termresponse    +visualextra     -xim
+byte_offset     +conceal         -ebcdic          +folding         +keymap          +menu            +mouse_sgr       +packages        +quickfix        -sun_workshop    +textobjects     +viminfo         -xpm
+channel         +cryptv          +emacs_tags      -footer          +lambda          +mksession       -mouse_sysmouse  +path_extra      +reltime         +syntax          +timers          +vreplace        -xsmp
+cindent         +cscope          +eval            +fork()          +langmap         +modify_fname    +mouse_urxvt     +perl            +rightleft       +tag_binary      +title           +wildignore      -xterm_clipboard
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.1
2 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.1/lib/perl5/5.24.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.1 -lobjc

ApexMessages:

************************************
 press 'q' to close this buffer
************************************

  --action=listCompletions --tempFolderPath='temp_path/temp' --config='projects_path/.settings/work_project.properties' --projectPath='projects_path/work_project' --column=10 --line=3 --currentFilePath='projects_path/work_project/src/classes/SyntaxTest.cls' --currentFileContentPath='/var/folders/3z/w10m48r534lb31p9gzpnky6c0000gn/T/vaFR4P9/16SyntaxTest.cls' --responseFilePath='projects_path/work_project/.vim-force.com/response_listCompletions' --pollWaitMillis=1000 --maxPollRequests=1000
ERROR: Operation failed
INFO: 0
neowit commented 7 years ago

Thanks for the details.

Everything looks in order at first glance.

Have you tried moving that test "SyntaxTest.cls" into your small "Developer Edition" project - do you get completion or do you get an error ?

If you do not get an error - can you also try renaming: projects/project_test1 (the working one) to something else temporarily, and rename projects/project_test2 (non working one) to projects/project_test1 then kill all java processes (to make sure tooling-force.com.jar) is not running and try to call completion in SyntaxTest class (which is now in new location) again.

If that still does not work then next I would try to see if there is a file (or files) in the current project which make apex code scanner crash. This can be checked by gradually removing groups of files from project folder and trying completion in SyntaxTest after each removal.

kgrzywacz commented 7 years ago

Hey, moving this class to another project worked, renaming didn't.

I've removed all classes except SyntaxtTest.cls from the project and it works. So my next question is: Is there a better way to identify faulty fields than removing them randomly and checking if code-completition works in other file? What exactly does :ApexCheckSyntax do?

neowit commented 7 years ago

What exactly does :ApexCheckSyntax do?

It checks syntax of a given file against the grammar.

Most problems with code completion relate to things in the source files which current grammar does not handle properly.

Is there a better way to identify faulty fields than removing them randomly and checking if code-completition works in other file?

Did you mean "identify faulty files" ? In the current version it is a manual process unfortunately.