feat: support ABAP/ADT files in insert_edit_into_file tool - #374
Open
tobiasmelcher wants to merge 2 commits into
Open
feat: support ABAP/ADT files in insert_edit_into_file tool#374tobiasmelcher wants to merge 2 commits into
tobiasmelcher wants to merge 2 commits into
Conversation
Editing ABAP source via the insert_edit_into_file tool did not work correctly for two reasons: - The ABAP source editor does not observe changes to the underlying file, so after writing new contents to disk its editor buffer stayed dirty and out of date. Force the open editor to reload by reverting the text file buffer when it is dirty. - ADT (ABAP Development Tools) files that are locked in a transport-relevant way must be associated with a transport request before they can be edited. Verify this before applying changes and fail with a clear error when no transport request is assigned. The ADT lock result is read reflectively since the com.sap.adt.* classes are not available at compile time. Add the org.eclipse.core.resources.semantic dependency required for ISemanticFile.
tobiasmelcher
requested review from
duzitong,
ethanyhou,
jdneo and
xinyi-gong
as code owners
July 27, 2026 09:24
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the insert_edit_into_file tool to better support ABAP/ADT workflows in Eclipse by (1) forcing certain editors to reload after disk writes and (2) preventing edits to transport-relevant ADT-locked files unless a transport request is assigned, adding the necessary Eclipse semantic resources dependency.
Changes:
- Revert dirty text file buffers after applying edits so ABAP editors reflect on-disk changes.
- Validate ADT transport-relevant locks (via reflective access to ADT lock metadata) and fail with a clear error when no transport request is assigned.
- Add
org.eclipse.core.resources.semanticbundle dependency forISemanticFile.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/EditFileTool.java | Adds ABAP editor buffer refresh and ADT transport-request enforcement before applying file edits. |
| com.microsoft.copilot.eclipse.ui/META-INF/MANIFEST.MF | Adds the semantic resources bundle dependency required for ISemanticFile. |
Comments suppressed due to low confidence (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/EditFileTool.java:212
- The buffer revert logic can discard a user's unsaved editor changes. If a text file buffer is already dirty before writing to disk, abort the edit with a clear error instead of calling revert(). Also wrap the input stream in try-with-resources so it is closed even when setContents()/refreshLocal() throws.
ByteArrayInputStream inputStream = getInputStream(changedContent, file);
// Set the file contents
file.setContents(inputStream, true, true, new NullProgressMonitor());
Comment on lines
+255
to
+264
| Boolean transportRelevant = readField(lockResult, "transportRelevant", Boolean.class); | ||
| if (!Boolean.TRUE.equals(transportRelevant)) { | ||
| return; | ||
| } | ||
| String transportRequestNumber = readField(lockResult, "transportRequestNumber", String.class); | ||
| if (transportRequestNumber == null || transportRequestNumber.isEmpty()) { | ||
| throw new CoreException(Status.error(String.format( | ||
| "Cannot edit %s: the file is transport-relevant but no transport request number is assigned.", | ||
| file.getFullPath()))); | ||
| } |
Comment on lines
267
to
276
| private <T> T readField(Object target, String fieldName, Class<T> type) { | ||
| try { | ||
| var field = target.getClass().getDeclaredField(fieldName); | ||
| field.setAccessible(true); | ||
| return type.cast(field.get(target)); | ||
| } catch (ReflectiveOperationException | SecurityException e) { | ||
| CopilotCore.LOGGER.error("Failed to read field '" + fieldName + "' from " + target.getClass().getName(), e); | ||
| return null; | ||
| } | ||
| } |
Address PR review feedback on the ADT transport-lock check: - readField no longer swallows reflection failures; it now propagates ReflectiveOperationException so the caller can tell a genuinely-null field apart from a failed read. - verifyTransportRequestForAdtLock enforces the transport request only when the lock fields are read successfully. If the reflective read fails (e.g. the ADT API changed or setAccessible is denied), the check cannot be performed reliably, so the failure is logged and the edit is allowed to continue instead of either bypassing the check silently or aborting the edit.
Author
@microsoft-github-policy-service agree company="SAP SE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Editing ABAP source via the insert_edit_into_file tool did not work correctly for two reasons:
The ABAP source editor does not observe changes to the underlying file, so after writing new contents to disk its editor buffer stayed dirty and out of date. Force the open editor to reload by reverting the text file buffer when it is dirty.
ADT (ABAP Development Tools) files that are locked in a transport-relevant way must be associated with a transport request before they can be edited. Verify this before applying changes and fail with a clear error when no transport request is assigned. The ADT lock result is read reflectively since the com.sap.adt.* classes are not available at compile time.
Add the org.eclipse.core.resources.semantic dependency required for ISemanticFile.