Clion Intellij

Posted onby admin

CLion uses the project model to inform its coding assistance, refactoring, coding style consistency, and other smart actions in the editor. Supported formats include CMake, Makefile, Gradle, and compilation database. CLion is built on top of the IntelliJ platform, which means it inherits a lot of IntelliJ IDEA (e.g. Editor, navigation, VCS, etc) function-ality, as well as most of WebStorm func-tionality, and Python support provided by PyCharm Community either out-of-the-box, or with corresponding plugins to be installed. SonarLint supports most JetBrains IDEs, including IntelliJ IDEA, WebStorm, PhpStorm, PyCharm, CLion and RubyMine. It can analyze code written in Java, JavaScript, TypeScript, Python, PHP, C, C. Intellij ultimate is $200 for the first year and $100 each year after. It has the functionality of pycharm, rubymine, phpstorm and webstorm. Then clion is $100 for the first year and $60 each year after. That's still not a bad deal. Of course I would also appreciate getting clion and their objective c IDE in my copy of intellij ultimate.

New Features

  • #6992 Provide initial experimental support for custom deriveprocedural macros. Now the plugin can expand such procedural macro calls and take into account expanded impl itemsin type inference and name resolution (other types of items are ignored for now).
    Note, it’s only an initial implementation,so it may work in an unexpected way in some cases. The feature is disabled by default for now. To turn it on, youshould enable Use experimental name resolution engine option in Preferences Languages & Frameworks Rustsettings and enable org.rust.cargo.evaluate.build.scripts and org.rust.macros.procexperimental features.Don’t forget to reload a project structure after enabling the corresponding features via Refresh Cargo Projectsaction on Cargo tool window. See tracking issue formore details and the current status of procedural macros support

  • #7093 Now the plugin takes Cargo config into account during evaluation of cfg conditions.Note, it works since Rust 1.52.0 (currently in beta)

  • Introduce new intention actions:

    • #6845, #7115Enable/Disable feature state to toggles feature state from a cfg attribute (by @Kobzol)

      By the way, we have a blog post about cargo features support

    • #7071Share in Playground to share a selected Rust code on Rust Playground

      Previously, this feature was only available as Rust Share in Playground action in Tools and context menus

    • #6960Expand dependency specification for Cargo.toml

    • #6837Create struct to create a struct from an unresolved struct literal (by @Kobzol)

  • #5650 Now Use destructuring declaration intention action replaces usages of destructured variable (by @Kobzol)

  • #6986 Allow specifying the function return type in Create function intention action if the inferred return typeis unknown (by @Kobzol)

  • Improve code folding:

    • #7111 Support folding for multiline where clauses (by @Stzx)

    • #7112 Enable folding for series of use items by default (by @Stzx)
      You can disable it via Imports option in Settings Editor General Code Folding settings

    • #7112 Support Method bodies option of Settings Editor General Code Folding - General settingsto fold function/method bodies by default (by @Stzx)

  • Improve experimental crate-local index:

    • #6801 Add Cargo.toml inspection that checks crate dependency version requirements that do not match any knowncrate version (by @Kobzol)

    • #6599 Use semantic versioning to improve version sorting in dependency completion

    • #7004 Don’t perform code completion and run inspections if the index is not ready

    Note, the corresponding feature is disabled by default for now. To use it, enableorg.rust.crates.local.indexexperimental feature

  • #7142 Drop support of org.rust.cargo.fetch.out.dir experimental feature.Use org.rust.cargo.evaluate.build.scripts instead if you need to evaluateenv!('OUT_DIR') in your include! macro calls

Fixes

  • Name resolution fixes:

    • #7119 Correctly resolve qualified attributeprocedural macro paths (like #[foo::bar])

    • #7132 Resolve field shorthandto a local variable in the case of unresolved struct literal

  • Improvements of new name resolution engine:

    • #7089 Correctly resolve macros with absolute paths (like ::foo::bar!())

    • #7057 Exclude some cfg-disabled items from completion

  • Change Signature refactoring (Refactor Change Signature or Ctrl+F6) fixes:

    • #7081 Fix some false positives in name conflict detection (by @Kobzol)

    • #7080 Do not needlessly import default type arguments (by @Kobzol)

    • #7076 Correctly place function visibility after attributes (by @Kobzol)

  • #7108 Insert correct use item by auto-import feature in the case of arenamedCargo package

  • #7101 Fix false positive in Needless lifetimes inspection when the lifetime is used in where clause (by @Kobzol)

  • #5491 Add line break after opening brace in struct blocks by built-in formatter (by @Kobzol)

  • #7131 Fix false-positive proofreading warnings for sentences written in several sequential Rust comments.Note, you can enable/disable proofreading in Rust files in Preferences Editor Proofreading Grammar settings

  • #7121 Reload project model automatically when workspace-root Cargo.toml file is changed (and saved).Previously it was work only for package Cargo.toml files

  • #7079 Fix proc macro expansion if proc macro crate is added as separate cargo project in Cargo tool window

  • #7072 Place Show the result of macro expansion intention lower in the intention list

  • #6013 Don’t run some inspections on Rust files outside a valid Cargo project to avoid expected false positive errors

  • #7070 Don’t show errors related to Rust edition if we don’t known the edition (by @Stzx)

  • #7150 Fix Can't find process starter error when running DTraceprofiler with CLion 2021.1

  • #6201 Avoid Cargo project duplication in the project model. This fixes some issues related to such duplications

