ABAP-AI-completion

ABAP AI Completion - Eclipse Plugin

🌐 Language / 语言: English 中文

Configure AI Press CTRL+ALT+.Completion comparison


English

An AI-powered code completion plugin for SAP ABAP developers, built for Eclipse. Based on Large Language Models (LLM), it pursues ultimate privacy and data security, supports local LLMs for in-house/enterprise use, preventing corporate code from being uploaded to the Internet to guarantee code confidentiality, and provides intelligent code suggestions and auto-completion while writing ABAP code.

Advantages over Copilot

Features


Installation (End Users)

System Requirements

Installation Methods

There are three ways to install; Method 1 (Eclipse Marketplace) is recommended.

  1. In the Eclipse menu bar, open HelpEclipse Marketplace...

  2. Type ABAP AI in the search box and find ABAP AI Completion

  3. Click Install and follow the prompts (accept the license, trust the certificate)

  4. After installation, click Restart Now (Restart Eclipse) to load the plugin

Method 2: Install via Install New Software
  1. In the Eclipse menu bar, select HelpInstall New Software... (some versions show HelpInstall Software...)

  2. Click the Add... button in the Available Software dialog and enter the update site URL:

    Name: ABAP AI Completion
    Location: https://yan252.github.io/ABAP-AI-completion/update-site
    

    💡 You can also click Archive... and select ABAP-AI-Completion-UpdateSite-1.0.5.zip for offline installation.

  3. Check ABAP AI Completion Feature, then click NextNext → accept the license → Finish

  4. After installation, click Restart Now (Restart Eclipse) to load the plugin

Method 3: Use the dropins approach (debugging/development)

Copy dist/com.sap.abap.ai.completion_1.0.5.jar to Eclipse’s <install-path>/dropins/ directory (create it if it does not exist), then restart Eclipse.


Usage

Manual Code Completion

  1. Open any ABAP source file (.abap, .prog, etc.)
  2. Place the cursor where you want completion
  3. Press Ctrl + Shift + . to invoke AI completion
  4. The AI suggestion displays as a floating overlay
  5. Press Tab to accept the suggestion, or any other key to cancel

Auto-Completion Mode

After enabling “Auto-complete while typing” in the configuration, AI suggestions automatically trigger after you stop typing for a period (default 2000ms).

Changing the Shortcut

To change the shortcut:

  1. Menu: WindowPreferences
  2. Navigate to: GeneralKeys
  3. Search: ABAP AI completion
  4. Click the Binding field and press the new key combination
  5. Click OK to save

Configuration

Opening the Configuration Page

  1. Menu: WindowPreferences
  2. Find ABAP AI Completion in the left navigation tree
  3. The configuration page is shown below:

Configuration Page

Configuration Items

AI Connection Settings
Setting Description Example
API Base URL AI service endpoint URL https://api.openai.com/v1
Model Name AI model name to use gpt-4, deepseek-v4-flash
API Key API authentication key (displayed as stars)
Max Tokens Maximum number of generated tokens 256
Temperature Creativity temperature (0.0-2.0) 0.3 (lower means more deterministic output)

💡 Tip: Click the Test Connection button to verify the API connection.

Feature Settings
Setting Description
Enable ABAP AI Completion plugin Enable/disable the entire plugin
Auto-complete while typing When enabled, auto-triggers AI suggestions after you stop typing
Auto-Completion Settings
Setting Description
Delay after typing (ms) How many milliseconds after you stop typing before auto-completion triggers

💡 Suggestion: Recommended value is 1500-3000 ms. Lower values increase API request frequency.

Skill Directory

Place .abap, .txt, or .skill files in the skill directory and the AI references these file code patterns for completion. This is very useful for project-specific coding standards and naming conventions.

Custom System Prompt

Customize the system prompt sent to the AI to guide it to follow specific code styles and standards.

Overlay Style

Customize the display colors of AI completion code in the editor.


Developer Guide (Custom Development)

Environment Requirements

Importing the Project

  1. Clone the repository locally:
    git clone https://github.com/yan252/ABAP-AI-completion.git
    
  2. Import the project into Eclipse:
    • FileImportExisting Projects into Workspace
    • Select the cloned project directory
    • Check the project and click Finish

Project Structure

com.sap.abap.ai.completion/
├── META-INF/
│   └── MANIFEST.MF              # OSGi bundle manifest
├── src/
│   └── com/sap/abap/ai/completion/
│       ├── client/              # AI API client
│       │   ├── AIClient.java
│       │   ├── AIClientException.java
│       │   └── PromptCacheManager.java    # Prompt compression & multi-node cache management
│       ├── editor/              # Editor integration
│       │   ├── AICompletionHandler.java
│       │   ├── AICompletionListener.java
│       │   ├── AICompletionOverlay.java
│       │   ├── AICompletionProposalPopup.java
│       │   ├── AICompletionService.java
│       │   └── AIOverlayManager.java
│       ├── logging/             # Logging
│       │   └── AILogger.java
│       ├── parser/              # ABAP parser
│       │   ├── AbapCodeTruncator.java
│       │   ├── AbapIncludeResolver.java
│       │   ├── AbapLanguageDetector.java
│       │   ├── ParentProgramContext.java
│       │   ├── ParentProgramResolver.java
│       │   └── WorkspaceCodeCollector.java
│       ├── preferences/         # Configuration management
│       │   ├── AICompletionPreferencePage.java
│       │   ├── AIConfiguration.java
│       │   ├── PreferenceConstants.java
│       │   └── PreferenceInitializer.java
│       ├── ui/                  # UI integration such as status bar
│       │   └── AbapAIStatusLineContribution.java
│       └── Activator.java       # Bundle activator
├── icons/
│   └── SAPLogo.ico              # Plugin icon
├── dist/                        # Published JAR
│   └── com.sap.abap.ai.completion_1.0.1.jar
├── update-site/                 # Update site
│   ├── features/
│   ├── plugins/
│   ├── artifacts.jar / artifacts.xml
│   ├── content.jar / content.xml
│   └── site.xml
├── tools/
│   └── CacheVerifyTool.java     # Cache verification tool
├── plugin.xml                   # Plugin extension point declarations
├── build.properties             # Build properties
├── build.ps1                    # Windows build script
├── build_plugin.xml             # Build script (ANT)
├── generate-update-site.ps1     # Update site generation script
└── rebuild.ps1                  # Rebuild script

