diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e2804ef..1ffe801 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,11 @@ jobs: strategy: fail-fast: false matrix: - image: [Pharo64-13, Moose64-13] + include: + - image: Pharo64-13 + config: .smalltalk.ston + - image: Moose64-13 + config: .smalltalk.moose.ston services: postgres: image: postgres:15 @@ -43,7 +47,7 @@ jobs: with: smalltalk-image: ${{ matrix.image }} - name: Load and test in a clean image - run: smalltalkci -s '${{ matrix.image }}' .smalltalk.ston + run: smalltalkci -s '${{ matrix.image }}' '${{ matrix.config }}' - name: Upload JUnit results if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/.smalltalk.moose.ston b/.smalltalk.moose.ston new file mode 100644 index 0000000..69a472d --- /dev/null +++ b/.smalltalk.moose.ston @@ -0,0 +1,20 @@ +SmalltalkCISpec { + #name : 'FAMIXNGSQL-2-Pharo13-Moose13', + #preLoading : 'scripts/ci/prepare-moose.st', + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'FAMIXNGSQL', + #directory : 'src', + #load : [ 'Tests', 'GeneratorTests', 'MooseIDETests' ], + #onConflict : #useIncoming, + #onUpgrade : #useIncoming, + #platforms : [ #pharo ] + } + ], + #preTesting : 'scripts/ci/configure-database.st', + #testing : { + #packages : [ 'FamixNGSQL-Importer-Tests', 'FAMIXNGSQLMetamodelGenerator-Tests', 'PgMetadata-tests', 'FamixNGSQL-MooseIDE-Tests' ], + #defaultTimeout : 120, + #failOnZeroTests : true + } +} diff --git a/docs/mooseide-integration.md b/docs/mooseide-integration.md new file mode 100644 index 0000000..84917fe --- /dev/null +++ b/docs/mooseide-integration.md @@ -0,0 +1,24 @@ +# Optional Moose 13 integration + +In a Moose 13 / Pharo 13 image with MooseIDE already installed, load the `MooseIDE` +group of FAMIXNGSQL. `MooseIDETests` adds its regression tests. The plain `Core` +group does not load these packages or require the Moose UI. + +```smalltalk +Metacello new + baseline: 'FAMIXNGSQL'; + repository: 'github://deem0n/FAMIXNGSQL:master/src'; + load: 'MooseIDE'. +``` + +The Source Text browser automatically selects the SQL adapter. Routine and view +sources display without filesystem anchors. AST highlights are translated from +owner-relative intervals into the displayed fragment; absent, invalid, unrelated +or outside-fragment intervals produce no highlight. Definitions are not modified. + +The dependency pin includes the cardinality-aware MooseQuery fix from +`deem0n/Famix` PR #2, required for views with scalar query containment. This is +fork-first v3 development work, not a published v3 release. + +GitHub CI loads these optional tests in the ready-made Moose image. The plain +Pharo job continues to test Core without GUI dependencies. diff --git a/scripts/ci/prepare-moose.st b/scripts/ci/prepare-moose.st new file mode 100644 index 0000000..c213b60 --- /dev/null +++ b/scripts/ci/prepare-moose.st @@ -0,0 +1,5 @@ +"Use immutable archive dependencies, independent of prebuilt Iceberg checkouts. + Only affects the disposable CI image." +Iceberg enableMetacelloIntegration: false. +IceRepository registry copy do: [ :repository | + IceRepository unregisterRepository: repository ifAbsent: [ ] ]. diff --git a/src/BaselineOfFAMIXNGSQL/BaselineOfFAMIXNGSQL.class.st b/src/BaselineOfFAMIXNGSQL/BaselineOfFAMIXNGSQL.class.st index e786250..cf29d08 100644 --- a/src/BaselineOfFAMIXNGSQL/BaselineOfFAMIXNGSQL.class.st +++ b/src/BaselineOfFAMIXNGSQL/BaselineOfFAMIXNGSQL.class.st @@ -19,6 +19,10 @@ BaselineOfFAMIXNGSQL >> baseline: spec [ requires: #('FamixNGSQL' 'PostgreSQLParser' 'PgMetadata' 'SymbolResolver' 'PetitParser') ]; package: #'FamixNGSQL-Importer-Tests' with: [ spec requires: #('FamixNGSQL-Importer' 'PgMetadata-Tests') ]; + package: #'FamixNGSQL-MooseIDE' + with: [ spec requires: #('FamixNGSQL-Importer') ]; + package: #'FamixNGSQL-MooseIDE-Tests' + with: [ spec requires: #('FamixNGSQL-MooseIDE') ]; package: #'FamixNGSQL-GTInspectorExtension' with: [ spec requires: #('FamixNGSQL-Importer') ]; package: #FAMIXNGSQLAnalysis @@ -29,7 +33,7 @@ BaselineOfFAMIXNGSQL >> baseline: spec [ spec baseline: 'Famix' with: [ spec - repository: 'github://moosetechnology/Famix:4fd41546375e0ab86a4920eff547cc898e22db0b/src'; + repository: 'github://deem0n/Famix:b0a762751dd06ebe46f98d016943613d28c18d82/src'; loads: #('Core' 'Basic') ]. spec baseline: 'SymbolResolver' @@ -66,5 +70,7 @@ BaselineOfFAMIXNGSQL >> baseline: spec [ group: 'Generator' with: #('Core' 'FAMIXNGSQLMetamodelGenerator'); group: 'GeneratorTests' with: #('Generator' 'FAMIXNGSQLMetamodelGenerator-Tests'); group: 'Tests' with: #('Core' 'FamixNGSQL-Importer-Tests'); + group: 'MooseIDE' with: #('Core' 'FamixNGSQL-MooseIDE'); + group: 'MooseIDETests' with: #('MooseIDE' 'FamixNGSQL-MooseIDE-Tests'); group: 'LegacyUI' with: #('Core' 'FamixNGSQL-GTInspectorExtension' 'FAMIXNGSQLAnalysis' 'FAMIXNGSQLAnalysis-ConnectionsManager') ] ] diff --git a/src/FamixNGSQL-MooseIDE-Tests/FmxSQLSourceTextAdapterTest.class.st b/src/FamixNGSQL-MooseIDE-Tests/FmxSQLSourceTextAdapterTest.class.st new file mode 100644 index 0000000..74e96b4 --- /dev/null +++ b/src/FamixNGSQL-MooseIDE-Tests/FmxSQLSourceTextAdapterTest.class.st @@ -0,0 +1,54 @@ +Class { + #name : #FmxSQLSourceTextAdapterTest, + #superclass : #TestCase, + #category : #'FamixNGSQL-MooseIDE-Tests' +} +{ #category : #tests } +FmxSQLSourceTextAdapterTest >> testAdapterSelectionAndPlainSourceFallback [ + | routine adapter | + routine := FmxSQLStoredProcedure new source: 'SELECT 1'; yourself. + adapter := MiAbstractSourceTextAnchorAdapter adapterFor: routine. + self assert: adapter class equals: FmxSQLSourceTextAdapter. + adapter initializeDisplayedText: routine sourceText andEntity: routine. + self assert: (adapter intervalForEntity: routine) isNil. + self assert: routine sourceText equals: 'SELECT 1' +] +{ #category : #tests } +FmxSQLSourceTextAdapterTest >> testFragmentOffsetsAndForeignOwner [ + | owner query reference adapter | + owner := FmxSQLStoredProcedure new source: 'prefix SELECT x suffix'; yourself. + query := FmxSQLSelectQuery new sourceAnchor: + (FmxSQLEntitySourceAnchor new entity: owner; start: 8; end: 15; yourself); yourself. + reference := FmxSQLColumnReference new sourceAnchor: + (FmxSQLEntitySourceAnchor new entity: owner; start: 15; end: 15; yourself); yourself. + adapter := FmxSQLSourceTextAdapter new initializeDisplayedText: query sourceText andEntity: query; yourself. + self assert: (adapter intervalForEntity: reference) equals: (8 to: 8). + reference sourceAnchor start: 1; end: 6. + self assert: (adapter intervalForEntity: reference) isNil. + reference sourceAnchor entity: (FmxSQLStoredProcedure new source: owner source; yourself); start: 15; end: 15. + self assert: (adapter intervalForEntity: reference) isNil +] +{ #category : #tests } +FmxSQLSourceTextAdapterTest >> testInvalidAnchorHasNoHighlight [ + | routine reference adapter | + routine := FmxSQLStoredProcedure new source: 'SELECT 1'; yourself. + reference := FmxSQLColumnReference new sourceAnchor: + (FmxSQLEntitySourceAnchor new entity: routine; start: 0; end: 99; yourself); yourself. + adapter := FmxSQLSourceTextAdapter new initializeDisplayedText: routine sourceText andEntity: routine; yourself. + self assert: (adapter intervalForEntity: reference) isNil +] +{ #category : #tests } +FmxSQLSourceTextAdapterTest >> testStandardBrowserOnRoutineAndView [ + | model view routine browser | + model := FmxSQLModel new. + view := FmxSQLView new name: 'example'; source: 'SELECT 1'; mooseModel: model; yourself. + FmxSQLSelectQuery new viewDefining: view; mooseModel: model. + routine := FmxSQLStoredProcedure new name: 'example'; source: 'SELECT 1'; mooseModel: model; yourself. + browser := MiSourceTextBrowser new. + [ browser open. + { routine. view } do: [ :entity | + browser followEntity: entity. + self assert: browser specModel selectedEntity identicalTo: entity. + self assert: browser specModel rendererModel displayedText asString equals: entity sourceText ] ] + ensure: [ browser window ifNotNil: #close ] +] diff --git a/src/FamixNGSQL-MooseIDE-Tests/package.st b/src/FamixNGSQL-MooseIDE-Tests/package.st new file mode 100644 index 0000000..9744e1f --- /dev/null +++ b/src/FamixNGSQL-MooseIDE-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'FamixNGSQL-MooseIDE-Tests' } diff --git a/src/FamixNGSQL-MooseIDE/FmxSQLSourceTextAdapter.class.st b/src/FamixNGSQL-MooseIDE/FmxSQLSourceTextAdapter.class.st new file mode 100644 index 0000000..3ab9663 --- /dev/null +++ b/src/FamixNGSQL-MooseIDE/FmxSQLSourceTextAdapter.class.st @@ -0,0 +1,34 @@ +"Adapts PostgreSQL definitions and owner-relative AST intervals without file anchors." +Class { + #name : #FmxSQLSourceTextAdapter, + #superclass : #MiAbstractSourceTextAnchorAdapter, + #instVars : [ 'sourceOwner', 'offset' ], + #category : #'FamixNGSQL-MooseIDE' +} +{ #category : #testing } +FmxSQLSourceTextAdapter class >> acceptEntity: entity [ + ^ (entity isKindOf: FmxSQLEntity) and: [ entity respondsTo: #sourceText ] +] +{ #category : #initialization } +FmxSQLSourceTextAdapter >> initializeDisplayedText: text andEntity: entity [ + | anchor | + super initializeDisplayedText: text andEntity: entity. + sourceOwner := entity. + offset := 0. + anchor := entity sourceAnchor. + ((anchor isKindOf: FmxSQLEntitySourceAnchor) and: [ anchor hasSourceText ]) ifTrue: [ + sourceOwner := anchor entity. + offset := anchor start - 1 ] +] +{ #category : #accessing } +FmxSQLSourceTextAdapter >> intervalForEntity: entity [ + | anchor start end | + (entity respondsTo: #sourceAnchor) ifFalse: [ ^ nil ]. + anchor := entity sourceAnchor. + ((anchor isKindOf: FmxSQLEntitySourceAnchor) and: [ anchor hasSourceText ]) ifFalse: [ ^ nil ]. + anchor entity == sourceOwner ifFalse: [ ^ nil ]. + start := anchor start - offset. + end := anchor end - offset. + (start > 0 and: [ end >= start and: [ end <= displayedText size ] ]) ifFalse: [ ^ nil ]. + ^ start to: end +] diff --git a/src/FamixNGSQL-MooseIDE/package.st b/src/FamixNGSQL-MooseIDE/package.st new file mode 100644 index 0000000..cba7d61 --- /dev/null +++ b/src/FamixNGSQL-MooseIDE/package.st @@ -0,0 +1 @@ +Package { #name : #'FamixNGSQL-MooseIDE' }