Skip to content

Commit

Permalink
Merge pull request #2 from fuhrmanator/master
Browse files Browse the repository at this point in the history
Sync repositories
  • Loading branch information
EyaBd authored Jul 26, 2023
2 parents d06e908 + 0f40cd3 commit 43fbcb5
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 160 deletions.
18 changes: 9 additions & 9 deletions src/Famix-TypeScript-Entities/FamixTypeScriptDecorator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Class {
#name : #FamixTypeScriptDecorator,
#superclass : #FamixTypeScriptNamedEntity,
#instVars : [
'#function => FMOne type: #FamixTypeScriptFunction opposite: #decorator',
'#namedEntity => FMOne type: #FamixTypeScriptNamedEntity opposite: #decorator'
'#expression => FMProperty',
'#namedEntity => FMOne type: #FamixTypeScriptNamedEntity opposite: #decorators'
],
#category : #'Famix-TypeScript-Entities-Entities'
}
Expand All @@ -21,23 +21,23 @@ FamixTypeScriptDecorator class >> annotation [
]

{ #category : #accessing }
FamixTypeScriptDecorator >> function [
"Relation named: #function type: #FamixTypeScriptFunction opposite: #decorator"
FamixTypeScriptDecorator >> expression [

<FMProperty: #expression type: #String>
<generated>
^ function
<FMComment: 'Decorators use the form @expression, where expression must evaluate to a function that will be called at runtime with information about the decorated declaration'>
^ expression
]

{ #category : #accessing }
FamixTypeScriptDecorator >> function: anObject [

FamixTypeScriptDecorator >> expression: anObject [
<generated>
function := anObject
expression := anObject
]

{ #category : #accessing }
FamixTypeScriptDecorator >> namedEntity [
"Relation named: #namedEntity type: #FamixTypeScriptNamedEntity opposite: #decorator"
"Relation named: #namedEntity type: #FamixTypeScriptNamedEntity opposite: #decorators"

<generated>
^ namedEntity
Expand Down
22 changes: 0 additions & 22 deletions src/Famix-TypeScript-Entities/FamixTypeScriptFunction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,3 @@ FamixTypeScriptFunction class >> annotation [
<generated>
^ self
]

{ #category : #adding }
FamixTypeScriptFunction >> addDecorator: anObject [
<generated>
^ self decorator add: anObject
]

{ #category : #accessing }
FamixTypeScriptFunction >> decorator [
"Relation named: #decorator type: #FamixTypeScriptDecorator opposite: #function"

<generated>
<derived>
^ decorator
]

{ #category : #accessing }
FamixTypeScriptFunction >> decorator: anObject [

<generated>
decorator value: anObject
]
5 changes: 0 additions & 5 deletions src/Famix-TypeScript-Entities/FamixTypeScriptMethod.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ FamixTypeScriptMethod class >> annotation [
<generated>
^ self
]

{ #category : #testing }
FamixTypeScriptMethod >> isStub [
^ super isStub or: [ self parentType isNotNil and: [ self parentType isStub ] ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class {
#traits : 'FamixTInvocationsReceiver + FamixTNamedEntity',
#classTraits : 'FamixTInvocationsReceiver classTrait + FamixTNamedEntity classTrait',
#instVars : [
'#decorator => FMMany type: #FamixTypeScriptDecorator opposite: #namedEntity'
'#decorators => FMMany type: #FamixTypeScriptDecorator opposite: #namedEntity'
],
#category : #'Famix-TypeScript-Entities-Entities'
}
Expand All @@ -29,21 +29,21 @@ FamixTypeScriptNamedEntity class >> isAbstract [
{ #category : #adding }
FamixTypeScriptNamedEntity >> addDecorator: anObject [
<generated>
^ self decorator add: anObject
^ self decorators add: anObject
]

{ #category : #accessing }
FamixTypeScriptNamedEntity >> decorator [
"Relation named: #decorator type: #FamixTypeScriptDecorator opposite: #namedEntity"
FamixTypeScriptNamedEntity >> decorators [
"Relation named: #decorators type: #FamixTypeScriptDecorator opposite: #namedEntity"

<generated>
<derived>
^ decorator
^ decorators
]

{ #category : #accessing }
FamixTypeScriptNamedEntity >> decorator: anObject [
FamixTypeScriptNamedEntity >> decorators: anObject [

<generated>
decorator value: anObject
decorators value: anObject
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ FamixTypeScriptParameterType class >> annotation [
<generated>
^ self
]

{ #category : #testing }
FamixTypeScriptParameterType >> isParameterType [
^ true
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,3 @@ FamixTypeScriptParameterizableClass class >> annotation [
<generated>
^ self
]

{ #category : #accessing }
FamixTypeScriptParameterizableClass >> parameters [
<FMProperty: #parameters type: #FamixTypeScriptParameterType> <multivalued> <derived>
<FMComment: 'Parameter types of this class.'>

^self types select: [:each | each isParameterType]
]

{ #category : #accessing }
FamixTypeScriptParameterizableClass >> parameters: aCollection [

self attributeAt: #parameters put: aCollection
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,3 @@ FamixTypeScriptSourceLanguage class >> annotation [
<generated>
^ self
]

{ #category : #testing }
FamixTypeScriptSourceLanguage >> isTypeScript [
^true
]

{ #category : #accessing }
FamixTypeScriptSourceLanguage >> name [

<FMProperty: #name type: #String>
<derived>
<FMComment: 'The name of the language'>

^ 'TypeScript'
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ FamixTypeScriptSourceTextAnchor class >> annotation [
<generated>
^ self
]

{ #category : #testing }
FamixTypeScriptSourceTextAnchor >> isTypescript [
^true
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Extension { #name : #FamixTypeScriptParameterizableClass }

{ #category : #'*Famix-TypeScript-Extensions' }
FamixTypeScriptParameterizableClass >> parameters [
<FMProperty: #parameters type: #FamixTypeScriptParameterType> <multivalued> <derived>
<FMComment: 'Parameter types of this class.'>

^self types select: [:each | each isParameterType]
]

{ #category : #'*Famix-TypeScript-Extensions' }
FamixTypeScriptParameterizableClass >> parameters: aCollection [

self attributeAt: #parameters put: aCollection
]
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ FamixTypeScriptGenerator >> defineProperties [

super defineProperties.

(decorator property: #expression type: #String)
comment: 'Decorators use the form @expression, where expression must evaluate to a function that will be called at runtime with information about the decorated declaration'.
"The following are not need because of THasKind (?)"

"(method property: #isConstructor type: #Boolean defaultValue: false)
Expand All @@ -280,8 +282,7 @@ FamixTypeScriptGenerator >> defineProperties [
{ #category : #definition }
FamixTypeScriptGenerator >> defineRelations [
super defineRelations.
(decorator property: #function) *- (function property:#decoratorCallingThisFunction).
(decorator property: #namedEntity) *- (namedEntity property:#DecoratorForThisEntity).
(decorator property: #namedEntity) *- (namedEntity property:#decorators).



Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,49 @@
Class {
#name : #FamixTypeScriptQueryTest,
#name : #FamixTypeScriptDecoratorTest,
#superclass : #TestCase,
#instVars : [
'model',
'p1',
'p2',
'c1',
'c2',
'c3',
'm1',
'm2',
'm3',
'm4',
'v1',
'pr1',
'pr2',
'at1',
'at2',
'annotationType1',
'annotationInstance1',
'annotationInstanceAttribute1'
'model'
],
#category : #'Famix-TypeScript-Tests'
}

{ #category : #tests }
FamixTypeScriptQueryTest >> model [
FamixTypeScriptDecoratorTest >> model [
^ model
]

{ #category : #tests }
FamixTypeScriptQueryTest >> model: anObject [
FamixTypeScriptDecoratorTest >> model: anObject [
model := anObject
]

{ #category : #tests }
FamixTypeScriptQueryTest >> setUp [
FamixTypeScriptDecoratorTest >> setUp [
| ns1 ns2 c1 c2 c3 m1 m2 m3 m4 v1 pr1 pr2 at1 at2 decorator1 f1 decorator2 |
super setUp.

p1 := FamixTypeScriptPackage new
ns1 := FamixTypeScriptNamespace new
name: 'p1';
stub: true;
yourself.
p2 := FamixTypeScriptPackage new
ns2 := FamixTypeScriptNamespace new
name: 'p2';
stub: true;
yourself.

f1 := FamixTypeScriptFunction new stub: true; name: 'F1'; yourself.

c1 := FamixTypeScriptClass new
stub: true;
name: 'C1';
parentPackage: p1;
yourself.
c2 := FamixTypeScriptClass new
stub: true;
name: 'C2';
parentPackage: p1;
yourself.
c3 := FamixTypeScriptClass new
stub: true;
name: 'C3';
parentPackage: p2;
yourself.

m1 := FamixTypeScriptMethod new
Expand Down Expand Up @@ -92,7 +75,7 @@ FamixTypeScriptQueryTest >> setUp [
declaredType: c3;
yourself.

v1 := FamixTypeScriptLocalVariable new
v1 := FamixTypeScriptVariable new
stub: true;
name: 'v1';
parentBehaviouralEntity: m2;
Expand All @@ -112,46 +95,43 @@ FamixTypeScriptQueryTest >> setUp [
declaredType: c3;
yourself.

at1 := FamixTypeScriptAttribute new
at1 := FamixTypeScriptField new
stub: true;
name: 'at1';
parentType: c1;
declaredType: c3;
yourself.
at2 := FamixTypeScriptAttribute new
at2 := FamixTypeScriptField new
stub: true;
name: 'at2';
parentType: c3;
declaredType: c2;
yourself.


annotationType1 := FamixTypeScriptAnnotationType new
stub: true;
name: 'annotationType1';
yourself.

annotationInstance1 := FamixTypeScriptAnnotationInstance new
"class decorator"
decorator1 := FamixTypeScriptDecorator new
stub: true;
annotationType: annotationType1;
annotatedEntity: at1;
name: 'decorator1';
namedEntity: c1;
expression: 'F1';
yourself.

annotationInstanceAttribute1 := FamixTypeScriptAnnotationInstanceAttribute new
"method decorator"
decorator2 := FamixTypeScriptDecorator new
stub: true;
parentAnnotationInstance: annotationInstance1;
value: 'instanceAttribute1Value';
name: 'decorator2';
namedEntity: m1;
expression: 'F1';
yourself.

self model: (FamixJavaModel withAll: {p1 . p2 . c1 . c2 . c3 . m1 . m2 . m3 . m4 . v1 . at1 . at2 . pr1 . pr2 . annotationType1 . annotationInstance1 . annotationInstanceAttribute1})
]

{ #category : #tests }
FamixTypeScriptQueryTest >> testFamixJavaAnnotationInstanceAttributeCanHaveIncoming [
self assert: annotationInstanceAttribute1 incomingMSEProperties isCollection
self model: (FamixTypeScriptModel withAll: {ns1 . ns2 . f1. c1 . c2 . c3 . m1 . m2 . m3 . m4 . v1 . at1 . at2 . pr1 . pr2 . decorator1 . decorator2})
]

{ #category : #tests }
FamixTypeScriptQueryTest >> testFamixJavaAnnotationInstanceAttributeCanHaveOutgoing [
self assert: annotationInstanceAttribute1 outgoingMSEProperties isCollection
FamixTypeScriptDecoratorTest >> testDecoratorForMethod [
| m1 |
m1 := model allMethods detect: [:m | m name = 'm1'].
self deny: m1 isNil.
self assert: m1 decorators size equals: 1.
self assert: m1 decorators anyOne expression equals: 'F1'
]
3 changes: 0 additions & 3 deletions src/Famix-TypeScript-Tests/FamixTypeScriptMethodTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ FamixTypeScriptMethodTest >> testIsStubWhenParentIsStub [
{ #category : #test }
FamixTypeScriptMethodTest >> testOverride [ [
| overridenMethod c1 c2 package |
package := FamixTypeScriptPackage new.
c1 := FamixTypeScriptClass new
parentPackage: package;
yourself.
c2 := FamixTypeScriptClass new
parentPackage: package;
yourself.
overridenMethod := FamixTypeScriptMethod new
name: 'method';
Expand Down
Loading

0 comments on commit 43fbcb5

Please sign in to comment.