-
Notifications
You must be signed in to change notification settings - Fork 2
feat(abapgit): add ENHO and ENHS enhancement object types #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3001a20
feat(abapgit): add ENHO and ENHS enhancement object types
ThePlenkov 178e716
style(abapgit): prettier formatting for ENHO/ENHS handlers
ThePlenkov 61509b9
fix(abapgit): complete ENHO/ENHS coverage — asx envelope, filters, ho…
ThePlenkov c2c2afc
fix(abapgit): preserve ENHO SOTR/SOTR_USE/ENHANCEMENTS/FILES metadata
ThePlenkov 7c43f62
fix(abapgit): map ENHO IMPL_SHORTTEXT_ID in both directions
ThePlenkov 7dacc9a
fix(abapgit): preserve all ENHO BADI_IMPL entries via impls[]
ThePlenkov 088ee0a
chore(codescene): scope rules for abapgit codegen output and handlers
ThePlenkov beeb6a8
chore(codescene): raise complexity thresholds for abapgit field mappers
ThePlenkov ba06bed
chore(codescene): disable Complex Method on abapgit field mappers
ThePlenkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
198 changes: 198 additions & 0 deletions
198
packages/adt-plugin-abapgit/src/lib/handlers/objects/enho.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| /** | ||
| * ENHO (Enhancement Implementation) object handler for abapGit format | ||
| * | ||
| * Enhancement implementations are XML-based with multiple tool sub-types: | ||
| * - BADI_IMPL: BAdI implementation (most common, ADK-supported via AdkBadi) | ||
| * - HOOK_IMPL: Hook implementation (source-driven) | ||
| * - CLASS: Class enhancement (source-driven) | ||
| * - INTF: Interface enhancement | ||
| * - WDYC: Web Dynpro component enhancement | ||
| * - FUGR: Function group enhancement | ||
| * - WDYN: Web Dynpro application enhancement | ||
| * | ||
| * File layout: | ||
| * src/zfoo.enho.xml — metadata (TOOL, SHORTTEXT, IMPL/ENHANCEMENTS, etc.) | ||
| * src/zfoo.enho.abap — source (for HOOK_IMPL, CLASS sub-types) | ||
| */ | ||
|
|
||
| import { enho } from '../../../schemas/generated'; | ||
| import { createHandler, normalizeItems } from '../base'; | ||
|
|
||
| type BadiImplData = { | ||
| SPOT_NAME?: string; | ||
| BADI_NAME?: string; | ||
| IMPL_NAME?: string; | ||
| IMPL_CLASS?: string; | ||
| ACTIVE?: string; | ||
| IMPL_SHORTTEXT?: string; | ||
| IMPL_SHORTTEXT_ID?: string; | ||
| LOCKED_IN_CUSTOMIZING?: string; | ||
| FILTER_ROOT?: unknown; | ||
| FILTER_VALUES?: unknown; | ||
| FILTERS?: unknown; | ||
| }; | ||
|
|
||
| type BadiImplLike = { | ||
| spotName?: string; | ||
| badiName?: string; | ||
| implName?: string; | ||
| implClass?: string; | ||
| active?: boolean; | ||
| implShorttext?: string; | ||
| implShorttextId?: string; | ||
| lockedInCustomizing?: boolean; | ||
| filterRoot?: unknown; | ||
| filterValues?: unknown; | ||
| filters?: unknown; | ||
| }; | ||
|
|
||
| type EnhancementImplementationLike = { | ||
| name: string; | ||
| description?: string; | ||
| tool?: string; | ||
| spotName?: string; | ||
| badiName?: string; | ||
| implName?: string; | ||
| implClass?: string; | ||
| active?: boolean; | ||
| implShorttext?: string; | ||
| implShorttextId?: string; | ||
| lockedInCustomizing?: boolean; | ||
| filterRoot?: unknown; | ||
| filterValues?: unknown; | ||
| filters?: unknown; | ||
| impls?: BadiImplLike[]; | ||
| originalObject?: { | ||
| pgmid?: string; | ||
| objType?: string; | ||
| objName?: string; | ||
| mainType?: string; | ||
| mainName?: string; | ||
| programName?: string; | ||
| }; | ||
| enhancements?: unknown; | ||
| files?: unknown; | ||
| sotr?: unknown; | ||
| sotrUse?: unknown; | ||
| getSource?: () => Promise<string> | string; | ||
| }; | ||
|
|
||
| export const enhancementImplementationHandler = createHandler< | ||
| EnhancementImplementationLike, | ||
| typeof enho | ||
| >('ENHO', { | ||
| schema: enho, | ||
| version: 'v1.0.0', | ||
| serializer: 'LCL_OBJECT_ENHO', | ||
| serializer_version: 'v1.0.0', | ||
|
|
||
| toAbapGit: (obj) => { | ||
| const tool = obj.tool || 'BADI_IMPL'; | ||
| const result: Record<string, unknown> = { | ||
| TOOL: tool, | ||
| SHORTTEXT: obj.description ?? '', | ||
| }; | ||
|
|
||
| if (tool === 'BADI_IMPL') { | ||
| const toImplXml = (i: BadiImplLike): BadiImplData => ({ | ||
| SPOT_NAME: i.spotName, | ||
| BADI_NAME: i.badiName, | ||
| IMPL_NAME: i.implName, | ||
| IMPL_CLASS: i.implClass, | ||
| ACTIVE: i.active ? 'X' : undefined, | ||
| IMPL_SHORTTEXT: i.implShorttext, | ||
| IMPL_SHORTTEXT_ID: i.implShorttextId, | ||
| LOCKED_IN_CUSTOMIZING: i.lockedInCustomizing ? 'X' : undefined, | ||
| FILTER_ROOT: i.filterRoot, | ||
| FILTER_VALUES: i.filterValues, | ||
| FILTERS: i.filters, | ||
| }); | ||
| const impls = obj.impls?.length ? obj.impls : [obj]; | ||
| result.SPOT_NAME = obj.spotName; | ||
| result.IMPL = { ENH_BADI_IMPL_DATA: impls.map(toImplXml) }; | ||
| } else if (obj.originalObject) { | ||
| result.ORIGINAL_OBJECT = { | ||
| PGMID: obj.originalObject.pgmid ?? 'R3TR', | ||
| ORG_OBJ_TYPE: obj.originalObject.objType, | ||
| ORG_OBJ_NAME: obj.originalObject.objName, | ||
| ORG_MAIN_TYPE: obj.originalObject.mainType, | ||
| ORG_MAIN_NAME: obj.originalObject.mainName, | ||
| PROGRAMNAME: obj.originalObject.programName, | ||
| }; | ||
| } | ||
|
|
||
| // Pass through enhancement metadata shared by all tool sub-types | ||
| result.ENHANCEMENTS = obj.enhancements; | ||
| result.FILES = obj.files; | ||
| result.SOTR = obj.sotr; | ||
| result.SOTR_USE = obj.sotrUse; | ||
|
|
||
| return result; | ||
| }, | ||
|
|
||
| fromAbapGit: ({ | ||
| TOOL, | ||
| SHORTTEXT, | ||
| SPOT_NAME, | ||
| IMPL, | ||
| ORIGINAL_OBJECT, | ||
| ENHANCEMENTS, | ||
| FILES, | ||
| SOTR, | ||
| SOTR_USE, | ||
| }) => { | ||
| const implRows = normalizeItems( | ||
| ( | ||
| IMPL as | ||
| { ENH_BADI_IMPL_DATA?: BadiImplData | BadiImplData[] } | undefined | ||
| )?.ENH_BADI_IMPL_DATA, | ||
| ); | ||
| const implData = implRows[0]; | ||
| return { | ||
| name: '', // ENHO name comes from filename, not XML content | ||
| description: SHORTTEXT, | ||
| tool: TOOL, | ||
| spotName: SPOT_NAME || implData?.SPOT_NAME, | ||
| badiName: implData?.BADI_NAME, | ||
| implName: implData?.IMPL_NAME, | ||
| implClass: implData?.IMPL_CLASS, | ||
| active: implData?.ACTIVE === 'X', | ||
| implShorttext: implData?.IMPL_SHORTTEXT, | ||
| implShorttextId: implData?.IMPL_SHORTTEXT_ID, | ||
| lockedInCustomizing: implData?.LOCKED_IN_CUSTOMIZING === 'X', | ||
| filterRoot: implData?.FILTER_ROOT, | ||
| filterValues: implData?.FILTER_VALUES, | ||
| filters: implData?.FILTERS, | ||
| impls: implRows.map((i) => ({ | ||
| spotName: i.SPOT_NAME, | ||
| badiName: i.BADI_NAME, | ||
| implName: i.IMPL_NAME, | ||
| implClass: i.IMPL_CLASS, | ||
| active: i.ACTIVE === 'X', | ||
| implShorttext: i.IMPL_SHORTTEXT, | ||
| implShorttextId: i.IMPL_SHORTTEXT_ID, | ||
| lockedInCustomizing: i.LOCKED_IN_CUSTOMIZING === 'X', | ||
| filterRoot: i.FILTER_ROOT, | ||
| filterValues: i.FILTER_VALUES, | ||
| filters: i.FILTERS, | ||
| })), | ||
| originalObject: ORIGINAL_OBJECT | ||
| ? { | ||
| pgmid: ORIGINAL_OBJECT.PGMID, | ||
| objType: ORIGINAL_OBJECT.ORG_OBJ_TYPE, | ||
| objName: ORIGINAL_OBJECT.ORG_OBJ_NAME, | ||
| mainType: ORIGINAL_OBJECT.ORG_MAIN_TYPE, | ||
| mainName: ORIGINAL_OBJECT.ORG_MAIN_NAME, | ||
| programName: ORIGINAL_OBJECT.PROGRAMNAME, | ||
| } | ||
| : undefined, | ||
| enhancements: ENHANCEMENTS, | ||
| files: FILES, | ||
| sotr: SOTR, | ||
| sotrUse: SOTR_USE, | ||
| }; | ||
| }, | ||
|
|
||
| // HOOK_IMPL / CLASS enhancements carry .enho.abap source | ||
| getSource: (obj) => Promise.resolve(obj.getSource?.() ?? ''), | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.