Skip to content

feat: support ABAP/ADT files in insert_edit_into_file tool - #374

Open
tobiasmelcher wants to merge 2 commits into
microsoft:mainfrom
tobiasmelcher:edit_file_tool_improved_abap_support
Open

feat: support ABAP/ADT files in insert_edit_into_file tool#374
tobiasmelcher wants to merge 2 commits into
microsoft:mainfrom
tobiasmelcher:edit_file_tool_improved_abap_support

Conversation

@tobiasmelcher

Copy link
Copy Markdown

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.

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.
Copilot AI review requested due to automatic review settings July 27, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.semantic bundle dependency for ISemanticFile.

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())));
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with [40fe27c]

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;
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with [40fe27c]

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.
@tobiasmelcher

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@microsoft-github-policy-service agree company="SAP SE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants