Giter Club home page Giter Club logo

camel-idea-plugin's Introduction

Apache Camel IDEA Plugin

Chat Twitter

Plugin for Intellij IDEA to provide a set of Apache Camel related capabilities to the code editor.

The plugin includes:

  • Code completion for Camel endpoints in Java, XML, properties or YAML files (ctrl + space)
  • Code completion for Camel message headers (available setHeader and header) in Java, XML and YAML files (ctrl + space) with corresponding Quick documentation (ctrl + j)
  • Code completion for Camel property placeholders (cursor after {{)
  • Code completion for Camel options' key and value in properties and YAML files (ctrl + space) with corresponding Quick documentation (ctrl + j)
  • Code completion for Kamelet name and options' key and value in Kamelet binding files (ctrl + space) with corresponding Quick documentation (ctrl + j)
  • Real time validation for Camel endpoints in Java, XML, YAML (underline errors in red)
  • Real time validation for Camel simple language in Java, XML, YAML (underline errors in red)
  • Endpoint options filtered to only include applicable options when used as consumer vs producer only mode
  • Quick navigation to other Camel routes routing to this route by clicking the Camel icon in the gutter
  • Intention to add new Camel endpoint (alt + enter in empty string)
  • Quick documentation for Camel endpoints and external link to Camel component opening in web browser (ctrl + j and shift-F1)
  • Show endpoint information in tooltip when hovering mouse over from/to etc in Java route builders
  • Supports 3rd party Camel components (if they have been properly built with Camel JSon schema metadata)
  • Attempts to use same version as camel-core dependency from the loaded project (may require download over internet)
  • Inspection (analyze code) to validate Camel endpoints in Java, XML, YAML
  • Camel icon in gutter can be customized by choosing one of the three provided icons
  • Supports loading camel-catalog from third party Maven repositories define in the project Maven pom.xml file
  • Defines the Camel Runtime (set manually or detected automatically) to adapt the completion of options' key and value in properties files accordingly (by default automatic detection is enabled)
  • Auto setup of the Camel Debugger for different Camel runtimes (Standalone/Main, SpringBoot, Quarkus). In case of Camel Quarkus, it is only possible using the Camel Quarkus runner.
  • Evaluate Camel expressions and set the body, Headers or Exchange properties from the Debugger Window thanks to custom actions
  • Set the body, Headers or Exchange properties from the context menu of the Debugger Window using the Camel simple language
  • Format the Camel routes written in Java for a better readability

When the plugin becomes more complete and stable then the intention is to donate the source code to Apache Software Foundation to be included out of the box at Apache Camel.

However currently the code is located at github to allow faster and wider collaboration in the community.

Screenshot

How to install

The plugin Apache Camel is available from Jetbrains Plugin Repository at: https://plugins.jetbrains.com/idea/plugin/9371-apache-camel-idea-plugin

You should be able to install the plugin from within IDEA plugin manager. Open the Preference menu and select Plugins. Click the Markeplace... and type Apache Camel in the search box to find the plugin, and then you can install it.

How to try

The plugin is editing Java endpoints in Java source code.

You can open any Camel example which uses Java code, such as the Camel Spring Boot Example and select the MySpringBootRouter route class and position the cursor on any of the Camel endpoints after the '?' mark and press ctrl + space.

Currently, its only endpoint options in the URI query section which can be edited. It's planned to add support for editing the options in the URI context-path section as well.

Plugin Preferences

The plugin comes with a preference where you can configure global settings for the plugin such as turning on or off the real time validation in the editor, or whether to show the Camel icon in the gutter, etc. If you want to change the default preferences open the Preferences... menu, select Languages & Frameworks and Apache Camel. Here are screenshots of it: Screenshot Screenshot

Building from source

You can build the plugin from source code, which requires to setup IDEA for plugin development.

You can follow the guide from Jetbrains here: http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/setting_up_environment.html

To be able to browse the IDEA SDK source code you can clone the IDEA community source code, as described in the guide above. I did this so I can peak inside their source code, because you need this to find out how to hook into various IDEA APIs which is massive and takes longer time to figure out to use. Sadly Jetbrains are not very good at documenting their APIs with neither javadoc, or documentation to their own plugins. However with some trial and run you can find out bit by bit.

Importing project as gradle project

Importing the project into IntelliJ as plug-in only require you choose ìmport from external model` and select gradle

Important : if you are using the Ultimate version you can set a gradle property in your gradle.properties intellij_type=IU

  • Open your IDEA
  • Create a new project from existing source
  • Select the "camel-idea-plugin" location
  • Import project from external module and select Gradle
  • Press next until you hit the page "Please select the project SDK"
  • Press the "+" and add new "IntelliJ Platform Plugin project"
  • Press next and finish
  • Open the "Module Settings" and select the tab "Plug-in Deployment"
  • Make sure the path to the "META-INF/plugin.xml" point to the "src/main/resources/" directory

Running the plug-in with a previous versions of IDEA

The plugin is tested with IDEA 2024.1.6 or newer, but if you want to try with an older version you can follow this guide

  • Follow the guide build from source
  • Change the attribute <idea-version since-build="231"/> in camel-idea-plugin/src/main/resources/META-INF/plugin.xml to match the version. please see document for build number description
  • Build the source with ./gradlew build
  • The new plugin zip file camel-idea-plugin-<version>-SNAPSHOT.jar is located in camel-idea-plugin/build/libs
  • Install the plugin from disk in IDEA preferences

Running and debugging the plugin from source

After completing all steps and if everything is setup correctly, then you can launch the plugin by running the gradle task runIde and for building and running test run the gradle task build

gradle task

You can also launch the plugin in debug mode where you can put breakpoints in the source code. This is very handy to debug the code and find issues. However for code changes you need to stop and start the plugin again.

Running the unit test

Running the IntelliJ unit test from gradle with the community version

gradle test

Contributing / Hacking on the code

We love contributions. Anyone is welcome to join and hack on the code. For code changes you can submit GitHub PRs (pull requests) which anyone can review and get merged into the code base.

For people who hack more on the code, can be granted commit rights.

You should be willing to provide any code changes under the ASF license and that the code later will be donated to Apache Software Foundation to be included out of the box at Apache Camel. If you are not willing to accept this, then we are sorry, but then any code contributions cannot be accepted.

IDEA SDK and FAQ

Jetbrains provides a FAQ for the IDEA SDK which is massive and takes time to learn.

They also provide a forum for API Plugin Development.

For Gitter Channel

Camel IDEA Plugin FAQ

We created a FAQ page to help other developers with common errors when working with the plugin sources.

Screenshots

We will post various screenshots of the plugin in the img directory which you can browse.

camel-idea-plugin's People

Contributors

adrianbumbas avatar ammachado avatar apupier avatar bennetelli avatar davsclaus avatar dependabot-preview[bot] avatar dependabot[bot] avatar dimitrisli avatar essobedo avatar fharms avatar javaduke avatar jeremyross avatar lhein avatar markomackic avatar mateusz-bajorek avatar mayyanar27 avatar mcollovati avatar rastislavpapp avatar rparree avatar snurmine avatar tcke83 avatar zohen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camel-idea-plugin's Issues

Add support for using version of Camel from the project

Currently we use the 2.19-SNAPSHOT camel catalog which is embedded in the plugin.

We should find a way to detect what version the user is using, eg 2.18.1 etc in a maven project / dependency list. And find that version, and configure the camel-catalog to use that version. There is API on CamelCatalog to switch version.

Smart completion - Support editing context-path of the uris

Currently we only support URI parameters, eg (foo=bar&me=you).

However the Camel endpoints have the context-path part which we can have smart completion / code assistance for. This is a bit more tricky because each component can have a bit different syntax of the context-path (some uses / others : etc to separate multi values). So we need to parse the syntax and understand which value your are editing and provide the right suggestion.

Intention to add new Camel endpoint

We could have an intention (alt + enter) if you position the cursor on an empty string.

Then the intention could have a dialog where you can select among the known Camel components from the project (eg on the classpath). And then the smart completion can take over to assist fill in the rest of the details of the uri.

Smart completion for any String values

Currently we are limited to Camel annotations such as @Produce

We should allow to edit Camel endpoints in any string, as you can use this in

  • route builder classes
  • producer templates etc

So there should maybe be some quick way to determine if its a Camel endpoint or not. Which we can use the catalog to match any known component name.

Language Server Protocol

Wonder if IDEA supports LSP or we can have some reuse of the plugin so parts of it can be used in Eclipse / Eclipse Che or other editors which can support LSP as well.

There are surely parts of this plugin that touches the camel catalog and checks the endpoint uri etc, that can be made reusable without relying on IDEA APIs.

Find Usages Provider - Camel Routes

If you are inside a route and need the from/to Usages. Same functionality you can do with Java

for example if you find usages from "timer:trigger" it should list the "timer:status"

from("timer:trigger")
    .transform().simple("ref:myBean")
    .to("log:out");

from("timer:status")
    .bean(health, "invoke")
    .log("Health is ${body}");

One instance of CamelCatalog

We need to use one instance of CamelCatalog so we use the same.

Also later when we add support for adding custom Camel components, switching to version of Camel catalog based on what Camel version the user has in his/her project, we need these changes on the same instance for the entire plugin code.

We can likely use a static instance as there is one plugin only.

Maybe have a CamelCatalogService where we have this static which we then use to get hold of.

Inspection to validate Camel endpoints

We could add a code inspection that discovers all your Camel endpoints and then uses the validate API from CamelCatalog to validate if they are okay or not, and then report issues.

Visual route diagram

Wonder if we can reuse yfrog from IDEA to show route diagram / diagram popup as IDEA can do for class hierarchy.

This plugin is in IDEA ultimate, and maybe its some kind of addon you can install on community as well.

screen shot 2016-12-28 at 9 43 33 am
screen shot 2016-12-28 at 9 43 46 am

Add Camel icon in gutter

Wonder if we should add a Camel icon on the lines which has detected a Camel endpoint?
For spring beans you also have an icon in the gutter when its a Spring Bean / @bean or something.

Add support for custom Camel components

If the user has their own camel components which has camel metadata, then we should allow to use them as well.

This requires detecting them from the project / classpath / maven pom etc. And then discover if there is Camel components and add them to the CamelCatalog, which has APIs for adding custom components.

We have some code in fabric8-forge that discovers this
https://github.com/fabric8io/fabric8-forge/blob/master/addons/camel/src/main/java/io/fabric8/forge/camel/commands/project/AbstractCamelProjectCommand.java#L541

Intention - Open component documentation

An intention or hint or something which allows you when the cursor is positioned on a Camel endpoint, to open the component documentation from the Camel website.

Or we can load the .adoc file from the camel-catalog, and show in some page inside IDEA itself or something.

Smart completion for property placeholders

So if you edit a camel endpoint such as

jms:foo?concurrentConsumers={{ CURSOR HERE

And then can press ctrl + space then we should try to find any keys from .properties files and show in the list.

Should we have a little website

Maybe using github pages to have a little website for the plugin?

We could try to build a site using adoc files which is something we are starting to use at Apache Camel and other projects. Then it can build a html site or I think github can show adoc files as well (not as sure for github pages).

https://pages.github.com/

Camel scratch file

IDEA has a stratch pad where you can chose a language, such as java, groovy, xpath, xml, json etc and then write some scratch code which you can run, debug etc.

Wonder if there is something we can do for Camel. Such as setting up a Camel endpoint and consume or produce a message to it easily?

Or try the simple expression language on a dummy exchange etc

The action is: new scratch file

screen shot 2016-12-27 at 1 56 18 pm

Smart completion for XML files

We should also do smart completions for XML files so you can edit Camel endpoints there as well.

This requires an XML reference
https://github.com/davsclaus/camel-idea-plugin/blob/master/resources/META-INF/plugin.xml#L26

And find out how to do that.

There is some IDEA plugins that can do this.
https://github.com/JetBrains/intellij-community/tree/master/plugins

Maybe xpath
https://github.com/JetBrains/intellij-community/blob/master/plugins/xpath/xpath-view/src/META-INF/plugin.xml#L159

F1 documentation for data formats and languages

If you position the cursor on a Camel route that uses data formats or languages, we should detect from the AST what is what and try to resolve which data format or language, eg jackson-json or simple language etc, and then load and show the documentation accordingly.

Only active Camel plugin if its a Camel project

We should add some logic in project open / close etc to detect if its a Camel project (eg has camel-core on dependency classpath) and if so only active the Camel smart completions if so.

Documentation - Make F1 doc about current options

and then refer to the general documentation with some kind of link.

eg so when users press F1 they see the docs about what their current endpoint is configured as. Its like the cmd hover thing we have today.

Its like this screenshot
https://github.com/davsclaus/camel-idea-plugin/blob/master/img/early6.png

And then if we have some kind of link in top so the user can see the general component docs.

As the cmd however thingy is obscure and not many people know it exists.

Intention - To add new Camel component from catalog

So you can add a new Camel component to your project classpath and have it added to your pom.xml or gradle build file as dependency.

The catalog can then show a list of all components, we may want to show by group so the list is not a big 200 lines, or have a table/spreadsheet like dialog where you can easily navigate in all four directions to find the component of choice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.