DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • ReactJS With ChatGPT: Building Conversational AI Into Your Web Apps
  • Anthropic’s Model Context Protocol (MCP): A Developer’s Guide to Long-Context LLM Integration
  • Exploration of Azure OpenAI
  • Instant APIs With Copilot and API Logic Server

Trending

  • Gen AI Debugging Tools Compared: Genkit vs Vercel AI SDK vs Mastra
  • Beyond State Consistency: Preventing Stale Decisions in AI Agent Systems
  • Running TypeSafe AI's Jev Inside Neo4j for Confidence-Aware Sentiment Decisions
  • Supercharging AI Agents with Azure Context: A Hands-On Guide to Azure MCP

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. AI Code Intentions

AI Code Intentions

Any modern IDE includes Code Intentions that allow you to perform some predefined actions on your code based on a context or do some manipulation with the code.

By 
Gregory Ledenev
·
Jul. 07, 23 · Opinion
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
5.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Any modern IDE includes Code Intentions that allow you to perform some predefined actions on your code based on a context. For example, for a  for statement, there can be several intentions like Convert to while, Reverse order, Use Streams, etc. The use of Intentions is very handy as it allows us to perform quick refactoring or do some manipulation with the code. 

Intentions are pretty hard to develop, so they are usually hard-coded and bundled with the IDEs by respective IDEs vendors. In some IDEs, it is possible to develop your own Intentions, but it is not so easy as it requires good knowledge of an IDE platform, writing lots of code, developing plug-ins to deploy your Intentions, etc.

Though, hard-coded Intentions can become obsolete. Today, you can ask an LLM, e.g., ChatGPT, to perform some action on your code, and it is pretty easy. You have to provide your code snippet and a proper prompt. For example, if you supply the following loop with the Reverse direction of a loop prompt to ChatGPT:

Java
 
for (int i = 1; i <= max; i++) 
    System.out.println("i = " + i);


You will get the same result as using similar hard-coded Intention provided by your IDE:

Java
 
for (int i = max; i >= 1; i--) 
    System.out.println("i = " + i);


So, it is pretty natural that we should introduce AI Intentions, which are basically named AI prompts bound to some context. Context can be a file, class, statement, particular method, etc., and IDE would be responsible for supplying the correct context, asking LLM with the correct prompt, obtaining and parsing results, and committing them back to the code. 

The advantages of having AI Intentions are:

  1. Almost any refactoring can be done using plain language. The prompts can be as simple as Replace using format for well-known  APIs (like Java’s PrintStream.println(String)), or they can be more complex with more instructions for less-known APIs.
  2. No need to hardcode AI Intentions.
  3. No need to write plugins to distribute AI Intentions.
  4. AI Intentions can be easily user-configurable.
  5. No need to use a Chat interface, especially for repeating activities.
  6. Less LLM token traffic to allow saving the cost compared to the use of a Chat interface.

Another cool option is AI intentions that are baked right into the API using annotations. Such declarative AI Intentions would instruct the IDE what intentions are available per class, field, or method and which prompt should be used to perform a particular Intention by asking an LLM. Such declarative AI Intentions can be supplied by framework/libraries authors, and therefore they can be immediately available to all the developers in IDEs that support them.

For example, the following annotation would specify a Replace using format AI Intention that allows replacing println(String) calls taking a concatenated string to println(String, Object...) calls taking format and arguments list:

Java
 
@AIIntention(title="Replace using format", prompt="Replace using format and arguments list")
public void println(String x) {
}


So applying such an Intention to a call:

Java
 
System.out.println("i = " + i);


Would result:

Java
 
System.out.printf("i = %d%n", i);


The use of declarative AI Intentions can drastically improve dealing with deprecated APIs. So some/each deprecated method can include a few AI Intentions to allow refactoring it to a modern version — no more need to skip refactoring in the future. Browse docs and manual coding - just make your code up-to-date in a single click.

I believe AI Intentions is the future of IDEs and LLMs integrations. So I hope they will appear in many IDEs in the nearest future.

AI API Integrated development environment ChatGPT Language model

Opinions expressed by DZone contributors are their own.

Related

  • ReactJS With ChatGPT: Building Conversational AI Into Your Web Apps
  • Anthropic’s Model Context Protocol (MCP): A Developer’s Guide to Long-Context LLM Integration
  • Exploration of Azure OpenAI
  • Instant APIs With Copilot and API Logic Server

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook