docs icon indicating copy to clipboard operation
docs copied to clipboard

avoid static imports in Java sample code

Open rjayasinghe opened this issue 1 year ago • 6 comments

in case this code is copied to an IDE the imports are missing and you have a bit of a challenge to find the right import for the static imports (VS Code Java extension does not support it at all at the moment).

Alternatively we could also use the new 'focus' feature for code blocks and include the static import statements as 'unfocused' but have them included in the clipboard after clicking the copy button.

rjayasinghe avatar May 09 '23 12:05 rjayasinghe

I think the static imports improve readability but should be mentioned somewhere

agoerler avatar May 10 '23 17:05 agoerler

I think the static imports improve readability but should be mentioned somewhere

Some of the statically imported symbols are ambiguous when being imported to an IDE. Even worse, VS Code has no way to resolve the imports with a code action.

So, either we avoid static imports (first commit) or have the imports as part of the code block (but blur them) in order to guide the readers eye.

rjayasinghe avatar May 11 '23 14:05 rjayasinghe

Can this be merged? I had the feeling it's not final, that's why I'm asking.

renejeglinsky avatar Jul 19 '23 12:07 renejeglinsky

Let's at least update with the base branch. @agoerler merge or talk? ;)

rjayasinghe avatar Jul 19 '23 12:07 rjayasinghe

@agoerler merge or talk? ;)

talk :-)

agoerler avatar Jul 19 '23 17:07 agoerler

We could do sth similar to what we've done in the getting started in a Nutshell. There we have the small snippets that is needed and in addition a detail box that can be expanded if you want the full code example incl. imports.

image

renejeglinsky avatar Sep 24 '24 12:09 renejeglinsky