Closed wsdjeg closed 7 years ago
@wsdjeg it seems to be putting my Neovim into an infinite loop. Running :JCclasspathGenerate
freezes my buffer until I exit
Is there any example project? I want to test it.
@wsdjeg I'll try to make one tonight when I have some time
@wsdjeg looking at the code, it looks like it's getting caught on the while loop. Would something like this be better?
let cp = ''
let flag = 0
for i in range(len(s:gradleOutput))
if s:gradleOutput[i] =~ '^CLASSPATH:'
let cp .= s:gradleOutput[i][10:]
if s:gradleOutput[i] !~ '^\s*$'
let cp .= s:gradleOutput[i]
endif
endif
endfor
Edit: Fixed some stuff
why do you add s:gradleOutput[i] twice? what I did means, check the output line by line, if a line beging with CLASSPATH, then add [10:] of this line into cp, then check the next line.
ok, I think I should not use while in it.
Ah, yeah, that was probably silly. It's just me trying to show what I mean, there are probably big issues with what I'm doing there since I'm not in a place that I can test it
I think it should be fixed.
Got back around to be able to test this
https://github.com/DonnieWest/Dispatch here's a sample project
It looks like the output still includes the last few lines BUILD SUCCESSFUL
and the timestamp. This is probably silly, but, this seems to work on my end
let cp = ''
for i in range(len(s:gradleOutput))
if s:gradleOutput[i] =~ '^CLASSPATH:'
let cp .= s:gradleOutput[i][10:]
for j in range(i, len(s:gradleOutput) - 1)
if s:gradleOutput[j] =~ '^BUILD'
break
endif
if s:gradleOutput[j] !~ '^\s*$'
let cp .= s:gradleOutput[j]
else
break
endif
endfor
break
endif
endfor
I'm sure there's a better way to test for that though. My Vimscript skills are lacking :)
as I know there is a black line before '^BUILD', I think the black line should not be added in to cp. I will test it.
@DonnieWest can you post a example of gradle out put? I can not test in local.
Here's a pastebin of it
@DonnieWest I just test my PR, it works well for me.
@wsdjeg I just tested and If I echom g:JavaComplete_LibsPath
it says
/jars/classes.jarBUILD SUCCESSFULTotal time: 24.698 secs
At the very end. If we leave that, it'll cause the last .jar file in the CLASSPATH to not have completions, right?
yes. but I do not know why. as you know there is a black line before BUILD SUCCESSFUL
, so this line should not be added to cp.
@wsdjeg I've found that there isn't a \n
or other whitespace character before BUILD SUCCESSFUL
. They seem to be removed by Neovim, otherwise we could do something like
let l:classpath = split(join(s:gradleOutput, ''), "\n")
let cp = filter(l:classpath, 'v:val =~ "^CLASSPATH:"')[0][10:]
and be done. Is checking for BUILD
at the start of the line going to be the fix or should we have Gradle print something to let us know it's the end of the CLASSPATH?
yes, good idea.
@wsdjeg #315 builds on this PR - mind checking it out? It seems to work for me locally but probably still does some silly stuff
nice work! It is ok to me.
@DonnieWest can you have a try?