Skip to content

Commit

Permalink
Merge pull request #759 from moosetechnology/rename-importing-context
Browse files Browse the repository at this point in the history
Rename importing context
  • Loading branch information
jecisc authored Apr 16, 2024
2 parents ec29054 + 3867efb commit 43ec039
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 109 deletions.
11 changes: 11 additions & 0 deletions src/Famix-Deprecated/MooseImportingContext.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #MooseImportingContext,
#superclass : #FamixStImporterContext,
#category : #'Famix-Deprecated'
}

{ #category : #testing }
MooseImportingContext class >> isDeprecated [

^ true
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ Class {
ImportingContextTest >> testAllDependentsOf [

| res1 res2 |
MooseImportingContext initialize.
res1 := MooseImportingContext new allDependentsOf: MooseImportingContext importingClass.
FamixStImporterContext initialize.
res1 := FamixStImporterContext new allDependentsOf: FamixStImporterContext importingClass.
self assert: res1 size equals: 2.
self assert: (res1 includes: MooseImportingContext importingClass).
res2 := MooseImportingContext new allDependentsOf: MooseImportingContext importingImplicitVariable.
self assert: (res1 includes: FamixStImporterContext importingClass).
res2 := FamixStImporterContext new allDependentsOf: FamixStImporterContext importingImplicitVariable.
self assert: res2 size equals: 4.
self assert: (res2 includes: MooseImportingContext importingClass).
self assert: (res2 includes: MooseImportingContext importingMethod).
self assert: (res2 includes: MooseImportingContext importingImplicitVariable)
self assert: (res2 includes: FamixStImporterContext importingClass).
self assert: (res2 includes: FamixStImporterContext importingMethod).
self assert: (res2 includes: FamixStImporterContext importingImplicitVariable)
]

{ #category : #tests }
ImportingContextTest >> testShouldComputeTypeOfAttributes [
| context |

context :=MooseImportingContext new.
context :=FamixStImporterContext new.
self deny: (context shouldComputeTypeOfAttributes).
context computeTypeOfAttributes.
self assert: (context shouldComputeTypeOfAttributes).
Expand All @@ -33,7 +33,7 @@ ImportingContextTest >> testShouldComputeTypeOfAttributes [
ImportingContextTest >> testShouldImportAllTheRest [

| context |
context := MooseImportingContext new.
context := FamixStImporterContext new.
context
importClass;
importMethod;
Expand All @@ -46,7 +46,7 @@ ImportingContextTest >> testShouldImportAllTheRest [
ImportingContextTest >> testShouldImportClasses [

| context |
context := MooseImportingContext new.
context := FamixStImporterContext new.
context importClass.
self assert: context shouldImportClass
]
Expand All @@ -58,7 +58,7 @@ ImportingContextTest >> testShouldImportClassesForInheritance [
entities without breaking it"

| context |
context :=MooseImportingContext new.
context :=FamixStImporterContext new.
context importInheritance.
(context class entityDependencies at: context class importingInheritance)
do: [:each | self assert: (context shouldImport: each)]
Expand All @@ -68,7 +68,7 @@ ImportingContextTest >> testShouldImportClassesForInheritance [
ImportingContextTest >> testShouldImportClassesForMethod [

| context |
context := MooseImportingContext new.
context := FamixStImporterContext new.
context importMethod.
self assert: context shouldImportClass
]
Expand All @@ -77,7 +77,7 @@ ImportingContextTest >> testShouldImportClassesForMethod [
ImportingContextTest >> testShouldImportMethodBody [

| context |
context :=MooseImportingContext new.
context :=FamixStImporterContext new.
context importArgument.
self assert: (context shouldImportMethodBody).
]
Expand All @@ -86,7 +86,7 @@ ImportingContextTest >> testShouldImportMethodBody [
ImportingContextTest >> testShouldImportMethodBody2 [

| context |
context :=MooseImportingContext new.
context :=FamixStImporterContext new.
context importImplicitVariable.

self assert: (context shouldImportMethodBody).
Expand All @@ -96,7 +96,7 @@ ImportingContextTest >> testShouldImportMethodBody2 [
ImportingContextTest >> testShouldImportMethodBodyBasedOnMaximum [

| context |
context :=MooseImportingContext new.
context :=FamixStImporterContext new.
context importMaximum.

self assert: (context shouldImportMethodBody).
Expand Down
10 changes: 5 additions & 5 deletions src/Moose-SmalltalkImporter-Core-Tests/MooseScripts.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MooseScripts class >> createLightModelForLAN [
model := FamixStModel new.
model name: 'lightLAN'.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importClass;
importMethod;
importInheritance;
Expand Down Expand Up @@ -44,7 +44,7 @@ MooseScripts class >> createLightModelForMorphic [
model := FamixStModel new.
model name: 'lightMorphic'.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importClass;
importMethod;
importInheritance;
Expand Down Expand Up @@ -74,7 +74,7 @@ MooseScripts class >> createLightModelForNetwork [
model := FamixStModel new.
model name: 'lightNetwork'.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importClass;
importMethod;
importInheritance;
Expand Down Expand Up @@ -103,7 +103,7 @@ MooseScripts class >> createLightModelForPharo [
model := FamixStModel new.
model name: 'lightPharo'.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importClass;
importMethod;
importInheritance;
Expand Down Expand Up @@ -213,7 +213,7 @@ MooseScripts class >> createModelNamed: modelName withPackages: packages importe
mooseModel := FamixStModel new.
mooseModel name: modelName.

importingContext := MooseImportingContext new.
importingContext := FamixStImporterContext new.
(context select: [:anAssoc | anAssoc value = true] thenCollect: [:each | each key]) do: [ :each | importingContext perform: (#import , each) asSymbol ].
merge ifTrue: [ importingContext mergeClassAndMetaclass ].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MooseSmalltalkImporterSubclassesTest >> setUp [
model name: 'Test'.
pharoImporterTask := FamixStPharoImporterTask new
doNotRunCandidateOperator;
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importPackage;
importInheritance;
importAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FamixStepwiseImporterTest >> testCheckFormalParameterIsCreated [
| mseFormalParameter model |
model := FamixStModel new.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importImplicitVariable;
importAccess;
mergeClassAndMetaclass;
Expand All @@ -44,7 +44,7 @@ FamixStepwiseImporterTest >> testCheckSelfIsCreated [
| model mseSelf |
model := FamixStModel new.
FamixStPharoImporterTask new
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importImplicitVariable;
importAccess;
mergeClassAndMetaclass;
Expand All @@ -62,7 +62,7 @@ FamixStepwiseImporterTest >> testImportAttribute [

| importTask importer nodeClass |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importAttribute;
importMethod;
Expand All @@ -80,7 +80,7 @@ FamixStepwiseImporterTest >> testImportAttributeAccesses [

| importTask importer nodeClass attr |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importAttribute;
importMethod;
Expand All @@ -100,7 +100,7 @@ FamixStepwiseImporterTest >> testImportClassAndAttributeAndMergeItsMetaclass [

| importTask importer nodeClass |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importAttribute;
mergeClassAndMetaclass;
Expand All @@ -116,7 +116,7 @@ FamixStepwiseImporterTest >> testImportClassAndInheritance [

| importTask importer importedClasses |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importInheritance;
mergeClassAndMetaclass;
Expand All @@ -134,7 +134,7 @@ FamixStepwiseImporterTest >> testImportClassAndMethodAndMergeItsMetaclass [

| importTask importer importedMethods |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importMethod;
mergeClassAndMetaclass;
Expand All @@ -153,7 +153,7 @@ FamixStepwiseImporterTest >> testImportLANPackage [
model := FamixStModel new.
FamixStPharoImporterTask new
doNotRunCandidateOperator;
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importClass;
importPackage;
yourself);
Expand All @@ -172,7 +172,7 @@ FamixStepwiseImporterTest >> testImportMergingMetaclassDoesNotDuplicateComment [

| importTask importer comments |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importComment;
mergeClassAndMetaclass;
Expand All @@ -194,7 +194,7 @@ FamixStepwiseImporterTest >> testImportMethodBody [

| importTask importer context importedClasses famixClassNode nextNodeMethod nameMethod xFormalParameter |
importTask := self newImportClassesTask.
context := MooseImportingContext new
context := FamixStImporterContext new
importArgument;
mergeClassAndMetaclass;
yourself.
Expand Down Expand Up @@ -226,7 +226,7 @@ FamixStepwiseImporterTest >> testImportNamespace [
model := FamixStModel new.
FamixStPharoImporterTask new
doNotRunCandidateOperator;
importingContext: (MooseImportingContext new
importingContext: (FamixStImporterContext new
importNamespace;
importClass;
importPackage;
Expand All @@ -244,7 +244,7 @@ FamixStepwiseImporterTest >> testImportOneClassAndItsMetaclass [

| importTask importer importedClasses |
importTask := self newImportClassesTask.
importTask importingContext: MooseImportingContext new importClass.
importTask importingContext: FamixStImporterContext new importClass.
importTask addClass: LANNode.
self assert: importTask classes size equals: 1.
importer := importTask run.
Expand All @@ -258,7 +258,7 @@ FamixStepwiseImporterTest >> testImportOneClassAndMergeItsMetaclass [

| importTask importer importedClasses |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
mergeClassAndMetaclass;
yourself).
Expand All @@ -275,7 +275,7 @@ FamixStepwiseImporterTest >> testImportOneClassAndMethodAndMergeItsMetaclass [

| importTask importer importedMethods |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importMethod;
mergeClassAndMetaclass;
Expand All @@ -292,7 +292,7 @@ FamixStepwiseImporterTest >> testImportOneClassAndOneAttributeAndMergeItsMetacla

| importTask importer nodeClass |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importAttribute;
mergeClassAndMetaclass;
Expand All @@ -308,7 +308,7 @@ FamixStepwiseImporterTest >> testImportWithoutMergingMetaclassDoesDuplicateComme

| importTask importer comments |
importTask := self newImportClassesTask.
importTask importingContext: (MooseImportingContext new
importTask importingContext: (FamixStImporterContext new
importClass;
importComment;
distinguishClassAndMetaclass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MoosePharoImporterTaskOnLANTest >> testImportClassUsingAddCategory [
| model |
FamixStPharoImporterTask new
model: (model := FamixStModel new);
importingContext: MooseImportingContext new importClass;
importingContext: FamixStImporterContext new importClass;
addFromPackage: (self packageOrganizer packageNamed: #'Moose-TestResources-LAN');
run.
self assert: model allClasses size equals: (self numberOfClassesIn: #( 'Moose-TestResources-LAN' )) * 2
Expand All @@ -49,7 +49,7 @@ MoosePharoImporterTaskOnLANTest >> testImportClassUsingAddClass [
| model |
FamixStPharoImporterTask new
model: (model := FamixStModel new);
importingContext: MooseImportingContext new importClass;
importingContext: FamixStImporterContext new importClass;
addClass: LANNode;
run.
self assert: model allClasses size equals: LANNode subclasses size + 1 * 2
Expand All @@ -61,7 +61,7 @@ MoosePharoImporterTaskOnLANTest >> testImportClassUsingAddPackage [
| model |
FamixStPharoImporterTask new
model: (model := FamixStModel new);
importingContext: MooseImportingContext new importClass;
importingContext: FamixStImporterContext new importClass;
addFromPackage: (self packageOrganizer packageNamed: #'Moose-TestResources-LAN');
run.
self assert: model allClasses size equals: 2 * (self packageOrganizer packageNamed: #'Moose-TestResources-LAN') definedClasses size
Expand All @@ -73,7 +73,7 @@ MoosePharoImporterTaskOnLANTest >> testImportClassUsingAddPackageNamed [
| model |
FamixStPharoImporterTask new
model: (model := FamixStModel new);
importingContext: MooseImportingContext new importClass;
importingContext: FamixStImporterContext new importClass;
addFromPackageNamed: 'Moose-TestResources-LAN';
run.
self assert: model allClasses size equals: 2 * (self packageOrganizer packageNamed: #'Moose-TestResources-LAN') definedClasses size
Expand Down
Loading

0 comments on commit 43ec039

Please sign in to comment.