Key Extension Points

This plugin integrates through the following Eclipse extension points:

Extension Point Purpose
org.eclipse.ui.startup Plugin auto-start
org.eclipse.ui.preferencePages Configuration page registration
org.eclipse.core.runtime.preferences Preference initialization
org.eclipse.ui.commands Completion command definition
org.eclipse.ui.bindings Shortcut key bindings

Core Architecture

  1. AIClient: Pure Java HTTP client that calls the AI Chat Completions API, no external JSON library required
  2. AICompletionService: Async completion service that handles timeouts, cancellation, and errors
  3. AbapIncludeResolver: Resolves ABAP INCLUDE programs to provide full context to the AI
  4. AIOverlayManager: Manages the display and interaction of the floating overlay
  5. AIConfiguration: Unified configuration management with preference storage

MESSAGE Nodes Sent to AI

When manual completion (Ctrl+Shift+.) is triggered, the plugin constructs a message list of 1 system node + 5 user nodes to send to the AI (corresponding to the buildUserMessages method in AICompletionService.java). The meaning of each node is as follows:

Node Role Content
System system System prompt. Defines the AI’s role (senior SAP ABAP development expert), completion rules, and output constraints. Can be overridden using Custom System Prompt
Node 1/5 user SKILL file content: .abap/.txt/.skill files loaded from the skill directory as code style and best-practice references. If no SKILL, it states “use system default ABAP coding standards”
Node 2/5 user Parent program call context: When the current file is an INCLUDE, deep search finds the code of the parent programs that call it (recursively searched by configured search depth). Compressed via PromptCacheManager.compressContent
Node 3/5 user Programs open in workspace: Other ABAP files open in the current Eclipse workspace as style reference and supplementary context (collected by WorkspaceCodeCollector, also compressed)
Node 4/5 user Program metadata: Summary of filename, code type, INCLUDE count, parent program/workspace/SKILL load status to help the AI comprehensively understand the overall context
Node 5/5 user Current program at cursor (with cursor position): Merged from the original “full code” node and “cursor context” node. Shows the complete code of the program at the cursor (with all INCLUDEs expanded via AbapIncludeResolver), with the insertion position marked with [[[CURSOR_HERE]]] — this is exactly where the AI generates the completion content

Note: Nodes 2 and 3 are uniformly compressed before sending via PromptCacheManager.compressContent (with the compression limit following the Max Workspace Code Chars configuration) to avoid context window overflow; Node 1 (SKILL) is sent in full, while the other nodes are sent according to their own rules. If a node has no matching content, a placeholder message (stating that node’s current status) is still sent to ensure the AI always receives the complete 1+5 node structure.

Comparison: Auto-completion (requestQuickCompletion) does not load SKILL or the above context; it uses a simplified standalone prompt and only sends 1 system node + 1 user node (current line context).

Building the Plugin

Using Eclipse Export
  1. Right-click the project → Export
  2. Select Deployable plug-ins and fragments
  3. Choose the output directory as dist/
  4. Click Finish
Using ANT Script
# Windows PowerShell
.\build.ps1

Or use the provided build_plugin.xml:

ant -f build_plugin.xml

Debugging the Plugin

Launch a new Eclipse instance in Eclipse to debug:

  1. RunRun Configurations
  2. Create a new Eclipse Application configuration
  3. In the Plug-ins tab, ensure com.sap.abap.ai.completion is included
  4. Click Run to start

FAQ

Q: The configuration option does not appear after installing the plugin?

A: Please verify:

  1. The JAR file is correctly placed in the dropins directory
  2. Eclipse has been restarted
  3. The Eclipse version meets the requirement (4.7+)
  4. The Java version is 17 or later

Q: What if code completion requests time out?

A:

Q: Which AI services are supported?

A: Any service compatible with the OpenAI Chat Completions API, including but not limited to:

Q: Can it be used offline?

A: No. This plugin requires a network connection to call the AI API service. However, reference files in the skill directory can help the AI generate code that better conforms to project standards.

Q: Is the API Key secure?

A: The API Key is stored in Eclipse preferences and displayed as stars. However, note that:


Technology Stack


License

This project is for learning and personal use only. Please comply with the terms of service and licensing requirements of the AI services you use.


Acknowledgments

This plugin is inspired by AI-assisted programming tools such as VS Code Copilot, aiming to provide a better coding experience for SAP ABAP developers.