Skip to content

Commit

Permalink
Merge pull request #65 from moosetechnology/tunOnEntity
Browse files Browse the repository at this point in the history
Add rawRunOnEntity:
  • Loading branch information
jecisc authored Jan 23, 2024
2 parents 0fde6e4 + cd3bf2b commit af0d046
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/Famix-Queries/FQAbstractQuery.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ FQAbstractQuery >> rawRunOn: aMooseGroup [
^ self subclassResponsibility
]

{ #category : #running }
FQAbstractQuery >> rawRunOnEntity: anEntity [
"I am a hook to allow to run a query on only one entity. I'll by default cast it as a MooseGroup but some subclasses can override me in order to speed things up."

^ self rawRunOn: anEntity asMooseGroup
]

{ #category : #removing }
FQAbstractQuery >> removeChild: aQuery [
children remove: aQuery
Expand Down
27 changes: 20 additions & 7 deletions src/Famix-Queries/FQCollectScriptQuery.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ Class {
#category : #'Famix-Queries-Queries-Unary'
}

{ #category : #running }
FQCollectScriptQuery >> addResultsFor: entity in: res [

| collected |
collected := script value: entity.
collected isCollection
ifTrue: [ res addAll: collected ]
ifFalse: [ res add: collected ].
^ res
]

{ #category : #default }
FQCollectScriptQuery >> beDefaultForParent [
script := [ :each | false ]
Expand All @@ -24,11 +35,13 @@ FQCollectScriptQuery >> defaultName [
{ #category : #running }
FQCollectScriptQuery >> rawRunOn: aMooseGroup [

^ (aMooseGroup rawAllUsing: TEntityMetaLevelDependency) inject: Set new into: [ :res :entity |
| collected |
collected := script value: entity.
collected isCollection
ifTrue: [ res addAll: collected ]
ifFalse: [ res add: collected ].
res ]
^ (aMooseGroup rawAllUsing: TEntityMetaLevelDependency) inject: Set new into: [ :res :entity | self addResultsFor: entity in: res ]
]

{ #category : #running }
FQCollectScriptQuery >> rawRunOnEntity: anEntity [

^ anEntity isQueryable
ifTrue: [ self addResultsFor: anEntity in: Set new ]
ifFalse: [ #( ) ]
]

0 comments on commit af0d046

Please sign in to comment.