Internal Improvements

  • #7114 Don’t show “Tip of the Day” at startup in internal IDEs (for the plugin developers)

  • #7094 Enable Gradle Build Cache for local builds(see #7094 for more details)

  • #6903 Introduce 2021 edition variant in the plugin and adjust the corresponding code

Full set of changes can be found here

News

Like C/C++ and other native languages, Rust includes support for conditional compilation. The most common way to instruct the compiler whether to include or ignore a piece of code in compilation is to add a cfg attribute with the required condition. For example, you can use this mechanism to check the target architecture and switch code blocks at compile-time depending on the operating system.

IntelliJ Rust detects conditionally disabled blocks in your project and excludes them from the codebase. This means that name resolution and analysis ignore those pieces, so you won’t get errors and warnings inside them, and no items from that code will appear elsewhere in auto-completion. Also, the plugin grays the disabled blocks out in the editor.

This level of cfg support has been available in the plugin for a long while, but something was missing. Conditional options can include Cargo features. Previously, IntelliJ Rust supported only the features declared in the project’s dependencies, but now your workspace features are supported too.

We’ve implemented a smart UI to make your work with features more transparent: you can enable or disable any specific feature of your workspace right inside a Cargo.toml file. Name resolution and code insight will take that into account.

Let’s examine in detail how IntelliJ Rust handles Cargo features when they are used across various levels of dependency.

Library features

The simplest case is when you need to exclude features from a library, or include only some of them in your build.

To start, let’s add the tokio crate and enable all of its features using the full option:

If we open tokio’s Cargo.toml and navigate to the [features] section, we’ll see the selected checkboxes next to all the features listed in full:

Intellij

Now we can specify a particular feature instead of full, for example, signal. In tokio’s Cargo.toml, the checkboxes’ state will change accordingly. Only signaland the features it depends on are enabled now:

Please note that in the case of external dependencies, this UI is intended to help you grasp the state of features but not to control it, so the checkboxes here in the library’s Cargo.toml are not clickable. If you need to change the list of features, keep using your project’s .toml config.

Independent package features

Intellij

Another case is when you create your own features inside a package and use them in cfg blocks. Unlike with external libraries, here you can control the list of features by clearing and selecting the corresponding checkboxes.

Usually, Cargo features are additive and don’t conflict when enabled all together, which is the reason why IntelliJ Rust enablesworkspace features by default. However, you may want to toggle them on and off, and the plugin’s UI will help you do that!

The ability to toggle workspace features is especially handy when you use them as switchers instead of additive instances (for example, the Amethyst library has features controlling which of the available rendering engines is invoked at the moment). Previously, you would have had to manually remove the unneeded features from your Cargo.toml in order to turn them off.

As the UI now allows you to easily switch between features, be careful not to enable any mutually exclusive ones simultaneously. The plugin will not prevent you from doing so and will not show a warning, because at the .toml file level there’s not enough information for the plugin to detect potential problems in the sources.

Below you can see a multiple resolve situation reported in the sources when non-additive features are enabled at the same time:

Package features that depend on each other

A slightly trickier case is when your features depend on each other:

If you toggle one of them on or off, IntelliJ Rust will recognize the dependencies and toggle the related features accordingly.

Features with cross-crate dependencies

Your package features can also depend on features from another crate. Let’s make core from the previous example dependent on the macros feature from tokio:

Switching into tokio’s Cargo.toml, we’ll notice how macros, which is disabled by default, gets enabled when we toggle core on and gets disabled again when we turn core off:

Clion intellij setup

Features in a workspace

A more complicated scenario is when features are used in a workspace consisting of several packages.

As a simple example, let’s create a workspace with two packages – bar and foo. In foo’s Cargo.toml, we can declare a dependency on bar and specify that it uses a feature from barcalled bar_feature:

When using a workspace, you may want to develop a single crate inside it like an independent instance. In this case, you’ll need control over the crate’s features, with the ability to disable those you don’t need at a certain point.

So what happens if you focus on barand intentionally disable bar_feature? As a result, all the code in foothat uses itwill not be resolved, and it might be tricky to find the reason for the errors you’ll get in foo.

Clion Intellij

To help you avoid these problems, IntelliJ Rust checks the required features in your workspace dependencies and suggests quick-fixes for them:

Finally, your workspace crates can have features that depend on each other. For example, foo_features in foo depending on bar_feature from bar:

Here when we disable bar_feature, the plugin disables foo_feature automatically. However, when we turn bar_feature back on, foo_feature will not get enabled, so you need to roll back the dependent features manually.

In the future we plan to add navigation and completion for features from both .toml and source files, and start supporting cfg_attr. In the meanwhile, we hope you find these new capabilities helpful, and we really want to hear your feedback! Please share your experience of the new UI and let us know how you would like support for Cargo features in IntelliJ Rustto improve.

Thank you!

Clion Intellij Free

Clion Intellij

Clion Vs Intellij Rust

Your Rust team
JetBrains
The Drive to Develop