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
Adds Kotlin (beta) content #11384
base: codeql-cli-2.11.4
Are you sure you want to change the base?
Adds Kotlin (beta) content #11384
Conversation
...odeql/codeql-language-guides/abstract-syntax-tree-classes-for-working-with-java-programs.rst
Show resolved
Hide resolved
|
|
||
| .. pull-quote:: Enabling Kotlin support | ||
|
|
||
| To enable Kotlin support, you should enable `java` as a language. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
If yes, it sounds a bit unintuitive that you have to enable java to enable Kotlin IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: Due to how common it is for Kotlin code to call Java code and vice versa within a single project, we treat them as essentially 2 compilers for the same language. This also means that the CodeQL libraries and queries can be shared between the two which, as they are very similar underneath, saves a lot of duplication. This is similar to how javascript and typescript are treated by CodeQL as a single language, as well as the C family (standard C and C++ in their various versions, as well as Microsoft and GNU extensions to those languages).
@subatoi - thank you for pitching in and getting these changes sorted out so quickly
Generally this looks good to me. I've added a few comments but nothing major.
One difference between RST and MD which trips us all up is the use of double backticks for monospaced font. A single backtick appears as italic text. I've fixed some of the backtick errors where I was commenting anyway, but it's worth checking for any that I missed.
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
…s-for-working-with-java-programs.rst
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Java/Kotlin: Make the basic query in docs work for both languages
|
|
||
| In that specific case, you can use the predicate ``Expr.getUnderlyingExpr()``. This goes directly to the underlying ``VarAccess`` to produce a more similar behavior to that in Java. | ||
|
|
||
| Nullable elements (`?`) can also produce unexpected behavior. To avoid a `NullPointerException`, Kotlin may inline calls like `expr.toString()` to `String.valueOf(expr)` when `expr` is nullable. Make sure that you write CodeQL around the extracted code, which may not exactly match the code as written in the codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@subatoi - it looks as if you may have an extension that's removing the double backticks because they've vanished again from this paragraph: 357c823#diff-8e08ecaf9b0928a502efdea7c357815043c20b9d0e11aa9a303b7ed07ddf2267.
Note that the content design plan noted possible additions to https://codeql.github.com/docs/codeql-cli/extractor-options/; I could not find a suitable place